From 4c8adcda6876bf6b57025b74e586edd608f7d85a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 22 Jan 2015 16:14:14 -0800 Subject: [PATCH] fixes --- .../com/intellectualcrafters/plot/PlotMain.java | 12 ++++++++++++ .../plot/commands/Claim.java | 3 +++ .../plot/commands/Inbox.java | 6 +++--- .../intellectualcrafters/plot/commands/Set.java | 7 ++++--- .../plot/config/Settings.java | 2 +- .../plot/listeners/PlayerEvents.java | 16 ++++++++++++++++ .../plot/listeners/WorldEditListener.java | 2 +- .../plot/util/ExpireManager.java | 3 --- .../plot/util/PlotHelper.java | 7 ++++--- 9 files changed, 44 insertions(+), 14 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index a581ef029..850e52e37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -65,6 +65,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import com.intellectualcrafters.plot.commands.Auto; import com.intellectualcrafters.plot.commands.Buy; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.WE_Anywhere; @@ -519,6 +520,17 @@ public class PlotMain extends JavaPlugin implements Listener { } } plots.get(world).remove(id); + + if (PlotHelper.lastPlot.containsKey(world)) { + PlotId last = PlotHelper.lastPlot.get(world); + int last_max = Math.max(last.x, last.y); + int this_max = Math.max(id.x, id.y); + + if (this_max < last_max) { + PlotHelper.lastPlot.put(world, id); + } + } + return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index dd602e141..545b3d91c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -51,6 +51,9 @@ public class Claim extends SubCommand { } public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { + if (plot.hasOwner() || plot.settings.isMerged()) { + return false; + } final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 5ec07485b..d81f6de52 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -47,11 +47,10 @@ public class Inbox extends SubCommand { public boolean execute(final Player plr, final String... args) { boolean report = false; if (args.length == 1){ - if (args[1].equalsIgnoreCase("reports")) { + if (args[0].equalsIgnoreCase("reports")) { report = true; } } - if (!PlayerFunctions.isInPlot(plr) && !report) { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return false; @@ -126,8 +125,9 @@ public class Inbox extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); return false; } + break; default: - PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[]{"admin", "owner", "helper", "trusted", "everyone"}, tier, 4)); + PlayerFunctions.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[]{"admin", "owner", "helper", "trusted", "everyone"}, Math.max(0, tier), 4)); return false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 4cb1ba231..32e3ac52f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -45,9 +45,11 @@ import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.UUIDHandler; /** * @author Citymonstret @@ -186,8 +188,7 @@ public class Set extends SubCommand { //set to current location World world = plr.getWorld(); Location base = PlotHelper.getPlotBottomLoc(world, plot.id); - int y = PlotHelper.getHeighestBlock(world, base.getBlockX(), base.getBlockZ()); - base.setY(y); + base.setY(0); Location relative = plr.getLocation().subtract(base); BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()); plot.settings.setPosition(blockloc); @@ -210,7 +211,7 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } - if (Bukkit.getOfflinePlayer(alias).hasPlayedBefore()) { + if (UUIDHandler.nameExists(new StringWrapper(alias))) { PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index c28eae4d9..37f39822a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -117,7 +117,7 @@ public class Settings { /** * Days until a plot gets cleared */ - public static int AUTO_CLEAR_DAYS = -1; + public static int AUTO_CLEAR_DAYS = 360; public static int MIN_BLOCKS_CHANGED = -1; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 506940305..2a4c93810 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -27,6 +27,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -68,6 +69,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.WorldLoadEvent; @@ -100,6 +102,20 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi PlotMain.loadWorld(event.getWorld()); } + @EventHandler + public static void onChunkLoad(final ChunkLoadEvent event) { + String worldname = event.getWorld().getName(); + Chunk chunk = event.getChunk(); + if (PlotHelper.worldBorder.containsKey(worldname)) { + int border = PlotHelper.getBorder(worldname); + int x = Math.abs(chunk.getX() << 4); + int z = Math.abs(chunk.getZ() << 4); + if (x > border || z > border) { + chunk.unload(false, true); + } + } + } + @EventHandler public static void onJoin(final PlayerJoinEvent event) { Player player = event.getPlayer(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index a2e59867e..0a7148612 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -192,7 +192,7 @@ public class WorldEditListener implements Listener { } final Location f = e.getFrom(); final Player p = e.getPlayer(); - if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { + if (PlotMain.hasPermission(p, "plots.worldedit.bypass") && !PWE.hasMask(p)) { return; } if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index cdfb0766e..8b6e3c6a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -98,7 +98,6 @@ public class ExpireManager { PlotMain.removePlot(world, plot.id, true); expiredPlots.get(world).remove(0); PlotMain.sendConsoleSenderMessage("&cDeleted expired plot: " + plot.id); - String owner; PlotMain.sendConsoleSenderMessage("&3 - World: "+plot.world); if (plot.hasOwner()) { PlotMain.sendConsoleSenderMessage("&3 - Owner: "+UUIDHandler.getName(plot.owner)); @@ -147,8 +146,6 @@ public class ExpireManager { } OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); if (op==null || !op.hasPlayedBefore()) { - toRemove.add(plot); - PlotMain.removePlot(plot.world, plot.id, true); continue; } long last = op.getLastPlayed(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index a7a8db302..2b2ece1bd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -946,16 +946,17 @@ import com.intellectualcrafters.plot.object.PlotWorld; Plot plot = getPlot(w, plotid); BlockLoc home = plot.settings.getPosition(); final Location bot = getPlotBottomLoc(w, plotid); + PlotManager manager = PlotMain.getPlotManager(w); if (home == null || (home.x == 0 && home.z == 0)) { final Location top = getPlotTopLoc(w, plotid); final int x = top.getBlockX() - bot.getBlockX(); final int z = top.getBlockZ() - bot.getBlockZ(); - final int y = getHeighestBlock(w, x, z); + final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotMain.getWorldSettings(w), plot).getBlockY()); return new Location(w, bot.getBlockX() + (x / 2), y, bot.getBlockZ() + (z / 2)); } else { - final int y = getHeighestBlock(w, home.x, home.z); - return bot.add(home.x, home.y + y, home.z); + final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); + return bot.add(home.x, y, home.z); } }