mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 06:28:49 +00:00
Add new economy actions, update API docs to use new repo, add metrics to Sponge (#398)
This commit is contained in:
1 parent
8b609010ec
commit
40cb340b15
33 files changed
+437
-159
No files matched your search
@@ -176,11 +176,11 @@ public class HomesManager {
|
||||
throw new ValidationException(ValidationException.Type.NOT_ENOUGH_HOME_SLOTS);
|
||||
}
|
||||
|
||||
if (!plugin.validateEconomyCheck(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT)) {
|
||||
if (!plugin.canPerformTransaction(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT)) {
|
||||
throw new ValidationException(ValidationException.Type.NOT_ENOUGH_MONEY);
|
||||
}
|
||||
|
||||
plugin.performEconomyTransaction(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT);
|
||||
plugin.performTransaction(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT);
|
||||
plugin.editUserData(online, (SavedUser saved) -> saved.setHomeSlots(saved.getHomeSlots() + 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.william278.huskhomes.manager;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
import net.william278.huskhomes.network.Message;
|
||||
import net.william278.huskhomes.network.Payload;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
@@ -254,6 +255,12 @@ public class RequestsManager {
|
||||
.ifPresent(recipient::sendMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate the economy check
|
||||
if (accepted && !plugin.canPerformTransaction(recipient, EconomyHook.Action.ACCEPT_TELEPORT_REQUEST)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleRequestResponse(lastRequest.get(), recipient, accepted);
|
||||
}
|
||||
|
||||
@@ -301,6 +308,7 @@ public class RequestsManager {
|
||||
// If the request is a tpa here request, teleport the recipient to the sender
|
||||
if (accepted && request.getType() == TeleportRequest.Type.TPA_HERE) {
|
||||
final TeleportBuilder builder = Teleport.builder(plugin)
|
||||
.economyActions(EconomyHook.Action.ACCEPT_TELEPORT_REQUEST)
|
||||
.teleporter(recipient);
|
||||
|
||||
// Strict /tpahere requests will teleport to where the sender was when typing the command
|
||||
@@ -313,7 +321,7 @@ public class RequestsManager {
|
||||
try {
|
||||
builder.toTimedTeleport().execute();
|
||||
} catch (TeleportationException e) {
|
||||
e.displayMessage(recipient, plugin, new String[0]);
|
||||
e.displayMessage(recipient, plugin);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -344,10 +352,11 @@ public class RequestsManager {
|
||||
Teleport.builder(plugin)
|
||||
.teleporter(requester)
|
||||
.target(request.getRecipientName())
|
||||
.economyActions(EconomyHook.Action.ACCEPT_TELEPORT_REQUEST)
|
||||
.toTimedTeleport()
|
||||
.execute();
|
||||
} catch (TeleportationException e) {
|
||||
e.displayMessage(requester, plugin, new String[0]);
|
||||
e.displayMessage(requester, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user