From b6ab172bcd77a7429f78af3b0814aa2d1da6d720 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Mon, 7 Aug 2023 19:29:33 -0400 Subject: [PATCH 1/3] Added regenInventoryClear Added the config options clearInventoryOnRegen & clearEnderChestOnRegen to allow servers to clear player inventories when regenerating islands. --- .../iridium/iridiumskyblock/commands/RegenCommand.java | 8 ++++++++ .../iridium/iridiumskyblock/configs/Configuration.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index 4ffd0c627..c78950384 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -51,6 +51,14 @@ 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 diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java index d1d82d126..9ec40accf 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 int distance = 151; public int netherUnlockLevel = 10; public int pasterDelayInTick = 1; From fda8bb3cee1387bcb64f8fa8d34583f5f6369299 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Mon, 7 Aug 2023 19:29:33 -0400 Subject: [PATCH 2/3] Added regenInventoryClear Added the config options clearInventoryOnRegen & clearEnderChestOnRegen to allow servers to clear player inventories when regenerating islands. --- .../iridium/iridiumskyblock/commands/RegenCommand.java | 8 ++++++++ .../iridium/iridiumskyblock/configs/Configuration.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index 4ffd0c627..c78950384 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -51,6 +51,14 @@ 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 diff --git a/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java b/src/main/java/com/iridium/iridiumskyblock/configs/Configuration.java index 1af96191f..aa80bc74f 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 int distance = 151; public int netherUnlockLevel = 10; public int pasterDelayInTick = 1; From a907b003949b488d81339282a2ebea4065b73929 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sat, 23 Sep 2023 09:07:40 -0400 Subject: [PATCH 3/3] made it good fixed inventory clear to be all members of an island and to trigger on both regen and delete --- .../iridiumskyblock/commands/RegenCommand.java | 8 +------- .../iridiumskyblock/managers/IslandManager.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index c78950384..bcc1179c0 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -51,13 +51,7 @@ public void execute(User user, Island island, String[] args, IridiumTeams Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { if (IridiumSkyblock.getInstance().getTeamManager().teleport(player, island.getHome(), island)) { diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 905c444ef..7b0e9226f 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -205,7 +205,9 @@ public void 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())); } @@ -580,4 +582,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()); + } + } + }