Skip to content

Commit

Permalink
made it good
Browse files Browse the repository at this point in the history
fixed inventory clear to be all members of an island and to trigger on both regen and delete
  • Loading branch information
sh0inx committed Sep 23, 2023
1 parent 71385fb commit a907b00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ public void execute(User user, Island island, String[] args, IridiumTeams<Island
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
)));

if(IridiumSkyblock.getInstance().getConfiguration().clearInventoryOnRegen) {
player.getInventory().clear();
}

if(IridiumSkyblock.getInstance().getConfiguration().clearEnderChestOnRegen) {
player.getEnderChest().clear();
}
IridiumSkyblock.getInstance().getIslandManager().clearTeamInventory(island);

IridiumSkyblock.getInstance().getIslandManager().generateIsland(island, schematicConfig.get()).thenRun(() -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> {
if (IridiumSkyblock.getInstance().getTeamManager().teleport(player, island.getHome(), island)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down Expand Up @@ -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());
}
}

}

0 comments on commit a907b00

Please sign in to comment.