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.

This commit is contained in:
Brettflan 2011-04-04 07:16:53 -05:00
parent 35e59f3c32
commit 7ffc4962b8
4 changed files with 21 additions and 0 deletions

View File

@ -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)) {

View File

@ -24,6 +24,9 @@ public class MyLocationTypeAdapter implements JsonDeserializer<Location>, 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();

View File

@ -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()) {

View File

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