diff --git a/changelog.md b/changelog.md index 3723baf..2f944fa 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 2.1.2 +* Fixed a bug where players got teleported one block beside the real portal. +* Fixed a bug where gates with no location caused multiple exceptions. ## 2.1.1 * Made the list command more reliable. * Error messages will be displayed less frequent. diff --git a/plugin.yml b/plugin.yml index 8add6bb..c17e863 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: Craft Inc. Gates -version: 2.1.1 +version: 2.1.2 description: A plugin to create gates for fast traveling. softdepend: [Vault] author: tomco, s1m0ne diff --git a/pom.xml b/pom.xml index ca5f186..460cccb 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.craftinc CraftIncGates jar - 2.1.1 + 2.1.2 UTF-8 diff --git a/src/de/craftinc/gates/Gate.java b/src/de/craftinc/gates/Gate.java index aa2a583..4bd8f06 100644 --- a/src/de/craftinc/gates/Gate.java +++ b/src/de/craftinc/gates/Gate.java @@ -300,8 +300,10 @@ public class Gate 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 cef218a..b933b36 100644 --- a/src/de/craftinc/gates/commands/BaseCommand.java +++ b/src/de/craftinc/gates/commands/BaseCommand.java @@ -206,17 +206,23 @@ public abstract class BaseCommand { return false; } - + + boolean permAtLocation; + + if (this.gate.getLocation() == null) { + permAtLocation = true; + } + else { boolean permAtLocation = Plugin.getPermission().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.getPermission().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 7d85bd6..5de36c7 100644 --- a/src/de/craftinc/gates/commands/CommandCreate.java +++ b/src/de/craftinc/gates/commands/CommandCreate.java @@ -56,9 +56,9 @@ public class CommandCreate extends BaseLocationCommand } catch (Exception e) {} } - else { - sendMessage(ChatColor.GREEN + "Gate with id \"" + id + "\" was created."); - sendMessage("Now you should build a frame and:"); + else + { + sendMessage("Now you should build a frame and execute:"); sendMessage(new CommandSetLocation().getUsageTemplate(true, true)); } } diff --git a/src/de/craftinc/gates/commands/CommandInfo.java b/src/de/craftinc/gates/commands/CommandInfo.java index 29f75c8..22bb6a5 100644 --- a/src/de/craftinc/gates/commands/CommandInfo.java +++ b/src/de/craftinc/gates/commands/CommandInfo.java @@ -18,7 +18,7 @@ public class CommandInfo extends BaseCommand requiredParameters.add("id"); - helpDescription = "Prints detailed informations about a certain gate."; + helpDescription = "Print detailed informations about a certain gate."; requiredPermission = Plugin.permissionInfo; @@ -49,12 +49,12 @@ public class CommandInfo extends BaseCommand if (gate.getLocation() != null) sendMessage(ChatColor.DARK_AQUA + "from: " + ChatColor.AQUA + "( " + gate.getLocation().getBlockX() + " | " + gate.getLocation().getBlockY() + " | " + gate.getLocation().getBlockZ() + " ) in " + gate.getLocation().getWorld().getName()); else - sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no 'from' location"); + sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no location"); if (gate.getExit() != null) sendMessage(ChatColor.DARK_AQUA + "to: " + ChatColor.AQUA + "( " + gate.getExit().getBlockX() + " | " + gate.getExit().getBlockY() + " | " + gate.getExit().getBlockZ() + " ) in " + gate.getExit().getWorld().getName()); else - sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no 'to' location"); + sendMessage(ChatColor.DARK_AQUA + "NOTE: this gate has no exit"); } } diff --git a/src/de/craftinc/gates/commands/CommandList.java b/src/de/craftinc/gates/commands/CommandList.java index 5cdc98c..2a73817 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) { + if (gate.getLocation() != null) { boolean permissionAtGateLocation = Plugin.getPermission().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 015743d..81d500b 100644 --- a/src/de/craftinc/gates/util/GateUtil.java +++ b/src/de/craftinc/gates/util/GateUtil.java @@ -52,10 +52,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; }