From 0e25e4933d1452f9ad7ffa08d79f70d3e73f4051 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 16 Mar 2020 15:19:16 +0100 Subject: [PATCH] BentoBox integration fixes --- .../external/listeners/BentoBoxListener.java | 2 +- .../shopchest/listeners/BentoBoxListener.java | 41 ++++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/external/listeners/BentoBoxListener.java b/src/main/java/de/epiceric/shopchest/external/listeners/BentoBoxListener.java index b28c7cf..c638d58 100644 --- a/src/main/java/de/epiceric/shopchest/external/listeners/BentoBoxListener.java +++ b/src/main/java/de/epiceric/shopchest/external/listeners/BentoBoxListener.java @@ -45,7 +45,7 @@ public class BentoBoxListener extends FlagListener { } private boolean handleForLocation(Player player, Location loc, Cancellable e) { - boolean allowed = checkIsland((Event) e, player, loc, BentoBoxShopFlag.SHOP_FLAG, true); + boolean allowed = checkIsland((Event) e, player, loc, BentoBoxShopFlag.SHOP_FLAG); if (!allowed) { e.setCancelled(true); plugin.debug("Cancel Reason: BentoBox"); diff --git a/src/main/java/de/epiceric/shopchest/listeners/BentoBoxListener.java b/src/main/java/de/epiceric/shopchest/listeners/BentoBoxListener.java index 3e3a59e..8364662 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/BentoBoxListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/BentoBoxListener.java @@ -15,9 +15,11 @@ import de.epiceric.shopchest.shop.Shop; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandBanEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandDeleteChunksEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandDeletedEvent; -import world.bentobox.bentobox.api.events.island.IslandEvent.IslandExpelEvent; import world.bentobox.bentobox.api.events.island.IslandEvent.IslandResettedEvent; +import world.bentobox.bentobox.api.events.team.TeamEvent.TeamKickEvent; +import world.bentobox.bentobox.api.events.team.TeamEvent.TeamLeaveEvent; import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.bentobox.database.objects.IslandDeletion; public class BentoBoxListener implements Listener { private ShopChest plugin; @@ -28,43 +30,42 @@ public class BentoBoxListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onIslandDeleted(IslandDeletedEvent e) { - deleteShops(e.getIsland().getWorld(), e.getDeletedIslandInfo().getBox()); + deleteShops(e.getDeletedIslandInfo()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onIslandDeleteChunks(IslandDeleteChunksEvent e) { + deleteShops(e.getDeletedIslandInfo()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onIslandResetted(IslandResettedEvent e) { + deleteShops(e.getIsland(), null); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onIslandBan(IslandBanEvent e) { deleteShops(e.getIsland(), e.getPlayerUUID()); } - - @EventHandler(priority = EventPriority.MONITOR) - public void onIslandResetted(IslandResettedEvent e) { - deleteShops(e.getIsland()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onIslandResettead(IslandDeleteChunksEvent e) { - deleteShops(e.getIsland().getWorld(), e.getDeletedIslandInfo().getBox()); - } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onIslandResettead(IslandExpelEvent e) { + public void onTeamKick(TeamKickEvent e) { deleteShops(e.getIsland(), e.getPlayerUUID()); } - // Utility methods + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onTeamLeave(TeamLeaveEvent e) { + deleteShops(e.getIsland(), e.getPlayerUUID()); + } - private void deleteShops(Island island) { - deleteShops(island.getWorld(), island.getBoundingBox(), null); + private void deleteShops(IslandDeletion deletedIsland) { + deleteShops(deletedIsland.getWorld(), deletedIsland.getBox(), null); } private void deleteShops(Island island, UUID vendorUuid) { deleteShops(island.getWorld(), island.getBoundingBox(), vendorUuid); } - private void deleteShops(World world, BoundingBox box) { - deleteShops(world, box, null); - } - private void deleteShops(World world, BoundingBox box, UUID vendorUuid) { if (!Config.enableBentoBoxIntegration) return;