From 7ffc4962b883d82f38322ea98944881829004237 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 4 Apr 2011 07:16:53 -0500 Subject: [PATCH] Fix for null faction home location, added "factions.adminBypass" permission which will allow players with that permission to bypass the building/destruction and usage limitations inside faction territory. --- src/com/bukkit/mcteam/factions/Factions.java | 4 ++++ .../bukkit/mcteam/factions/MyLocationTypeAdapter.java | 3 +++ .../mcteam/factions/listeners/FactionsBlockListener.java | 5 +++++ .../factions/listeners/FactionsPlayerListener.java | 9 +++++++++ 4 files changed, 21 insertions(+) diff --git a/src/com/bukkit/mcteam/factions/Factions.java b/src/com/bukkit/mcteam/factions/Factions.java index 82801234..4300398e 100644 --- a/src/com/bukkit/mcteam/factions/Factions.java +++ b/src/com/bukkit/mcteam/factions/Factions.java @@ -213,6 +213,10 @@ public class Factions extends JavaPlugin { public static boolean hasPermManageSafeZone(CommandSender sender) { return hasPerm(sender, "factions.manageSafeZone", true); } + + public static boolean hasPermAdminBypass(CommandSender sender) { + return hasPerm(sender, "factions.adminBypass", true); + } private static boolean hasPerm(CommandSender sender, String permNode, boolean fallbackOnlyOp) { if (Factions.Permissions == null || ! (sender instanceof Player)) { diff --git a/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java b/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java index 8e349171..6248039b 100644 --- a/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java +++ b/src/com/bukkit/mcteam/factions/MyLocationTypeAdapter.java @@ -24,6 +24,9 @@ public class MyLocationTypeAdapter implements JsonDeserializer, JsonSe @Override public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = json.getAsJsonObject(); + + if (obj.isJsonNull() || obj.get(WORLD).isJsonNull()) + return null; World world = Factions.instance.getServer().getWorld(obj.get(WORLD).getAsString()); double x = obj.get(X).getAsDouble(); diff --git a/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java b/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java index 231a972f..bae95f36 100644 --- a/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java +++ b/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java @@ -53,6 +53,11 @@ public class FactionsBlockListener extends BlockListener { } public boolean playerCanBuildDestroyBlock(Player player, Block block, String action) { + + if (Factions.hasPermAdminBypass(player)) { + return true; + } + Faction otherFaction = Board.getFactionAt(new FLocation(block)); if (otherFaction.isNone()) { diff --git a/src/com/bukkit/mcteam/factions/listeners/FactionsPlayerListener.java b/src/com/bukkit/mcteam/factions/listeners/FactionsPlayerListener.java index 5bb8376a..76706fd5 100644 --- a/src/com/bukkit/mcteam/factions/listeners/FactionsPlayerListener.java +++ b/src/com/bukkit/mcteam/factions/listeners/FactionsPlayerListener.java @@ -159,6 +159,10 @@ public class FactionsPlayerListener extends PlayerListener{ public boolean playerCanUseItemHere(Player player, Block block, Material material) { + if (Factions.hasPermAdminBypass(player)) { + return true; + } + if ( ! Conf.territoryDenyUseageMaterials.contains(material)) { return true; // Item isn't one we're preventing. } @@ -191,6 +195,11 @@ public class FactionsPlayerListener extends PlayerListener{ } public boolean canPlayerUseRightclickBlock(Player player, Block block) { + + if (Factions.hasPermAdminBypass(player)) { + return true; + } + Material material = block.getType(); // We only care about some material types.