From 0346ea8a23b0677cd763d45de0cfb863cbe07f1e Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Tue, 30 Oct 2018 18:22:26 +0100 Subject: [PATCH] Added resetting money when joining/leaving island (untested) --- .../bentobox/api/commands/admin/AdminDeleteCommand.java | 2 +- .../bentobox/api/commands/island/IslandResetCommand.java | 2 +- .../commands/island/team/IslandTeamInviteAcceptCommand.java | 2 +- .../api/commands/island/team/IslandTeamKickCommand.java | 5 +++-- .../api/commands/island/team/IslandTeamLeaveCommand.java | 2 +- .../world/bentobox/bentobox/managers/IslandsManager.java | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java index 556fbf66e..f0fe89b71 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommand.java @@ -72,7 +72,7 @@ public class AdminDeleteCommand extends ConfirmableCommand { target.getPlayer().getInventory().clear(); } if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) { - // TODO: needs Vault + getPlugin().getVault().ifPresent(vault -> vault.getEconomy().withdrawPlayer(target.getPlayer(), vault.getEconomy().getBalance(target.getPlayer()))); } } getIslands().deleteIsland(oldIsland, true); diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java index b8f3b1ab3..375354bf1 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java @@ -82,7 +82,7 @@ public class IslandResetCommand extends ConfirmableCommand { user.getPlayer().getInventory().clear(); } if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) { - // TODO: needs Vault + getPlugin().getVault().ifPresent(vault -> vault.getEconomy().withdrawPlayer(user.getPlayer(), vault.getEconomy().getBalance(user.getPlayer()))); } // Add a reset getPlayers().addReset(getWorld(), user.getUniqueId()); diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java index ec2d16557..73a61555b 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java @@ -85,7 +85,7 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand { user.getPlayer().getInventory().clear(); } if (getSettings().isUseEconomy() && (getIWM().isOnLeaveResetMoney(getWorld()) || getIWM().isOnJoinResetMoney(getWorld()))) { - // TODO: needs Vault + getPlugin().getVault().ifPresent(vault -> vault.getEconomy().withdrawPlayer(user.getPlayer(), vault.getEconomy().getBalance(user.getPlayer()))); } // Add the player as a team member of the new island getIslands().setJoinTeam(teamIsland, playerUUID); diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java index b75f58ab7..416f68a30 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java @@ -62,7 +62,8 @@ public class IslandTeamKickCommand extends ConfirmableCommand { } private void kick(User user, UUID targetUUID) { - User.getInstance(targetUUID).sendMessage("commands.island.team.kick.leader-kicked"); + User target = User.getInstance(targetUUID); + target.sendMessage("commands.island.team.kick.leader-kicked"); getIslands().removePlayer(getWorld(), targetUUID); // Remove money inventory etc. if (getIWM().isOnLeaveResetEnderChest(getWorld())) { @@ -72,7 +73,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand { user.getPlayer().getInventory().clear(); } if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) { - // TODO: needs Vault + getPlugin().getVault().ifPresent(vault -> vault.getEconomy().withdrawPlayer(target.getPlayer(), vault.getEconomy().getBalance(target.getPlayer()))); } user.sendMessage("general.success"); diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommand.java index 7b0f02bac..14ba8c33a 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommand.java @@ -54,7 +54,7 @@ public class IslandTeamLeaveCommand extends ConfirmableCommand { user.getPlayer().getInventory().clear(); } if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) { - // TODO: needs Vault + getPlugin().getVault().ifPresent(vault -> vault.getEconomy().withdrawPlayer(user.getPlayer(), vault.getEconomy().getBalance(user.getPlayer()))); } user.sendMessage("general.success"); } diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 6360ad763..e43e4eb78 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -568,7 +568,7 @@ public class IslandsManager { user.getPlayer().getInventory().clear(); } if (plugin.getSettings().isUseEconomy() && plugin.getIWM().isOnJoinResetMoney(world)) { - // TODO: needs Vault + plugin.getVault().ifPresent(vault -> vault.getEconomy().withdrawPlayer(user.getPlayer(), vault.getEconomy().getBalance(user.getPlayer()))); } } }