From f117847fc33ee77e688b7281c255791ca0fdfed0 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 29 Mar 2021 08:54:36 +0100 Subject: [PATCH] Fixed towny again --- .../antigrief/AntigriefTowny.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/integrations/antigrief/AntigriefTowny.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/integrations/antigrief/AntigriefTowny.java index 5af454a0..def012b2 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/integrations/antigrief/AntigriefTowny.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/integrations/antigrief/AntigriefTowny.java @@ -19,15 +19,24 @@ public class AntigriefTowny implements AntigriefWrapper { @Override public boolean canBreakBlock(@NotNull final Player player, @NotNull final Block block) { + TownyWorld world = TownyUniverse.getInstance().getWorldMap().get(block.getLocation().getWorld().getName()); + if (world == null) { + return true; + } if (TownyAPI.getInstance().isWilderness(block)) { return true; } - return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY); + return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY) + || PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.BUILD); } @Override public boolean canCreateExplosion(@NotNull final Player player, @NotNull final Location location) { + TownyWorld world = TownyUniverse.getInstance().getWorldMap().get(location.getWorld().getName()); + if (world == null) { + return true; + } if (TownyAPI.getInstance().isWilderness(location)) { return true; } @@ -37,6 +46,10 @@ public class AntigriefTowny implements AntigriefWrapper { @Override public boolean canPlaceBlock(@NotNull final Player player, @NotNull final Block block) { + TownyWorld world = TownyUniverse.getInstance().getWorldMap().get(block.getLocation().getWorld().getName()); + if (world == null) { + return true; + } if (TownyAPI.getInstance().isWilderness(block)) { return true; } @@ -46,14 +59,13 @@ public class AntigriefTowny implements AntigriefWrapper { @Override public boolean canInjure(@NotNull final Player player, @NotNull final LivingEntity victim) { + TownyWorld world = TownyUniverse.getInstance().getWorldMap().get(victim.getLocation().getWorld().getName()); + if (world == null) { + return true; + } if (TownyAPI.getInstance().isWilderness(victim.getLocation())) { if (victim instanceof Player) { - TownyWorld world = TownyUniverse.getInstance().getWorldMap().get(victim.getLocation().getWorld().getName()); - if (world != null) { - if (world.isPVP()) { - return true; - } - } + return world.isPVP(); } else { return true; }