use of com.iridium.iridiumskyblock.utils.PlayerUtils in project IridiumSkyblock by Iridium-Development.
the class IslandManager method deleteIsland.
/**
* Deletes the specified Island.
*
* @param island The Island which should be deleted
* @param user The user who deleted the island
*/
public void deleteIsland(@NotNull Island island, @Nullable User user) {
IslandDeleteEvent islandDeleteEvent = new IslandDeleteEvent(island, user);
Bukkit.getPluginManager().callEvent(islandDeleteEvent);
if (islandDeleteEvent.isCancelled())
return;
clearIslandCache();
deleteIslandBlocks(island, getWorld(), 3);
deleteIslandBlocks(island, getNetherWorld(), 3);
deleteIslandBlocks(island, getEndWorld(), 3);
deleteIslanDatabasedEntries(island);
getIslandMembers(island).stream().map(User::getPlayer).forEach(player -> {
if (player != null) {
if (IridiumSkyblock.getInstance().getConfiguration().deleteSettings.clearInventories) {
player.getInventory().clear();
}
if (IridiumSkyblock.getInstance().getConfiguration().deleteSettings.clearEnderChests) {
player.getEnderChest().clear();
}
if (IridiumSkyblock.getInstance().getConfiguration().deleteSettings.resetVaultBalances) {
IridiumSkyblock.getInstance().getEconomy().withdrawPlayer(player, IridiumSkyblock.getInstance().getEconomy().getBalance(player));
}
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().islandDeleted.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
});
getEntities(island, getWorld(), getEndWorld(), getNetherWorld()).thenAccept(entities -> Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> entities.stream().filter(entity -> entity instanceof Player).map(entity -> (Player) entity).forEach(PlayerUtils::teleportSpawn)));
}
Aggregations