diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java index 43cfadee7..a94351011 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java @@ -77,14 +77,14 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand { user.teleport(newHome); // Remove player as owner of the old island getIslands().removePlayer(getWorld(), playerUUID); - // Remove money inventory etc. - if (getIWM().isOnLeaveResetEnderChest(getWorld())) { + // Remove money inventory etc. for leaving + if (getIWM().isOnLeaveResetEnderChest(getWorld()) || getIWM().isOnJoinResetEnderChest(getWorld())) { user.getPlayer().getEnderChest().clear(); } - if (getIWM().isOnLeaveResetInventory(getWorld())) { + if (getIWM().isOnLeaveResetInventory(getWorld()) || getIWM().isOnJoinResetInventory(getWorld())) { user.getPlayer().getInventory().clear(); } - if (getSettings().isUseEconomy() && getIWM().isOnLeaveResetMoney(getWorld())) { + if (getSettings().isUseEconomy() && (getIWM().isOnLeaveResetMoney(getWorld()) || getIWM().isOnJoinResetMoney(getWorld()))) { // TODO: needs Vault } // Add the player as a team member of the new island diff --git a/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java b/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java index bf0b9c245..626de2ba6 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java +++ b/src/main/java/us/tastybento/bskyblock/managers/IslandsManager.java @@ -474,17 +474,44 @@ public class IslandsManager { * @param player - the player */ public void homeTeleport(World world, Player player) { - homeTeleport(world, player, 1); + homeTeleport(world, player, 1, false); } /** * Teleport player to a home location. If one cannot be found a search is done to * find a safe place. + * + * @param world - world to check * @param player - the player * @param number - a number - home location to do to */ - @SuppressWarnings("deprecation") public void homeTeleport(World world, Player player, int number) { + homeTeleport(world, player, number, false); + } + + /** + * This teleports player to their island. If not safe place can be found + * then the player is sent to spawn via /spawn command + * + * @param world - world to check + * @param player - the player + * @param newIsland - true if this is a new island teleport + */ + public void homeTeleport(World world, Player player, boolean newIsland) { + homeTeleport(world, player, 1, newIsland); + } + + /** + * Teleport player to a home location. If one cannot be found a search is done to + * find a safe place. + * + * @param world - world to check + * @param player - the player + * @param number - a number - home location to do to + * @param newIsland - true if this is a new island teleport + */ + @SuppressWarnings("deprecation") + public void homeTeleport(World world, Player player, int number, boolean newIsland) { User user = User.getInstance(player); Location home = getSafeHomeLocation(world, user, number); // Stop any gliding @@ -518,6 +545,21 @@ public class IslandsManager { if (player.getGameMode().equals(GameMode.SPECTATOR)) { player.setGameMode(plugin.getIWM().getDefaultGameMode(world)); } + // If this is a new island, then run commands and do resets + if (newIsland) { + // TODO add command running + + // Remove money inventory etc. + if (plugin.getIWM().isOnJoinResetEnderChest(world)) { + user.getPlayer().getEnderChest().clear(); + } + if (plugin.getIWM().isOnJoinResetInventory(world)) { + user.getPlayer().getInventory().clear(); + } + if (plugin.getSettings().isUseEconomy() && plugin.getIWM().isOnJoinResetMoney(world)) { + // TODO: needs Vault + } + } } /** diff --git a/src/main/java/us/tastybento/bskyblock/managers/island/NewIsland.java b/src/main/java/us/tastybento/bskyblock/managers/island/NewIsland.java index dee27ec63..6fc78820a 100644 --- a/src/main/java/us/tastybento/bskyblock/managers/island/NewIsland.java +++ b/src/main/java/us/tastybento/bskyblock/managers/island/NewIsland.java @@ -132,7 +132,7 @@ public class NewIsland { ib.setType(IslandType.END).build(); } // Teleport player to their island - plugin.getIslands().homeTeleport(world, user.getPlayer()); + plugin.getIslands().homeTeleport(world, user.getPlayer(), true); // Fire exit event Reason reasonDone = Reason.CREATED; switch (reason) {