From cac6eb6022cc3f8ff960445ef9357ee254475316 Mon Sep 17 00:00:00 2001 From: Paul Schulze Date: Mon, 13 May 2013 17:48:09 +0200 Subject: [PATCH 1/9] Fixed bug: When x or z was negative a player was teleported one block beside the real portal blocks. --- src/de/craftinc/gates/util/LocationUtil.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/de/craftinc/gates/util/LocationUtil.java b/src/de/craftinc/gates/util/LocationUtil.java index f93940c..2edf256 100644 --- a/src/de/craftinc/gates/util/LocationUtil.java +++ b/src/de/craftinc/gates/util/LocationUtil.java @@ -2,7 +2,6 @@ package de.craftinc.gates.util; import java.util.HashMap; import java.util.Map; - import org.bukkit.Location; import org.bukkit.World; @@ -90,13 +89,13 @@ public class LocationUtil if (l1.getWorld() != l2.getWorld() && (l1.getWorld() == null || !l1.getWorld().equals(l2.getWorld()))) { return false; } - if (new Double(l1.getX()).longValue() != new Double(l2.getX()).longValue()) { + if (l1.getBlockX() != l2.getBlockX()) { return false; } - if (new Double(l1.getY()).longValue() != new Double(l2.getY()).longValue()) { + if (l1.getBlockY() != l2.getBlockY()) { return false; } - if (new Double(l1.getZ()).longValue() != new Double(l2.getZ()).longValue()) { + if (l1.getBlockZ() != l2.getBlockZ()) { return false; } From ed2683affcb8f2a1e4b14fdcb8df05a1c57daf76 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 20:13:49 +0200 Subject: [PATCH 2/9] Fixed issue #18. Gates with 'null' as location did cause exceptions at many locations. --- src/de/craftinc/gates/BaseGate.java | 2 +- src/de/craftinc/gates/Gate.java | 6 +++-- .../craftinc/gates/commands/BaseCommand.java | 22 ++++++++++++------- .../gates/commands/CommandCreate.java | 4 +++- .../craftinc/gates/commands/CommandList.java | 10 +++++---- src/de/craftinc/gates/util/GateUtil.java | 7 ++++-- 6 files changed, 33 insertions(+), 18 deletions(-) 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; } From 4b7fff2277c01e7cddbeaafa68ec8ab98beab893 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 20:53:36 +0200 Subject: [PATCH 3/9] Fixed some typos --- plugin.yml | 2 +- src/de/craftinc/gates/commands/CommandCreate.java | 2 +- src/de/craftinc/gates/commands/CommandInfo.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) 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/src/de/craftinc/gates/commands/CommandCreate.java b/src/de/craftinc/gates/commands/CommandCreate.java index f441037..d39c481 100644 --- a/src/de/craftinc/gates/commands/CommandCreate.java +++ b/src/de/craftinc/gates/commands/CommandCreate.java @@ -42,7 +42,7 @@ public class CommandCreate extends BaseLocationCommand } catch (Exception e) { - sendMessage(ChatColor.RED + "Creating the gate failed!" + e.getMessage() + "See server log for more information"); + sendMessage(ChatColor.RED + "Creating the gate failed!" + e.getMessage() + " See server log for more information"); return; } 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"); } } From 916dc1b3a1474c7e022ec07c009a07c3cd8c4300 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 21:05:36 +0200 Subject: [PATCH 4/9] Updated changelog. --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index 3723baf..a64a14d 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 multiply exceptions. ## 2.1.1 * Made the list command more reliable. * Error messages will be displayed less frequent. From 1056fbf969eb63f08fdad97768db14967b33e23e Mon Sep 17 00:00:00 2001 From: Paul Schulze Date: Mon, 13 May 2013 17:32:50 +0200 Subject: [PATCH 5/9] updated pom.xml --- pom.xml | 68 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 1ebb82f..ca5f186 100644 --- a/pom.xml +++ b/pom.xml @@ -5,41 +5,79 @@ de.craftinc CraftIncGates jar - 1.1.1 + 2.1.1 UTF-8 + + src + + + resources + true + + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + exec-maven-plugin + org.codehaus.mojo + 1.2.1 + + + Run Test Bukkit Server + package + + exec + + + ${basedir}/scripts/test-deployment.sh + + + + + + + org.bukkit bukkit - RELEASE + 1.5.2-R0.1 + jar + compile + + + org.bukkit + craftbukkit + 1.5.2-R0.1 jar compile net.milkbowl.vault Vault - 1.2.23-SNAPSHOT + 1.2.26-SNAPSHOT jar compile - - target - target/classes - ${project.artifactId} - src - - - resources - - - - bukkit-repo From e0b30135ccdcf1e13230ff9935a5c9d5f6fc7b3c Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 21:14:19 +0200 Subject: [PATCH 6/9] Removed duplicate log message. --- src/de/craftinc/gates/commands/CommandCreate.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/craftinc/gates/commands/CommandCreate.java b/src/de/craftinc/gates/commands/CommandCreate.java index d39c481..666aeaa 100644 --- a/src/de/craftinc/gates/commands/CommandCreate.java +++ b/src/de/craftinc/gates/commands/CommandCreate.java @@ -64,7 +64,6 @@ public class CommandCreate extends BaseLocationCommand } else { - sendMessage(ChatColor.GREEN + "Gate with id \"" + id + "\" was created."); sendMessage("Now you should build a frame and execute:"); sendMessage(new CommandSetLocation().getUsageTemplate(true, true)); } From 7f8b8eee0fc1e9bc4078f57ac9327b10a97b0629 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 21:14:36 +0200 Subject: [PATCH 7/9] updated pom.xml to version 2.1.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From f2bfe27eba3a100e6520e7642dec1deaff0972d8 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 21:24:57 +0200 Subject: [PATCH 8/9] Removed debug print. --- src/de/craftinc/gates/commands/CommandCreate.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/de/craftinc/gates/commands/CommandCreate.java b/src/de/craftinc/gates/commands/CommandCreate.java index 666aeaa..afc5da1 100644 --- a/src/de/craftinc/gates/commands/CommandCreate.java +++ b/src/de/craftinc/gates/commands/CommandCreate.java @@ -48,8 +48,6 @@ public class CommandCreate extends BaseLocationCommand Location playerLocation = getValidPlayerLocation(); - Plugin.log("player location:" + playerLocation); - if (playerLocation != null) { try From 0e13f6012284578aadec712a258befda231868a6 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Fri, 17 May 2013 21:28:56 +0200 Subject: [PATCH 9/9] Fixer a typo. --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index a64a14d..2f944fa 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +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 multiply exceptions. +* 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.