From d9a544572d964f1ff19f1c0facefbc55cf743eaa Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sat, 23 Sep 2023 09:41:34 -0400 Subject: [PATCH] Added regenInventoryClear (#724) * Added regenInventoryClear Added the config options clearInventoryOnRegen & clearEnderChestOnRegen to allow servers to clear player inventories when regenerating islands. * Added regenInventoryClear Added the config options clearInventoryOnRegen & clearEnderChestOnRegen to allow servers to clear player inventories when regenerating islands. * made it good fixed inventory clear to be all members of an island and to trigger on both regen and delete --------- Co-authored-by: Peaches_MLG --- .../iridiumskyblock/commands/RegenCommand.java | 3 +++ .../iridiumskyblock/configs/Configuration.java | 2 ++ .../iridiumskyblock/managers/IslandManager.java | 15 +++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index fdedd1ce4..01a9a7f80 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -54,7 +54,10 @@ public void execute(User user, Island island, String[] args, IridiumTeams Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { + if (IridiumSkyblock.getInstance().getTeamManager().teleport(player, island.getHome(), island)) { player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().teleportingHome .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java index 46d333e08..5b873a8ce 100644 --- a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java +++ b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java @@ -49,6 +49,8 @@ public Configuration() { public boolean obsidianBucket = true; public boolean removeIslandBlocksOnDelete = false; + public boolean clearInventoryOnRegen = false; + public boolean clearEnderChestOnRegen = false; public boolean allowPvPOnIslands = false; public int distance = 151; public int netherUnlockLevel = 10; diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index cdb7182c2..94ade66bc 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -215,7 +215,9 @@ public boolean deleteTeam(Island island, User user) { if (IridiumSkyblock.getInstance().getConfiguration().removeIslandBlocksOnDelete) { deleteIslandBlocks(island); } + IridiumSkyblock.getInstance().getDatabaseManager().getIslandTableManager().delete(island); + IridiumSkyblock.getInstance().getIslandManager().clearTeamInventory(island); getMembersOnIsland(island).forEach(member -> PlayerUtils.teleportSpawn(member.getPlayer())); @@ -592,4 +594,17 @@ public void handleBlockPlaceOutsideTerritory(BlockPlaceEvent blockEvent) { } } + public void clearTeamInventory(Island island) { + + if(IridiumSkyblock.getInstance().getConfiguration().clearInventoryOnRegen) { + IridiumSkyblock.getInstance().getIslandManager().getMembersOnIsland(island).forEach(member -> + member.getPlayer().getInventory().clear()); + } + + if(IridiumSkyblock.getInstance().getConfiguration().clearEnderChestOnRegen) { + IridiumSkyblock.getInstance().getIslandManager().getMembersOnIsland(island).forEach(member -> + member.getPlayer().getEnderChest().clear()); + } + } + }