Skip to content

Commit

Permalink
Added regenInventoryClear (#724)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
sh0inx and PeachesMLG authored Sep 23, 2023
1 parent 4436171 commit d9a5445
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public void execute(User user, Island island, String[] args, IridiumTeams<Island
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
)));

IridiumSkyblock.getInstance().getIslandManager().clearTeamInventory(island);

IridiumSkyblock.getInstance().getIslandManager().generateIsland(island, schematicConfig).thenRun(() -> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down Expand Up @@ -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());
}
}

}

0 comments on commit d9a5445

Please sign in to comment.