Removes islands from Top Ten when admin deleted.

Fixes https://github.com/BentoBoxWorld/Level/issues/155
This commit is contained in:
tastybento 2020-06-13 08:05:33 -07:00
parent f78b2c8231
commit c19ae41cbb

View File

@ -2,12 +2,15 @@ package world.bentobox.level.listeners;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandCreatedEvent; 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.IslandRegisteredEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandUnregisteredEvent; 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) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onNewIslandOwner(TeamSetownerEvent e) { public void onNewIslandOwner(TeamSetownerEvent e) {
// Remove player from the top ten and level // Remove player from the top ten and level