BentoBox integration fixes

This commit is contained in:
Eric 2020-03-16 15:19:16 +01:00
parent 0002055e5f
commit 0e25e4933d
2 changed files with 22 additions and 21 deletions

View File

@ -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");

View File

@ -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;