diff --git a/src/de/craftinc/gates/BaseGate.java b/src/de/craftinc/gates/BaseGate.java index 271ef01..9545c30 100644 --- a/src/de/craftinc/gates/BaseGate.java +++ b/src/de/craftinc/gates/BaseGate.java @@ -177,7 +177,7 @@ public abstract class BaseGate throw new Exception("Gate got closed. It has no exit."); } - if (gateBlockLocations.size() == 0) { + if (gateBlockLocations == null || gateBlockLocations.size() == 0) { setOpen(false); throw new Exception("Gate got closed. The frame is missing or broken."); } diff --git a/src/de/craftinc/gates/Gate.java b/src/de/craftinc/gates/Gate.java index d6a4fd7..cc81cd4 100644 --- a/src/de/craftinc/gates/Gate.java +++ b/src/de/craftinc/gates/Gate.java @@ -142,8 +142,10 @@ public class Gate extends BaseGate implements ConfigurationSerializable retVal.put(exitYawKey, exit.getYaw()); } - retVal.put(locationPitchKey, location.getPitch()); - retVal.put(locationYawKey, location.getYaw()); + if (location != null) { + retVal.put(locationPitchKey, location.getPitch()); + retVal.put(locationYawKey, location.getYaw()); + } List> serializedGateBlocks = new ArrayList>(); diff --git a/src/de/craftinc/gates/commands/BaseCommand.java b/src/de/craftinc/gates/commands/BaseCommand.java index d3c1634..78aefe0 100644 --- a/src/de/craftinc/gates/commands/BaseCommand.java +++ b/src/de/craftinc/gates/commands/BaseCommand.java @@ -142,7 +142,7 @@ public abstract class BaseCommand */ protected boolean hasPermission() { - if (Plugin.permission == null) // fallback Рuse the standard bukkit permission system + if (Plugin.permission == null) // fallback � use the standard bukkit permission system { return this.sender.hasPermission(this.requiredPermission); } @@ -156,7 +156,7 @@ public abstract class BaseCommand } else { - // sender is no player Рthere is no information about the senders locations + // sender is no player � there is no information about the senders locations return Plugin.permission.has(this.sender, this.requiredPermission); } @@ -205,17 +205,23 @@ public abstract class BaseCommand { return false; } - - boolean permAtLocation = Plugin.permission.has(this.gate.getLocation().getWorld(), p.getName(), this.requiredPermission); + + boolean permAtLocation; + + if (this.gate.getLocation() == null) { + permAtLocation = true; + } + else { + permAtLocation = Plugin.permission.has(this.gate.getLocation().getWorld(), p.getName(), this.requiredPermission); + } + boolean permAtExit; - if (this.gate.getExit() == null) - { + if (this.gate.getExit() == null) { permAtExit = true; } - else - { + else { permAtExit = Plugin.permission.has(this.gate.getExit().getWorld(), p.getName(), this.requiredPermission); } diff --git a/src/de/craftinc/gates/commands/CommandCreate.java b/src/de/craftinc/gates/commands/CommandCreate.java index df3f7f2..f441037 100644 --- a/src/de/craftinc/gates/commands/CommandCreate.java +++ b/src/de/craftinc/gates/commands/CommandCreate.java @@ -48,6 +48,8 @@ public class CommandCreate extends BaseLocationCommand Location playerLocation = getValidPlayerLocation(); + Plugin.log("player location:" + playerLocation); + if (playerLocation != null) { try @@ -63,7 +65,7 @@ public class CommandCreate extends BaseLocationCommand else { sendMessage(ChatColor.GREEN + "Gate with id \"" + id + "\" was created."); - sendMessage("Now you should build a frame and:"); + sendMessage("Now you should build a frame and execute:"); sendMessage(new CommandSetLocation().getUsageTemplate(true, true)); } } diff --git a/src/de/craftinc/gates/commands/CommandList.java b/src/de/craftinc/gates/commands/CommandList.java index 6dd575d..44ebdac 100644 --- a/src/de/craftinc/gates/commands/CommandList.java +++ b/src/de/craftinc/gates/commands/CommandList.java @@ -144,10 +144,12 @@ public class CommandList extends BaseCommand for (Gate gate : gatesCopy) { - boolean permissionAtGateLocation = Plugin.permission.has(gate.getLocation().getWorld(), p.getName(), this.requiredPermission); - if (!permissionAtGateLocation) { - gates.remove(gate); - continue; + if (gate.getLocation() != null) { + boolean permissionAtGateLocation = Plugin.permission.has(gate.getLocation().getWorld(), p.getName(), this.requiredPermission); + if (!permissionAtGateLocation) { + gates.remove(gate); + continue; + } } if (gate.getExit() != null) { diff --git a/src/de/craftinc/gates/util/GateUtil.java b/src/de/craftinc/gates/util/GateUtil.java index 168fdb9..bd02fd1 100644 --- a/src/de/craftinc/gates/util/GateUtil.java +++ b/src/de/craftinc/gates/util/GateUtil.java @@ -51,10 +51,13 @@ public class GateUtil } // Check if the gate is open and useable + if (g.getLocation() == null) { + continue; + } + World gateWorld = g.getLocation().getWorld(); - if (!g.isOpen() || !gateWorld.equals(playerWorld)) - { + if (!g.isOpen() || !gateWorld.equals(playerWorld)) { continue; }