From c19ae41cbb213b5e7d3b434cb21b87e996e72439 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 13 Jun 2020 08:05:33 -0700 Subject: [PATCH] Removes islands from Top Ten when admin deleted. Fixes https://github.com/BentoBoxWorld/Level/issues/155 --- .../level/listeners/IslandTeamListeners.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/world/bentobox/level/listeners/IslandTeamListeners.java b/src/main/java/world/bentobox/level/listeners/IslandTeamListeners.java index 047c0f6..613357f 100644 --- a/src/main/java/world/bentobox/level/listeners/IslandTeamListeners.java +++ b/src/main/java/world/bentobox/level/listeners/IslandTeamListeners.java @@ -2,12 +2,15 @@ package world.bentobox.level.listeners; import java.util.HashMap; import java.util.Map; +import java.util.UUID; +import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandCreatedEvent; +import world.bentobox.bentobox.api.events.island.IslandEvent.IslandPreclearEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandRegisteredEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandUnregisteredEvent; @@ -55,6 +58,15 @@ public class IslandTeamListeners implements Listener { } } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onIslandDelete(IslandPreclearEvent e) { + // Remove player from the top ten and level + final UUID owner = e.getIsland().getOwner(); + final World world = e.getIsland().getWorld(); + addon.setIslandLevel(world, owner, 0); + addon.getTopTen().removeEntry(world, owner); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onNewIslandOwner(TeamSetownerEvent e) { // Remove player from the top ten and level