diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java index ae7d9b1a4..e5525a7bc 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java @@ -29,8 +29,8 @@ public class Helpers extends SubCommand { } private boolean hasBeenOnServer(String name) { - Player plr; - if ((plr = Bukkit.getPlayer(name)) == null) { + Player plr = Bukkit.getPlayerExact(name); + if (plr == null) { OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); if (oplr == null) { return false; @@ -74,11 +74,15 @@ public class Helpers extends SubCommand { return true; } UUID uuid = null; - if ((Bukkit.getPlayer(args[1]) != null) && Bukkit.getPlayer(args[1]).isOnline()) { - uuid = Bukkit.getPlayer(args[1]).getUniqueId(); + if ((Bukkit.getPlayerExact(args[1]) != null)) { + uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + return true; + } plot.addHelper(uuid); DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); @@ -101,11 +105,15 @@ public class Helpers extends SubCommand { return true; } UUID uuid = null; - if (Bukkit.getPlayer(args[1]).isOnline()) { - uuid = Bukkit.getPlayer(args[1]).getUniqueId(); + if (Bukkit.getPlayerExact(args[1]) != null) { + uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + return true; + } if (!plot.helpers.contains(uuid)) { PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java index 4eca67bd0..b3748a554 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java @@ -29,8 +29,8 @@ public class Trusted extends SubCommand { } private boolean hasBeenOnServer(String name) { - Player plr; - if ((plr = Bukkit.getPlayer(name)) == null) { + Player plr = Bukkit.getPlayerExact(name); + if (plr == null) { OfflinePlayer oplr = Bukkit.getOfflinePlayer(name); if (oplr == null) { return false; @@ -74,11 +74,15 @@ public class Trusted extends SubCommand { return true; } UUID uuid = null; - if ((Bukkit.getPlayer(args[1]) != null) && Bukkit.getPlayer(args[1]).isOnline()) { - uuid = Bukkit.getPlayer(args[1]).getUniqueId(); + if ((Bukkit.getPlayerExact(args[1]) != null)) { + uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + return true; + } plot.addTrusted(uuid); DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); @@ -101,11 +105,15 @@ public class Trusted extends SubCommand { return true; } UUID uuid = null; - if (Bukkit.getPlayer(args[1]).isOnline()) { - uuid = Bukkit.getPlayer(args[1]).getUniqueId(); + if (Bukkit.getPlayerExact(args[1]) != null) { + uuid = Bukkit.getPlayerExact(args[1]).getUniqueId(); } else { uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + return true; + } if (!plot.trusted.contains(uuid)) { PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java index c3c3a2666..e90e4596c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -456,13 +456,12 @@ public class PlayerEvents implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onStructureGrow(final StructureGrowEvent e) { List blocks = e.getBlocks(); - boolean f = false; - for (int i = 0; i < blocks.size(); i++) { - if (f || isPlotWorld(blocks.get(i).getLocation())) { - f = true; + boolean remove = false; + for (int i = blocks.size() -1; i >= 0; i--) { + if (remove || isPlotWorld(blocks.get(i).getLocation())) { + remove = true; if (!isInPlot(blocks.get(i).getLocation())) { e.getBlocks().remove(i); - i--; } } }