From fc80f1980b30f7763c7263801c860fdc0cc2c69c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 8 Mar 2015 23:51:11 +1100 Subject: [PATCH 001/223] temporary --- .../com/intellectualcrafters/plot/config/C_german.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C_german.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C_german.java index 2d2b17570..05f8c2d98 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C_german.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C_german.java @@ -34,7 +34,7 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation; * * @author Citymonstret */ -public enum C { +public enum C_german { /* * Confirm */ @@ -484,7 +484,7 @@ public enum C { /** * Constructor for custom strings. */ - C() { + C_german() { /* * use setCustomString(); */ @@ -496,7 +496,7 @@ public enum C { * @param d default * @param prefix use prefix */ - C(final String d, final boolean prefix) { + C_german(final String d, final boolean prefix) { this.d = d; if (this.s == null) { this.s = ""; @@ -509,7 +509,7 @@ public enum C { * * @param d default */ - C(final String d) { + C_german(final String d) { this(d, true); } @@ -517,7 +517,7 @@ public enum C { manager = new TranslationManager(); defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read(); // register everything in this class - for (final C c : values()) { + for (final C_german c : values()) { manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", "")); } } From c7fe57841b39f03de3133807bcbf9f89decec158 Mon Sep 17 00:00:00 2001 From: Roman Alexander Date: Mon, 9 Mar 2015 12:44:50 -0400 Subject: [PATCH 002/223] Need to use world folder container than getting the relative path. Nullpo protection. --- .../plot/util/bukkit/BukkitChunkManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 93dbafc29..6d3fe9a2f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -62,10 +62,13 @@ public class BukkitChunkManager extends ChunkManager { @Override public ArrayList getChunkChunks(final String world) { - final String directory = new File(".").getAbsolutePath() + File.separator + world + File.separator + "region"; + final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region"; final File folder = new File(directory); final File[] regionFiles = folder.listFiles(); final ArrayList chunks = new ArrayList<>(); + if (regionFiles == null) { + throw new RuntimeException("Could not find worlds folder."); + } for (final File file : regionFiles) { final String name = file.getName(); if (name.endsWith("mca")) { From 044abeaee9016d0e703ba4221d667c5d683480c0 Mon Sep 17 00:00:00 2001 From: Roman Alexander Date: Mon, 9 Mar 2015 18:17:22 -0400 Subject: [PATCH 003/223] Use unicode escapes instead of UTF8 file encoding. --- .../intellectualcrafters/plot/util/MainUtil.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 04b4d0a19..0292e96b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -873,7 +873,7 @@ public class MainUtil { final char[] b = message.toCharArray(); for (int i = 0; i < (b.length - 1); i++) { if ((b[i] == alt) && ("0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[(i + 1)]) > -1)) { - b[i] = '§'; + b[i] = '\u00A7'; b[(i + 1)] = Character.toLowerCase(b[(i + 1)]); } } @@ -907,8 +907,8 @@ public class MainUtil { int lineColorChars = 0; for (int i = 0; i < rawChars.length; i++) { final char c = rawChars[i]; - if (c == '§') { - word.append('§' + (rawChars[(i + 1)])); + if (c == '\u00A7') { + word.append('\u00A7' + (rawChars[(i + 1)])); lineColorChars += 2; i++; } else if ((c == ' ') || (c == '\n')) { @@ -945,16 +945,16 @@ public class MainUtil { if (line.length() > 0) { lines.add(line.toString()); } - if ((lines.get(0).length() == 0) || (lines.get(0).charAt(0) != '§')) { - lines.set(0, "§f" + lines.get(0)); + if ((lines.get(0).length() == 0) || (lines.get(0).charAt(0) != '\u00A7')) { + lines.set(0, "\u00A7f" + lines.get(0)); } for (int i = 1; i < lines.size(); i++) { final String pLine = lines.get(i - 1); final String subLine = lines.get(i); - final char color = pLine.charAt(pLine.lastIndexOf('§') + 1); - if ((subLine.length() == 0) || (subLine.charAt(0) != '§')) { - lines.set(i, '§' + (color) + subLine); + final char color = pLine.charAt(pLine.lastIndexOf('\u00A7') + 1); + if ((subLine.length() == 0) || (subLine.charAt(0) != '\u00A7')) { + lines.set(i, '\u00A7' + (color) + subLine); } } return lines.toArray(new String[lines.size()]); From 61ebd2a144e7af01faecc04489318c554d26f7b7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 10 Mar 2015 20:01:06 +1100 Subject: [PATCH 004/223] 2.8.3 --- PlotSquared/pom.xml | 2 +- .../plot/commands/Confirm.java | 3 +- .../plot/generator/BukkitHybridUtils.java | 42 ++++++++++++++----- .../plot/generator/HybridUtils.java | 1 - .../plot/util/bukkit/BukkitChunkManager.java | 4 +- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 2ceca78fd..1234a06fc 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.1 + 2.8.3 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java index 81e73bf20..7ac04b8b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.CmdInstance; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -32,7 +33,7 @@ import com.intellectualcrafters.plot.util.TaskManager; */ public class Confirm extends SubCommand { public Confirm() { - super(Command.CONFIRM, "Confirm command execution", "confirm", CommandCategory.ACTIONS, true); + super("confirm", "plots.use", "Confirm an action", "confirm", "confirm", CommandCategory.ACTIONS, false); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 08601cd05..7b0f4090a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -85,6 +85,7 @@ public class BukkitHybridUtils extends HybridUtils { final Chunk chunk = world.getChunkAt(x, z); chunks2.add(chunk); regenerateRoad(worldname, new ChunkLoc(x, z)); + ChunkManager.manager.unloadChunk(worldname, new ChunkLoc(x, z)); } } BukkitSetBlockManager.setBlockManager.update(chunks2); @@ -92,6 +93,8 @@ public class BukkitHybridUtils extends HybridUtils { private static boolean UPDATE = false; private int task; + private long LAST = 0; + private double AV = 1000; @Override public boolean scheduleRoadUpdate(final String world) { @@ -109,18 +112,35 @@ public class BukkitHybridUtils extends HybridUtils { Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task); return; } else { - try { - final ChunkLoc loc = chunks.get(0); - PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)"); - PlotSquared.log("Remaining regions: " + chunks.size()); - regenerateChunkChunk(world, loc); - chunks.remove(0); - } catch (final Exception e) { - final ChunkLoc loc = chunks.get(0); - PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); - PlotSquared.log("&d - Potentially skipping 256 chunks"); - PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); + if (LAST == 0) { + LAST = System.currentTimeMillis(); } + AV = (System.currentTimeMillis() - LAST + AV) / 2; + if (AV < 1050) { + try { + final ChunkLoc loc = chunks.get(0); + PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)"); + PlotSquared.log("Remaining regions: " + chunks.size()); + regenerateChunkChunk(world, loc); + chunks.remove(0); + } catch (final Exception e) { + final ChunkLoc loc = chunks.get(0); + PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); + final int sx = loc.x << 5; + final int sz = loc.z << 5; + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z)); + } + } + PlotSquared.log("&d - Potentially skipping 256 chunks"); + PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); + } + } + else { + System.out.print("TPS LOW: " + (System.currentTimeMillis() - LAST) + " | " + AV); + } + LAST = System.currentTimeMillis(); } } }, 20, 20); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index de74ba811..be33557cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -164,7 +164,6 @@ public abstract class HybridUtils { } } } - ChunkManager.manager.unloadChunk(world, chunk); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 6d3fe9a2f..bb330e878 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -169,8 +169,6 @@ public class BukkitChunkManager extends ChunkManager { final int c2z = c2.getZ(); final int c3x = c3.getX(); final int c3z = c3.getZ(); - final int c4x = c4.getX(); - final int c4z = c4.getZ(); final ArrayList chunks = new ArrayList<>(); final ArrayList toGenerate = new ArrayList<>(); // Load chunks @@ -254,7 +252,7 @@ public class BukkitChunkManager extends ChunkManager { tasks.put(currentIndex, loadTask); return true; } - + @Override public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { index.increment(); From 073b0b612c92387435b8b0eefca876eed16245b1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 10 Mar 2015 21:21:38 +1100 Subject: [PATCH 005/223] Fixed issue with default flags not being parsed when added --- .../java/com/intellectualcrafters/plot/PlotSquared.java | 4 ++++ .../com/intellectualcrafters/plot/flag/FlagManager.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 16b6f6de1..3ead9f356 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -936,4 +936,8 @@ public class PlotSquared { public static Set getPlotWorlds() { return plotworlds.keySet(); } + + public static Collection getPlotWorldObjects() { + return plotworlds.values(); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index dfd8b7cf0..355a7390e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -59,7 +59,13 @@ public class FlagManager { */ public static boolean addFlag(final AbstractFlag af) { PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af); - af.getKey(); + for (PlotWorld plotworld : PlotSquared.getPlotWorldObjects()) { + for (final Flag flag : plotworld.DEFAULT_FLAGS) { + if (flag.getAbstractFlag().getKey().equals(af.getKey())) { + flag.setKey(af); + } + } + } if (PlotSquared.getAllPlotsRaw() != null) { for (final Plot plot : PlotSquared.getPlots()) { for (final Flag flag : plot.settings.flags) { From e6fc6e070ed919e7eca3ea482550738da6165e6d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 10 Mar 2015 21:48:20 +1100 Subject: [PATCH 006/223] More lenient default flags --- PlotSquared/pom.xml | 2 +- .../plot/flag/FlagManager.java | 9 +++++- .../plot/object/PlotWorld.java | 28 +++++++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 1234a06fc..23648cfb2 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.3 + 2.8.4 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 355a7390e..3f31b270b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -339,8 +339,15 @@ public class FlagManager { public static Flag[] parseFlags(final List flagstrings) { final Flag[] flags = new Flag[flagstrings.size()]; for (int i = 0; i < flagstrings.size(); i++) { - final String[] split = flagstrings.get(i).split(";"); + final String[] split; + if (flagstrings.get(i).contains(";")) { + split = flagstrings.get(i).split(";"); + } + else { + split = flagstrings.get(i).split(":"); + } if (split.length == 1) { + System.out.print(split[0]); flags[i] = new Flag(getFlag(split[0], true), ""); } else { flags[i] = new Flag(getFlag(split[0], true), split[1]); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 8b29c521b..2dd16a0e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -20,8 +20,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.object; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; import org.apache.commons.lang.StringUtils; import org.bukkit.configuration.ConfigurationSection; @@ -116,17 +118,25 @@ public abstract class PlotWorld { this.SELL_PRICE = config.getDouble("economy.prices.sell"); this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.WORLD_BORDER = config.getBoolean("world.border"); - final List flags = config.getStringList("flags.default"); - if (flags == null) { - this.DEFAULT_FLAGS = new Flag[] {}; - } else { - try { - this.DEFAULT_FLAGS = FlagManager.parseFlags(flags); - } catch (final Exception e) { - PlotSquared.log("&cInvalid default flags for " + this.worldname + ": " + StringUtils.join(flags, ",")); - this.DEFAULT_FLAGS = new Flag[] {}; + List flags = config.getStringList("flags.default"); + if (flags == null || flags.size() == 0) { + flags = config.getStringList("flags"); + if (flags == null || flags.size() == 0) { + flags = new ArrayList(); + ConfigurationSection section = config.getConfigurationSection("flags"); + Set keys = section.getKeys(false); + for (String key : keys) { + flags.add(key + ";" + section.get(key)); + } } } + try { + this.DEFAULT_FLAGS = FlagManager.parseFlags(flags); + } catch (final Exception e) { + e.printStackTrace(); + PlotSquared.log("&cInvalid default flags for " + this.worldname + ": " + StringUtils.join(flags, ",")); + this.DEFAULT_FLAGS = new Flag[] {}; + } this.PVP = config.getBoolean("event.pvp"); this.PVE = config.getBoolean("event.pve"); this.SPAWN_EGGS = config.getBoolean("event.spawn.egg"); From 0c3b084f73433b62538df27f2ebb97999dd99d19 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 11 Mar 2015 19:47:22 +1100 Subject: [PATCH 007/223] 2.8.7: Plot home sorting, critical world init fix, piston fix --- PlotSquared/pom.xml | 2 +- .../intellectualcrafters/plot/BukkitMain.java | 1 + .../plot/PlotSquared.java | 1 + .../plot/commands/Home.java | 14 ++++++---- .../plot/commands/Visit.java | 2 +- .../plot/flag/FlagManager.java | 1 - .../plot/generator/BukkitHybridUtils.java | 18 +++++++----- .../plot/generator/HybridGen.java | 23 ++------------- .../plot/listeners/PlayerEvents.java | 2 +- .../plot/object/PlotGenerator.java | 28 +++++++++++++++++-- .../plot/util/bukkit/UUIDHandler.java | 28 +++++++++++-------- 11 files changed, 67 insertions(+), 53 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 23648cfb2..1719432e9 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.4 + 2.8.7 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index af0964ecb..9e75b9eda 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -198,6 +198,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { + PlotSquared.GEN_WORLD = world; if (!PlotSquared.setupPlotWorld(world, id)) { return null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 3ead9f356..9b92739c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -72,6 +72,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class PlotSquared { public static final String MAIN_PERMISSION = "plots.use"; public static final String ADMIN_PERMISSION = "plots.admin"; + public static String GEN_WORLD = "__PLACEHOLDER__"; public static File styleFile; public static YamlConfiguration style; public static File configFile; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 28c2b6a53..ec3c16b65 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -20,6 +20,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; + import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; @@ -46,11 +48,11 @@ public class Home extends SubCommand { @Override public boolean execute(final PlotPlayer plr, String... args) { - final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]); - if (plots.length == 1) { - MainUtil.teleportPlayer(plr, plr.getLocation(), plots[0]); + final ArrayList plots = PlotSquared.sortPlots(PlotSquared.getPlots(plr), plr.getLocation().getWorld()); + if (plots.size() == 1) { + MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); return true; - } else if (plots.length > 1) { + } else if (plots.size() > 1) { if (args.length < 1) { args = new String[] { "1" }; } @@ -72,11 +74,11 @@ public class Home extends SubCommand { MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); return true; } - if ((id > (plots.length)) || (id < 1)) { + if ((id > (plots.size())) || (id < 1)) { MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); return false; } - MainUtil.teleportPlayer(plr, plr.getLocation(), plots[id - 1]); + MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(id - 1)); return true; } else { MainUtil.sendMessage(plr, C.NO_PLOTS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index 65c996dc3..facfbad9a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -55,7 +55,7 @@ public class Visit extends SubCommand { final UUID uuid = UUIDHandler.getUUID(username); List plots = null; if (uuid != null) { - plots = getPlots(uuid); + plots = PlotSquared.sortPlots(getPlots(uuid), plr.getLocation().getWorld()); } if ((uuid == null) || plots.isEmpty()) { return sendMessage(plr, C.FOUND_NO_PLOTS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 3f31b270b..c430217aa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -347,7 +347,6 @@ public class FlagManager { split = flagstrings.get(i).split(":"); } if (split.length == 1) { - System.out.print(split[0]); flags[i] = new Flag(getFlag(split[0], true), ""); } else { flags[i] = new Flag(getFlag(split[0], true), split[1]); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 7b0f4090a..61fda9480 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -115,12 +115,14 @@ public class BukkitHybridUtils extends HybridUtils { if (LAST == 0) { LAST = System.currentTimeMillis(); } - AV = (System.currentTimeMillis() - LAST + AV) / 2; - if (AV < 1050) { + long current = System.currentTimeMillis() - LAST; + AV = Math.max(current, (current + AV * 5) / 6); + LAST = System.currentTimeMillis(); + if (AV < 1500) { try { final ChunkLoc loc = chunks.get(0); - PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)"); - PlotSquared.log("Remaining regions: " + chunks.size()); + PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)"); + PlotSquared.log(" - Remaining: " + chunks.size()); regenerateChunkChunk(world, loc); chunks.remove(0); } catch (final Exception e) { @@ -133,14 +135,16 @@ public class BukkitHybridUtils extends HybridUtils { ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z)); } } - PlotSquared.log("&d - Potentially skipping 256 chunks"); + PlotSquared.log("&d - Potentially skipping 1024 chunks"); PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); } } else { - System.out.print("TPS LOW: " + (System.currentTimeMillis() - LAST) + " | " + AV); + double tps = (20000.0/Math.min(AV, current)); + if (tps < 19) { + System.out.print("waiting for chunks to unload..."); + } } - LAST = System.currentTimeMillis(); } } }, 20, 20); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 7b27d2a1e..0b7a0ab0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -32,6 +32,7 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; @@ -88,9 +89,6 @@ public class HybridGen extends PlotGenerator { * Initialize variables, and create plotworld object used in calculations */ public void init(PlotWorld plotworld) { - if (this.plotworld == null) { - this.plotworld = (HybridPlotWorld) plotworld; - } this.plotsize = this.plotworld.PLOT_WIDTH; this.pathsize = this.plotworld.ROAD_WIDTH; this.roadblock = this.plotworld.ROAD_BLOCK.id; @@ -198,24 +196,7 @@ public class HybridGen extends PlotGenerator { /** * Return the block populator */ - public List getPopulators(final World world) { - // disabling spawning for this world - if (!this.plotworld.MOB_SPAWNING) { - if (!this.plotworld.SPAWN_EGGS) { - world.setSpawnFlags(false, false); - } - world.setAmbientSpawnLimit(0); - world.setAnimalSpawnLimit(0); - world.setMonsterSpawnLimit(0); - world.setWaterAnimalSpawnLimit(0); - } - else { - world.setSpawnFlags(true, true); - world.setAmbientSpawnLimit(-1); - world.setAnimalSpawnLimit(-1); - world.setMonsterSpawnLimit(-1); - world.setWaterAnimalSpawnLimit(-1); - } + public List getPopulators(final String world) { // You can have as many populators as you would like, e.g. tree // populator, ore populator return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld)); 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 8cf463d7a..703818a02 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -541,7 +541,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!PlotSquared.isPlotWorld(world)) { return; } - if (block.getType() != Material.PISTON_STICKY_BASE) { + if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_MOVING_PIECE) { return; } Plot plot = MainUtil.getPlot(loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 78758a4d4..c180663ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -21,7 +21,10 @@ package com.intellectualcrafters.plot.object; import java.util.List; +import java.util.Random; +import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; @@ -29,13 +32,32 @@ import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.PlotSquared; public abstract class PlotGenerator extends ChunkGenerator { + @Override public List getDefaultPopulators(World world) { - PlotSquared.loadWorld(world.getName(), this); - return getPopulators(world); + PlotSquared.loadWorld(PlotSquared.GEN_WORLD, this); +// world = Bukkit.getWorld(PlotSquared.GEN_WORLD); + PlotWorld plotworld = PlotSquared.getPlotWorld(PlotSquared.GEN_WORLD); + if (!plotworld.MOB_SPAWNING) { + if (!plotworld.SPAWN_EGGS) { + world.setSpawnFlags(false, false); + } + world.setAmbientSpawnLimit(0); + world.setAnimalSpawnLimit(0); + world.setMonsterSpawnLimit(0); + world.setWaterAnimalSpawnLimit(0); + } + else { + world.setSpawnFlags(true, true); + world.setAmbientSpawnLimit(-1); + world.setAnimalSpawnLimit(-1); + world.setMonsterSpawnLimit(-1); + world.setWaterAnimalSpawnLimit(-1); + } + return getPopulators(PlotSquared.GEN_WORLD); } - public abstract List getPopulators(World world); + public abstract List getPopulators(String world); public abstract void init(PlotWorld plotworld); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index 63989284b..3c8872251 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -1,6 +1,9 @@ package com.intellectualcrafters.plot.util.bukkit; +import java.io.File; +import java.io.FilenameFilter; import java.util.HashMap; +import java.util.HashSet; import java.util.UUID; import com.google.common.collect.BiMap; @@ -13,6 +16,7 @@ import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper; @@ -86,17 +90,7 @@ public class UUIDHandler { PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); UUIDHandler.CACHED = true; - for (OfflinePlotPlayer op : uuidWrapper.getOfflinePlayers()) { - if (op.getLastPlayed() != 0) { - String name = op.getName(); - StringWrapper wrap = new StringWrapper(name); - UUID uuid = uuidWrapper.getUUID(op); - add(wrap, uuid); - } - } - // OLD UUID CACHING SYSTEM - /* final HashSet worlds = new HashSet<>(); worlds.add(world); worlds.add("world"); @@ -139,7 +133,7 @@ public class UUIDHandler { final UUIDWrapper wrapper = new DefaultUUIDWrapper(); for (UUID uuid : uuids) { try { - final BukkitOfflinePlayer player = wrapper.getOfflinePlayer(uuid); + final OfflinePlotPlayer player = wrapper.getOfflinePlayer(uuid); uuid = UUIDHandler.uuidWrapper.getUUID(player); final StringWrapper name = new StringWrapper(player.getName()); add(name, uuid); @@ -152,8 +146,18 @@ public class UUIDHandler { final StringWrapper nameWrap = new StringWrapper(name); add(nameWrap, uuid); } - */ + + if (uuidMap.size() == 0) { + for (OfflinePlotPlayer op : uuidWrapper.getOfflinePlayers()) { + if (op.getLastPlayed() != 0) { + String name = op.getName(); + StringWrapper wrap = new StringWrapper(name); + UUID uuid = uuidWrapper.getUUID(op); + add(wrap, uuid); + } + } + } // add the Everyone '*' UUID add(new StringWrapper("*"), DBFunc.everyone); PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); From d5fe805d8f12ec9f5bc0a7e2a7c746a9034ff2b8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 11 Mar 2015 21:27:30 +1100 Subject: [PATCH 008/223] Improved sorting --- .../plot/PlotSquared.java | 38 +++++++++++-------- .../plot/commands/Purge.java | 2 +- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 9b92739c0..2ead8a81f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -149,7 +149,21 @@ public class PlotSquared { Collections.sort(newPlots, new Comparator() { @Override public int compare(Plot p1, Plot p2) { - return p1.hashCode() + p1.world.hashCode() - p2.hashCode() + p2.world.hashCode(); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + if (h1 < 0) { + h1 = -h1*2 - 1; + } + else { + h1*=2; + } + if (h2 < 0) { + h2 = -h2*2 - 1; + } + else { + h2*=2; + } + return h1-h2; } }); return newPlots; @@ -157,21 +171,15 @@ public class PlotSquared { public static ArrayList sortPlots(Collection plots, final String priorityWorld) { ArrayList newPlots = new ArrayList<>(); - newPlots.addAll(plots); - Collections.sort(newPlots, new Comparator() { - @Override - public int compare(Plot p1, Plot p2) { - int w1 = 0; - int w2 = 0; - if (!p1.world.equals(priorityWorld)) { - w1 = p1.hashCode(); - } - if (!p2.world.equals(priorityWorld)) { - w2 = p2.hashCode(); - } - return p1.hashCode() + w1 - p2.hashCode() - w2; + HashMap worldPlots = PlotSquared.plots.get(priorityWorld); + if (worldPlots != null) { + newPlots.addAll(sortPlots(worldPlots.values())); + } + for (Entry> entry : PlotSquared.plots.entrySet()) { + if (!entry.getKey().equals(priorityWorld)) { + entry.getValue().values(); } - }); + } return newPlots; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index e9438a3b7..f7e1d7bce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -92,7 +92,7 @@ public class Purge extends SubCommand { return false; } final String worldname = args[1]; - if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) { + if (!PlotSquared.getAllPlotsRaw().containsKey(worldname)) { MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } From 34eb2b00777e1f0ac69e34b0822dec0efb7b778b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 11 Mar 2015 21:53:16 +1100 Subject: [PATCH 009/223] Fix UUID mode detection --- .../src/main/java/com/intellectualcrafters/plot/BukkitMain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 9e75b9eda..7be1dfd13 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -326,7 +326,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } else { AbstractTitle.TITLE_CLASS = new DefaultTitle(); } - if (Settings.OFFLINE_MODE) { + if (Settings.OFFLINE_MODE || Bukkit.getOnlineMode() == false) { UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); Settings.OFFLINE_MODE = true; } else if (checkVersion) { From c7b1af7f66f5c186061aa9cb94aee58fc31209f1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 11 Mar 2015 22:04:08 +1100 Subject: [PATCH 010/223] quotes around name --- .../com/intellectualcrafters/plot/database/PlotMeConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 681d1d42a..a76b2b2c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -110,7 +110,7 @@ public class PlotMeConverter { if (name.equals("*")) { owner = DBFunc.everyone; } else { - sendMessage("&cCould not identify owner for plot: " + id + " -> " + name); + sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); continue; } } From 15b24b0a0006d0ba2c5184b38b8010e8457f8365 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 11 Mar 2015 22:16:57 +1100 Subject: [PATCH 011/223] Fixed default key --- .../java/com/intellectualcrafters/plot/object/PlotWorld.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 2dd16a0e2..9af2659b9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -126,7 +126,9 @@ public abstract class PlotWorld { ConfigurationSection section = config.getConfigurationSection("flags"); Set keys = section.getKeys(false); for (String key : keys) { - flags.add(key + ";" + section.get(key)); + if (!key.equals("default")) { + flags.add(key + ";" + section.get(key)); + } } } } From a32c3067c5f16033c69c50490c5ef5ea2d08b844 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 11 Mar 2015 23:26:39 +1100 Subject: [PATCH 012/223] fix list (again) and update debugroadregen --- .../plot/PlotSquared.java | 36 ++++++++++++------- .../plot/commands/DebugRoadRegen.java | 1 + .../plot/commands/Home.java | 2 +- .../plot/commands/list.java | 5 ++- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 2ead8a81f..edd471e5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -173,11 +173,19 @@ public class PlotSquared { ArrayList newPlots = new ArrayList<>(); HashMap worldPlots = PlotSquared.plots.get(priorityWorld); if (worldPlots != null) { - newPlots.addAll(sortPlots(worldPlots.values())); + for (Plot plot : sortPlots(worldPlots.values())) { + if (plots.contains(plot)) { + newPlots.add(plot); + } + } } for (Entry> entry : PlotSquared.plots.entrySet()) { if (!entry.getKey().equals(priorityWorld)) { - entry.getValue().values(); + for (Plot plot : entry.getValue().values()) { + if (plots.contains(plot)) { + newPlots.add(plot); + } + } } } return newPlots; @@ -504,18 +512,20 @@ public class PlotSquared { // Set chunk ChunkManager.manager = IMP.initChunkManager(); // PlotMe - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - if (IMP.initPlotMeConverter()) { - log("&c=== IMPORTANT ==="); - log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); - log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); - log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); - log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'"); + if (Settings.CONVERT_PLOTME) { + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + if (IMP.initPlotMeConverter()) { + log("&c=== IMPORTANT ==="); + log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); + log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); + log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); + log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'"); + } } - } - }, 200); + }, 200); + } if (Settings.AUTO_CLEAR) { ExpireManager.runTask(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 0c8c4ff4d..8ba3ee56f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -47,6 +47,7 @@ public class DebugRoadRegen extends SubCommand { MainUtil.update(loc); } MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + MainUtil.update(loc); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index ec3c16b65..6a3e13d11 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -81,7 +81,7 @@ public class Home extends SubCommand { MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(id - 1)); return true; } else { - MainUtil.sendMessage(plr, C.NO_PLOTS); + MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index b47a9ae79..d563738d9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -113,16 +113,19 @@ public class list extends SubCommand { break; } plots = PlotSquared.getPlots(plr); + break; } case "shared": { if (plr == null) { break; } + plots = new ArrayList(); for (Plot plot : PlotSquared.getPlots()) { if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) { plots.add(plot); } } + break; } case "world": { plots = PlotSquared.getPlots(world).values(); @@ -185,7 +188,7 @@ public class list extends SubCommand { } if (plots.size() == 0) { - MainUtil.sendMessage(plr, C.NO_PLOTS); + MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS); return false; } From e016cb5c85156b02d3b82379906689d6f5c30063 Mon Sep 17 00:00:00 2001 From: Roman Alexander Date: Wed, 11 Mar 2015 11:08:51 -0400 Subject: [PATCH 013/223] Fixed plot permissions never working. --- .../java/com/intellectualcrafters/plot/commands/Auto.java | 2 +- .../main/java/com/intellectualcrafters/plot/commands/Buy.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Claim.java | 2 +- .../java/com/intellectualcrafters/plot/util/MainUtil.java | 4 ++-- .../java/com/intellectualcrafters/plot/util/Permissions.java | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 31cecb185..ef40badde 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -120,7 +120,7 @@ public class Auto extends SubCommand { return false; } final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); - final int diff = currentPlots - MainUtil.getAllowedPlots(plr, currentPlots); + final int diff = currentPlots - MainUtil.getAllowedPlots(plr); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 624ff89cf..256a152bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -68,7 +68,7 @@ public class Buy extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); - if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { + if (currentPlots >= MainUtil.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } if (!plot.hasOwner()) { 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 afa6813fd..d4210dd80 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -91,7 +91,7 @@ public class Claim extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr); - if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) { + if (currentPlots >= MainUtil.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } if (plot.hasOwner()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0292e96b7..97389b968 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -1101,8 +1101,8 @@ public class MainUtil { * @param p * @return */ - public static int getAllowedPlots(final PlotPlayer p, final int current) { - return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS, current); + public static int getAllowedPlots(final PlotPlayer p) { + return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); } public static Plot getPlot(final Location loc) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 28f5594e2..491888487 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -36,14 +36,14 @@ public class Permissions { return false; } - public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range, final int min) { + public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) { return Byte.MAX_VALUE; } if (player.hasPermission(stub + ".*")) { return Byte.MAX_VALUE; } - for (int i = min; i < range; i++) { + for (int i = range; i > 0; i--) { if (player.hasPermission(stub + "." + i)) { return i; } From 79f97a73091a6e3faabd9693257fc0c5f8256f0d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 07:36:41 +1100 Subject: [PATCH 014/223] Remove workaround as issue was fixed by spigot --- .../main/java/com/intellectualcrafters/plot/BukkitMain.java | 1 - .../java/com/intellectualcrafters/plot/PlotSquared.java | 1 - .../com/intellectualcrafters/plot/object/PlotGenerator.java | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 7be1dfd13..ed1444b97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -198,7 +198,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) { - PlotSquared.GEN_WORLD = world; if (!PlotSquared.setupPlotWorld(world, id)) { return null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index edd471e5b..54e1bb439 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -72,7 +72,6 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class PlotSquared { public static final String MAIN_PERMISSION = "plots.use"; public static final String ADMIN_PERMISSION = "plots.admin"; - public static String GEN_WORLD = "__PLACEHOLDER__"; public static File styleFile; public static YamlConfiguration style; public static File configFile; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index c180663ef..3af8c37ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -35,9 +35,9 @@ public abstract class PlotGenerator extends ChunkGenerator { @Override public List getDefaultPopulators(World world) { - PlotSquared.loadWorld(PlotSquared.GEN_WORLD, this); + PlotSquared.loadWorld(world.getName(), this); // world = Bukkit.getWorld(PlotSquared.GEN_WORLD); - PlotWorld plotworld = PlotSquared.getPlotWorld(PlotSquared.GEN_WORLD); + PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName()); if (!plotworld.MOB_SPAWNING) { if (!plotworld.SPAWN_EGGS) { world.setSpawnFlags(false, false); @@ -54,7 +54,7 @@ public abstract class PlotGenerator extends ChunkGenerator { world.setMonsterSpawnLimit(-1); world.setWaterAnimalSpawnLimit(-1); } - return getPopulators(PlotSquared.GEN_WORLD); + return getPopulators(world.getName()); } public abstract List getPopulators(String world); From 12f024664a2f5b99d89c05a41be6dd85c69c4bfc Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 14:15:17 +1100 Subject: [PATCH 015/223] titles for 1.8.3 --- .../plot/titles/DefaultTitle.java | 2 +- .../plot/titles/DefaultTitleManager_183.java | 404 ++++++++++++++++++ .../plot/titles/DefaultTitle_183.java | 19 + 3 files changed, 424 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle_183.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java index 028687206..a4238665c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle.java @@ -12,7 +12,7 @@ public class DefaultTitle extends AbstractTitle { title.setSubtitleColor(sub_color); title.send(player); } catch (final Throwable e) { - AbstractTitle.TITLE_CLASS = new HackTitle(); + AbstractTitle.TITLE_CLASS = new DefaultTitle_183(); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java new file mode 100644 index 000000000..cb175c28a --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java @@ -0,0 +1,404 @@ +package com.intellectualcrafters.plot.titles; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +/** + * [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ] + * + * @version 1.1.0 + * @author Maxim Van de Wynckel + * + */ +public class DefaultTitleManager_183 { + /* Title packet */ + private Class packetTitle; + /* Title packet actions ENUM */ + private Class packetActions; + /* Chat serializer */ + private Class nmsChatSerializer; + private Class chatBaseComponent; + /* Title text and color */ + private String title = ""; + private ChatColor titleColor = ChatColor.WHITE; + /* Subtitle text and color */ + private String subtitle = ""; + private ChatColor subtitleColor = ChatColor.WHITE; + /* Title timings */ + private int fadeInTime = -1; + private int stayTime = -1; + private int fadeOutTime = -1; + private boolean ticks = false; + private static final Map, Class> CORRESPONDING_TYPES = new HashMap, Class>(); + + /** + * Create a new 1.8 title + * + * @param title + * Title + * @throws ClassNotFoundException + */ + public DefaultTitleManager_183(final String title) throws ClassNotFoundException { + this.title = title; + loadClasses(); + } + + /** + * Create a new 1.8 title + * + * @param title + * Title text + * @param subtitle + * Subtitle text + * @throws ClassNotFoundException + */ + public DefaultTitleManager_183(final String title, final String subtitle) throws ClassNotFoundException { + this.title = title; + this.subtitle = subtitle; + loadClasses(); + } + + /** + * Copy 1.8 title + * + * @param title + * Title + * @throws ClassNotFoundException + */ + public DefaultTitleManager_183(final DefaultTitleManager_183 title) throws ClassNotFoundException { + // Copy title + this.title = title.title; + this.subtitle = title.subtitle; + this.titleColor = title.titleColor; + this.subtitleColor = title.subtitleColor; + this.fadeInTime = title.fadeInTime; + this.fadeOutTime = title.fadeOutTime; + this.stayTime = title.stayTime; + this.ticks = title.ticks; + loadClasses(); + } + + /** + * Create a new 1.8 title + * + * @param title + * Title text + * @param subtitle + * Subtitle text + * @param fadeInTime + * Fade in time + * @param stayTime + * Stay on screen time + * @param fadeOutTime + * Fade out time + * @throws ClassNotFoundException + */ + public DefaultTitleManager_183(final String title, final String subtitle, final int fadeInTime, final int stayTime, final int fadeOutTime) throws ClassNotFoundException { + this.title = title; + this.subtitle = subtitle; + this.fadeInTime = fadeInTime; + this.stayTime = stayTime; + this.fadeOutTime = fadeOutTime; + loadClasses(); + } + + /** + * Load spigot and NMS classes + * @throws ClassNotFoundException + */ + private void loadClasses() throws ClassNotFoundException { + this.packetTitle = getNMSClass("PacketPlayOutTitle"); + this.chatBaseComponent = getNMSClass("IChatBaseComponent"); + this.packetActions = getNMSClass("PacketPlayOutTitle$EnumTitleAction"); + this.nmsChatSerializer = getNMSClass("IChatBaseComponent$ChatSerializer"); + + } + + /** + * Set title text + * + * @param title + * Title + */ + public void setTitle(final String title) { + this.title = title; + } + + /** + * Get title text + * + * @return Title text + */ + public String getTitle() { + return this.title; + } + + /** + * Set subtitle text + * + * @param subtitle + * Subtitle text + */ + public void setSubtitle(final String subtitle) { + this.subtitle = subtitle; + } + + /** + * Get subtitle text + * + * @return Subtitle text + */ + public String getSubtitle() { + return this.subtitle; + } + + /** + * Set the title color + * + * @param color + * Chat color + */ + public void setTitleColor(final ChatColor color) { + this.titleColor = color; + } + + /** + * Set the subtitle color + * + * @param color + * Chat color + */ + public void setSubtitleColor(final ChatColor color) { + this.subtitleColor = color; + } + + /** + * Set title fade in time + * + * @param time + * Time + */ + public void setFadeInTime(final int time) { + this.fadeInTime = time; + } + + /** + * Set title fade out time + * + * @param time + * Time + */ + public void setFadeOutTime(final int time) { + this.fadeOutTime = time; + } + + /** + * Set title stay time + * + * @param time + * Time + */ + public void setStayTime(final int time) { + this.stayTime = time; + } + + /** + * Set timings to ticks + */ + public void setTimingsToTicks() { + this.ticks = true; + } + + /** + * Set timings to seconds + */ + public void setTimingsToSeconds() { + this.ticks = false; + } + + /** + * Send the title to a player + * + * @param player + * Player + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + public void send(final Player player) throws Exception { + if (this.packetTitle != null) { + // First reset previous settings + resetTitle(player); + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20), this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20)); + // Send if set + if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) { + sendPacket.invoke(connection, packet); + } + // Send title + Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); + packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized); + sendPacket.invoke(connection, packet); + if (this.subtitle != "") { + // Send subtitle if present + serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name().toLowerCase() + "}"); + packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized); + sendPacket.invoke(connection, packet); + } + } + } + + /** + * Broadcast the title to all players + * @throws Exception + */ + public void broadcast() throws Exception { + for (final Player p : Bukkit.getOnlinePlayers()) { + send(p); + } + } + + /** + * Clear the title + * + * @param player + * Player + */ + public void clearTitle(final Player player) { + try { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null); + sendPacket.invoke(connection, packet); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + /** + * Reset the title settings + * + * @param player + * Player + */ + public void resetTitle(final Player player) { + try { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null); + sendPacket.invoke(connection, packet); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + private Class getPrimitiveType(final Class clazz) { + return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; + } + + private Class[] toPrimitiveTypeArray(final Class[] classes) { + final int a = classes != null ? classes.length : 0; + final Class[] types = new Class[a]; + for (int i = 0; i < a; i++) { + types[i] = getPrimitiveType(classes[i]); + } + return types; + } + + private static boolean equalsTypeArray(final Class[] a, final Class[] o) { + if (a.length != o.length) { + return false; + } + for (int i = 0; i < a.length; i++) { + if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) { + return false; + } + } + return true; + } + + private Object getHandle(final Object obj) { + try { + return getMethod("getHandle", obj.getClass()).invoke(obj); + } catch (final Exception e) { + e.printStackTrace(); + return null; + } + } + + private Method getMethod(final String name, final Class clazz, final Class... paramTypes) { + final Class[] t = toPrimitiveTypeArray(paramTypes); + for (final Method m : clazz.getMethods()) { + final Class[] types = toPrimitiveTypeArray(m.getParameterTypes()); + if (m.getName().equals(name) && equalsTypeArray(types, t)) { + return m; + } + } + return null; + } + + private String getVersion() { + final String name = Bukkit.getServer().getClass().getPackage().getName(); + final String version = name.substring(name.lastIndexOf('.') + 1) + "."; + return version; + } + + private Class getNMSClass(final String className) throws ClassNotFoundException { + final String fullName = "net.minecraft.server." + getVersion() + className; + Class clazz = null; + clazz = Class.forName(fullName); + return clazz; + } + + private Field getField(final Class clazz, final String name) { + try { + final Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + return field; + } catch (final Exception e) { + e.printStackTrace(); + return null; + } + } + + private Method getMethod(final Class clazz, final String name, final Class... args) { + for (final Method m : clazz.getMethods()) { + if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) { + m.setAccessible(true); + return m; + } + } + return null; + } + + private boolean ClassListEqual(final Class[] l1, final Class[] l2) { + boolean equal = true; + if (l1.length != l2.length) { + return false; + } + for (int i = 0; i < l1.length; i++) { + if (l1[i] != l2[i]) { + equal = false; + break; + } + } + return equal; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle_183.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle_183.java new file mode 100644 index 000000000..3d0fee636 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitle_183.java @@ -0,0 +1,19 @@ +package com.intellectualcrafters.plot.titles; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +public class DefaultTitle_183 extends AbstractTitle { + @Override + public void sendTitle(final Player player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color) { + try { + final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, 1, 2, 1); + title.setTitleColor(head_color); + title.setSubtitleColor(sub_color); + title.send(player); + } catch (final Throwable e) { + AbstractTitle.TITLE_CLASS = new HackTitle(); + AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color); + } + } +} From 1f8702f072b00152a04626dc64ad26ea59aca433 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 19:52:26 +1100 Subject: [PATCH 016/223] Entity tracking and invalid world detection --- .../plot/PlotSquared.java | 6 +- .../plot/util/ChunkManager.java | 2 + .../plot/util/MainUtil.java | 2 +- .../plot/util/bukkit/BukkitChunkManager.java | 72 +++++++++++++++++++ 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 54e1bb439..9c9326ba7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -136,8 +136,10 @@ public class PlotSquared { public static Set getPlots() { final ArrayList newplots = new ArrayList<>(); - for (final HashMap world : plots.values()) { - newplots.addAll(world.values()); + for (final Entry> entry : plots.entrySet()) { + if (isPlotWorld(entry.getKey())) { + newplots.addAll(entry.getValue().values()); + } } return new LinkedHashSet<>(newplots); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index 6e94e3656..a007f5009 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -21,6 +21,8 @@ public abstract class ChunkManager { final int z = loc.getZ() >> 9; return new ChunkLoc(x, z); } + + public abstract int countEntities(Plot plot); public abstract boolean loadChunk(String world, ChunkLoc loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0292e96b7..cbe2db01e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -54,7 +54,7 @@ public class MainUtil { static long state = 1; public static HashMap lastPlot = new HashMap<>(); public static HashMap worldBorder = new HashMap<>(); - + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { final Plot plot1 = PlotSquared.getPlots(world).get(pos1); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index bb330e878..f96679c86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -865,4 +865,76 @@ public class BukkitChunkManager extends ChunkManager { clearAllEntities(MainUtil.getPlot(worldname, pos2)); // FIXME swap plots } + + @Override + public int countEntities(Plot plot) { + int count = 0; + World world = BukkitUtil.getWorld(plot.world); + + Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + int bx = bot.getX() >> 4; + int bz = bot.getZ() >> 4; + + int tx = top.getX() >> 4; + int tz = top.getZ() >> 4; + + int size = (tx-bx) << 4; + + HashSet chunks = new HashSet<>(); + for (int X = bx; X <= tx; X++) { + for (int Z = bz; Z <= tz; Z++) { + chunks.add(world.getChunkAt(X,Z)); + } + } + + boolean doWhole = false; + List entities = null; + if (size > 200) { + entities = world.getEntities(); + if (entities.size() < 16 + (size * size / 64)) { + doWhole = true; + } + } + + if (doWhole) { + for (final Entity entity : entities) { + org.bukkit.Location loc = entity.getLocation(); + Chunk chunk = loc.getChunk(); + if (chunks.contains(chunk)) { + int X = chunk.getX(); + int Z = chunk.getX(); + if (X > bx && X < tx && Z > bz && Z < tz) { + count++; + } + else { + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc)); + if (plot.id.equals(id)) { + count++; + } + } + } + } + } + else { + for (Chunk chunk : chunks) { + int X = chunk.getX(); + int Z = chunk.getX(); + Entity[] ents = chunk.getEntities(); + if (X == bx || X == tx || Z == bz || Z == tz) { + for (final Entity entity : ents) { + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); + if (plot.id.equals(id)) { + count++; + } + } + } + else { + count += ents.length; + } + } + return count; + } + return count; + } } From a1d476321f89d79eb2688a7c2befe411ca18ac7f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 20:20:17 +1100 Subject: [PATCH 017/223] Fixed purge in offline mode servers + typo --- .../plot/commands/Purge.java | 22 +++++++++---------- .../intellectualcrafters/plot/config/C.java | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index f7e1d7bce..2fd574adc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -107,17 +107,6 @@ public class Purge extends SubCommand { DBFunc.purgeIds(worldname, ids); return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0); } - final UUID uuid = UUIDHandler.getUUID(args[0]); - if (uuid != null) { - final Set plots = PlotSquared.getPlots(worldname, uuid); - final Set ids = new HashSet<>(); - for (final Plot plot : plots) { - ids.add(plot.id); - } - int length = ids.size(); - DBFunc.purge(worldname, ids); - return finishPurge(length); - } if (arg.equals("all")) { final Set ids = PlotSquared.getPlots(worldname).keySet(); int length = ids.size(); @@ -160,6 +149,17 @@ public class Purge extends SubCommand { DBFunc.purge(worldname, ids); return finishPurge(length); } + final UUID uuid = UUIDHandler.getUUID(args[0]); + if (uuid != null) { + final Set plots = PlotSquared.getPlots(worldname, uuid); + final Set ids = new HashSet<>(); + for (final Plot plot : plots) { + ids.add(plot.id); + } + int length = ids.size(); + DBFunc.purge(worldname, ids); + return finishPurge(length); + } MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 0184af139..f32d3e76d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -236,7 +236,7 @@ public enum C { * purge */ PURGE_SYNTAX("Use /plot purge "), - PURGE_SUCCESS("$4Successfully purge %s plots"), + PURGE_SUCCESS("$4Successfully purged %s plots"), /* * trim */ From 27f6675d8f91c70630ceb041f255c3a89a73e7de Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 20:28:08 +1100 Subject: [PATCH 018/223] Optional permission caching --- .../plot/PlotSquared.java | 4 +++ .../plot/config/Settings.java | 1 + .../plot/object/BukkitPlayer.java | 26 +++++++++++-------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 9c9326ba7..3bcb1324a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -781,6 +781,9 @@ public class PlotSquared { options.put("max_plots", Settings.MAX_PLOTS); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK); + + options.put("cache.permissions", Settings.PERMISSION_CACHING); + options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); @@ -795,6 +798,7 @@ public class PlotSquared { log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } + Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete"); Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink"); 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 051ab5cf0..10f253877 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -32,6 +32,7 @@ public class Settings { * Default UUID_FECTHING: false */ public static boolean UUID_FECTHING = false; + public static boolean PERMISSION_CACHING = false; public static boolean UUID_FROM_DISK = false; /** * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 2c2d86bd2..dc7c85592 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -5,6 +5,7 @@ import java.util.UUID; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -40,19 +41,22 @@ public class BukkitPlayer implements PlotPlayer { @Override public boolean hasPermission(final String perm) { - if (this.noPerm.contains(perm)) { - return false; - } - if (this.hasPerm.contains(perm)) { + if (Settings.PERMISSION_CACHING) { + if (this.noPerm.contains(perm)) { + return false; + } + if (this.hasPerm.contains(perm)) { + return true; + } + final boolean result = this.player.hasPermission(perm); + if (!result) { + this.noPerm.add(perm); + return false; + } + this.hasPerm.add(perm); return true; } - final boolean result = this.player.hasPermission(perm); - if (!result) { - this.noPerm.add(perm); - return false; - } - this.hasPerm.add(perm); - return true; + return this.player.hasPermission(perm); } @Override From d0fe132c8243cb188401480c33af946cb2d0fea5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 23:25:59 +1100 Subject: [PATCH 019/223] Fixed PlotMe convert for some cases of SQLite --- .../plot/commands/Set.java | 2 +- .../plot/database/SQLManager.java | 62 +++++++++++++++---- 2 files changed, 52 insertions(+), 12 deletions(-) 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 d52b13113..bfaf58697 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -164,7 +164,7 @@ public class Set extends SubCommand { final String world = plr.getLocation().getWorld(); final Location base = MainUtil.getPlotBottomLoc(world, plot.id); base.setY(0); - final Location relative = plr.getLocation().subtract(base.getX(), base.getZ(), base.getY()); + final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ()); final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ()); plot.settings.setPosition(blockloc); DBFunc.setPosition(loc.getWorld(), plot, relative.getX() + "," + relative.getY() + "," + relative.getZ()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 3beeb683e..bf019160a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -26,6 +26,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -241,7 +242,7 @@ public class SQLManager implements AbstractDB { if (PlotSquared.getMySQL() != null) { packet = Math.min(size, 50000); } else { - packet = Math.min(size, 5000); + packet = Math.min(size, 100); } final int amount = size / packet; for (int j = 0; j <= amount; j++) { @@ -271,19 +272,58 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); } catch (final Exception e) { - e.printStackTrace(); - PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower..."); try { - for (final Plot plot : plots) { - try { - createPlot(plot); - } catch (final Exception e3) { - PlotSquared.log("&c[ERROR] " + "Failed to save plot: " + plot.id); - } + // TODO UNION + + /* + + INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values + + INSERT INTO 'tablename' + SELECT 'data1' AS 'column1', 'data2' AS 'column2' + UNION SELECT 'data3', 'data4' + UNION SELECT 'data5', 'data6' + UNION SELECT 'data7', 'data8' + + + */ + StringBuilder unionstmt = new StringBuilder("INSERT INTO `" + this.prefix + "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` "); + for (int i = 0; i < (plots.size() - 2); i++) { + unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ? "); } - } catch (final Exception e2) { + unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ? "); + stmt = this.connection.prepareStatement(unionstmt.toString()); + for (int i = 0; i < plots.size(); i++) { + final Plot plot = plots.get(i); + stmt.setNull((i * 6) + 1, 4); + stmt.setInt((i * 6) + 2, plot.id.x); + stmt.setInt((i * 6) + 3, plot.id.y); + try { + stmt.setString((i * 6) + 4, plot.owner.toString()); + } catch (final Exception e1) { + stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); + } + stmt.setString((i * 6) + 5, plot.world); + stmt.setTimestamp((i * 6) + 6, new Timestamp(System.currentTimeMillis())); + } + stmt.executeUpdate(); + stmt.close(); + } + catch (Exception e2) { e2.printStackTrace(); - PlotSquared.log("&c[ERROR] " + "Failed to save plots!"); + PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower..."); + try { + for (final Plot plot : plots) { + try { + createPlot(plot); + } catch (final Exception e3) { + PlotSquared.log("&c[ERROR] " + "Failed to save plot: " + plot.id); + } + } + } catch (final Exception e4) { + e4.printStackTrace(); + PlotSquared.log("&c[ERROR] " + "Failed to save plots!"); + } } } } From 76daef844041a28acbec060e197c2f6a6eef15f7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 12 Mar 2015 23:41:11 +1100 Subject: [PATCH 020/223] Fixed piston retract for pre 1.8 --- .../plot/listeners/PlayerEvents.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 703818a02..eadeb29ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -546,13 +546,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null) { - for (final Block b : event.getBlocks()) { - Location bloc = BukkitUtil.getLocation(b.getLocation()); - Plot newPlot = MainUtil.getPlot(bloc); - if (!plot.equals(newPlot)) { - event.setCancelled(true); - return; - } + final Block b = event.getRetractLocation().getBlock(); + Location bloc = BukkitUtil.getLocation(b.getLocation()); + Plot newPlot = MainUtil.getPlot(bloc); + if (!plot.equals(newPlot)) { + event.setCancelled(true); + return; } } } From 79d548aaf96cd3dd3d00e63f5ff2405901fb6f1f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 00:17:37 +1100 Subject: [PATCH 021/223] Update version --- PlotSquared/pom.xml | 2 +- .../main/java/com/intellectualcrafters/plot/util/MainUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 1719432e9..841f5f969 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.7 + 2.8.8 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index cbe2db01e..01f29bbe8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -158,7 +158,7 @@ public class MainUtil { public static void update(final Location loc) { final String world = loc.getWorld(); int ox = loc.getX() >> 4; - int oz = loc.getX() >> 4; + int oz = loc.getZ() >> 4; final ArrayList chunks = new ArrayList<>(); final int distance = BukkitUtil.getViewDistance(); for (int cx = -distance; cx <= distance; cx++) { From 8363acb735ca1f466d6e7023a337c80443ebdeaa Mon Sep 17 00:00:00 2001 From: xion87 Date: Thu, 12 Mar 2015 17:40:31 +0100 Subject: [PATCH 022/223] Added Italian Translation file --- translation/It_it/PlotSquared.use_THIS.yml | 229 +++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 translation/It_it/PlotSquared.use_THIS.yml diff --git a/translation/It_it/PlotSquared.use_THIS.yml b/translation/It_it/PlotSquared.use_THIS.yml new file mode 100644 index 000000000..4caa21259 --- /dev/null +++ b/translation/It_it/PlotSquared.use_THIS.yml @@ -0,0 +1,229 @@ +camera_started: "$2You have entered camera mode for plot $1%s" +command_syntax: "$1Usa: $2%s" +not_valid_flag: "$2Quella non è una flag valida" +setup_world_taken: "$2%s è già un mondo lotti registrato" +plot_list_item: "$2>> $1%id$2:$1%world $2- $1%owner" +schematic_invalid: "$2Schematic invalido. Motivo: $2%s" +setup_invalid_generator: "$2Generatore invalido. Opzioni possibili: %s" +teleported_to_road: "$2Sei stato teletrasportato in strada" +debug_section: "$2>> $1&l%val%" +plot_id_form: "$2L'id del lotto deve essere scritto in questa forma: $1X;Y $2esempio $1-5;7" +invalid_position: "$2Non è una posizione valida" +not_in_plot_world: "$2Non sei in un mondo lotti" +cannot_buy_own: "$2Non puoi acquistare il tuo stesso lotto" +help_item: "$1%usage% [%alias%]&- $3- $2%desc%&-" +not_valid_world: "$2Quello non è un mondo valido (case sensitive)" +home_argument: "$2Usa /plot set home" +title_left_plot_color: "GOLD" +debug_line: "$2>> $1%var%$2:$1 %val% " +comment_added: "$4Un commento è stato lasciato" +alias_is_taken: "$2Quel alias è già in uso" +setup_missing_generator: "$2Devi specificare un generatore($1/plot setup &l&r$2)&-$1Commandi addizionali:&-$2 - $1/plot setup &-$2 - $1/plot setup back&-$2 - $1/plot setup cancel" +block_list_separater: "$1,$2 " +alias_set_to: "$2Alias lotto cambiato in $1%alias%" +did_you_mean: "$2Intendevi dire: $1%s" +cluster_not_added: "$2Quel giocatore non è stato aggiunto al lotto cluster" +position_set: "$1Casa settata nella tua posizione corrente" +cluster_regenerated: "$4Rigenerazione Cluster iniziata correttamente" +not_valid_data: "$2Quello non è un id valido." +not_for_sale: "$2Questo lotto non è in vendita" +not_in_cluster: "$2Devi essere dentro a un lotto cluster per eseguire quel commando" +schematic_paste_success: "$4Schematic incollato con successo" +set_block_action_finished: "$1L'ultima azione setblock ora è terminata." +missing_alias: "$2Devi specificare un alias" +paste_failed: "$2Incollaggio fallito. Motivo: $2%s" +invalid_player: "$2Giocatore non trovato: $1%s." +plot_info_helpers: "$1Aiutanti:$2 %helpers%" +cluster_added: "$4Creato un cluster con successo." +setup_init: "$1Usa: $2/plot setup " +bossbar_clearing: "$2Pulizia lotto: $1%id%" +title_entered_plot_sub_color: "RED" +prefix_greeting: "$1%id%$2> " +not_your_plot: "$2Quel lotto non è tuo." +not_valid_plot_id: "$2Non è un id lotto valido." +unclaim_success: "$4Hai liberato il lotto con successo." +teleport_failed: "$2Teletrasporto annulato per movimento o danni" +need_plot_world: "$2Devi specificare un mondo lotti." +plot_not_claimed: "$2Lotto non claimato" +title_entered_plot_color: "GOLD" +denied_removed: "$4YHai rimosso con successo il giocatori dalla lista bloccati di questo lotto" +plot_removed_helper: "$1Lotto %s il quale eri stato aggiunto è stato eliminato per inattività del proprietario" +generating_component: "$1Iniziando a generare componenti dalla tua configurazione" +not_valid_block_list_header: "$2Quel blocco non è valido. I blocchi validi sono: " +alias_too_long: "$2L'alias deve esssere deve essere lungo meno di 50 caratteri" +move_success: "$4Spostato il lotto con successo." +no_plot_perms: "$2Devi essere il proprietario di questo lotto per eseguire questo commando" +command_went_wrong: "$2Ops qualcosa è andato storto..." +helper_added: "$4Hai aggiunto con sucesso un aiutante nel tuo lotto" +schematic_paste_failed: "$2Incollaggio schematic fallito" +removed_balance: "$1%s $2sono stati detrati dal tuo bilancio" +setup_step: "$3[$1Passo %s$3] $1%s $2- $1Stimato: $2%s $1Default: $2%s" +schematic_valid: "$2Quello è uno schema valido" +owner_sign_line_4: "$3Claimato" +cluster_added_helper: "$4Aggiunto con successo un aiutante al cluster" +owner_sign_line_3: "$2%plr%" +already_owner: "$2Quel utente è già il proprietario di questo lotto" +owner_sign_line_2: "$1Proprietario:" +owner_sign_line_1: "$1ID: $1%id%" +not_valid_subcommand: "$2Non è un sottocomando valido" +subcommand_set_options_header: "$2Valori possibili: " +requires_unowned: "$2La località specificata è già occupata." +plot_unowned: "$2Il lotto corrente deve avere un proprietario per eseguire questo commando" +cannot_kick_player: "$2Non puoi cacciare quel giocatore" +clearing_done: "$4Pulizia completata! tempo %sms." +setup_valid_arg: "$2Valore $1%s $2settato a %s" +camera_stopped: "$2You are no longer in camera mode" +flag_type: "$2Tipo: %s" +pasted: "$4La selezione dei lotti è stata incollata. Ed è stata pulita dal tuo clipboard." +cluster_info: "$1Cluster corrente: $2%id%&-$1Nome: $2%name%&-$1Proprietario: $2%owner%&-$1Dimensione: $2%size%&-$1Permessi: $2%rights%" +cluster_cannot_leave: "$1Devi eliminare o transferire la proprietà prima di lasciarlo" +help_header: "$3====== $1Aiuto Plot² $3======" +cannot_afford_merge: "$2Non hai abbastanza soldi per unire i lotti. Costa $1%s" +setting_updated: "$4Hai aggiornato le impostazioni con successo" +need_key: "$2Valori possibili: $1%values%" +compass_target: "$4Lotto targetato con successo co il compasso" +flag_not_added: "$2Quella flag non può essere aggiunta" +no_plots: "$2Non hai nessun lotto. Se prima lo avevi contatta lo staff." +need_plot_id: "$2Devi specificare un id lotto." +flag_not_removed: "$2Quella flag non può essere rimossa" +trusted_removed: "$1Hai rimosso con successo un opsite dal lotto" +flag_removed: "$4Flag rimossa con successo" +rating_applied: "$4Hai votato con succeso il lotto $2%s" +requires_confirm: "$2Sei sicuro di eseguire: $1%s$2?&-$2Non può essere annullato! Se sei sicuro: $1/plot confirm" +flag_added: "$4Flag aggiunta con successo" +econ_disabled: "$2Economia non abilitata" +not_valid_hybrid_plot_world: "Un hybrid plot manager è richiesto per fare questa azione" +no_commands: "$2Nessun permesso per eseguire i sottocomandi." +missing_position: "$2Devi specificare una posizione. Valori possibili: $1none" +record_play: "$2%player $2started playing record $1%name" +unlink_required: "$2Un slaciamento del lotto è richiesto." +denied_need_argument: "$2Devi specificare un argomento. $1/plot denied add $2oppure $1/plot helpers remove " +added_balance: "$1%s $2sono stati aggiunti al tuo bilancio" +not_using_plotme: "$2Questo server usa il sistema lotti $2PlotSquared. Digita $1/plots $2oppure $1/p" +player_has_not_been_on: "$2Quel giocatore non è mai stato nei mondi lotti" +plot_list_footer: "$2>> $1%word% ha un totale di $2%num% %plot% %1claimati." +trim_in_progress: "Un world trim task è già in esecuzione!" +cluster_deleted: "$4Eliminato il cluster con successo." +cant_claim_more_plots: "$2Non puoi avere ulteriori lotti." +unlink_success: "$2Lotti scollegati con successo." +prefix: "$3[$1P²$3] " +claimed: "$4Hai claimato il lotto con successo!" +schematic_missing_arg: "$2YDevi specificare un argomento. Valori possibili: $1test $2 , $1save$2 , $1paste $2, $1exportall" +block_list_item: " $1%mat%$2," +not_in_plot: "$2Non sei in un lotto." +reload_failed: "$2Ricarimento configurazione fallita" +found_no_plots: "$2Non ho trovato lotti con la tua ricerca" +prefix_farewell: "$1%id%$2> " +was_not_denied: "$2Quel giocatore non è bloccato nel tuo lotto" +clipboard_info: "$2Selezione corrente - ID Lotto: $1%id$2, Lunghezza: $1%width$2, Blocchi totali: $1%total$2" +plot_info_denied: "$1Bloccati:$2 %denied%" +notify_enter: "$2%player $2è entrato nel tuo lotto ($1%plot$2)" +time_format: "$1%hours%, %min%, %sec%" +helper_need_argument: "$2Devi specificare un argomento. $1/plot helpers add $2or $1/plot helpers remove " +require_selection_in_mask: "$2%s delle tue selezioni non è dentro alla tua mask del lotto. Puoi fare modifiche solo all'interno del tuo lotto." +flag_desc: "$2Desc: %s" +purge_syntax: "Usa /plot purge " +plot_list_header: "$1Elenco dei lotti di %word%" +helper_removed: "$4Hai rimosso con successo un aiutante dal tuo lotto" +custom_string: "-" +cluster_list_element: "$2 - $1%s&-" +cluster_intersection: "$2La area proposta copre di $1%s$2 clusters/s esistenti" +info_syntax_console: "$2/plot info X;Y" +plot_info_trusted: "$1Ospiti:$2 %trusted%" +flag_key: "$2Key: %s" +plot_info_owner: "$1Proprietario:$2 %owner%" +title_left_plot_sub: "Proprietà di %s" +setup_finished: "$3Se stai usando MULTIVERSE o MULTIWORLD ili mondo è stato creato. Altrimenti devi aggiungere il mondo manualmente modificando il file bukkit.yml" +purge_success: "$4Eliminati con successo %s lotti" +enabled: "$1PlotSquared è ora abilitato" +no_free_plots: "$2Non ci sono lotti liberi disponibili" +comment_syntax: "$2Usa /plots comment " +title_entered_plot: "Sei entrato nel lotto %world%;%x%;%z%" +invalid_cluster: "$1Nome cluster invalido: $2%s" +plot_sold: "$4Il tuo lotto; $1%s$4, è stato venduto a $1%s$4 per $1$%s" +setup_invalid_arg: "$2%s non è un valido argomento per il passaggio %s. Per cancellare la installazione usa: $1/plot setup cancel" +rating_not_your_own: "$2Non puoi votare il proprio lotto" +no_permission: "$2Hai bisogno del permesso: $1%s" +need_plot_number: "$2Devi specificare un numero del lotto o alias" +plot_info_header: "$3====== $1INFO $3======" +comment_removed: "$4Cancellato con successo %s." +is_console: "$2Questo commando può essere eseguito solo da un giocatore." +flag_not_in_plot: "$2I lotto non può avere quella flag" +example_message: "$2Questo è un messaggio di esempio &k!!!" +help_category: "$1Categoria: $2%category%$2,$1 Pagina: $2%current%$3/$2%max%$2,$1 Mostra: $2%dis%$3/$2%total%" +you_be_denied: "$2Sei stato bloccato da questo lotto" +plot_info: "$1ID: $2%id%$1&-$1Alias: $2%alias%$1&-$1Proprietario: $2%owner%$1&-$1Biomassa: $2%biome%$1&-$1Puoi costruire: $2%build%$1&-$1Voto: $2%rating%$1/$210$1&-$1Aiutanti: $2%helpers%$1&-$1Invitati: $2%trusted%$1&-$1Bannati: $2%denied%$1&-$1Flags: $2%flags%" +plot_info_flags: "$1Flags:$2 %flags%" +plot_info_biome: "$1Biomassa:$2 %biome%" +plot_info_rating: "$1Voto:$2 %rating%" +trim_syntax: "Usa /plot trim " +swap_success: "$4Lotti scambiati con successo" +plot_info_unclaimed: "$2Il lotto $1%s$2 non è ancora claimato" +rating_not_valid: "$2Devi specificare un numero da 1 a 10" +plot_info_id: "$1ID:$2 %id%" +title_entered_plot_sub: "Proprietà di %s" +plot_chat_format: "$2[$1Plot Chat$2][$1%plot_id%$2] $1%sender%$2: $1%msg%" +was_not_added: "$2Quel giocatore non è aiutante in questo lotto" +no_perm_merge: "$2Non sei il proprietario del lotto: $1%plot%" +no_such_plot: "$2Quel lotto non esiste" +setup_missing_world: "$2Devi specificare un nome del mondo con ($1/plot setup &l$1 $2)&-$1Additional commands:&-$2 - $1/plot setup &-$2 - $1/plot setup back&-$2 - $1/plot setup cancel" +not_console: "$2Per ragioni di sicurezza, questo commando può essere eseguito solo dalla console." +need_on_off: "$2Devi specificare un valore. Valori possibili: $1on$2, $1off" +not_valid_plot_world: "$2Quello non è un mondo lotti (case sensitive)" +deubg_header: "$1Informazioni Debug " +plot_list_item_ordered: "$2[$1%in$2] >> $1%id$2:$1%world $2- $1%owner" +already_added: "$2Quella persona esiste già in quella categoria." +not_valid_number: "$2Non è un numero valido" +no_schematic_permission: "$2Non hai i permessi per usare quello schematic $1%s" +wait_for_timer: "$2Un setblock timer è segnato sul tuo lotto o su di te. Attendi la conclusione." +cluster_kicked_user: "$4Cacciato con successo la persona" +border: "$2Sei fuori dal limite di questa mappa" +teleport_in_seconds: "$1Teletrasporto tra %s secondi. Non muoverti..." +help_info: "$3====== $1Scegli una categoria $3======" +cluster_invited: "$1Sei stato invitato a seguire questo cluster: $2%s" +cluster_removed_helper: "$4Rimosso con successo un aiutante dal cluster" +cluster_teleporting: "$4Ti sto teletrasportando..." +rating_not_owned: "$2Non puoi votare un lotto che non è stato claimato" +reloaded_configs: "$1Traduzioni e configurazioni del mondo ricaricate" +need_block: "$2Devi specificare un blocco" +title_left_plot_sub_color: "RED" +no_merge_to_mega: "$2I mega lotti non posso essere uniti. Unisci da un altro mega lotto." +invalid_inbox: "$2Non è un valido inbox.&-$1Valori accettati: %s" +need_biome: "$2Devi specificare una biomassa" +cluster_available_args: "$1I seguenti commandi sono disponibili: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4helpers$2, $4info$2, $4tp$2, $4sethome" +cluster_list_heading: "$2Ci sono $1%s$2 clusters in questo mondo" +plot_info_size: "$1Dimensione:$2 %size%" +cannot_afford_plot: "$2Non hai denaro sufficiente per questo lotto. Ti costa $1%s" +trusted_need_argument: "$2Argomento mancante. $1/plot trusted add $2or $1/plot trusted remove " +set_owner: "$4Hai settato con successo il proprietario" +no_clipboard: "$2Non hai una selezione nel tuo clipboard" +cant_claim_more_plots_num: "$2Non puoi claimare più di $1%s $2lotti alla volta" +plot_user_list: " $1%user%$2," +not_valid_block: "$2Non è un blocco valido." +rating_already_exists: "$2Hai già votato quel lotto $2%s" +cluster_removed: "$1Sei stato rimosso dal cluster: $2%s" +clearing_plot: "$2Pulizia del lotto." +left_plot: "$2Hai lasciato il lotto" +teleported_to_plot: "$1Sei stato teletrasportato" +cluster_resized: "$4Cluster ridimensionato con successo." +trim_start: "Iniziato il trim del mondo..." +trusted_added: "$4Hai aggiunto con successo un ospite al tuo lotto" +swap_syntax: "$2/plots swap " +plot_list_header_paged: "$2(Pagina $1%cur$2/$1%max$2) $1Lista dei lotti di %word%" +t_was_not_added: "$2Quel giocatore non è stato aggiunto come ospite a questo lotto" +cluster_current_plotid: "$1Lotto corrente: $2%s" +notify_leave: "$2%player $2ha lasciato il tuo lotto ($1%plot$2)" +direction: "$1Direzione corrente: %dir%" +unlink_impossible: "$2Hai scollegato un mega-lotto" +plot_is_claimed: "$2Questo lotto è già claimato" +biome_set_to: "$2Settata la biomassa del lotto a $2" +cluster_added_user: "$4Aggiunta la persona al cluster." +name_little: "$2IL nome %s è troppo corto, $1%s$2<$1%s" +plot_info_alias: "$1Alias:$2 %alias%" +clipboard_set: "$2Il lotto corrente è ora copiato nel tuo clipboard, usa $1/plot paste$2 per incollarlo" +failed_confirm: "$2Non hai azioni da confermare!" +not_valid_value: "$2Il valore delle flag deve essere alfanumerica" +title_left_plot: "Hai lasciato il lotto %s" +help_info_item: "$1/plots help %category% $3- $2%category_desc%" +denied_added: "$4Hai bloccato con successo quel giocatore dal tuo lotto." +need_user: "$2Devi specificare un nome." From 86f3b993a6a3cf7a86d0d1da24769c76f2078523 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 14:15:00 +1100 Subject: [PATCH 023/223] added Plot API class --- .gitignore | 1 + .../intellectualcrafters/plot/BukkitMain.java | 2 +- .../plot/api/PlotAPI.java | 674 ++++++++++++++++++ .../plot/util/MainUtil.java | 8 + .../plot/util/bukkit/BukkitUtil.java | 4 + 5 files changed, 688 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java diff --git a/.gitignore b/.gitignore index 71dadcdda..2f104e978 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,7 @@ tmp/ local.properties .settings/ .loadpath +\doc # External tool builders .externalToolBuilders/ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index ed1444b97..af0964ecb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -325,7 +325,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } else { AbstractTitle.TITLE_CLASS = new DefaultTitle(); } - if (Settings.OFFLINE_MODE || Bukkit.getOnlineMode() == false) { + if (Settings.OFFLINE_MODE) { UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); Settings.OFFLINE_MODE = true; } else if (checkVersion) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java new file mode 100644 index 000000000..135220174 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -0,0 +1,674 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// + +package com.intellectualcrafters.plot.api; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.commands.MainCommand; +import com.intellectualcrafters.plot.commands.SubCommand; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.flag.AbstractFlag; +import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.ClusterManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.PlotSquaredException; +import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; + +/** + * PlotSquared API + * + * @author Citymonstret + * @author Empire92 + * @version API 2.0 + */ + +@SuppressWarnings("unused") public class PlotAPI { + + /** + * Permission that allows for admin access, this permission node will allow the player to use any part of the + * plugin, without limitations. + */ + public static final String ADMIN_PERMISSION = "plots.admin"; + + /** + * Constructor. Insert any Plugin. (Optimally the plugin that is accessing the method) + * + * @param plugin Plugin used to access this method + * + * @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotSquared + * instance + * @see com.intellectualcrafters.plot.PlotSquared + */ + @Deprecated + public PlotAPI(final JavaPlugin plugin) { + } + + /** + * Get all plots + * + * @return all plots + * + * @see com.intellectualcrafters.plot.PlotSquared#getPlots() + */ + public Set getAllPlots() { + return PlotSquared.getPlots(); + } + + /** + * Return all plots for a player + * + * @param player Player, whose plots to search for + * + * @return all plots that a player owns + */ + public Set getPlayerPlots(final Player player) { + return PlotSquared.getPlots(BukkitUtil.getPlayer(player)); + } + + /** + * Add a plot world + * + * @param world World Name + * @param plotWorld Plot World Object + * @param manager World Manager + * + * @see com.intellectualcrafters.plot.PlotSquared#addPlotWorld(String, com.intellectualcrafters.plot.object.PlotWorld, + * com.intellectualcrafters.plot.object.PlotManager) + */ + public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) { + PlotSquared.addPlotWorld(world, plotWorld, manager); + } + + /** + * @return main configuration + * + * @see com.intellectualcrafters.plot.PlotSquared#config + */ + public YamlConfiguration getConfig() { + return PlotSquared.config; + } + + /** + * @return storage configuration + * + * @see com.intellectualcrafters.plot.PlotSquared#storage + */ + public YamlConfiguration getStorage() { + return PlotSquared.storage; + } + + /** + * Get the main class for this plugin
- Contains a lot of fields and methods - not very well organized
+ * Only use this if you really need it + * + * @return PlotSquared PlotSquared Main Class + * + * @see com.intellectualcrafters.plot.PlotSquared + */ + public PlotSquared getMain() { + return PlotSquared.THIS; + } + + /** + * ChunkManager class contains several useful methods
+ * - Chunk deletion
+ * - Moving or copying regions
+ * - plot swapping
+ * - Entity tracking
+ * - region regeneration
+ * + * @return ChunkManager + * + * @see com.intellectualcrafters.plot.util.ChunkManager + */ + public ChunkManager getChunkManager() { + return ChunkManager.manager; + } + + /** + * BlockManager class contains useful methods relating to blocks. + * + * @return BlockManager + * + * @see com.intellectualcrafters.plot.util.BlockManager + */ + public BlockManager getBlockManager() { + return BlockManager.manager; + } + + /** + * BukkitSetBlockManager class contains useful methods relating to bukkit blocks. + * + * @return BukkitSetBlockManager + * + * @see com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager + */ + public BukkitSetBlockManager getBukkitBlockManager() { + return BukkitSetBlockManager.setBlockManager; + } + + /** + * UUIDWrapper class has basic methods for getting UUIDS (it's recommended to use the UUIDHandler class instead) + * + * @return UUIDWrapper + * + * @see com.intellectualcrafters.plot.uuid.UUIDWrapper + */ + public UUIDWrapper getUUIDWrapper() { + return UUIDHandler.uuidWrapper; + } + + /** + * Do not use this. Instead use FlagManager. in your code. + * - Flag related stuff + * + * @return FlagManager + * + * @see com.intellectualcrafters.plot.flag.FlagManager + */ + @Deprecated + public FlagManager getFlagManager() { + return new FlagManager(); + } + + /** + * Do not use this. Instead use ClusterManager. in your code. + * - Plot cluster related stuff + * + * @return ClusterManager + * + * @see com.intellectualcrafters.plot.util.ClusterManager + */ + @Deprecated + public ClusterManager getClusterManager() { + return new ClusterManager(); + } + + /** + * Do not use this. Instead use MainUtil. in your code. + * - Basic plot management stuff + * + * @return MainUtil + * + * @see com.intellectualcrafters.plot.util.MainUtil + */ + @Deprecated + public MainUtil getMainUtil() { + return new MainUtil(); + } + + /** + * Do not use this. Instead use Permissions. in your code. + * - Basic permission management stuff + * + * @return MainUtil + * + * @see com.intellectualcrafters.plot.util.Permissions + */ + @Deprecated + public Permissions getPermissions() { + return new Permissions(); + } + + /** + * SchematicHandler class contains methods related to pasting, reading and writing schematics + * + * @return SchematicHandler + * + * @see com.intellectualcrafters.plot.util.SchematicHandler + */ + public SchematicHandler getSchematicHandler() { + return SchematicHandler.manager; + } + + /** + * Use C. instead + * + * @return C + * + * @see com.intellectualcrafters.plot.config.C + */ + @Deprecated + public C[] getCaptions() { + return C.values(); + } + + /** + * Get the plot manager for a world. - Most of these methods can be accessed through the MainUtil + * + * @param world Which manager to get + * + * @return PlotManager + * + * @see com.intellectualcrafters.plot.object.PlotManager + * @see PlotSquared#getPlotManager(org.bukkit.World) + */ + public PlotManager getPlotManager(final World world) { + return PlotSquared.getPlotManager(world.getName()); + } + + /** + * Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and + * tessellation + * + * @param world Plot World + * + * @return PlotManager + * + * @see PlotSquared#getPlotManager(String) + * @see com.intellectualcrafters.plot.object.PlotManager + */ + public PlotManager getPlotManager(final String world) { + return PlotSquared.getPlotManager(world); + } + + /** + * Get the settings for a world (settings bundled in PlotWorld class) - You will need to downcast for the specific + * settings a Generator has. e.g. DefaultPlotWorld class implements PlotWorld + * + * @param world (to get settings of) + * + * @return PlotWorld class for that world ! will return null if not a plot world world + * + * @see PlotSquared#getWorldSettings(org.bukkit.World) + * @see com.intellectualcrafters.plot.object.PlotWorld + */ + public PlotWorld getWorldSettings(final World world) { + return PlotSquared.getPlotWorld(world.getName()); + } + + /** + * Get the settings for a world (settings bundled in PlotWorld class) + * + * @param world (to get settings of) + * + * @return PlotWorld class for that world ! will return null if not a plot world world + * + * @see PlotSquared#getWorldSettings(String) + * @see com.intellectualcrafters.plot.object.PlotWorld + */ + public PlotWorld getWorldSettings(final String world) { + return PlotSquared.getPlotWorld(world); + } + + /** + * Send a message to a player. + * + * @param player Player that will receive the message + * @param c (Caption) + * + * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, + * com.intellectualcrafters.plot.config.C, String...) + */ + public void sendMessage(final Player player, final C c) { + MainUtil.sendMessage(BukkitUtil.getPlayer(player), c); + } + + /** + * Send a message to a player. - Supports color codes + * + * @param player Player that will receive the message + * @param string The message + * + * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, String) + */ + public void sendMessage(final Player player, final String string) { + MainUtil.sendMessage(BukkitUtil.getPlayer(player), string); + } + + /** + * Send a message to the console. - Supports color codes + * + * @param msg Message that should be sent to the console + * + * @see PlotSquared#sendConsoleSenderMessage(String) + */ + public void sendConsoleMessage(final String msg) { + MainUtil.sendConsoleMessage(msg); + } + + /** + * Send a message to the console + * + * @param c (Caption) + * + * @see #sendConsoleMessage(String) + * @see com.intellectualcrafters.plot.config.C + */ + public void sendConsoleMessage(final C c) { + sendConsoleMessage(c.s()); + } + + /** + * Register a flag for use in plots + * + * @param flag Flag that should be registered + * + * @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag) + * @see com.intellectualcrafters.plot.flag.AbstractFlag + */ + public void addFlag(final AbstractFlag flag) { + FlagManager.addFlag(flag); + } + + /** + * get all the currently registered flags + * + * @return array of Flag[] + * + * @see com.intellectualcrafters.plot.flag.FlagManager#getFlags() + * @see com.intellectualcrafters.plot.flag.AbstractFlag + */ + public AbstractFlag[] getFlags() { + return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]); + } + + /** + * Get a plot based on the ID + * + * @param world World in which the plot is located + * @param x Plot Location X Co-ord + * @param z Plot Location Z Co-ord + * + * @return plot, null if ID is wrong + * + * @see MainUtil#getPlot(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Plot getPlot(final World world, final int x, final int z) { + return MainUtil.getPlot(world.getName(), new PlotId(x, z)); + } + + /** + * Get a plot based on the location + * + * @param l The location that you want to to retrieve the plot from + * + * @return plot if found, otherwise it creates a temporary plot- + * + * @see MainUtil#getCurrentPlot(org.bukkit.Location) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Plot getPlot(final Location l) { + return MainUtil.getPlot(BukkitUtil.getLocation(l)); + } + + /** + * Get a plot based on the player location + * + * @param player Get the current plot for the player location + * + * @return plot if found, otherwise it creates a temporary plot + * + * @see #getPlot(org.bukkit.Location) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Plot getPlot(final Player player) { + return this.getPlot(player.getLocation()); + } + + /** + * Check whether or not a player has a plot + * + * @param player Player that you want to check for + * + * @return true if player has a plot, false if not. + * + * @see #getPlots(org.bukkit.World, org.bukkit.entity.Player, boolean) + */ + public boolean hasPlot(final World world, final Player player) { + return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0); + } + + /** + * Get all plots for the player + * + * @param plr to search for + * @param just_owner should we just search for owner? Or with rights? + * + * @see com.intellectualcrafters.plot.object.Plot + */ + public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) { + final ArrayList pPlots = new ArrayList<>(); + for (final Plot plot : PlotSquared.getPlots(world.getName()).values()) { + if (just_owner) { + if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) { + pPlots.add(plot); + } + } else { + if (plot.isAdded(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) { + pPlots.add(plot); + } + } + } + return pPlots.toArray(new Plot[pPlots.size()]); + } + + /** + * Get all plots for the world + * + * @param world to get plots of + * + * @return Plot[] - array of plot objects in world + * + * @see PlotSquared#getWorldPlots(org.bukkit.World) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Plot[] getPlots(final World world) { + Collection plots = PlotSquared.getPlots(world.getName()).values(); + return plots.toArray(new Plot[plots.size()]); + } + + /** + * Get all plot worlds + * + * @return World[] - array of plot worlds + * + * @see com.intellectualcrafters.plot.PlotSquared#getPlotWorlds() + */ + public String[] getPlotWorlds() { + Set worlds = PlotSquared.getPlotWorlds(); + return worlds.toArray(new String[worlds.size()]); + } + + /** + * Get if plot world + * + * @param world (to check if plot world) + * + * @return boolean (if plot world or not) + * + * @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(org.bukkit.World) + */ + public boolean isPlotWorld(final World world) { + return PlotSquared.isPlotWorld(world.getName()); + } + + /** + * Get plot locations + * + * @param p Plot that you want to get the locations for + * + * @return [0] = bottomLc, [1] = topLoc, [2] = home + * + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(org.bukkit.World, + * com.intellectualcrafters.plot.object.PlotId) + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotTopLoc(org.bukkit.World, + * com.intellectualcrafters.plot.object.PlotId) + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(org.bukkit.World, + * com.intellectualcrafters.plot.object.Plot) + * @see com.intellectualcrafters.plot.object.PlotHomePosition + * @see com.intellectualcrafters.plot.object.Plot + */ + public Location[] getLocations(final Plot p) { + return new Location[]{BukkitUtil.getLocation(MainUtil.getPlotBottomLoc(p.world, p.id)), BukkitUtil.getLocation(MainUtil.getPlotTopLoc(p.world, p.id)), BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id))}; + } + + /** + * Get home location + * + * @param p Plot that you want to get the location for + * + * @return plot bottom location + * + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(org.bukkit.World, + * com.intellectualcrafters.plot.object.Plot) + * @see com.intellectualcrafters.plot.object.PlotHomePosition + * @see com.intellectualcrafters.plot.object.Plot + */ + public Location getHomeLocation(final Plot p) { + return BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id)); + } + + /** + * Get Bottom Location (min, min, min) + * + * @param p Plot that you want to get the location for + * + * @return plot bottom location + * + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(org.bukkit.World, + * com.intellectualcrafters.plot.object.PlotId) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Location getBottomLocation(final Plot p) { + return BukkitUtil.getLocation(MainUtil.getPlotBottomLoc(p.world, p.id)); + } + + /** + * Get Top Location (max, max, max) + * + * @param p Plot that you want to get the location for + * + * @return plot top location + * + * @see MainUtil#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Location getTopLocation(final Plot p) { + return BukkitUtil.getLocation(MainUtil.getPlotTopLoc(p.world, p.id)); + } + + /** + * Check whether or not a player is in a plot + * + * @param player who we're checking for + * + * @return true if the player is in a plot, false if not- + * + * @see com.intellectualcrafters.plot.util.PlayerFunctions#isInPlot(org.bukkit.entity.Player) + */ + public boolean isInPlot(final Player player) { + return MainUtil.getPlot(BukkitUtil.getLocation(player)) != null; + } + + /** + * Register a subcommand + * + * @param c SubCommand, that we want to register + * + * @see com.intellectualcrafters.plot.commands.MainCommand#subCommands + * @see com.intellectualcrafters.plot.commands.SubCommand + */ + public void registerCommand(final SubCommand c) { + MainCommand.subCommands.add(c); + } + + /** + * Get the PlotSquared class + * + * @return PlotSquared Class + * + * @see com.intellectualcrafters.plot.PlotSquared + */ + public PlotSquared getPlotSquared() { + return PlotSquared.THIS; + } + + /** + * Get the player plot count + * + * @param world Specify the world we want to select the plots from + * @param player Player, for whom we're getting the plot count + * + * @return the number of plots the player has + * + * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlotCount(org.bukkit.World, + * org.bukkit.entity.Player) + */ + public int getPlayerPlotCount(final World world, final Player player) { + return MainUtil.getPlayerPlotCount(world.getName(), BukkitUtil.getPlayer(player)); + } + + /** + * Get a collection containing the players plots + * + * @param world Specify the world we want to select the plots from + * @param player Player, for whom we're getting the plots + * + * @return a set containing the players plots + * + * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlots(org.bukkit.World, + * org.bukkit.entity.Player) + * @see com.intellectualcrafters.plot.object.Plot + */ + public Set getPlayerPlots(final World world, final Player player) { + return PlotSquared.getPlots(world.getName(), BukkitUtil.getPlayer(player)); + } + + /** + * Get the numbers of plots, which the player is able to build in + * + * @param player Player, for whom we're getting the plots (trusted, helper and owner) + * + * @return the number of allowed plots + * + * @see com.intellectualcrafters.plot.util.PlayerFunctions#getAllowedPlots(org.bukkit.entity.Player) + */ + public int getAllowedPlots(final Player player) { + PlotPlayer pp = BukkitUtil.getPlayer(player); + return MainUtil.getAllowedPlots(pp, MainUtil.getPlayerPlotCount(player.getWorld().getName(), pp)); + } +} \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 01f29bbe8..923f32c96 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -879,6 +879,14 @@ public class MainUtil { } return new String(b); } + + public static void sendConsoleMessage(String msg) { + sendMessage(null, msg); + } + + public static void sendConsoleMessage(C caption, String... args) { + sendMessage(null, caption, args); + } public static boolean sendMessage(final PlotPlayer plr, String msg, final boolean prefix) { msg = colorise('&', msg); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index d127b70b8..1732a9010 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -65,6 +65,10 @@ public class BukkitUtil extends BlockManager { public static Location getLocation(final org.bukkit.Location loc) { return new Location(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); } + + public static org.bukkit.Location getLocation(final Location loc) { + return new org.bukkit.Location(getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()); + } public static World getWorld(final String string) { if (string == lastString) { From 238b14652ea66f983447f98b3a23b01849600271 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 16:47:22 +1100 Subject: [PATCH 024/223] vault repo --- PlotSquared/pom.xml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 841f5f969..f48cecf9c 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.8 + 2.8.9 PlotSquared jar @@ -67,6 +67,10 @@ sk80q http://maven.sk89q.com/artifactory/repo/ + + vault-repo + http://nexus.theyeticave.net/content/repositories/pub_releases + @@ -79,11 +83,6 @@ bukkit 1.8-R0.1-SNAPSHOT - - net.milkbowl.vault - Vault - 1.3.2 - com.sk89q worldedit @@ -108,5 +107,11 @@ junit 4.11 + + net.milkbowl.vault + VaultAPI + 1.5 + provided + \ No newline at end of file From 1f05fcb39bc66c971a952412b0ce1d37b85fb519 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 16:49:50 +1100 Subject: [PATCH 025/223] remove worldguard --- PlotSquared/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index f48cecf9c..6e6ce18ba 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -95,13 +95,6 @@ BarAPI 2.0 - - com.sk89q - worldguard - 5.9 - jar - compile - junit junit From a97dc4c0648a0ec725adf938db8764576b6eec0c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 17:04:33 +1100 Subject: [PATCH 026/223] javadoc plugin --- PlotSquared/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 6e6ce18ba..73c51c2ad 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -36,6 +36,14 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.1 + + public + + maven-compiler-plugin 2.3.2 From cf33fe69a82d8fa28a425c4868df9250679479c2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 17:16:50 +1100 Subject: [PATCH 027/223] Update ReadMe.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff685936a..b61fb995f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ PlotSquared - Plot Plugin Extraordinaire. Build the project using your favourite compiler (maven is the recommended way to build), then package the jar using `mvn package` **MAVEN IS REQUIRED TO BUILD AND PACKAGE THE JAR** ## API: ## -The main API class can be found [here](https://github.com/IntellectualCrafters/PlotSquared/blob/master/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java "API"). JavaDoc's can be found [here](http://git.plotworld.info/jdocs/ "JDOCS"). +The main API class can be found [here](https://github.com/IntellectualCrafters/PlotSquared/blob/master/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java "API"). JavaDoc's can be found [here](http://ci.nixium.com/job/PlotSquared/javadoc/ "JDOCS"). ## Links: ## From e887cf8aec84a9c74957c45d259f0a3242c39ba2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 18:02:48 +1100 Subject: [PATCH 028/223] Fix jdoc errors --- PlotSquared/pom.xml | 1 + .../com/intellectualcrafters/json/Kim.java | 4 +- .../plot/api/PlotAPI.java | 45 +++++++++---------- .../plot/commands/SubCommand.java | 3 +- .../plot/database/AbstractDB.java | 12 +++-- .../plot/database/DBFunc.java | 27 +++++------ .../plot/database/MySQL.java | 1 - .../plot/database/SQLManager.java | 39 +--------------- .../plot/database/SQLite.java | 1 - .../plot/flag/FlagManager.java | 10 ++--- .../plot/object/Plot.java | 10 ++--- .../plot/util/MainUtil.java | 27 +++++------ .../plot/util/SchematicHandler.java | 7 +-- .../util/bukkit/BukkitPlayerFunctions.java | 8 ++-- .../plot/util/bukkit/Metrics.java | 4 +- .../plot/util/bukkit/SetBlockFast.java | 3 +- .../plot/util/bukkit/SetBlockFast_1_8.java | 6 +-- .../translation/bukkit/BukkitTranslation.java | 2 - 18 files changed, 82 insertions(+), 128 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 73c51c2ad..2af82a31f 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -42,6 +42,7 @@ 2.10.1 public + false diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java index facac85e4..3a60033b1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java @@ -197,7 +197,7 @@ public class Kim { * @param at the index of the char value. The first character is at 0. * * @throws JSONException if at does not point to a valid character. - * @returns a Unicode character between 0 and 0x10FFFF. + * @return a Unicode character between 0 and 0x10FFFF. */ public int characterAt(final int at) throws JSONException { final int c = get(at); @@ -239,7 +239,7 @@ public class Kim { * * @param obj the other kim with which to compare. * - * @returns true if this and obj are both kim objects containing identical byte sequences. + * @return true if this and obj are both kim objects containing identical byte sequences. */ @Override public boolean equals(final Object obj) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 135220174..5e207db66 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -283,7 +283,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @return PlotManager * * @see com.intellectualcrafters.plot.object.PlotManager - * @see PlotSquared#getPlotManager(org.bukkit.World) + * @see PlotSquared#getPlotManager(String) */ public PlotManager getPlotManager(final World world) { return PlotSquared.getPlotManager(world.getName()); @@ -312,7 +312,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return PlotWorld class for that world ! will return null if not a plot world world * - * @see PlotSquared#getWorldSettings(org.bukkit.World) + * @see PlotSquared#getPlotWorld(String) * @see com.intellectualcrafters.plot.object.PlotWorld */ public PlotWorld getWorldSettings(final World world) { @@ -326,7 +326,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return PlotWorld class for that world ! will return null if not a plot world world * - * @see PlotSquared#getWorldSettings(String) + * @see PlotSquared#getPlotWorld(String) * @see com.intellectualcrafters.plot.object.PlotWorld */ public PlotWorld getWorldSettings(final String world) { @@ -339,7 +339,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @param player Player that will receive the message * @param c (Caption) * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, + * @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, C, String...) * com.intellectualcrafters.plot.config.C, String...) */ public void sendMessage(final Player player, final C c) { @@ -352,7 +352,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * @param player Player that will receive the message * @param string The message * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#sendMessage(org.bukkit.entity.Player, String) + * @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, String) */ public void sendMessage(final Player player, final String string) { MainUtil.sendMessage(BukkitUtil.getPlayer(player), string); @@ -363,7 +363,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @param msg Message that should be sent to the console * - * @see PlotSquared#sendConsoleSenderMessage(String) + * @see MainUtil#sendConsoleMessage(String) */ public void sendConsoleMessage(final String msg) { MainUtil.sendConsoleMessage(msg); @@ -414,7 +414,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return plot, null if ID is wrong * - * @see MainUtil#getPlot(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + * @see MainUtil#getPlot(String, com.intellectualcrafters.plot.object.PlotId) * @see com.intellectualcrafters.plot.object.Plot */ public Plot getPlot(final World world, final int x, final int z) { @@ -428,7 +428,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return plot if found, otherwise it creates a temporary plot- * - * @see MainUtil#getCurrentPlot(org.bukkit.Location) + * @see MainUtil#getPlot(com.intellectualcrafters.plot.object.Location) * @see com.intellectualcrafters.plot.object.Plot */ public Plot getPlot(final Location l) { @@ -456,7 +456,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return true if player has a plot, false if not. * - * @see #getPlots(org.bukkit.World, org.bukkit.entity.Player, boolean) + * @see #getPlots(World, Player, boolean) */ public boolean hasPlot(final World world, final Player player) { return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0); @@ -493,7 +493,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return Plot[] - array of plot objects in world * - * @see PlotSquared#getWorldPlots(org.bukkit.World) + * @see PlotSquared#getPlots(String) * @see com.intellectualcrafters.plot.object.Plot */ public Plot[] getPlots(final World world) { @@ -520,7 +520,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return boolean (if plot world or not) * - * @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(org.bukkit.World) + * @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(String) */ public boolean isPlotWorld(final World world) { return PlotSquared.isPlotWorld(world.getName()); @@ -533,13 +533,12 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return [0] = bottomLc, [1] = topLoc, [2] = home * - * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(org.bukkit.World, + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(String, * com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.util.MainUtil#getPlotTopLoc(org.bukkit.World, + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotTopLoc(String, * com.intellectualcrafters.plot.object.PlotId) - * @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(org.bukkit.World, + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(String, * com.intellectualcrafters.plot.object.Plot) - * @see com.intellectualcrafters.plot.object.PlotHomePosition * @see com.intellectualcrafters.plot.object.Plot */ public Location[] getLocations(final Plot p) { @@ -553,9 +552,8 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return plot bottom location * - * @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(org.bukkit.World, + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(String, * com.intellectualcrafters.plot.object.Plot) - * @see com.intellectualcrafters.plot.object.PlotHomePosition * @see com.intellectualcrafters.plot.object.Plot */ public Location getHomeLocation(final Plot p) { @@ -569,7 +567,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return plot bottom location * - * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(org.bukkit.World, + * @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(String, * com.intellectualcrafters.plot.object.PlotId) * @see com.intellectualcrafters.plot.object.Plot */ @@ -584,7 +582,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return plot top location * - * @see MainUtil#getPlotTopLoc(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + * @see MainUtil#getPlotTopLoc(String, com.intellectualcrafters.plot.object.PlotId) * @see com.intellectualcrafters.plot.object.Plot */ public Location getTopLocation(final Plot p) { @@ -598,7 +596,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return true if the player is in a plot, false if not- * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#isInPlot(org.bukkit.entity.Player) + * @see com.intellectualcrafters.plot.util.MainUtil#getPlot(com.intellectualcrafters.plot.object.Location) */ public boolean isInPlot(final Player player) { return MainUtil.getPlot(BukkitUtil.getLocation(player)) != null; @@ -635,8 +633,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return the number of plots the player has * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlotCount(org.bukkit.World, - * org.bukkit.entity.Player) + * @see com.intellectualcrafters.plot.util.MainUtil#getPlayerPlotCount(String, PlotPlayer) */ public int getPlayerPlotCount(final World world, final Player player) { return MainUtil.getPlayerPlotCount(world.getName(), BukkitUtil.getPlayer(player)); @@ -650,7 +647,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return a set containing the players plots * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#getPlayerPlots(org.bukkit.World, + * @see com.intellectualcrafters.plot.PlotSquared#getPlots(String, PlotPlayer) * org.bukkit.entity.Player) * @see com.intellectualcrafters.plot.object.Plot */ @@ -665,7 +662,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * * @return the number of allowed plots * - * @see com.intellectualcrafters.plot.util.PlayerFunctions#getAllowedPlots(org.bukkit.entity.Player) + * @see com.intellectualcrafters.plot.util.MainUtil#getAllowedPlots(PlotPlayer, int) */ public int getAllowedPlots(final Player player) { PlotPlayer pp = BukkitUtil.getPlayer(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index ace7d182f..fecaa5cc0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -144,8 +144,7 @@ public abstract class SubCommand { * @param c Caption * @param args Arguments (%s's) * - * @see com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions#sendMessage(org.bukkit.entity.Player, - * com.intellectualcrafters.plot.config.C, String...) + * @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, C, String...) */ public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { MainUtil.sendMessage(plr, c, args); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 53252ca88..4c45eb927 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -115,8 +115,7 @@ public interface AbstractDB { * Get the id of a given plot cluster * * @param world Which the plot is located in - * @param pos1 bottom Plot ID - * @param pos2 top Plot ID + * @param id cluster id * * @return Integer = Cluster Entry Id */ @@ -160,7 +159,6 @@ public interface AbstractDB { /** * Set cluster flags * - * @param world World in which the plot is located * @param cluster PlotCluster Object * @param flags flags to set (flag[]) */ @@ -183,7 +181,7 @@ public interface AbstractDB { * Purgle a plot * * @param world World in which the plot is located - * @param id Plot ID + * @param uniqueIds list of plot id (db) to be purged */ public void purgeIds(final String world, final Set uniqueIds); @@ -219,7 +217,7 @@ public interface AbstractDB { /** * * @param id - * @return + * @return HashMap */ public HashMap getClusterSettings(final int id); @@ -276,13 +274,13 @@ public interface AbstractDB { /** * @param plot Plot Object - * @param player Player that should be added + * @param uuid Player uuid */ public void removeDenied(final String world, final Plot plot, final UUID uuid); /** * @param plot Plot Object - * @param player Player that should be added + * @param uuid Player uuid that should be added */ public void setDenied(final String world, final Plot plot, final UUID uuid); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 7fa9b4f05..6c760e337 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -198,9 +198,9 @@ public class DBFunc { } /** + * * @param id - * - * @return + * @return HashMap */ public static HashMap getSettings(final int id) { return dbManager.getSettings(id); @@ -231,7 +231,7 @@ public class DBFunc { /** * @param plot - * @param player + * @param uuid */ public static void removeHelper(final String world, final Plot plot, final UUID uuid) { dbManager.removeHelper(world, plot, uuid); @@ -239,7 +239,7 @@ public class DBFunc { /** * @param cluster - * @param player + * @param uuid */ public static void removeHelper(final PlotCluster cluster, final UUID uuid) { dbManager.removeHelper(cluster, uuid); @@ -248,14 +248,12 @@ public class DBFunc { /** * @param world * @param cluster - * @param name */ public static void createCluster(final String world, final PlotCluster cluster) { dbManager.createCluster(cluster); } /** - * @param world * @param current * @param resize */ @@ -265,7 +263,7 @@ public class DBFunc { /** * @param plot - * @param player + * @param uuid */ public static void removeTrusted(final String world, final Plot plot, final UUID uuid) { dbManager.removeTrusted(world, plot, uuid); @@ -273,8 +271,7 @@ public class DBFunc { /** * - * @param world - * @param plot + * @param cluster * @param uuid */ public static void removeInvited(final PlotCluster cluster, final UUID uuid) { @@ -282,8 +279,9 @@ public class DBFunc { } /** + * @param world * @param plot - * @param player + * @param uuid */ public static void setHelper(final String world, final Plot plot, final UUID uuid) { dbManager.setHelper(world, plot, uuid); @@ -294,8 +292,9 @@ public class DBFunc { } /** + * @param world * @param plot - * @param player + * @param uuid */ public static void setTrusted(final String world, final Plot plot, final UUID uuid) { dbManager.setTrusted(world, plot, uuid); @@ -306,16 +305,18 @@ public class DBFunc { } /** + * @param world * @param plot - * @param player + * @param uuid */ public static void removeDenied(final String world, final Plot plot, final UUID uuid) { dbManager.removeDenied(world, plot, uuid); } /** + * @param world * @param plot - * @param player + * @param uuid */ public static void setDenied(final String world, final Plot plot, final UUID uuid) { dbManager.setDenied(world, plot, uuid); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 53984cd46..fbf294c5e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -45,7 +45,6 @@ public class MySQL extends Database { /** * Creates a new MySQL instance * - * @param plugin Plugin instance * @param hostname Name of the host * @param port Port number * @param database Database name diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index bf019160a..9a2ae8931 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -233,7 +233,7 @@ public class SQLManager implements AbstractDB { /** * Create a plot * - * @param plots + * @param mylist list of plots to be created */ @Override public void createPlots(final ArrayList mylist) { @@ -874,10 +874,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param alias - */ @Override public void setAlias(final String world, final Plot plot, final String alias) { plot.settings.setAlias(alias); @@ -972,10 +968,6 @@ public class SQLManager implements AbstractDB { } } - /** - * @param plot - * @param position - */ @Override public void setPosition(final String world, final Plot plot, final String position) { TaskManager.runTaskAsync(new Runnable() { @@ -996,11 +988,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param id - * - * @return - */ @Override public HashMap getSettings(final int id) { final HashMap h = new HashMap(); @@ -1130,10 +1117,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param player - */ @Override public void removeHelper(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1153,10 +1136,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param player - */ @Override public void removeTrusted(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1176,10 +1155,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param player - */ @Override public void setHelper(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1217,10 +1192,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param player - */ @Override public void setTrusted(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1240,10 +1211,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param player - */ @Override public void removeDenied(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @@ -1263,10 +1230,6 @@ public class SQLManager implements AbstractDB { }); } - /** - * @param plot - * @param player - */ @Override public void setDenied(final String world, final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 6b9f66734..3810ab34c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -43,7 +43,6 @@ public class SQLite extends Database { /** * Creates a new SQLite instance * - * @param plugin Plugin instance * @param dbLocation Location of the Database (Must end in .db) */ public SQLite(final PlotSquared plotsquared, final String dbLocation) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index c430217aa..8c6e0238a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -53,9 +53,9 @@ public class FlagManager { /** * Register an AbstractFlag with PlotSquared * - * @param flag Flag to register + * @param af Flag to register * - * @return success? + * @return boolean success */ public static boolean addFlag(final AbstractFlag af) { PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af); @@ -99,7 +99,7 @@ public class FlagManager { * Get the value of a flag for a plot (respects flag defaults) * @param plot * @param flag - * @return + * @return Flag */ public static Flag getPlotFlag(final Plot plot, final String flag) { return getSettingFlag(plot.world, plot.settings, flag); @@ -120,7 +120,7 @@ public class FlagManager { * Get the value of a flag for a plot (ignores flag defaults) * @param plot * @param flag - * @return + * @return Flag */ public static Flag getPlotFlagAbs(final Plot plot, final String flag) { return getSettingFlagAbs(plot.settings, flag); @@ -171,7 +171,7 @@ public class FlagManager { /** * * @param plot - * @return + * @return Set */ public static Set getPlotFlags(final Plot plot) { return getSettingFlags(plot.world, plot.settings); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index bbe9614bc..d75142f14 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -142,7 +142,7 @@ public class Plot implements Cloneable { /** * Check if the player is either the owner or on the helpers list * - * @param player + * @param uuid * * @return true if the player is added as a helper or is the owner */ @@ -153,9 +153,9 @@ public class Plot implements Cloneable { /** * Should the player be allowed to enter? * - * @param player + * @param uuid * - * @return false if the player is allowed to enter + * @return boolean false if the player is allowed to enter */ public boolean isDenied(final UUID uuid) { return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); @@ -171,7 +171,7 @@ public class Plot implements Cloneable { /** * Set the owner * - * @param player + * @param uuid */ public void setOwner(final UUID uuid) { this.owner = uuid; @@ -187,7 +187,7 @@ public class Plot implements Cloneable { /** * Get a clone of the plot * - * @return + * @return Plot */ @Override public Object clone() throws CloneNotSupportedException { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 923f32c96..ab98a87fc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -82,7 +82,7 @@ public class MainUtil { * * @param plr * - * @return + * @return int plot count */ public static int getPlayerPlotCount(final String world, final PlotPlayer plr) { final UUID uuid = plr.getUUID(); @@ -188,7 +188,7 @@ public class MainUtil { * @param id * @param direction * - * @return + * @return PlotId relative */ public static PlotId getPlotIdRelative(final PlotId id, final int direction) { switch (direction) { @@ -485,8 +485,9 @@ public class MainUtil { /** * Clear a plot and associated sections: [sign, entities, border] * - * @param requester * @param plot + * @param isDelete + * @param whenDone */ public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { if (runners.containsKey(plot)) { @@ -658,7 +659,7 @@ public class MainUtil { * * @return Plot Home Location * - * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) + * @see #getPlotHome(String, Plot) */ public static Location getPlotHome(final String w, final Plot plot) { return getPlotHome(w, plot.id); @@ -709,7 +710,7 @@ public class MainUtil { * @param world * @param id * - * @return + * @return Location top */ public static Location getPlotTopLocAbs(final String world, final PlotId id) { final PlotWorld plotworld = PlotSquared.getPlotWorld(world); @@ -724,7 +725,7 @@ public class MainUtil { * @param world * @param id * - * @return + * @return Location bottom */ public static Location getPlotBottomLocAbs(final String world, final PlotId id) { final PlotWorld plotworld = PlotSquared.getPlotWorld(world); @@ -738,7 +739,7 @@ public class MainUtil { * @param world * @param id * - * @return + * @return int width of plot */ public static int getPlotWidth(final String world, final PlotId id) { return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX(); @@ -751,7 +752,7 @@ public class MainUtil { * @param world * @param id * - * @return + * @return Location top of mega plot */ public static Location getPlotTopLoc(final String world, PlotId id) { final Plot plot = PlotSquared.getPlots(world).get(id); @@ -770,7 +771,7 @@ public class MainUtil { * @param world * @param id * - * @return + * @return Location bottom of mega plot */ public static Location getPlotBottomLoc(final String world, PlotId id) { final Plot plot = PlotSquared.getPlots(world).get(id); @@ -995,7 +996,7 @@ public class MainUtil { * @param plr Player to recieve message * @param c Caption to send * - * @return + * @return boolean success */ public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) { if (c.s().length() > 1) { @@ -1070,7 +1071,7 @@ public class MainUtil { /** * Returns the plot at a location (mega plots are not considered, all plots are treated as small plots) * @param loc - * @return + * @return PlotId underlying plot id of loc */ public static PlotId getPlotAbs(final Location loc) { final String world = loc.getWorld(); @@ -1085,7 +1086,7 @@ public class MainUtil { /** * Returns the plot id at a location (mega plots are considered) * @param loc - * @return + * @return PlotId PlotId observed id */ public static PlotId getPlotId(final Location loc) { final String world = loc.getWorld(); @@ -1107,7 +1108,7 @@ public class MainUtil { * Get the maximum number of plots a player is allowed * * @param p - * @return + * @return int */ public static int getAllowedPlots(final PlotPlayer p, final int current) { return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS, current); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 46e172a5f..ce35aab44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -34,11 +34,12 @@ public abstract class SchematicHandler { /** * Paste a schematic * - * @param location origin - * @param schematic schematic to paste + * @param schematic the schematic object to paste * @param plot plot to paste in + * @param x_offset offset x to paste it from plot origin + * @param z_offset offset z to paste it from plot origin * - * @return true if succeeded + * @return boolean true if succeeded */ public boolean paste(final Schematic schematic, final Plot plot, final int x_offset, final int z_offset) { if (schematic == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 724c497f3..c45e5c4f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -76,7 +76,7 @@ public class BukkitPlayerFunctions { * @param world * @param plotIds * - * @return + * @return boolean */ public static boolean mergePlots(final Player plr, final String world, final ArrayList plotIds) { final PlotWorld plotworld = PlotSquared.getPlotWorld(world); @@ -109,7 +109,7 @@ public class BukkitPlayerFunctions { /** * @param player player * - * @return + * @return boolean */ public static boolean isInPlot(final Player player) { return getCurrentPlot(player) != null; @@ -138,7 +138,7 @@ public class BukkitPlayerFunctions { * * @param player * - * @return + * @return boolean */ public static Plot getCurrentPlot(final Player player) { if (!PlotSquared.isPlotWorld(player.getWorld().getName())) { @@ -160,7 +160,7 @@ public class BukkitPlayerFunctions { * * @param plr * - * @return + * @return boolean */ public static Set getPlayerPlots(final String world, final Player plr) { final Set p = PlotSquared.getPlots(world, plr.getName()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java index 8e6677624..cfdd31452 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/Metrics.java @@ -128,7 +128,7 @@ public class Metrics { * * @param input * - * @return + * @return byte[] the file as a byte array */ public static byte[] gzip(final String input) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -185,7 +185,7 @@ public class Metrics { * * @param text * - * @return + * @return String */ private static String escapeJSON(final String text) { final StringBuilder builder = new StringBuilder(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index 5405ae533..d62ac9b62 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -68,7 +68,6 @@ public class SetBlockFast extends BukkitSetBlockManager { * @param blockId Block ID * @param data Block Data Value * - * @return true */ @Override public void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) { @@ -81,7 +80,7 @@ public class SetBlockFast extends BukkitSetBlockManager { /** * Update chunks * - * @param player Player whose chunks we're updating + * @param chunks list of chunks to update */ @Override public void update(final List chunks) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 6080910d9..7dfca58dc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -74,10 +74,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { * @param x X Coordinate * @param y Y Coordinate * @param z Z Coordinate - * @param blockId Block ID + * @param id Block ID * @param data Block Data Value - * - * @return true */ @SuppressWarnings("deprecation") @Override @@ -286,7 +284,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { /** * Update chunks * - * @param player Player whose chunks we're updating + * @param chunks chunks to be updated */ @Override public void update(final List chunks) { diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java index 32b47622b..7561edf3f 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/bukkit/BukkitTranslation.java @@ -31,8 +31,6 @@ public class BukkitTranslation { /** * Get the universal parent based on the plugin data folder * - * @param plugin to check - * * @return parent folder */ public static File getParent() { From 1fedb1e347ba6cd645e17e758d8b968904ab0e5a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 18:05:06 +1100 Subject: [PATCH 029/223] Fix tag p --- .../jnbt/CompoundTag.java | 30 ++++++++-------- .../intellectualcrafters/jnbt/ListTag.java | 30 ++++++++-------- .../jnbt/NBTInputStream.java | 2 +- .../jnbt/NBTOutputStream.java | 2 +- .../com/intellectualcrafters/json/CDL.java | 6 ++-- .../intellectualcrafters/json/CookieList.java | 2 +- .../com/intellectualcrafters/json/HTTP.java | 36 +++++++++---------- .../intellectualcrafters/json/JSONArray.java | 14 ++++---- .../com/intellectualcrafters/json/JSONML.java | 4 +-- .../intellectualcrafters/json/JSONObject.java | 30 ++++++++-------- .../json/JSONStringer.java | 16 ++++----- .../intellectualcrafters/json/JSONWriter.java | 16 ++++----- .../com/intellectualcrafters/json/Kim.java | 10 +++--- .../com/intellectualcrafters/json/XML.java | 4 +-- .../plot/commands/SubCommand.java | 10 +++--- .../plot/generator/ClassicPlotWorld.java | 2 +- .../plot/object/BlockWrapper.java | 2 +- .../plot/util/StringComparison.java | 2 +- 18 files changed, 109 insertions(+), 109 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java index 88f642d6f..842aba19b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/CompoundTag.java @@ -69,7 +69,7 @@ public final class CompoundTag extends Tag { } /** - * Get a byte array named with the given key.

If the key does not exist or its value is not a byte array + * Get a byte array named with the given key.

If the key does not exist or its value is not a byte array * tag, then an empty byte array will be returned.

* * @param key the key @@ -86,7 +86,7 @@ public final class CompoundTag extends Tag { } /** - * Get a byte named with the given key.

If the key does not exist or its value is not a byte tag, then + * Get a byte named with the given key.

If the key does not exist or its value is not a byte tag, then * {@code 0} will be returned.

* * @param key the key @@ -103,7 +103,7 @@ public final class CompoundTag extends Tag { } /** - * Get a double named with the given key.

If the key does not exist or its value is not a double tag, then + * Get a double named with the given key.

If the key does not exist or its value is not a double tag, then * {@code 0} will be returned.

* * @param key the key @@ -120,7 +120,7 @@ public final class CompoundTag extends Tag { } /** - * Get a double named with the given key, even if it's another type of number.

If the key does not exist or + * Get a double named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

* * @param key the key @@ -147,7 +147,7 @@ public final class CompoundTag extends Tag { } /** - * Get a float named with the given key.

If the key does not exist or its value is not a float tag, then + * Get a float named with the given key.

If the key does not exist or its value is not a float tag, then * {@code 0} will be returned.

* * @param key the key @@ -164,7 +164,7 @@ public final class CompoundTag extends Tag { } /** - * Get a {@code int[]} named with the given key.

If the key does not exist or its value is not an int array + * Get a {@code int[]} named with the given key.

If the key does not exist or its value is not an int array * tag, then an empty array will be returned.

* * @param key the key @@ -181,7 +181,7 @@ public final class CompoundTag extends Tag { } /** - * Get an int named with the given key.

If the key does not exist or its value is not an int tag, then + * Get an int named with the given key.

If the key does not exist or its value is not an int tag, then * {@code 0} will be returned.

* * @param key the key @@ -198,7 +198,7 @@ public final class CompoundTag extends Tag { } /** - * Get an int named with the given key, even if it's another type of number.

If the key does not exist or + * Get an int named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

* * @param key the key @@ -225,7 +225,7 @@ public final class CompoundTag extends Tag { } /** - * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, + * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, * then an empty list will be returned.

* * @param key the key @@ -242,7 +242,7 @@ public final class CompoundTag extends Tag { } /** - * Get a {@code TagList} named with the given key.

If the key does not exist or its value is not a list + * Get a {@code TagList} named with the given key.

If the key does not exist or its value is not a list * tag, then an empty tag list will be returned.

* * @param key the key @@ -259,7 +259,7 @@ public final class CompoundTag extends Tag { } /** - * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, + * Get a list of tags named with the given key.

If the key does not exist or its value is not a list tag, * then an empty list will be returned. If the given key references a list but the list of of a different type, then * an empty list will also be returned.

* @@ -285,7 +285,7 @@ public final class CompoundTag extends Tag { } /** - * Get a long named with the given key.

If the key does not exist or its value is not a long tag, then + * Get a long named with the given key.

If the key does not exist or its value is not a long tag, then * {@code 0} will be returned.

* * @param key the key @@ -302,7 +302,7 @@ public final class CompoundTag extends Tag { } /** - * Get a long named with the given key, even if it's another type of number.

If the key does not exist or + * Get a long named with the given key, even if it's another type of number.

If the key does not exist or * its value is not a number, then {@code 0} will be returned.

* * @param key the key @@ -329,7 +329,7 @@ public final class CompoundTag extends Tag { } /** - * Get a short named with the given key.

If the key does not exist or its value is not a short tag, then + * Get a short named with the given key.

If the key does not exist or its value is not a short tag, then * {@code 0} will be returned.

* * @param key the key @@ -346,7 +346,7 @@ public final class CompoundTag extends Tag { } /** - * Get a string named with the given key.

If the key does not exist or its value is not a string tag, then + * Get a string named with the given key.

If the key does not exist or its value is not a string tag, then * {@code ""} will be returned.

* * @param key the key diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java index 2f517ef77..614a86af4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java @@ -84,7 +84,7 @@ public final class ListTag extends Tag { } /** - * Get a byte array named with the given index.

If the index does not exist or its value is not a byte + * Get a byte array named with the given index.

If the index does not exist or its value is not a byte * array tag, then an empty byte array will be returned.

* * @param index the index @@ -101,7 +101,7 @@ public final class ListTag extends Tag { } /** - * Get a byte named with the given index.

If the index does not exist or its value is not a byte tag, then + * Get a byte named with the given index.

If the index does not exist or its value is not a byte tag, then * {@code 0} will be returned.

* * @param index the index @@ -118,7 +118,7 @@ public final class ListTag extends Tag { } /** - * Get a double named with the given index.

If the index does not exist or its value is not a double tag, + * Get a double named with the given index.

If the index does not exist or its value is not a double tag, * then {@code 0} will be returned.

* * @param index the index @@ -135,7 +135,7 @@ public final class ListTag extends Tag { } /** - * Get a double named with the given index, even if it's another type of number.

If the index does not + * Get a double named with the given index, even if it's another type of number.

If the index does not * exist or its value is not a number, then {@code 0} will be returned.

* * @param index the index @@ -162,7 +162,7 @@ public final class ListTag extends Tag { } /** - * Get a float named with the given index.

If the index does not exist or its value is not a float tag, + * Get a float named with the given index.

If the index does not exist or its value is not a float tag, * then {@code 0} will be returned.

* * @param index the index @@ -179,7 +179,7 @@ public final class ListTag extends Tag { } /** - * Get a {@code int[]} named with the given index.

If the index does not exist or its value is not an int + * Get a {@code int[]} named with the given index.

If the index does not exist or its value is not an int * array tag, then an empty array will be returned.

* * @param index the index @@ -196,7 +196,7 @@ public final class ListTag extends Tag { } /** - * Get an int named with the given index.

If the index does not exist or its value is not an int tag, then + * Get an int named with the given index.

If the index does not exist or its value is not an int tag, then * {@code 0} will be returned.

* * @param index the index @@ -213,7 +213,7 @@ public final class ListTag extends Tag { } /** - * Get an int named with the given index, even if it's another type of number.

If the index does not exist + * Get an int named with the given index, even if it's another type of number.

If the index does not exist * or its value is not a number, then {@code 0} will be returned.

* * @param index the index @@ -240,7 +240,7 @@ public final class ListTag extends Tag { } /** - * Get a list of tags named with the given index.

If the index does not exist or its value is not a list + * Get a list of tags named with the given index.

If the index does not exist or its value is not a list * tag, then an empty list will be returned.

* * @param index the index @@ -257,7 +257,7 @@ public final class ListTag extends Tag { } /** - * Get a {@code TagList} named with the given index.

If the index does not exist or its value is not a list + * Get a {@code TagList} named with the given index.

If the index does not exist or its value is not a list * tag, then an empty tag list will be returned.

* * @param index the index @@ -274,7 +274,7 @@ public final class ListTag extends Tag { } /** - * Get a list of tags named with the given index.

If the index does not exist or its value is not a list + * Get a list of tags named with the given index.

If the index does not exist or its value is not a list * tag, then an empty list will be returned. If the given index references a list but the list of of a different * type, then an empty list will also be returned.

* @@ -300,7 +300,7 @@ public final class ListTag extends Tag { } /** - * Get a long named with the given index.

If the index does not exist or its value is not a long tag, then + * Get a long named with the given index.

If the index does not exist or its value is not a long tag, then * {@code 0} will be returned.

* * @param index the index @@ -317,7 +317,7 @@ public final class ListTag extends Tag { } /** - * Get a long named with the given index, even if it's another type of number.

If the index does not exist + * Get a long named with the given index, even if it's another type of number.

If the index does not exist * or its value is not a number, then {@code 0} will be returned.

* * @param index the index @@ -344,7 +344,7 @@ public final class ListTag extends Tag { } /** - * Get a short named with the given index.

If the index does not exist or its value is not a short tag, + * Get a short named with the given index.

If the index does not exist or its value is not a short tag, * then {@code 0} will be returned.

* * @param index the index @@ -361,7 +361,7 @@ public final class ListTag extends Tag { } /** - * Get a string named with the given index.

If the index does not exist or its value is not a string tag, + * Get a string named with the given index.

If the index does not exist or its value is not a string tag, * then {@code ""} will be returned.

* * @param index the index diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java index be6702d6b..7bf7ae2c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java @@ -11,7 +11,7 @@ import java.util.Map; /** * This class reads NBT, or Named Binary Tag streams, and produces an object graph of - * subclasses of the {@code Tag} object.

The NBT format was created by Markus Persson, and the specification + * subclasses of the {@code Tag} object.

The NBT format was created by Markus Persson, and the specification * may be found at http://www.minecraft.net/docs/NBT.txt.

*/ public final class NBTInputStream implements Closeable { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index 884366100..9db7fb9e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -28,7 +28,7 @@ import java.util.List; /** *

This class writes NBT, or Named Binary Tag Tag objects to an - * underlying OutputStream.

The NBT format was created by Markus Persson, and the + * underlying OutputStream.

The NBT format was created by Markus Persson, and the * specification may be found at http://www.minecraft.net/docs/NBT.txt. *

* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java index fde894749..fb69ce28b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java @@ -4,13 +4,13 @@ package com.intellectualcrafters.json; * This provides static methods to convert comma delimited text into a JSONArray, and to covert a JSONArray into comma * delimited text. Comma delimited text is a very popular format for data interchange. It is understood by most * database, spreadsheet, and organizer programs. - *

+ * * Each row of text represents a row in a table or a data record. Each row ends with a NEWLINE character. Each row * contains one or more values. Values are separated by commas. A value can contain any character except for comma, * unless is is wrapped in single quotes or double quotes. - *

+ * * The first row usually contains the names of the columns. - *

+ * * A comma delimited list can be converted into a JSONArray of JSONObjects. The names for the elements in the * JSONObjects can be taken from the names in the first row. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java index c8ee0136d..85553dc13 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CookieList.java @@ -13,7 +13,7 @@ public class CookieList { * Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated * from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly * converting '+' and '%' sequences. - *

+ * * To add a cookie to a cooklist, cookielistJSONObject.put(cookieJSONObject.getString("name"), * cookieJSONObject.getString("value")); * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java index c78f24d61..ee8594944 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java @@ -37,8 +37,8 @@ public class HTTP { /** * Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request * header will contain - *

- *

+ * + * *

      * {
      *    Method: "POST" (for example),
@@ -46,10 +46,10 @@ public class HTTP {
      *    "HTTP-Version": "HTTP/1.1" (for example)
      * }
      * 
- *

+ * * A response header will contain - *

- *

+ * + * *

      * {
      *    "HTTP-Version": "HTTP/1.1" (for example),
@@ -57,20 +57,20 @@ public class HTTP {
      *    "Reason-Phrase": "OK" (for example)
      * }
      * 
- *

+ * * In addition, the other parameters in the header will be captured, using the HTTP field names as JSON names, so * that - *

- *

+ * + * *

      *    Date: Sun, 26 May 2002 18:06:04 GMT
      *    Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
      *    Cache-Control: no-cache
      * 
- *

+ * * become - *

- *

+ * + * *

      * {...
      *    Date: "Sun, 26 May 2002 18:06:04 GMT",
@@ -78,7 +78,7 @@ public class HTTP {
      *    "Cache-Control": "no-cache",
      * ...}
      * 
- *

+ * * It does no further checking or conversion. It does not parse dates. It does not do '%' transforms on URLs. * * @param string An HTTP header string. @@ -116,8 +116,8 @@ public class HTTP { /** * Convert a JSONObject into an HTTP header. A request header must contain - *

- *

+ * + * *

      * {
      *    Method: "POST" (for example),
@@ -125,10 +125,10 @@ public class HTTP {
      *    "HTTP-Version": "HTTP/1.1" (for example)
      * }
      * 
- *

+ * * A response header must contain - *

- *

+ * + * *

      * {
      *    "HTTP-Version": "HTTP/1.1" (for example),
@@ -136,7 +136,7 @@ public class HTTP {
      *    "Reason-Phrase": "OK" (for example)
      * }
      * 
- *

+ * * Any other members of the JSONObject will be output as HTTP fields. The result will end with two CRLF pairs. * * @param jo A JSONObject diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java index 026613a2b..c31b44653 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java @@ -34,16 +34,16 @@ import java.util.Map; * accessing the values by index, and put methods for adding or replacing values. The values can be any of * these types: Boolean, JSONArray, JSONObject, Number, * String, or the JSONObject.NULL object. - *

+ * * The constructor can convert a JSON text into a Java object. The toString method converts to JSON text. - *

+ * * A get method returns a value if one can be found, and throws an exception if one cannot be found. An * opt method returns a default value instead of throwing an exception, and so is useful for obtaining * optional values. - *

+ * * The generic get() and opt() methods return an object which you can cast or query for type. * There are also typed get and opt methods that do type checking and type coercion for you. - *

+ * * The texts produced by the toString methods strictly conform to JSON syntax rules. The constructors are * more forgiving in the texts they will accept:

  • An extra , (comma) may appear * just before the closing bracket.
  • The null value will be inserted when there is , @@ -789,7 +789,7 @@ public class JSONArray { * Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to * produce a syntactically correct JSON text then null will be returned instead. This could occur if the array * contains an invalid number. - *

    + * * Warning: This method assumes that the data structure is acyclical. * * @return a printable, displayable, transmittable representation of the array. @@ -824,7 +824,7 @@ public class JSONArray { /** * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. - *

    + * * Warning: This method assumes that the data structure is acyclical. * * @return The writer. @@ -837,7 +837,7 @@ public class JSONArray { /** * Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. - *

    + * * Warning: This method assumes that the data structure is acyclical. * * @param indentFactor The number of spaces to add to each level of indentation. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java index 73c5b0b35..ac419e1a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java @@ -222,7 +222,7 @@ public class JSONML { * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes * will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes" * property which will be an array of strings and JsonML JSONObjects. - *

    + * * Comments, prologs, DTDs, and <[ [ ]]> are ignored. * * @param x An XMLTokener of the XML source text. @@ -240,7 +240,7 @@ public class JSONML { * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes * will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes" * property which will be an array of strings and JsonML JSONObjects. - *

    + * * Comments, prologs, DTDs, and <[ [ ]]> are ignored. * * @param string The XML source text. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java index 7d830b2e5..408a2ec91 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java @@ -27,21 +27,21 @@ import java.util.Set; * values into a JSON text using the put and toString methods. A get method * returns a value if one can be found, and throws an exception if one cannot be found. An opt method * returns a default value instead of throwing an exception, and so is useful for obtaining optional values. - *

    + * * The generic get() and opt() methods return an object, which you can cast or query for type. * There are also typed get and opt methods that do type checking and type coercion for you. * The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such * as null. - *

    + * * The put methods add or replace values in an object. For example, - *

    - *

    + * + * *

      * myString = new JSONObject().put("JSON", "Hello, World!").toString();
      * 
    - *

    + * * produces the string {"JSON": "Hello, World"}. - *

    + * * The texts produced by the toString methods strictly conform to the JSON syntax rules. The constructors * are more forgiving in the texts they will accept:

    • An extra , (comma) may * appear just before the closing brace.
    • Strings may be quoted with ' (single @@ -164,10 +164,10 @@ public class JSONObject { * For each of the methods with no parameters and a name starting with "get" or "is" * followed by an uppercase letter, the method is invoked, and a key and the value returned from the getter method * are put into the new JSONObject. - *

      + * * The key is formed by removing the "get" or "is" prefix. If the second remaining * character is not upper case, then the first character is converted to lower case. - *

      + * * For example, if an object has a method named "getName", and if the result of calling * object.getName() is "Larry Fine", then the JSONObject will contain "name": "Larry * Fine". @@ -495,8 +495,8 @@ public class JSONObject { * If the value is an array or Collection, then a JSONArray will be made from it and its toJSONString method will be * called. If the value is a MAP, then a JSONObject will be made from it and its toJSONString method will be called. * Otherwise, the value's toString method will be called, and the result will be quoted. - *

      - *

      + * + * * Warning: This method assumes that the data structure is acyclical. * * @param value The value to be serialized. @@ -620,7 +620,7 @@ public class JSONObject { * Accumulate values under a key. It is similar to the put method except that if there is already an object stored * under the key then a JSONArray is stored under the key to hold all of the accumulated values. If there is already * a JSONArray, then the new value is appended to it. In contrast, the put method replaces the previous value. - *

      + * * If only one value is accumulated that is not a JSONArray, then the result will be the same as using put. But if * multiple values are accumulated, then the result will be like append. * @@ -1347,7 +1347,7 @@ public class JSONObject { /** * Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not result in a * syntactically correct JSON text, then null will be returned instead. - *

      + * * Warning: This method assumes that the data structure is acyclical. * * @return a printable, displayable, portable, transmittable representation of the object, beginning with @@ -1365,7 +1365,7 @@ public class JSONObject { /** * Make a prettyprinted JSON text of this JSONObject. - *

      + * * Warning: This method assumes that the data structure is acyclical. * * @param indentFactor The number of spaces to add to each level of indentation. @@ -1385,7 +1385,7 @@ public class JSONObject { /** * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. - *

      + * * Warning: This method assumes that the data structure is acyclical. * * @return The writer. @@ -1398,7 +1398,7 @@ public class JSONObject { /** * Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added. - *

      + * * Warning: This method assumes that the data structure is acyclical. * * @return The writer. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java index 053001408..56d67ad6f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONStringer.java @@ -6,28 +6,28 @@ import java.io.StringWriter; * JSONStringer provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON * syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of * JSONStringer can produce one JSON text. - *

      + * * A JSONStringer instance provides a value method for appending values to the text, and a key * method for adding keys before values in objects. There are array and endArray methods that * make and bound array values, and object and endObject methods which make and bound object * values. All of these methods return the JSONWriter instance, permitting cascade style. For example, - *

      - *

      + * + * *

        * myString = new JSONStringer().object().key("JSON").value("Hello,
        * World!").endObject().toString();
        * 
      - *

      + * * which produces the string - *

      - *

      + * + * *

        * {"JSON":"Hello, World!"}
        * 
      - *

      + * * The first method called must be array or object. There are no methods for adding commas or * colons. JSONStringer adds them for you. Objects and arrays can be nested up to 20 levels deep. - *

      + * * This can sometimes be easier than using a JSONObject to build a string. * * @author JSON.org diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java index 082d37e26..7530c40f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java @@ -7,27 +7,27 @@ import java.io.Writer; * JSONWriter provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON * syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of * JSONWriter can produce one JSON text. - *

      + * * A JSONWriter instance provides a value method for appending values to the text, and a key * method for adding keys before values in objects. There are array and endArray methods that * make and bound array values, and object and endObject methods which make and bound object * values. All of these methods return the JSONWriter instance, permitting a cascade style. For example, - *

      - *

      + * + * *

        * new JSONWriter(myWriter).object().key("JSON").value("Hello, World!").endObject();
        * 
      - *

      + * * which writes - *

      - *

      + * + * *

        * {"JSON":"Hello, World!"}
        * 
      - *

      + * * The first method called must be array or object. There are no methods for adding commas or * colons. JSONWriter adds them for you. Objects and arrays can be nested up to 20 levels deep. - *

      + * * This can sometimes be easier than using a JSONObject to build a string. * * @author JSON.org diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java index 3a60033b1..e8e90a7a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/Kim.java @@ -5,22 +5,22 @@ package com.intellectualcrafters.json; * byte. The last byte of a character never has the MSB reset. Every byte that is not the last byte has the MSB set. Kim * stands for "Keep it minimal". A Unicode character is never longer than 3 bytes. Every byte contributes 7 bits to the * character. ASCII is unmodified. - *

      + * * Kim UTF-8 one byte U+007F U+007F two bytes U+3FFF U+07FF three bytes U+10FFF U+FFFF four bytes U+10FFFF - *

      + * * Characters in the ranges U+0800..U+3FFF and U+10000..U+10FFFF will be one byte smaller when encoded in Kim compared * to UTF-8. - *

      + * * Kim is beneficial when using scripts such as Old South Arabian, Aramaic, Avestan, Balinese, Batak, Bopomofo, * Buginese, Buhid, Carian, Cherokee, Coptic, Cyrillic, Deseret, Egyptian Hieroglyphs, Ethiopic, Georgian, Glagolitic, * Gothic, Hangul Jamo, Hanunoo, Hiragana, Kanbun, Kaithi, Kannada, Katakana, Kharoshthi, Khmer, Lao, Lepcha, Limbu, * Lycian, Lydian, Malayalam, Mandaic, Meroitic, Miao, Mongolian, Myanmar, New Tai Lue, Ol Chiki, Old Turkic, Oriya, * Osmanya, Pahlavi, Parthian, Phags-Pa, Phoenician, Samaritan, Sharada, Sinhala, Sora Sompeng, Tagalog, Tagbanwa, * Takri, Tai Le, Tai Tham, Tamil, Telugu, Thai, Tibetan, Tifinagh, UCAS. - *

      + * * A kim object can be constructed from an ordinary UTF-16 string, or from a byte array. A kim object can produce a * UTF-16 string. - *

      + * * As with UTF-8, it is possible to detect character boundaries within a byte sequence. UTF-8 is one of the world's * great inventions. While Kim is more efficient, it is not clear that it is worth the expense of transition. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java index 6e0d36127..1bad5a232 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XML.java @@ -48,8 +48,8 @@ public class XML { /** * Replace special characters with XML escapes: - *

      - *

      + * + * *

            * & (ampersand) is replaced by &amp;
            * < (less than) is replaced by &lt;
      diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java
      index fecaa5cc0..245aadc82 100644
      --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java
      +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java
      @@ -160,31 +160,31 @@ public abstract class SubCommand {
           public enum CommandCategory {
               /**
                * Claiming Commands
      -         * 

      + * * Such as: /plot claim */ CLAIMING("Claiming"), /** * Teleportation Commands - *

      + * * Such as: /plot visit */ TELEPORT("Teleportation"), /** * Action Commands - *

      + * * Such as: /plot clear */ ACTIONS("Actions"), /** * Information Commands - *

      + * * Such as: /plot info */ INFO("Information"), /** * Debug Commands - *

      + * * Such as: /plot debug */ DEBUG("Debug"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java index d3130bf94..ba6e01065 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java @@ -31,7 +31,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { /** * CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP - *

      + * * Set the last boolean to false if you do not require a specific config node to be set while using the setup * command - this may be useful if a config value can be changed at a later date, and has no impact on the actual * world generation diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java index 216d2b351..7f30e4c30 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java @@ -25,7 +25,7 @@ import org.bukkit.block.Block; /** * Wrapper class for blocks, using pure data rather than the object. - *

      + * * Useful for NMS * * @author Empire92 diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index 261128cb8..19c68820f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -36,7 +36,7 @@ public class StringComparison { private String bestMatch; /** * Match Value - *

      + * * Can be checked for low match (< .25 or something) */ private double match = 0; From 61a225937d44a82c396cba9eec50e6bf164e141f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 13 Mar 2015 18:26:08 +1100 Subject: [PATCH 030/223] More jdoc stuff --- PlotSquared/pom.xml | 1 + .../jnbt/ListTagBuilder.java | 5 ++ .../jnbt/NBTInputStream.java | 4 +- .../jnbt/NBTOutputStream.java | 3 +- .../intellectualcrafters/jnbt/NBTUtils.java | 1 + .../com/intellectualcrafters/json/HTTP.java | 53 ------------------ .../com/intellectualcrafters/json/JSONML.java | 1 - .../intellectualcrafters/json/JSONObject.java | 1 - .../com/intellectualcrafters/json/XML.java | 56 ------------------- .../intellectualcrafters/json/XMLTokener.java | 10 ++-- .../plot/api/PlotAPI.java | 12 ++-- .../plot/flag/AbstractFlag.java | 2 +- .../intellectualcrafters/plot/flag/Flag.java | 2 +- .../plot/flag/FlagManager.java | 2 +- .../plot/object/Plot.java | 4 +- 15 files changed, 27 insertions(+), 130 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 2af82a31f..faead4fd6 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -43,6 +43,7 @@ public false + -Xdoclint:none diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java index c076aaf80..af94f866d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java @@ -27,6 +27,8 @@ public class ListTagBuilder { /** * Create a new builder instance. + * + * @param type * * @return a new builder */ @@ -36,6 +38,9 @@ public class ListTagBuilder { /** * Create a new builder instance. + * + * @param entries + * @param * * @return a new builder */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java index 7bf7ae2c9..ef73bb881 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTInputStream.java @@ -11,8 +11,8 @@ import java.util.Map; /** * This class reads NBT, or Named Binary Tag streams, and produces an object graph of - * subclasses of the {@code Tag} object.

      The NBT format was created by Markus Persson, and the specification - * may be found at http://www.minecraft.net/docs/NBT.txt.

      + * subclasses of the {@code Tag} object. The NBT format was created by Markus Persson, and the specification + * may be found at @linktourl http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt. */ public final class NBTInputStream implements Closeable { private final DataInputStream is; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index 9db7fb9e4..452784981 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -29,7 +29,8 @@ import java.util.List; /** *

      This class writes NBT, or Named Binary Tag Tag objects to an * underlying OutputStream.

      The NBT format was created by Markus Persson, and the - * specification may be found at http://www.minecraft.net/docs/NBT.txt. + * specification may be found at + * @linktourl http://www.minecraft.net/docs/NBT.txt *

      * * @author Graham Edgecombe diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java index d56c9808e..06b23b22c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java @@ -134,6 +134,7 @@ public final class NBTUtils { * @param items the map to read from * @param key the key to look for * @param expected the expected NBT class type + * @param * * @return child tag */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java index ee8594944..2e5f2b763 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/HTTP.java @@ -34,59 +34,6 @@ public class HTTP { */ public static final String CRLF = "\r\n"; - /** - * Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request - * header will contain - * - * - *
      -     * {
      -     *    Method: "POST" (for example),
      -     *    "Request-URI": "/" (for example),
      -     *    "HTTP-Version": "HTTP/1.1" (for example)
      -     * }
      -     * 
      - * - * A response header will contain - * - * - *
      -     * {
      -     *    "HTTP-Version": "HTTP/1.1" (for example),
      -     *    "Status-Code": "200" (for example),
      -     *    "Reason-Phrase": "OK" (for example)
      -     * }
      -     * 
      - * - * In addition, the other parameters in the header will be captured, using the HTTP field names as JSON names, so - * that - * - * - *
      -     *    Date: Sun, 26 May 2002 18:06:04 GMT
      -     *    Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
      -     *    Cache-Control: no-cache
      -     * 
      - * - * become - * - * - *
      -     * {...
      -     *    Date: "Sun, 26 May 2002 18:06:04 GMT",
      -     *    Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
      -     *    "Cache-Control": "no-cache",
      -     * ...}
      -     * 
      - * - * It does no further checking or conversion. It does not parse dates. It does not do '%' transforms on URLs. - * - * @param string An HTTP header string. - * - * @return A JSONObject containing the elements and attributes of the XML string. - * - * @throws JSONException - */ public static JSONObject toJSONObject(final String string) throws JSONException { final JSONObject jo = new JSONObject(); final HTTPTokener x = new HTTPTokener(string); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java index ac419e1a2..c63a5670b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONML.java @@ -188,7 +188,6 @@ public class JSONML { * Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each * XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then * the second element will be JSONObject containing the name/value pairs. If the tag contains children, then strings - * and JSONArrays will represent the child tags. Comments, prologs, DTDs, and <[ [ ]]> are ignored. * * @param string The source string. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java index 408a2ec91..3cac13db7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java @@ -343,7 +343,6 @@ public class JSONObject { /** * Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted - * within '. - */ public static final Character GT = '>'; - /** - * The Character '<'. - */ public static final Character LT = '<'; - /** - * The Character '?'. - */ public static final Character QUEST = '?'; - /** - * The Character '"'. - */ public static final Character QUOT = '"'; - /** - * The Character '/'. - */ public static final Character SLASH = '/'; - /** - * Replace special characters with XML escapes: - * - * - *
      -     * & (ampersand) is replaced by &amp;
      -     * < (less than) is replaced by &lt;
      -     * > (greater than) is replaced by &gt;
      -     * " (double quote) is replaced by &quot;
      -     * 
      - * - * @param string The string to be escaped. - * - * @return The escaped string. - */ public static String escape(final String string) { final StringBuilder sb = new StringBuilder(string.length()); for (int i = 0, length = string.length(); i < length; i++) { @@ -300,20 +258,6 @@ public class XML { return string; } - /** - * Convert a well-formed (but not necessarily valid) XML string into a JSONObject. Some information may be lost in - * this transformation because JSON is a data format and XML is a document format. XML uses elements, attributes, - * and content text, while JSON uses unordered collections of name/value pairs and arrays of values. JSON does not - * does not like to distinguish between elements and attributes. Sequences of similar elements are represented as - * JSONArrays. Content text may be placed in a "content" member. Comments, prologs, DTDs, and <[ [ - * ]]> are ignored. - * - * @param string The source string. - * - * @return A JSONObject containing the structured data from the XML string. - * - * @throws JSONException - */ public static JSONObject toJSONObject(final String string) throws JSONException { final JSONObject jo = new JSONObject(); final XMLTokener x = new XMLTokener(string); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java index d0e39ad36..94edd5792 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/XMLTokener.java @@ -55,10 +55,10 @@ public class XMLTokener extends JSONTokener { } /** - * Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins + * Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins * a markup tag, and the content text between markup tags. * - * @return A string, or a '<' Character, or null if there is no more source text. + * @return A string, or a '<' Character, or null if there is no more source text. * * @throws JSONException */ @@ -90,7 +90,7 @@ public class XMLTokener extends JSONTokener { } /** - * Return the next entity. These entities are translated to Characters: & ' > < + * Return the next entity. These entities are translated to Characters: & " > < * ". * * @param ampersand An ampersand character. @@ -119,7 +119,7 @@ public class XMLTokener extends JSONTokener { /** * Returns the next XML meta token. This is used for skipping over and structures. * - * @return Syntax characters (< > / = ! ?) are returned as Character, and strings and names are + * @return Syntax characters (< > / = ! ?) are returned as Character, and strings and names are * returned as Boolean. We don't care what the values actually are. * * @throws JSONException If a string is not properly closed or if the XML is badly structured. @@ -182,7 +182,7 @@ public class XMLTokener extends JSONTokener { /** * Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters: - * / > = ! ? or it may be a string wrapped in single quotes or double quotes, or it may be a name. + * / >= ! ? or it may be a string wrapped in single quotes or double quotes, or it may be a name. * * @return a String or a Character. * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 5e207db66..ba67693d7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -201,7 +201,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; } /** - * Do not use this. Instead use FlagManager. in your code. + * Do not use this. Instead use FlagManager.[method] in your code. * - Flag related stuff * * @return FlagManager @@ -214,7 +214,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; } /** - * Do not use this. Instead use ClusterManager. in your code. + * Do not use this. Instead use ClusterManager.[method] in your code. * - Plot cluster related stuff * * @return ClusterManager @@ -227,7 +227,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; } /** - * Do not use this. Instead use MainUtil. in your code. + * Do not use this. Instead use MainUtil.[method] in your code. * - Basic plot management stuff * * @return MainUtil @@ -240,7 +240,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; } /** - * Do not use this. Instead use Permissions. in your code. + * Do not use this. Instead use Permissions.[method] in your code. * - Basic permission management stuff * * @return MainUtil @@ -264,7 +264,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; } /** - * Use C. instead + * Use C.[caption] instead * * @return C * @@ -293,7 +293,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; * Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and * tessellation * - * @param world Plot World + * @param world * * @return PlotManager * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java index f204be4ae..0eec59d6c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java @@ -38,7 +38,7 @@ public class AbstractFlag { /** * AbstractFlag is a parameter used in creating a new Flag
      - * The key must be alphabetical characters and <= 16 characters in length + * The key must be alphabetical characters and <= 16 characters in length * @param key */ public AbstractFlag(final String key, final FlagValue value) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index e5eab6261..c31c4456b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -31,7 +31,7 @@ public class Flag { * player, you need to register it with PlotSquared. * * @param key AbstractFlag - * @param value Value must be alphanumerical (can have spaces) and be <= 48 characters + * @param value Value must be alphanumerical (can have spaces) and be <= 48 characters * * @throws IllegalArgumentException if you provide inadequate inputs */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 8c6e0238a..2ac43e608 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -171,7 +171,7 @@ public class FlagManager { /** * * @param plot - * @return Set + * @return set of flags */ public static Set getPlotFlags(final Plot plot) { return getSettingFlags(plot.world, plot.settings); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index d75142f14..8abad98ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -283,8 +283,8 @@ public class Plot implements Cloneable { /** * Get the plot hashcode * - * @return integer. You can easily make this a character array
      xI = c[0] x = c[1 -> xI...] yI = c[xI ... + 1] y - * = c[xI ... + 2 -> yI ...] + * @return integer. You can easily make this a character array
      xI = c[0] x = c[1 -> xI...] yI = c[xI ... + 1] y + * = c[xI ... + 2 -> yI ...] */ @Override public int hashCode() { From cdcab96d89fe55f526ce2b0138021b9133f78f38 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 14 Mar 2015 00:29:58 +1100 Subject: [PATCH 031/223] Fix condense with no plots --- .../java/com/intellectualcrafters/plot/commands/Condense.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 48dc09b63..77ba45daa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -94,6 +94,10 @@ public class Condense extends SubCommand { } start = Auto.getNextPlot(start, 1); } + if (free.size() == 0 || to_move.size() == 0) { + MainUtil.sendMessage(plr, "NO PLOTS FOUND"); + return false; + } MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() { @Override public void run() { From c689dff014a024b63b334608cd43224f46c4754f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 14 Mar 2015 00:48:08 +1100 Subject: [PATCH 032/223] Actually fixed unlink bug --- .../intellectualcrafters/plot/generator/ClassicPlotManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index b0be9b5f6..56dec6691 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -188,7 +188,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int ez = (sz + dpw.ROAD_WIDTH) - 1; final int sx = pos1.getX() - 1; final int ex = pos2.getX() + 2; - MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0)); MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); From fb076adfabb7dd70cb4a3bbeb903fce9e9d21318 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 14 Mar 2015 17:00:51 +1100 Subject: [PATCH 033/223] Fixed plot clearing --- .../plot/generator/HybridPlotManager.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index df718070a..0ee71ccab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -100,7 +100,6 @@ public class HybridPlotManager extends ClassicPlotManager { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - setWall(dpw, plot.id, new PlotBlock[] { wall }); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -147,14 +146,10 @@ public class HybridPlotManager extends ClassicPlotManager { } final int I = i; final int J = j; - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - BukkitUtil.regenerateChunk(world, I / 16, J / 16); - } - }, PseudoRandom.random(40)); + BukkitUtil.regenerateChunk(world, I / 16, J / 16); } } + setWall(dpw, plot.id, new PlotBlock[] { wall }); final Location max = mx; final Location min = mn; if (min == null) { From 421a7dfb99461e3d8d0ecf4dabf9e7aa2bcd6379 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 14 Mar 2015 18:57:58 +1100 Subject: [PATCH 034/223] Fixed piston retract --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 eadeb29ac..9f2b355da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -546,8 +546,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null) { - final Block b = event.getRetractLocation().getBlock(); - Location bloc = BukkitUtil.getLocation(b.getLocation()); + Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(block.getRelative(event.getDirection()).getRelative(event.getDirection()).getLocation())); Plot newPlot = MainUtil.getPlot(bloc); if (!plot.equals(newPlot)) { event.setCancelled(true); From e0970dcdd26e082807b5ca149007627be94dbb82 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 11:49:22 +1100 Subject: [PATCH 035/223] misc fixes --- PlotSquared/pom.xml | 2 +- .../intellectualcrafters/plot/BukkitMain.java | 7 +++- .../plot/api/PlotAPI.java | 2 +- .../plot/commands/Clear.java | 4 +- .../plot/generator/HybridPlotManager.java | 3 ++ .../plot/util/MainUtil.java | 38 ------------------- .../plot/util/bukkit/BukkitUtil.java | 6 ++- .../plot/util/bukkit/SetBlockFast.java | 3 +- .../plot/util/bukkit/SetBlockFast_1_8.java | 3 +- 9 files changed, 21 insertions(+), 47 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index faead4fd6..e35e257ad 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.9 + 2.8.10 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index af0964ecb..afd1418e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -275,7 +275,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { BlockUpdateUtil.setBlockManager = BukkitSetBlockManager.setBlockManager; try { new SendChunk(); - MainUtil.canSendChunk = true; + if (checkVersion(1, 7, 10) && !checkVersion(1, 7, 11)) { + MainUtil.canSendChunk = false; + } + else { + MainUtil.canSendChunk = true; + } } catch (final Throwable e) { MainUtil.canSendChunk = false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index ba67693d7..f49f80a5f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -666,6 +666,6 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; */ public int getAllowedPlots(final Player player) { PlotPlayer pp = BukkitUtil.getPlayer(player); - return MainUtil.getAllowedPlots(pp, MainUtil.getPlayerPlotCount(player.getWorld().getName(), pp)); + return MainUtil.getAllowedPlots(pp); } } \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 872675644..5aee193ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -62,7 +62,7 @@ public class Clear extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - MainUtil.clear(world, plot, true, null); + MainUtil.clear(world, plot, plot.owner == null, null); PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } }; @@ -122,7 +122,7 @@ public class Clear extends SubCommand { @Override public void run() { final long start = System.currentTimeMillis(); - final boolean result = MainUtil.clearAsPlayer(plot, false, new Runnable() { + final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 0ee71ccab..4bdd53197 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -147,6 +147,9 @@ public class HybridPlotManager extends ClassicPlotManager { final int I = i; final int J = j; BukkitUtil.regenerateChunk(world, I / 16, J / 16); + if (!MainUtil.canSendChunk) { + BukkitUtil.refreshChunk(world, I / 16, J / 16); + } } } setWall(dpw, plot.id, new PlotBlock[] { wall }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c760f1a05..b4607df24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -665,44 +665,6 @@ public class MainUtil { return getPlotHome(w, plot.id); } - /** - * Refresh the plot chunks - * - * @param world World in which the plot is located - * @param plot Plot Object - */ - public static void refreshPlotChunks(final String world, final Plot plot) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX(); - final int topX = getPlotTopLoc(world, plot.id).getX(); - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); - final int topZ = getPlotTopLoc(world, plot.id).getZ(); - final int minChunkX = (int) Math.floor((double) bottomX / 16); - final int maxChunkX = (int) Math.floor((double) topX / 16); - final int minChunkZ = (int) Math.floor((double) bottomZ / 16); - final int maxChunkZ = (int) Math.floor((double) topZ / 16); - final ArrayList chunks = new ArrayList<>(); - for (int x = minChunkX; x <= maxChunkX; x++) { - for (int z = minChunkZ; z <= maxChunkZ; z++) { - if (canSendChunk) { - final ChunkLoc chunk = new ChunkLoc(x, z); - chunks.add(chunk); - } else { - BukkitUtil.refreshChunk(world, x, z); - } - } - } - try { - SendChunk.sendChunk(world, chunks); - } catch (final Throwable e) { - canSendChunk = false; - for (int x = minChunkX; x <= maxChunkX; x++) { - for (int z = minChunkZ; z <= maxChunkZ; z++) { - BukkitUtil.refreshChunk(world, x, z); - } - } - } - } - /** * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot * use getPlotTopLoc(...) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 1732a9010..3b8f20348 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -145,8 +145,10 @@ public class BukkitUtil extends BlockManager { } } - public static void refreshChunk(final String world, final int x, final int z) { - getWorld(world).refreshChunk(x, z); + public static void refreshChunk(final String name, final int x, final int z) { + World world = getWorld(name); + world.unloadChunk(x, z); + world.loadChunk(x, z); } public static void regenerateChunk(final String world, final int x, final int z) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index d62ac9b62..ddca18980 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -90,7 +90,8 @@ public class SetBlockFast extends BukkitSetBlockManager { if (!MainUtil.canSendChunk) { final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.refreshChunk(chunk.getX(), chunk.getZ()); + world.unloadChunk(chunk); + world.loadChunk(chunk); } return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 7dfca58dc..2d86c5cb0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -294,7 +294,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { if (!MainUtil.canSendChunk) { final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.refreshChunk(chunk.getX(), chunk.getZ()); + world.unloadChunk(chunk); + world.loadChunk(chunk); } return; } From 688544da28d58f09e3be3f99ddf318bff3148ec1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 12:10:31 +1100 Subject: [PATCH 036/223] test export --- PlotSquared/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index e35e257ad..ab2ca1d87 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,11 +8,11 @@ UTF-8 PlotSquared - 2.8.10 + 2.8.10.0 PlotSquared jar - PlotSquared + PlotSquared-${project.version} src/main/java From d9aa12b9843a232cbc9f85dd4c1ec46273616f35 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 13:08:45 +1100 Subject: [PATCH 037/223] title detection --- PlotSquared/pom.xml | 4 +- .../plot/titles/DefaultTitleManager.java | 26 ++++---- .../plot/titles/DefaultTitleManager_183.java | 34 +++++------ .../plot/titles/HackTitleManager.java | 60 ++++++++----------- 4 files changed, 54 insertions(+), 70 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index ab2ca1d87..a0b2dbd92 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,11 +8,11 @@ UTF-8 PlotSquared - 2.8.10.0 + 2.8.11 PlotSquared jar - PlotSquared-${project.version} + PlotSquared src/main/java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java index 6902460b4..789d03d74 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager.java @@ -273,9 +273,10 @@ public class DefaultTitleManager { * * @param player * Player + * @throws IllegalAccessException + * @throws IllegalArgumentException */ - public void clearTitle(final Player player) { - try { + public void clearTitle(final Player player) throws Exception { // Send timings first final Object handle = getHandle(player); final Object connection = getField(handle.getClass(), "playerConnection").get(handle); @@ -283,9 +284,6 @@ public class DefaultTitleManager { final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null); sendPacket.invoke(connection, packet); - } catch (final Exception e) { - e.printStackTrace(); - } } /** @@ -294,18 +292,14 @@ public class DefaultTitleManager { * @param player * Player */ - public void resetTitle(final Player player) { - try { + public void resetTitle(final Player player) throws Exception { // Send timings first - final Object handle = getHandle(player); - final Object connection = getField(handle.getClass(), "playerConnection").get(handle); - final Object[] actions = this.packetActions.getEnumConstants(); - final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null); - sendPacket.invoke(connection, packet); - } catch (final Exception e) { - e.printStackTrace(); - } + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null); + sendPacket.invoke(connection, packet); } private Class getPrimitiveType(final Class clazz) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java index cb175c28a..4e8ff569c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/DefaultTitleManager_183.java @@ -274,9 +274,10 @@ public class DefaultTitleManager_183 { * * @param player * Player + * @throws IllegalAccessException + * @throws IllegalArgumentException */ - public void clearTitle(final Player player) { - try { + public void clearTitle(final Player player) throws Exception { // Send timings first final Object handle = getHandle(player); final Object connection = getField(handle.getClass(), "playerConnection").get(handle); @@ -284,9 +285,6 @@ public class DefaultTitleManager_183 { final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null); sendPacket.invoke(connection, packet); - } catch (final Exception e) { - e.printStackTrace(); - } } /** @@ -294,19 +292,21 @@ public class DefaultTitleManager_183 { * * @param player * Player + * @throws SecurityException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws InstantiationException */ - public void resetTitle(final Player player) { - try { - // Send timings first - final Object handle = getHandle(player); - final Object connection = getField(handle.getClass(), "playerConnection").get(handle); - final Object[] actions = this.packetActions.getEnumConstants(); - final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null); - sendPacket.invoke(connection, packet); - } catch (final Exception e) { - e.printStackTrace(); - } + public void resetTitle(final Player player) throws Exception { + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null); + sendPacket.invoke(connection, packet); } private Class getPrimitiveType(final Class clazz) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java index f5d015b83..52034bfa5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.titles; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -265,20 +266,17 @@ public class HackTitleManager { * * @param player * Player + * @throws Exception */ - public void clearTitle(final Player player) { + public void clearTitle(final Player player) throws Exception { if ((getProtocolVersion(player) >= 47) && isSpigot()) { - try { - // Send timings first - final Object handle = getHandle(player); - final Object connection = getField(handle.getClass(), "playerConnection").get(handle); - final Object[] actions = this.packetActions.getEnumConstants(); - final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]); - sendPacket.invoke(connection, packet); - } catch (final Exception e) { - e.printStackTrace(); - } + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]); + sendPacket.invoke(connection, packet); } } @@ -287,20 +285,17 @@ public class HackTitleManager { * * @param player * Player + * @throws Exception */ - public void resetTitle(final Player player) { + public void resetTitle(final Player player) throws Exception { if ((getProtocolVersion(player) >= 47) && isSpigot()) { - try { - // Send timings first - final Object handle = getHandle(player); - final Object connection = getField(handle.getClass(), "playerConnection").get(handle); - final Object[] actions = this.packetActions.getEnumConstants(); - final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); - final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]); - sendPacket.invoke(connection, packet); - } catch (final Exception e) { - e.printStackTrace(); - } + // Send timings first + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object[] actions = this.packetActions.getEnumConstants(); + final Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + final Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]); + sendPacket.invoke(connection, packet); } } @@ -310,18 +305,13 @@ public class HackTitleManager { * @param player * Player * @return Protocol version + * @throws Exception */ - private int getProtocolVersion(final Player player) { - int version = 0; - try { - final Object handle = getHandle(player); - final Object connection = getField(handle.getClass(), "playerConnection").get(handle); - final Object networkManager = getValue("networkManager", connection); - version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager); - return version; - } catch (final Exception ex) { - ex.printStackTrace(); - } + private int getProtocolVersion(final Player player) throws Exception { + final Object handle = getHandle(player); + final Object connection = getField(handle.getClass(), "playerConnection").get(handle); + final Object networkManager = getValue("networkManager", connection); + Integer version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager); return version; } From d23bfa0bde7098177f13e015f4b0e17d4906d207 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 13:38:23 +1100 Subject: [PATCH 038/223] test without javadoc plugin --- PlotSquared/pom.xml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index a0b2dbd92..b9994bcc7 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -36,16 +36,7 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.1 - - public - false - -Xdoclint:none - - + maven-compiler-plugin 2.3.2 From 7878d0b52531275828df07b11329cedb15888381 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 14:21:50 +1100 Subject: [PATCH 039/223] Fixed plot copy and move arguments --- .../plot/commands/Copy.java | 82 +++++++++++++++++++ .../plot/commands/MainCommand.java | 2 +- .../plot/commands/Move.java | 3 +- .../intellectualcrafters/plot/config/C.java | 1 + .../plot/util/MainUtil.java | 56 +++++++++++++ 5 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java new file mode 100644 index 000000000..ba31cfc75 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -0,0 +1,82 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; + +/** + * Created 2014-08-01 for PlotSquared + * + * @author Empire92 + */ +public class Copy extends SubCommand { + public Copy() { + super("copy", "plots.copy", "Copy a plot", "copypaste", "", CommandCategory.ACTIONS, true); + } + + @Override + public boolean execute(final PlotPlayer plr, final String... args) { + if (args.length < 1) { + MainUtil.sendMessage(plr, C.NEED_PLOT_ID); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy "); + return false; + } + final Location loc = plr.getLocation(); + final Plot plot1 = MainUtil.getPlot(loc); + if (plot1 == null) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } + if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN)) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); + return false; + } + final String world = loc.getWorld(); + final PlotId plot2 = MainUtil.parseId(args[0]); + if ((plot2 == null)) { + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy "); + return false; + } + if (plot1.id.equals(plot2)) { + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy "); + return false; + } + if (MainUtil.copy(world, plot1.id, plot2, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(plr, C.COPY_SUCCESS); + MainUtil.update(plr.getLocation()); + } + })) { + return true; + } else { + MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED); + return false; + } + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index e5aa7240a..9b8b18724 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -40,7 +40,7 @@ public class MainCommand { /** * Main Permission Node */ - private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm() }; + private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm(), new Copy() }; public final static ArrayList subCommands = new ArrayList() { { addAll(Arrays.asList(_subCommands)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index e71443ea6..0d50acb03 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -55,7 +55,7 @@ public class Move extends SubCommand { return false; } final String world = loc.getWorld(); - final PlotId plot2 = MainUtil.parseId(args[1]); + final PlotId plot2 = MainUtil.parseId(args[0]); if ((plot2 == null)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); @@ -70,6 +70,7 @@ public class Move extends SubCommand { @Override public void run() { MainUtil.sendMessage(plr, C.MOVE_SUCCESS); + MainUtil.update(plr.getLocation()); } })) { return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index f32d3e76d..1e5ab4541 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -44,6 +44,7 @@ public enum C { * Move */ MOVE_SUCCESS("$4Successfully moved plot."), + COPY_SUCCESS("$4Successfully copied plot."), REQUIRES_UNOWNED("$2The location specified is already occupied."), /* * Compass diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index b4607df24..fd130fbdd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.UUID; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.commands.Claim; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -819,6 +820,61 @@ public class MainUtil { }); return true; } + + public static boolean copy(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { + final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current); + final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); + final Location top = MainUtil.getPlotTopLoc(world, current); + final Plot currentPlot = MainUtil.getPlot(world, current); + if (currentPlot.owner == null) { + TaskManager.runTaskLater(whenDone, 1); + return false; + } + final Plot pos1 = getBottomPlot(currentPlot); + final Plot pos2 = getTopPlot(currentPlot); + final PlotId size = MainUtil.getSize(world, currentPlot); + if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { + TaskManager.runTaskLater(whenDone, 1); + return false; + } + final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); + final int offset_x = newPlot.x - pos1.id.x; + final int offset_y = newPlot.y - pos1.id.y; + for (final PlotId id : selection) { + int x = id.x + offset_x; + int y = id.y + offset_y; + Plot plot = createPlotAbs(currentPlot.owner, getPlot(world, new PlotId(x, y))); + if (currentPlot.settings.flags != null && currentPlot.settings.flags.size() > 0) { + plot.settings.flags = currentPlot.settings.flags; + DBFunc.setFlags(world, plot, currentPlot.settings.flags); + } + if (currentPlot.settings.isMerged()) { + plot.settings.setMerged(currentPlot.settings.getMerged()); + DBFunc.setMerged(world, plot, currentPlot.settings.getMerged()); + } + if (currentPlot.trusted != null && currentPlot.trusted.size() > 0) { + plot.trusted = currentPlot.trusted; + for (UUID trusted : plot.trusted) { + DBFunc.setTrusted(world, plot, trusted); + } + } + if (currentPlot.helpers != null && currentPlot.helpers.size() > 0) { + plot.trusted = currentPlot.helpers; + for (UUID helpers : plot.helpers) { + DBFunc.setHelper(world, plot, helpers); + } + } + if (currentPlot.denied != null && currentPlot.denied.size() > 0) { + plot.trusted = currentPlot.denied; + for (UUID denied : plot.denied) { + DBFunc.setDenied(world, plot, denied); + } + } + PlotSquared.getPlots(world).put(plot.id, plot); + } + ChunkManager.manager.copyRegion(bot1, top, bot2, whenDone); + return true; + } /** * Send a message to the player From 2634853050181581fe423439a29f435e0a24c9c9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 14:35:03 +1100 Subject: [PATCH 040/223] Revert "test without javadoc plugin" This reverts commit d23bfa0bde7098177f13e015f4b0e17d4906d207. --- PlotSquared/pom.xml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index b9994bcc7..a0b2dbd92 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -36,7 +36,16 @@ - + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.1 + + public + false + -Xdoclint:none + + maven-compiler-plugin 2.3.2 From 271cc026d450b33cce07b19ba164b08e6601ae60 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 15 Mar 2015 21:40:55 +1100 Subject: [PATCH 041/223] Fixed piston retract (finally) --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9f2b355da..561707039 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -546,7 +546,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null) { - Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(block.getRelative(event.getDirection()).getRelative(event.getDirection()).getLocation())); + BlockFace dir = event.getDirection(); + Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); Plot newPlot = MainUtil.getPlot(bloc); if (!plot.equals(newPlot)) { event.setCancelled(true); From 20d64508a59cccd2fff7934e1f84e3a264e3fe7d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 19:17:15 +1100 Subject: [PATCH 042/223] More piston fixes, potential chunk send fix, home teleport fix --- .../plot/listeners/PlayerEvents.java | 5 +++- .../plot/util/MainUtil.java | 25 +++++++++++++++---- .../plot/util/bukkit/BukkitChunkManager.java | 2 +- .../plot/util/bukkit/BukkitUtil.java | 2 +- .../plot/util/bukkit/SetBlockFast.java | 4 +-- .../plot/util/bukkit/SetBlockFast_1_8.java | 4 +-- 6 files changed, 30 insertions(+), 12 deletions(-) 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 561707039..d19e50aea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -62,6 +62,7 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; @@ -522,8 +523,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null) { + BlockFace face = event.getDirection(); + Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); for (final Block b : event.getBlocks()) { - Location bloc = BukkitUtil.getLocation(b.getLocation()); + Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative)); Plot newPlot = MainUtil.getPlot(bloc); if (!plot.equals(newPlot)) { event.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index fd130fbdd..3a3b92e32 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -95,18 +95,33 @@ public class MainUtil { } return count; } + + public static Location getPlotFront(Plot plot) { + final Location top = getPlotTopLoc(plot.world, plot.id); + final Location bot = getPlotBottomLoc(plot.world, plot.id); + final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); + final int z = 0; + PlotManager manager = PlotSquared.getPlotManager(plot.world); + final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY()); + return new Location(plot.world, x, y, z); + } public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) { final Plot bot = MainUtil.getBottomPlot(plot); // TODO // boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); - - final boolean result = false; + boolean result = EventUtil.manager.callTeleport(player, from, plot); // TOOD ^ remove that - if (!result) { - final Location location = MainUtil.getPlotHome(bot.world, bot); + if (result) { + final Location location; + if (plot.isAdded(player.getUUID())) { + location = MainUtil.getPlotHome(bot.world, bot); + } + else { + location = getPlotFront(plot); + } if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { sendMessage(player, C.TELEPORTED_TO_PLOT); player.teleport(location); @@ -132,7 +147,7 @@ public class MainUtil { }, Settings.TELEPORT_DELAY * 20); return true; } - return !result; + return result; } public static int getBorder(final String worldname) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index f96679c86..7dde64ef3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -765,7 +765,7 @@ public class BukkitChunkManager extends ChunkManager { if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - MainUtil.teleportPlayer(BukkitUtil.getPlayer(player), BukkitUtil.getLocation(entity), plot); + BukkitUtil.getPlayer(player).teleport(MainUtil.getPlotFront(plot)); PlotListener.plotExit(player, plot); } else { entity.remove(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 3b8f20348..b76150681 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -147,7 +147,7 @@ public class BukkitUtil extends BlockManager { public static void refreshChunk(final String name, final int x, final int z) { World world = getWorld(name); - world.unloadChunk(x, z); + world.refreshChunk(x, z); world.loadChunk(x, z); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index ddca18980..d149ce32b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -90,8 +90,8 @@ public class SetBlockFast extends BukkitSetBlockManager { if (!MainUtil.canSendChunk) { final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.unloadChunk(chunk); - world.loadChunk(chunk); + world.refreshChunk(chunk.getX(), chunk.getZ()); + chunk.load(false); } return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 2d86c5cb0..8f871a61b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -294,8 +294,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { if (!MainUtil.canSendChunk) { final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.unloadChunk(chunk); - world.loadChunk(chunk); + world.refreshChunk(chunk.getX(), chunk.getZ()); + chunk.load(false); } return; } From 10ad9261b10cee37290ba3d9421b4a0152cfd2a4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 19:32:21 +1100 Subject: [PATCH 043/223] optional debugclear/fastclear for classic plot worlds --- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 2 ++ .../java/com/intellectualcrafters/plot/config/Settings.java | 1 + .../main/java/com/intellectualcrafters/plot/util/MainUtil.java | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 3bcb1324a..d131f48dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -765,6 +765,7 @@ public class PlotSquared { options.put("clusters.enabled", Settings.ENABLE_CLUSTERS); + options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); options.put("plotme-alias", Settings.USE_PLOTME_ALIAS); options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME); options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); @@ -802,6 +803,7 @@ public class PlotSquared { Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete"); Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink"); + Settings.FAST_CLEAR = config.getBoolean("clear.fastmode"); Settings.TELEPORT_DELAY = config.getInt("teleport.delay"); Settings.CONSOLE_COLOR = config.getBoolean("console.color"); 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 10f253877..6b62fdb4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -28,6 +28,7 @@ package com.intellectualcrafters.plot.config; */ public class Settings { public static boolean ENABLE_CLUSTERS = false; + public static boolean FAST_CLEAR = false; /** * Default UUID_FECTHING: false */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 3a3b92e32..1b559ee18 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -527,7 +527,7 @@ public class MainUtil { final Location location = MainUtil.getPlotHomeDefault(plot); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); runners.put(plot, 1); - if (plotworld.TERRAIN != 0) { + if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override From b06999f2beeb9f1a1f80eaec888c6fdb6b90e75a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 19:38:06 +1100 Subject: [PATCH 044/223] javadoc --- PlotSquared/pom.xml | 11 +---------- .../com/intellectualcrafters/plot/BukkitMain.java | 3 +++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index a0b2dbd92..ff6f30347 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -36,16 +36,7 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.1 - - public - false - -Xdoclint:none - - + maven-compiler-plugin 2.3.2 diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index afd1418e4..470e75d3b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -112,6 +112,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void log(String message) { + if (message == null) { + return; + } message = message.replaceAll("\u00B2", "2"); if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) { System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message))); From cdd6eb9c44251ff49d1dea304f5edeb10a3a6495 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 20:42:16 +1100 Subject: [PATCH 045/223] Fix home location --- .../main/java/com/intellectualcrafters/plot/util/MainUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 1b559ee18..d60667641 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -100,7 +100,7 @@ public class MainUtil { final Location top = getPlotTopLoc(plot.world, plot.id); final Location bot = getPlotBottomLoc(plot.world, plot.id); final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); - final int z = 0; + final int z = bot.getZ(); PlotManager manager = PlotSquared.getPlotManager(plot.world); final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY()); return new Location(plot.world, x, y, z); From e1b3966204edc7382f1221bf263b4df9a42fa097 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 22:20:18 +1100 Subject: [PATCH 046/223] projectile protection --- .../plot/listeners/PlayerEvents.java | 110 ++++++++++++++++-- 1 file changed, 98 insertions(+), 12 deletions(-) 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 d19e50aea..87c0af62d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -14,14 +14,21 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.block.Dispenser; import org.bukkit.entity.Animals; import org.bukkit.entity.Arrow; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; +import org.bukkit.entity.Fireball; import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.SmallFireball; import org.bukkit.entity.Tameable; +import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.minecart.RideableMinecart; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -43,6 +50,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.inventory.InventoryClickEvent; @@ -62,6 +70,10 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.plugin.Plugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.projectiles.BlockProjectileSource; +import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; import com.intellectualcrafters.plot.PlotSquared; @@ -95,6 +107,48 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; */ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { + @EventHandler + public void onProjectileHit(ProjectileHitEvent event) { + Projectile entity = (Projectile) event.getEntity(); + Location loc = BukkitUtil.getLocation(entity); + if (!isPlotWorld(loc.getWorld())) { + return; + } + Plot plot = MainUtil.getPlot(loc); + if (!isPlotArea(loc)) { + return; + } + ProjectileSource shooter = entity.getShooter(); + if (shooter instanceof BlockProjectileSource) { + if (plot == null) { + entity.remove(); + return; + } + Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation()); + Plot sPlot = MainUtil.getPlot(sLoc); + if (sPlot == null || sPlot.owner.equals(plot.owner)) { + entity.remove(); + return; + } + } + if (!(shooter instanceof Player)) { + PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); + if (plot == null) { + if (!pp.hasPermission("plots.projectile.unowned")) { + entity.remove(); + } + return; + } + if (plot.isAdded(pp.getUUID())) { + return; + } + if (pp.hasPermission("plots.projectile.other")) { + return; + } + entity.remove(); + } + } + @EventHandler public void PlayerCommand(final PlayerCommandPreprocessEvent event) { final String message = event.getMessage(); @@ -1038,21 +1092,52 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { final Location l = BukkitUtil.getLocation(e.getEntity()); - final Entity d = e.getDamager(); - final Entity a = e.getEntity(); - if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0) && (a instanceof Player)) { - final Player player = (Player) a; + final Entity damager = e.getDamager(); + final Entity victim = e.getEntity(); + if ((Settings.TELEPORT_DELAY != 0) && (TaskManager.TELEPORT_QUEUE.size() > 0) && (victim instanceof Player)) { + final Player player = (Player) victim; final String name = player.getName(); if (TaskManager.TELEPORT_QUEUE.contains(name)) { TaskManager.TELEPORT_QUEUE.remove(name); } } if (isPlotWorld(l)) { - if (d instanceof Player) { - final Player p = (Player) d; - final boolean aPlr = a instanceof Player; + Player p = null; + if (damager instanceof Player) { + p = (Player) damager; + } + else if (damager instanceof Projectile) { + //Arrow, Egg, EnderPearl, Fireball, Fish, FishHook, LargeFireball, SmallFireball, Snowball, ThrownExpBottle, ThrownPotion, WitherSkull + if (damager instanceof Arrow || damager instanceof LargeFireball || damager instanceof Fireball || damager instanceof SmallFireball) { + ProjectileSource shooter = ((Projectile) damager).getShooter(); + if (shooter == null || !(shooter instanceof Player)) { + return; + } + p = (Player) shooter; + } + else if (damager instanceof ThrownPotion) { + ThrownPotion potion = (ThrownPotion) damager; + Collection effects = potion.getEffects(); + for (PotionEffect effect : effects) { + PotionEffectType type = effect.getType(); + if (type == PotionEffectType.BLINDNESS || type == PotionEffectType.CONFUSION || type == PotionEffectType.HARM || type == PotionEffectType.POISON || type == PotionEffectType.SLOW || type == PotionEffectType.SLOW_DIGGING || type == PotionEffectType.WEAKNESS || type == PotionEffectType.WITHER) { + ProjectileSource shooter = ((Projectile) damager).getShooter(); + if (shooter == null || !(shooter instanceof Player)) { + return; + } + p = (Player) shooter; + break; + } + } + } + else { + return; + } + } + if (p != null) { + final boolean aPlr = victim instanceof Player; final PlotWorld pW = PlotSquared.getPlotWorld(l.getWorld()); - if (!aPlr && pW.PVE && (!(a instanceof ItemFrame) && !(a.getType().getTypeId() == 30))) { + if (!aPlr && pW.PVE && (!(victim instanceof ItemFrame) && !(victim.getType().getTypeId() == 30))) { return; } else if (aPlr && pW.PVP) { return; @@ -1082,13 +1167,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi assert plot != null; final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!plot.isAdded(pp.getUUID())) { - if ((a instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { + if ((victim instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-attack")) { return; } - if ((a instanceof Animals) && FlagManager.isPlotFlagTrue(plot, "animal-attack")) { + if ((victim instanceof Animals) && FlagManager.isPlotFlagTrue(plot, "animal-attack")) { return; } - if ((a instanceof Tameable) && ((Tameable) a).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { + if ((victim instanceof Tameable) && ((Tameable) victim).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-attack")) { return; } if (!Permissions.hasPermission(pp, "plots.admin.pve.other")) { @@ -1100,8 +1185,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } + return; } - if ((d instanceof Arrow) && isPlotArea(l) && (!(a instanceof Creature))) { + if ((damager instanceof Arrow) && isPlotArea(l) && (!(victim instanceof Creature))) { e.setCancelled(true); } } From d43cff88db6a20dbf5efc8af0f4c902a014643c4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 22:34:53 +1100 Subject: [PATCH 047/223] Remove arrow on cancel --- PlotSquared/pom.xml | 1 - .../plot/listeners/PlayerEvents.java | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index ff6f30347..b2d836294 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -36,7 +36,6 @@ - maven-compiler-plugin 2.3.2 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 87c0af62d..71595bf27 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -14,7 +14,6 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; -import org.bukkit.block.Dispenser; import org.bukkit.entity.Animals; import org.bukkit.entity.Arrow; import org.bukkit.entity.Creature; @@ -22,7 +21,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Fireball; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LargeFireball; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -1103,13 +1101,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (isPlotWorld(l)) { Player p = null; + Projectile projectile = null; if (damager instanceof Player) { p = (Player) damager; } else if (damager instanceof Projectile) { + projectile = (Projectile) damager; //Arrow, Egg, EnderPearl, Fireball, Fish, FishHook, LargeFireball, SmallFireball, Snowball, ThrownExpBottle, ThrownPotion, WitherSkull if (damager instanceof Arrow || damager instanceof LargeFireball || damager instanceof Fireball || damager instanceof SmallFireball) { - ProjectileSource shooter = ((Projectile) damager).getShooter(); + ProjectileSource shooter = projectile.getShooter(); if (shooter == null || !(shooter instanceof Player)) { return; } @@ -1155,6 +1155,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.pve.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.unowned"); + if (projectile != null) { + projectile.remove(); + } e.setCancelled(true); return; } @@ -1179,6 +1182,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!Permissions.hasPermission(pp, "plots.admin.pve.other")) { if (isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.other"); + if (projectile != null) { + projectile.remove(); + } e.setCancelled(true); return; } From 4d7cc990e2ba79f5b71bbe1eaa001944ba824ce1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 17 Mar 2015 22:43:06 +1100 Subject: [PATCH 048/223] Invisibility could also be considered "annoying" --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 4 ++-- .../com/intellectualcrafters/plot/object/BukkitPlayer.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) 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 71595bf27..16b19330a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -129,7 +129,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - if (!(shooter instanceof Player)) { + else if ((shooter instanceof Player)) { PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); if (plot == null) { if (!pp.hasPermission("plots.projectile.unowned")) { @@ -1120,7 +1120,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi Collection effects = potion.getEffects(); for (PotionEffect effect : effects) { PotionEffectType type = effect.getType(); - if (type == PotionEffectType.BLINDNESS || type == PotionEffectType.CONFUSION || type == PotionEffectType.HARM || type == PotionEffectType.POISON || type == PotionEffectType.SLOW || type == PotionEffectType.SLOW_DIGGING || type == PotionEffectType.WEAKNESS || type == PotionEffectType.WITHER) { + if (type == PotionEffectType.BLINDNESS || type == PotionEffectType.CONFUSION || type == PotionEffectType.HARM || type == PotionEffectType.INVISIBILITY || type == PotionEffectType.POISON || type == PotionEffectType.SLOW || type == PotionEffectType.SLOW_DIGGING || type == PotionEffectType.WEAKNESS || type == PotionEffectType.WITHER) { ProjectileSource shooter = ((Projectile) damager).getShooter(); if (shooter == null || !(shooter instanceof Player)) { return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index dc7c85592..5cc267c79 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -23,6 +23,9 @@ public class BukkitPlayer implements PlotPlayer { * @param player */ public BukkitPlayer(final Player player) { + if (player == null) { + System.out.print("=================== NULL PLAYER ========================="); + } this.player = player; } From fd39eb036d910cf1223be3ef1a677385739f7597 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 18 Mar 2015 16:50:07 +1100 Subject: [PATCH 049/223] Should fix #209 --- .../java/com/intellectualcrafters/plot/BukkitMain.java | 1 + .../plot/generator/AugmentedPopulator.java | 8 +++++++- .../java/com/intellectualcrafters/plot/util/MainUtil.java | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 470e75d3b..c9ca0e064 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -272,6 +272,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { try { BukkitSetBlockManager.setBlockManager = new SetBlockFast(); } catch (final Throwable e) { + MainUtil.canSetFast = false; BukkitSetBlockManager.setBlockManager = new SetBlockSlow(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index b43c12f79..b050e8a7b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -19,7 +19,9 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.BlockUpdateUtil; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; @@ -187,7 +189,11 @@ public class AugmentedPopulator extends BlockPopulator { } } for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { - populator.populate(world, this.r, world.getChunkAt(X, Z)); + Chunk chunk = world.getChunkAt(X, Z); + if (MainUtil.canSetFast) { + ((BukkitSetBlockManager) BlockUpdateUtil.setBlockManager).update(Arrays.asList(chunk)); + } + populator.populate(world, this.r, chunk); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index d60667641..98b3a6dda 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -51,6 +51,7 @@ import com.intellectualcrafters.plot.util.bukkit.SendChunk; public class MainUtil { public final static HashMap runners = new HashMap<>(); public static boolean canSendChunk = false; + public static boolean canSetFast = true; public static ArrayList runners_p = new ArrayList<>(); static long state = 1; public static HashMap lastPlot = new HashMap<>(); From 5be83cd780f4c23491d137fa08faa014ca0fb05d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 18 Mar 2015 22:56:07 +1100 Subject: [PATCH 050/223] fixes #202 --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 3 +++ 1 file changed, 3 insertions(+) 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 16b19330a..d25146048 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -791,6 +791,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Plot plot = getCurrentPlot(q); final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.isDenied(pp.getUUID())) { + if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) { + return; + } MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); event.setCancelled(true); return; From 8bd47b5e84fc443464453ad8925523f079a290db Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 18 Mar 2015 23:19:17 +1100 Subject: [PATCH 051/223] Fixes #205 --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d25146048..bf3f65ba0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -693,7 +693,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final PlotWorld pW = PlotSquared.getPlotWorld(world); final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); - if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) && !pW.SPAWN_EGGS) { + if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG || reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) && !pW.SPAWN_EGGS) { event.setCancelled(true); return; } else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !pW.SPAWN_BREEDING) { From 657c1a1d5416afc5284e168ed4547abc60b81d7c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Mar 2015 23:07:57 +1100 Subject: [PATCH 052/223] Fixes #211 --- .../plot/generator/ClassicPlotManager.java | 1 + .../main/java/com/intellectualcrafters/plot/util/MainUtil.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index 56dec6691..a15bad233 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -309,6 +309,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { if (!claim.equals(unclaim)) { setWall(plotworld, plot.id, new PlotBlock[] { unclaim }); } + MainUtil.removeSign(plot); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 98b3a6dda..c765a8af0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -337,6 +337,9 @@ public class MainUtil { final String world = p.world; final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + if (!plotworld.ALLOW_SIGNS) { + return; + } final Location loc = manager.getSignLoc(plotworld, p); BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 }); } From bdbebfa29dc7e8c674b9939a25ae8d19b1509fd9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Mar 2015 13:13:27 +1100 Subject: [PATCH 053/223] [IN PROGRESS] multi-owner mega plots --- .../plot/PlotSquared.java | 5 +- .../plot/api/PlotAPI.java | 2 +- .../plot/commands/Auto.java | 4 +- .../plot/commands/Buy.java | 16 ++-- .../plot/commands/Confirm.java | 2 +- .../plot/commands/Merge.java | 80 ++++++++++++++++--- .../intellectualcrafters/plot/config/C.java | 3 + .../plot/database/SQLManager.java | 8 +- .../plot/listeners/PlayerEvents.java | 3 +- .../plot/listeners/PlotListener.java | 2 +- .../plot/listeners/PlotPlusListener.java | 59 +++++++------- .../plot/listeners/WorldEditListener.java | 27 ++++--- .../plot/object/InfoInventory.java | 4 +- .../plot/object/Plot.java | 42 ++++++---- .../plot/object/PlotHandler.java | 76 ++++++++++++++++++ .../plot/util/ExpireManager.java | 25 +++--- .../plot/util/MainUtil.java | 18 ++--- .../plot/util/bukkit/BukkitChunkManager.java | 4 +- .../plot/util/bukkit/PWE.java | 3 +- 19 files changed, 283 insertions(+), 100 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index d131f48dd..e7d97e31b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -52,6 +52,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -206,7 +207,7 @@ public class PlotSquared { final ArrayList myplots = new ArrayList<>(); for (final Plot plot : getPlots(world).values()) { if (plot.hasOwner()) { - if (plot.getOwner().equals(uuid)) { + if (PlotHandler.isOwner(plot, uuid)) { myplots.add(plot); } } @@ -247,7 +248,7 @@ public class PlotSquared { if (isPlotWorld(world)) { for (final Plot plot : plots.get(world).values()) { if (plot.hasOwner()) { - if (plot.getOwner().equals(uuid)) { + if (PlotHandler.isOwner(plot, uuid)) { myplots.add(plot); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index f49f80a5f..fd1f29417 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -474,7 +474,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; final ArrayList pPlots = new ArrayList<>(); for (final Plot plot : PlotSquared.getPlots(world.getName()).values()) { if (just_owner) { - if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) { + if ((plot.owner_ != null) && (plot.owner_ == UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) { pPlots.add(plot); } } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index ef40badde..d121fec4f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -193,7 +193,7 @@ public class Auto extends SubCommand { if ((size_x == 1) && (size_z == 1)) { while (!br) { final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname)); - if ((plot.owner == null)) { + if ((plot.owner_ == null)) { Claim.claimPlot(plr, plot, true, true); br = true; } @@ -207,7 +207,7 @@ public class Auto extends SubCommand { MainUtil.lastPlot.put(worldname, start); if (lastPlot) { } - if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) { + if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner_ != null)) { continue; } else { lastPlot = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 256a152bf..91ba1901e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -27,6 +27,7 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; @@ -74,7 +75,7 @@ public class Buy extends SubCommand { if (!plot.hasOwner()) { return sendMessage(plr, C.PLOT_UNOWNED); } - if (plot.owner.equals(plr.getUUID())) { + if (PlotHandler.isOwner(plot, plr.getUUID())) { return sendMessage(plr, C.CANNOT_BUY_OWN); } final Flag flag = FlagManager.getPlotFlag(plot, "price"); @@ -97,15 +98,20 @@ public class Buy extends SubCommand { } EconHandler.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); - EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); - final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); + EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner_), initPrice); + final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner_); if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } FlagManager.removePlotFlag(plot, "price"); } - plot.owner = plr.getUUID(); - DBFunc.setOwner(plot, plot.owner); + Plot top = MainUtil.getTopPlot(plot); + + for (PlotId myId : MainUtil.getPlotSelectionIds(plot.id, top.id)) { + Plot myPlot = MainUtil.getPlot(plot.world, myId); + myPlot.owner_ = plr.getUUID(); + DBFunc.setOwner(plot, myPlot.owner_); + } MainUtil.sendMessage(plr, C.CLAIMED); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java index 7ac04b8b8..90d0badaf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java @@ -44,7 +44,7 @@ public class Confirm extends SubCommand { return false; } CmdConfirm.removePending(plr); - if (System.currentTimeMillis() - command.timestamp > 10000) { + if (System.currentTimeMillis() - command.timestamp > 20000) { MainUtil.sendMessage(plr, C.FAILED_CONFIRM); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 8af139d56..f8dbdf2a7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -21,6 +21,8 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import java.util.HashSet; +import java.util.UUID; import org.apache.commons.lang.StringUtils; @@ -31,6 +33,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; @@ -105,39 +108,96 @@ public class Merge extends SubCommand { } PlotId bot = MainUtil.getBottomPlot(plot).id; PlotId top = MainUtil.getTopPlot(plot).id; - ArrayList plots; + ArrayList selPlots; final String world = loc.getWorld(); switch (direction) { case 0: // north = -y - plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); + selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); break; case 1: // east = +x - plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); + selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); break; case 2: // south = +y - plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); + selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); break; case 3: // west = -x - plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); + selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); break; default: return false; } - final PlotId botId = plots.get(0); - final PlotId topId = plots.get(plots.size() - 1); + final PlotId botId = selPlots.get(0); + final PlotId topId = selPlots.get(selPlots.size() - 1); final PlotId bot1 = MainUtil.getBottomPlot(MainUtil.getPlot(world, botId)).id; final PlotId bot2 = MainUtil.getBottomPlot(MainUtil.getPlot(world, topId)).id; final PlotId top1 = MainUtil.getTopPlot(MainUtil.getPlot(world, topId)).id; final PlotId top2 = MainUtil.getTopPlot(MainUtil.getPlot(world, botId)).id; bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y)); top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y)); - plots = MainUtil.getMaxPlotSelectionIds(world, bot, top); + final ArrayList plots = MainUtil.getMaxPlotSelectionIds(world, bot, top); + boolean multiMerge = false; + final HashSet multiUUID = new HashSet(); + HashSet multiPlots = new HashSet<>(); + final UUID u1 = plot.getOwner(); for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) { + UUID u2 = myplot.getOwner(); + if (myplot == null || u2 == null) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } + if (u2.equals(u1)) { + continue; + } + PlotPlayer p2 = UUIDHandler.getPlayer(u2); + if (p2 == null) { + MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); + return false; + } + multiMerge = true; + multiPlots.add(myid); + } + if (multiMerge) { + for (final UUID uuid : multiUUID) { + CmdConfirm.addPending(UUIDHandler.getPlayer(uuid), "merge request", new Runnable() { + @Override + public void run() { + PlotPlayer accepter = UUIDHandler.getPlayer(uuid); + multiUUID.remove(uuid); + if (multiUUID.size() == 0) { + PlotPlayer pp = UUIDHandler.getPlayer(u1); + if (pp == null) { + sendMessage(plr, C.MERGE_NOT_VALID); + return; + } + final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); + if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) { + double cost = plotWorld.MERGE_PRICE; + cost = plots.size() * cost; + if (cost > 0d) { + if (EconHandler.getBalance(plr) < cost) { + sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + ""); + return; + } + EconHandler.withdrawPlayer(plr, cost); + sendMessage(plr, C.REMOVED_BALANCE, cost + ""); + } + } + final boolean result = EventUtil.manager.callMerge(world, plot, plots); + if (!result) { + MainUtil.sendMessage(plr, "&cMerge has been cancelled"); + return; + } + MainUtil.sendMessage(plr, C.SUCCESS_MERGE); + MainUtil.mergePlots(world, plots, true); + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.update(loc); + } + MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); + } + }); + } + return true; } final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) { @@ -157,7 +217,7 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, "&cMerge has been cancelled"); return false; } - MainUtil.sendMessage(plr, "&cPlots have been merged"); + MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.update(loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 1e5ab4541..dc7a5b53d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -216,6 +216,9 @@ public enum C { UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"), UNLINK_SUCCESS("$2Successfully unlinked plots."), NO_MERGE_TO_MEGA("$2Mega plots cannot be merged into. Please merge from the desired mega plot."), + MERGE_NOT_VALID("$2This merge request is no longer valid."), + MERGE_ACCEPTED("$2The merge request has been accepted"), + SUCCESS_MERGE("$2Plots have been merged!"), /* * Commands */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 9a2ae8931..11a1835f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -263,7 +263,7 @@ public class SQLManager implements AbstractDB { stmt.setInt((i * 4) + 1, plot.id.x); stmt.setInt((i * 4) + 2, plot.id.y); try { - stmt.setString((i * 4) + 3, plot.owner.toString()); + stmt.setString((i * 4) + 3, plot.owner_.toString()); } catch (final Exception e) { stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); } @@ -299,7 +299,7 @@ public class SQLManager implements AbstractDB { stmt.setInt((i * 6) + 2, plot.id.x); stmt.setInt((i * 6) + 3, plot.id.y); try { - stmt.setString((i * 6) + 4, plot.owner.toString()); + stmt.setString((i * 6) + 4, plot.owner_.toString()); } catch (final Exception e1) { stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); } @@ -344,7 +344,7 @@ public class SQLManager implements AbstractDB { stmt = SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT); stmt.setInt(1, plot.id.x); stmt.setInt(2, plot.id.y); - stmt.setString(3, plot.owner.toString()); + stmt.setString(3, plot.owner_.toString()); stmt.setString(4, plot.world); stmt.executeUpdate(); stmt.close(); @@ -366,7 +366,7 @@ public class SQLManager implements AbstractDB { stmt = SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT); stmt.setInt(1, plot.id.x); stmt.setInt(2, plot.id.y); - stmt.setString(3, plot.owner.toString()); + stmt.setString(3, plot.owner_.toString()); stmt.setString(4, plot.world); stmt.executeUpdate(); stmt.close(); 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 bf3f65ba0..fa11227bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -84,6 +84,7 @@ import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -124,7 +125,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation()); Plot sPlot = MainUtil.getPlot(sLoc); - if (sPlot == null || sPlot.owner.equals(plot.owner)) { + if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) { entity.remove(); return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 549fed1e5..909da03bd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -180,7 +180,7 @@ public class PlotListener { } if ((booleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + ""); - final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); + final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner_)); if (AbstractTitle.TITLE_CLASS != null) { AbstractTitle.TITLE_CLASS.sendTitle(player, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 7c17764c8..8bec3842c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -64,7 +65,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; * * @author Citymonstret */ -@SuppressWarnings({ "deprecation", "unused" }) +@SuppressWarnings({ "deprecation"}) public class PlotPlusListener extends PlotListener implements Listener { private final static HashMap feedRunnable = new HashMap<>(); private final static HashMap healRunnable = new HashMap<>(); @@ -214,21 +215,23 @@ public class PlotPlusListener extends PlotListener implements Listener { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString())); } if (booleanFlag(plot, "notify-enter", false)) { + final Player trespasser = event.getPlayer(); + final PlotPlayer pt = BukkitUtil.getPlayer(trespasser); + if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) { + return; + } if (plot.hasOwner()) { - final PlotPlayer pp = UUIDHandler.getPlayer(plot.getOwner()); - if (pp == null) { - return; - } - final Player trespasser = event.getPlayer(); - final PlotPlayer pt = BukkitUtil.getPlayer(trespasser); - if (pp.getUUID().equals(pt.getUUID())) { - return; - } - if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) { - return; - } - if (pp.isOnline()) { - MainUtil.sendMessage(pp, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + for (UUID owner : PlotHandler.getOwners(plot)) { + final PlotPlayer pp = UUIDHandler.getPlayer(owner); + if (pp == null) { + return; + } + if (pp.getUUID().equals(pt.getUUID())) { + return; + } + if (pp.isOnline()) { + MainUtil.sendMessage(pp, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + } } } } @@ -263,19 +266,21 @@ public class PlotPlusListener extends PlotListener implements Listener { healRunnable.remove(leaver); } if (booleanFlag(plot, "notify-leave", false)) { + if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) { + return; + } if (plot.hasOwner()) { - final PlotPlayer pp = UUIDHandler.getPlayer(plot.getOwner()); - if (pp == null) { - return; - } - if (pp.getUUID().equals(pl.getUUID())) { - return; - } - if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) { - return; - } - if (pp.isOnline()) { - MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", pl.getName()).replace("%plot", plot.getId().toString())); + for (UUID owner : PlotHandler.getOwners(plot)) { + final PlotPlayer pp = UUIDHandler.getPlayer(owner); + if (pp == null) { + return; + } + if (pp.getUUID().equals(pl.getUUID())) { + return; + } + if (pp.isOnline()) { + MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", leaver.getName()).replace("%plot", plot.getId().toString())); + } } } } 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 a44c432a9..2098afbe4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; @@ -45,6 +46,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -75,20 +77,27 @@ public class WorldEditListener implements Listener { final String world = e.getWorld(); final PlotId id = e.getPlotId(); final Plot plot = PlotSquared.getPlots(world).get(id); - if ((plot == null) || (plot.owner == null)) { + if (plot == null) { return; } - final PlotPlayer player = UUIDHandler.getPlayer(plot.owner); - if (player == null) { + HashSet members = PlotHandler.getOwners(plot); + if (members == null) { return; } - if (!world.equals(player.getLocation().getWorld())) { - return; + members.addAll(plot.helpers); + for (UUID member : members) { + final PlotPlayer player = UUIDHandler.getPlayer(member); + if (player == null) { + continue; + } + if (!world.equals(player.getLocation().getWorld())) { + return; + } + if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { + return; + } + PWE.setNoMask(player); } - if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { - return; - } - PWE.setNoMask(player); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index ff3a88197..8c4168ae1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -43,7 +43,7 @@ public class InfoInventory implements InventoryHolder { } public String getName(final UUID uuid) { - final String name = UUIDHandler.getName(this.plot.getOwner()); + final String name = UUIDHandler.getName(this.plot.owner_); if (name == null) { return "unknown"; } @@ -52,7 +52,7 @@ public class InfoInventory implements InventoryHolder { public InfoInventory build() { final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player)); - final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); + final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner_), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players"); final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 8abad98ba..7d9fb2641 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -48,7 +48,7 @@ public class Plot implements Cloneable { /** * plot owner */ - public UUID owner; + public UUID owner_; /** * Deny Entry */ @@ -90,8 +90,8 @@ public class Plot implements Cloneable { public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList denied, final String world) { this.id = id; this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner == null; + this.owner_ = owner; + this.deny_entry = this.owner_ == null; this.helpers = helpers; this.denied = denied; this.trusted = new ArrayList<>(); @@ -113,8 +113,8 @@ public class Plot implements Cloneable { public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) { this.id = id; this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner != null; + this.owner_ = owner; + this.deny_entry = this.owner_ != null; this.trusted = trusted; this.helpers = helpers; this.denied = denied; @@ -136,7 +136,7 @@ public class Plot implements Cloneable { * @return false if there is no owner */ public boolean hasOwner() { - return this.owner != null; + return this.owner_ != null; } /** @@ -147,7 +147,21 @@ public class Plot implements Cloneable { * @return true if the player is added as a helper or is the owner */ public boolean isAdded(final UUID uuid) { - return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone))); + if (this.owner_ == null) { + return false; + } + if (this.denied.contains(uuid)) { + return false; + } + if (this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)) { + return true; + } + if (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone)) { + if (PlotHandler.isOnline(this)) { + return true; + } + } + return PlotHandler.isOwner(this, uuid); } /** @@ -164,18 +178,18 @@ public class Plot implements Cloneable { /** * Get the UUID of the owner */ - public UUID getOwner() { - return this.owner; - } +// public UUID getOwner() { +// return this.owner_; +// } /** * Set the owner * * @param uuid */ - public void setOwner(final UUID uuid) { - this.owner = uuid; - } +// public void setOwner(final UUID uuid) { +// this.owner_ = uuid; +// } /** * Get the plot ID @@ -193,7 +207,7 @@ public class Plot implements Cloneable { public Object clone() throws CloneNotSupportedException { final Plot p = (Plot) super.clone(); if (!p.equals(this) || (p != this)) { - return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); + return new Plot(this.id, this.owner_, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); } return p; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java new file mode 100644 index 000000000..329daff22 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -0,0 +1,76 @@ +package com.intellectualcrafters.plot.object; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.UUID; + +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class PlotHandler { + public static HashSet getOwners(Plot plot) { + if (plot.owner_ == null) { + return new HashSet(); + } + if (plot.settings.isMerged()) { + HashSet owners = new HashSet(); + Plot top = MainUtil.getTopPlot(plot); + ArrayList ids = MainUtil.getPlotSelectionIds(plot.id, top.id); + for (PlotId id : ids) { + UUID owner = MainUtil.getPlot(plot.world, id).owner_; + if (owner != null) { + owners.add(owner); + } + } + return owners; + } + return new HashSet<>(Arrays.asList(plot.owner_)); + } + + public static boolean isOwner(Plot plot, UUID uuid) { + if (plot.owner_ == null) { + return false; + } + if (plot.settings.isMerged()) { + Plot top = MainUtil.getTopPlot(plot); + ArrayList ids = MainUtil.getPlotSelectionIds(plot.id, top.id); + for (PlotId id : ids) { + UUID owner = MainUtil.getPlot(plot.world, id).owner_; + if (owner != null && owner.equals(uuid)) { + return true; + } + } + } + return plot.owner_.equals(uuid); + } + + public static boolean isOnline(Plot plot) { + if (plot.owner_ == null) { + return false; + } + if (plot.settings.isMerged()) { + Plot top = MainUtil.getTopPlot(plot); + ArrayList ids = MainUtil.getPlotSelectionIds(plot.id, top.id); + for (PlotId id : ids) { + UUID owner = MainUtil.getPlot(plot.world, id).owner_; + if (owner != null) { + if (UUIDHandler.getPlayer(owner) != null) { + return true; + } + } + } + return false; + } + return UUIDHandler.getPlayer(plot.owner_) != null; + } + + public static boolean sameOwners(Plot plot1, Plot plot2) { + if (plot1.owner_ == null || plot2.owner_ == null) { + return false; + } + HashSet owners = getOwners(plot1); + owners.retainAll(getOwners(plot2)); + return owners.size() > 0; + } +} 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 eeb650719..6852c839a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -20,6 +20,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; @@ -85,13 +86,7 @@ public class ExpireManager { continue; } final Plot plot = plots.iterator().next(); - if (plot.owner != null) { - if (UUIDHandler.getPlayer(plot.owner) != null) { - expiredPlots.get(world).remove(plot); - return; - } - } - if (!isExpired(plot.owner)) { + if (!isExpired(plot)) { expiredPlots.get(world).remove(plot); return; } @@ -121,7 +116,7 @@ public class ExpireManager { PlotSquared.log("&cDeleted expired plot: " + plot.id); PlotSquared.log("&3 - World: " + plot.world); if (plot.hasOwner()) { - PlotSquared.log("&3 - Owner: " + UUIDHandler.getName(plot.owner)); + PlotSquared.log("&3 - Owner: " + UUIDHandler.getName(plot.owner_)); } else { PlotSquared.log("&3 - Owner: Unowned"); } @@ -132,6 +127,9 @@ public class ExpireManager { } public static boolean isExpired(final UUID uuid) { + if (UUIDHandler.getPlayer(uuid) != null) { + return false; + } final String name = UUIDHandler.getName(uuid); if (name != null) { final OfflinePlayer op = Bukkit.getOfflinePlayer(name); @@ -145,6 +143,15 @@ public class ExpireManager { } return false; } + + public static boolean isExpired(Plot plot) { + for (UUID owner : PlotHandler.getOwners(plot)) { + if (!isExpired(owner)) { + return false; + } + } + return true; + } public static HashMap getOldPlots(final String world) { final Collection plots = PlotSquared.getPlots(world).values(); @@ -152,7 +159,7 @@ public class ExpireManager { final HashMap remove = new HashMap<>(); final Set keep = new HashSet<>(); for (final Plot plot : plots) { - final UUID uuid = plot.owner; + final UUID uuid = plot.owner_; if ((uuid == null) || remove.containsKey(uuid)) { Long stamp; if (uuid == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c765a8af0..c586f59a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -90,7 +90,7 @@ public class MainUtil { final UUID uuid = plr.getUUID(); int count = 0; for (final Plot plot : PlotSquared.getPlots(world).values()) { - if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { + if (plot.hasOwner() && plot.owner_.equals(uuid) && plot.countsTowardsMax) { count++; } } @@ -369,10 +369,10 @@ public class MainUtil { if (plot == null) { return; } - if (plot.owner == null) { + if (plot.owner_ == null) { return; } - if (!plot.owner.equals(uuid)) { + if (!plot.owner_.equals(uuid)) { return; } ArrayList plots; @@ -427,7 +427,7 @@ public class MainUtil { final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) { + if ((myplot == null) || myplot.owner_ == null || !(myplot.owner_.equals(uuid))) { return false; } final PlotId top = getTopPlot(myplot).id; @@ -770,7 +770,7 @@ public class MainUtil { for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); if (PlotSquared.getPlots(world).get(id) != null) { - if (PlotSquared.getPlots(world).get(id).owner != null) { + if (PlotSquared.getPlots(world).get(id).owner_ != null) { return false; } } @@ -782,7 +782,7 @@ public class MainUtil { public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { Plot p1 = PlotSquared.getPlots(world).get(current); Plot p2 = PlotSquared.getPlots(world).get(newPlot); - if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) { + if (p1==null || p2 == null || p1.owner_ == null || !p1.owner_.equals(p2.owner_)) { return false; } // Swap blocks @@ -807,7 +807,7 @@ public class MainUtil { final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); final Location top = MainUtil.getPlotTopLoc(world, current); final Plot currentPlot = MainUtil.getPlot(world, current); - if (currentPlot.owner == null) { + if (currentPlot.owner_ == null) { TaskManager.runTaskLater(whenDone, 1); return false; } @@ -845,7 +845,7 @@ public class MainUtil { final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); final Location top = MainUtil.getPlotTopLoc(world, current); final Plot currentPlot = MainUtil.getPlot(world, current); - if (currentPlot.owner == null) { + if (currentPlot.owner_ == null) { TaskManager.runTaskLater(whenDone, 1); return false; } @@ -862,7 +862,7 @@ public class MainUtil { for (final PlotId id : selection) { int x = id.x + offset_x; int y = id.y + offset_y; - Plot plot = createPlotAbs(currentPlot.owner, getPlot(world, new PlotId(x, y))); + Plot plot = createPlotAbs(currentPlot.owner_, getPlot(world, new PlotId(x, y))); if (currentPlot.settings.flags != null && currentPlot.settings.flags.size() > 0) { plot.settings.flags = currentPlot.settings.flags; DBFunc.setFlags(world, plot, currentPlot.settings.flags); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 7dde64ef3..e9936705f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -115,12 +115,12 @@ public class BukkitChunkManager extends ChunkManager { final Location bot = new Location(world, x1, 0, z1); Plot plot; plot = MainUtil.getPlot(bot); - if ((plot != null) && (plot.owner != null)) { + if ((plot != null) && (plot.owner_ != null)) { return plot; } final Location top = new Location(world, x2, 0, z2); plot = MainUtil.getPlot(top); - if ((plot != null) && (plot.owner != null)) { + if ((plot != null) && (plot.owner_ != null)) { return plot; } return null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index e59dc8939..1d21f0994 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; @@ -64,7 +65,7 @@ public class PWE { if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { return; } - final boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(p.getUUID())) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUUID()); + final boolean r = (PlotHandler.isOwner(plot, p.getUUID())) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUUID()); if (r) { final String w = l.getWorld(); final Location bloc = MainUtil.getPlotBottomLoc(w, plot.id); From fbaca34218e5538b0595c07c5b73e587802e2bda Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Mar 2015 14:00:02 +1100 Subject: [PATCH 054/223] Fixed errors. --- .../plot/commands/Clear.java | 6 ++-- .../plot/commands/Cluster.java | 6 ++-- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugClear.java | 2 +- .../plot/commands/DebugExec.java | 2 +- .../plot/commands/Delete.java | 4 +-- .../plot/commands/Denied.java | 4 +-- .../plot/commands/Helpers.java | 4 +-- .../plot/commands/Home.java | 2 +- .../plot/commands/Inbox.java | 4 +-- .../plot/commands/Info.java | 22 +++++++++------ .../plot/commands/Kick.java | 2 +- .../plot/commands/Merge.java | 10 +++---- .../plot/commands/Purge.java | 6 ++-- .../plot/commands/Rate.java | 2 +- .../plot/commands/SchematicCmd.java | 4 +-- .../plot/commands/SetOwner.java | 8 +++--- .../plot/commands/Swap.java | 4 +-- .../plot/commands/Trusted.java | 4 +-- .../plot/commands/Unclaim.java | 2 +- .../plot/commands/Unlink.java | 6 ++-- .../plot/commands/Visit.java | 2 +- .../plot/commands/list.java | 8 +++--- .../plot/object/Plot.java | 28 +++++++++---------- .../plot/object/PlotHandler.java | 19 +++++++++++++ 25 files changed, 92 insertions(+), 71 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 5aee193ad..f0b363208 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -62,7 +62,7 @@ public class Clear extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - MainUtil.clear(world, plot, plot.owner == null, null); + MainUtil.clear(world, plot, plot.owner_ == null, null); PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } }; @@ -110,7 +110,7 @@ public class Clear extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -122,7 +122,7 @@ public class Clear extends SubCommand { @Override public void run() { final long start = System.currentTimeMillis(); - final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() { + final boolean result = MainUtil.clearAsPlayer(plot, plot.owner_ == null, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 89a5ee654..3613a7e26 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -129,9 +129,9 @@ public class Cluster extends SubCommand { // Add any existing plots to the current cluster for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster current = ClusterManager.getCluster(plot); - if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { - cluster.invited.add(plot.owner); - DBFunc.setInvited(world, cluster, plot.owner); + if (cluster.equals(current) && !cluster.hasRights(plot.owner_)) { + cluster.invited.add(plot.owner_); + DBFunc.setInvited(world, cluster, plot.owner_); } } if (!PlotSquared.isPlotWorld(world)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 76b92e195..d7ec5885c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -123,7 +123,7 @@ public class DebugClaimTest extends SubCommand { } if (uuid != null) { MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); - plot.owner = uuid; + plot.owner_ = uuid; plot.hasChanged = true; plots.add(plot); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index 509106be0..2883c198c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -85,7 +85,7 @@ public class DebugClear extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 83f52878f..71d46599a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -97,7 +97,7 @@ public class DebugExec extends SubCommand { for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { final Plot plot = entry.getKey(); final Long stamp = entry.getValue(); - MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); + MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner_) + " : " + stamp); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index a4a844b7b..541d5ee5a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -50,7 +50,7 @@ public class Delete extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { + if ((((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -62,7 +62,7 @@ public class Delete extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) { final double c = pWorld.SELL_PRICE; if (c > 0d) { EconHandler.depositPlayer(plr, c); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 168b6b8a7..9fbe31017 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -53,7 +53,7 @@ public class Denied extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } @@ -69,7 +69,7 @@ public class Denied extends SubCommand { return false; } if (!plot.denied.contains(uuid)) { - if (plot.owner.equals(uuid)) { + if (plot.isOwner(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 3f3b6573c..b1d5c880d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -52,7 +52,7 @@ public class Helpers extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } @@ -68,7 +68,7 @@ public class Helpers extends SubCommand { return false; } if (!plot.helpers.contains(uuid)) { - if (plot.owner.equals(uuid)) { + if (plot.isOwner(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 6a3e13d11..838ea3b0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -63,7 +63,7 @@ public class Home extends SubCommand { Plot temp; if ((temp = isAlias(args[0])) != null) { if (temp.hasOwner()) { - if (temp.getOwner().equals(UUIDHandler.getUUID(plr))) { + if (temp.isOwner(plr.getUUID())) { MainUtil.teleportPlayer(plr, plr.getLocation(), temp); return true; } 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 144da8cbb..544219a82 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -59,10 +59,10 @@ public class Inbox extends SubCommand { return false; } Integer tier; - final UUID uuid = UUIDHandler.getUUID(plr); + final UUID uuid = plr.getUUID(); if (Permissions.hasPermission(plr, "plots.comment.admin")) { tier = 0; - } else if ((plot != null) && plot.owner.equals(uuid)) { + } else if ((plot != null) && plot.isOwner(uuid)) { tier = 1; } else if ((plot != null) && plot.helpers.contains(uuid)) { tier = 2; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 7e0268e0f..fb0b65a29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -21,6 +21,9 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; import java.util.UUID; import org.apache.commons.lang.StringUtils; @@ -110,11 +113,11 @@ public class Info extends SubCommand { return true; } String owner = "none"; - if (plot.owner != null) { - owner = UUIDHandler.getName(plot.owner); + if (plot.owner_ == null) { + owner = "unowned"; } - if (owner == null) { - owner = plot.owner.toString(); + else { + owner = getPlayerList(plot.getOwners()); } String info = C.PLOT_INFO.s(); if (args.length == 1) { @@ -170,11 +173,11 @@ public class Info extends SubCommand { final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = "none"; - if (plot.owner != null) { - owner = UUIDHandler.getName(plot.owner); + if (plot.owner_ == null) { + owner = "unowned"; } - if (owner == null) { - owner = plot.owner.toString(); + else { + owner = getPlayerList(plot.getOwners()); } info = info.replaceAll("%alias%", alias); info = info.replaceAll("%id%", id.toString()); @@ -192,7 +195,8 @@ public class Info extends SubCommand { return info; } - private String getPlayerList(final ArrayList l) { + private String getPlayerList(final Collection uuids) { + ArrayList l = new ArrayList<>(uuids); if ((l == null) || (l.size() < 1)) { return " none"; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 0540bf88e..3de39de9f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -42,7 +42,7 @@ public class Kick extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index f8dbdf2a7..0b9504469 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -85,7 +85,7 @@ public class Merge extends SubCommand { return false; } final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge"); - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { + if (!plot.isOwner(plr.getUUID()) && !admin) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -138,10 +138,10 @@ public class Merge extends SubCommand { boolean multiMerge = false; final HashSet multiUUID = new HashSet(); HashSet multiPlots = new HashSet<>(); - final UUID u1 = plot.getOwner(); + final UUID u1 = plot.owner_; for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - UUID u2 = myplot.getOwner(); + UUID u2 = myplot.owner_; if (myplot == null || u2 == null) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; @@ -190,7 +190,7 @@ public class Merge extends SubCommand { } MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); MainUtil.update(loc); } MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); @@ -219,7 +219,7 @@ public class Merge extends SubCommand { } MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); MainUtil.update(loc); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index 2fd574adc..e6327b99b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -120,8 +120,8 @@ public class Purge extends SubCommand { final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { - if (plot.owner != null) { - final String name = UUIDHandler.getName(plot.owner); + if (plot.owner_ != null) { + final String name = UUIDHandler.getName(plot.owner_); if (name == null) { ids.add(plot.id); } @@ -138,7 +138,7 @@ public class Purge extends SubCommand { final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { - if (plot.owner == null) { + if (plot.owner_ == null) { ids.add(plot.id); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 6073c9fae..9b46e38f3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -52,7 +52,7 @@ public class Rate extends SubCommand { sendMessage(plr, C.RATING_NOT_OWNED); return true; } - if (plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + if (plot.isOwner(plr.getUUID())) { sendMessage(plr, C.RATING_NOT_YOUR_OWN); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 0524b48e0..913806733 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -222,7 +222,7 @@ public class SchematicCmd extends SubCommand { } final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final CompoundTag sch = SchematicHandler.manager.getCompoundTag(worldname, plot.id); - final String o = UUIDHandler.getName(plot.owner); + final String o = UUIDHandler.getName(plot.owner_); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); @@ -303,7 +303,7 @@ public class SchematicCmd extends SubCommand { } final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final CompoundTag sch = SchematicHandler.manager.getCompoundTag(world, plot.id); - final String o = UUIDHandler.getName(plot.owner); + final String o = UUIDHandler.getName(plot.owner_); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 2c8449666..0f5c4e2bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -52,7 +52,7 @@ public class SetOwner extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if ((plot == null) || (plot.owner == null)) { + if ((plot == null) || (plot.owner_ == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } @@ -60,7 +60,7 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.NEED_USER); return false; } - if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } @@ -75,9 +75,9 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - current.owner = uuid; + current.owner_ = uuid; PlotSquared.updatePlot(current); - DBFunc.setOwner(current, current.owner); + DBFunc.setOwner(current, current.owner_); } MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 424923313..aa6f2b435 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -52,7 +52,7 @@ public class Swap extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -66,7 +66,7 @@ public class Swap extends SubCommand { try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot2 == null) || !plot2.hasOwner() || !(plot2.owner_.equals(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 38ebc32aa..04a6f78e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -53,7 +53,7 @@ public class Trusted extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } @@ -69,7 +69,7 @@ public class Trusted extends SubCommand { return false; } if (!plot.trusted.contains(uuid)) { - if (plot.owner.equals(uuid)) { + if (plot.isOwner(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index 71af1cc06..f4a468829 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -47,7 +47,7 @@ public class Unclaim extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { + if ((((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index e827ef7a7..fffb7226a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -56,7 +56,7 @@ public class Unlink extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { @@ -124,14 +124,14 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); } } manager.finishPlotUnlink(plotworld, ids); for (final PlotId id : ids) { final Plot myPlot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { - final String name = UUIDHandler.getName(myPlot.owner); + final String name = UUIDHandler.getName(myPlot.owner_); if (name != null) { MainUtil.setSign(name, myPlot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index facfbad9a..1fe36383e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -39,7 +39,7 @@ public class Visit extends SubCommand { public List getPlots(final UUID uuid) { final List plots = new ArrayList<>(); for (final Plot p : PlotSquared.getPlots()) { - if (p.hasOwner() && p.owner.equals(uuid)) { + if (p.hasOwner() && p.isOwner(uuid)) { plots.add(p); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index d563738d9..d41bb5fec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -151,7 +151,7 @@ public class list extends SubCommand { case "unowned": { plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.owner == null) { + if (plot.owner_ == null) { plots.add(plot); } } @@ -160,10 +160,10 @@ public class list extends SubCommand { case "unknown": { plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.owner == null) { + if (plot.owner_ == null) { continue; } - if (UUIDHandler.getName(plot.owner) == null) { + if (UUIDHandler.getName(plot.owner_) == null) { plots.add(plot); } } @@ -219,7 +219,7 @@ public class list extends SubCommand { // This might work xD for (int x = (page * 12); x < max; x++) { p = (Plot) plots.toArray()[x]; - string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); + string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner_))).append("\n"); } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.size() + "").replaceAll("%plot%", plots.size() == 1 ? "plot" : "plots")); MainUtil.sendMessage(player, string.toString()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 7d9fb2641..d495d29e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -138,6 +138,18 @@ public class Plot implements Cloneable { public boolean hasOwner() { return this.owner_ != null; } + + public boolean isOwner(UUID uuid) { + return PlotHandler.isOwner(this, uuid); + } + + /** + * Get a list of owner UUIDs for a plot (supports multi-owner mega-plots) + * @return + */ + public HashSet getOwners() { + return PlotHandler.getOwners(this); + } /** * Check if the player is either the owner or on the helpers list @@ -147,21 +159,7 @@ public class Plot implements Cloneable { * @return true if the player is added as a helper or is the owner */ public boolean isAdded(final UUID uuid) { - if (this.owner_ == null) { - return false; - } - if (this.denied.contains(uuid)) { - return false; - } - if (this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)) { - return true; - } - if (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone)) { - if (PlotHandler.isOnline(this)) { - return true; - } - } - return PlotHandler.isOwner(this, uuid); + return PlotHandler.isAdded(this, uuid); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java index 329daff22..057a4a2c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.UUID; +import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -73,4 +74,22 @@ public class PlotHandler { owners.retainAll(getOwners(plot2)); return owners.size() > 0; } + + public static boolean isAdded(Plot plot, final UUID uuid) { + if (plot.owner_ == null) { + return false; + } + if (plot.denied.contains(uuid)) { + return false; + } + if (plot.helpers.contains(uuid) || plot.helpers.contains(DBFunc.everyone)) { + return true; + } + if (plot.trusted.contains(uuid) || plot.trusted.contains(DBFunc.everyone)) { + if (PlotHandler.isOnline(plot)) { + return true; + } + } + return PlotHandler.isOwner(plot, uuid); + } } From 0d75622196f39218a6f857e3f410d5d781e03303 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Mar 2015 15:11:02 +1100 Subject: [PATCH 055/223] Refactor --- .../plot/api/PlotAPI.java | 2 +- .../plot/commands/Auto.java | 4 ++-- .../plot/commands/Buy.java | 8 +++---- .../plot/commands/Clear.java | 4 ++-- .../plot/commands/Cluster.java | 6 ++--- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugExec.java | 2 +- .../plot/commands/Info.java | 4 ++-- .../plot/commands/Merge.java | 8 +++---- .../plot/commands/Purge.java | 6 ++--- .../plot/commands/SchematicCmd.java | 4 ++-- .../plot/commands/SetOwner.java | 6 ++--- .../plot/commands/Swap.java | 2 +- .../plot/commands/Unlink.java | 4 ++-- .../plot/commands/list.java | 8 +++---- .../plot/database/SQLManager.java | 8 +++---- .../plot/listeners/PlotListener.java | 2 +- .../plot/object/InfoInventory.java | 4 ++-- .../plot/object/Plot.java | 14 ++++++------ .../plot/object/PlotHandler.java | 22 +++++++++---------- .../plot/util/ExpireManager.java | 4 ++-- .../plot/util/MainUtil.java | 18 +++++++-------- .../plot/util/bukkit/BukkitChunkManager.java | 4 ++-- 23 files changed, 73 insertions(+), 73 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index fd1f29417..f49f80a5f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -474,7 +474,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; final ArrayList pPlots = new ArrayList<>(); for (final Plot plot : PlotSquared.getPlots(world.getName()).values()) { if (just_owner) { - if ((plot.owner_ != null) && (plot.owner_ == UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) { + if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) { pPlots.add(plot); } } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index d121fec4f..ef40badde 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -193,7 +193,7 @@ public class Auto extends SubCommand { if ((size_x == 1) && (size_z == 1)) { while (!br) { final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname)); - if ((plot.owner_ == null)) { + if ((plot.owner == null)) { Claim.claimPlot(plr, plot, true, true); br = true; } @@ -207,7 +207,7 @@ public class Auto extends SubCommand { MainUtil.lastPlot.put(worldname, start); if (lastPlot) { } - if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner_ != null)) { + if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) { continue; } else { lastPlot = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 91ba1901e..d9b4ff159 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -98,8 +98,8 @@ public class Buy extends SubCommand { } EconHandler.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); - EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner_), initPrice); - final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner_); + EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); + final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } @@ -109,8 +109,8 @@ public class Buy extends SubCommand { for (PlotId myId : MainUtil.getPlotSelectionIds(plot.id, top.id)) { Plot myPlot = MainUtil.getPlot(plot.world, myId); - myPlot.owner_ = plr.getUUID(); - DBFunc.setOwner(plot, myPlot.owner_); + myPlot.owner = plr.getUUID(); + DBFunc.setOwner(plot, myPlot.owner); } MainUtil.sendMessage(plr, C.CLAIMED); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index f0b363208..287c0e05d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -62,7 +62,7 @@ public class Clear extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - MainUtil.clear(world, plot, plot.owner_ == null, null); + MainUtil.clear(world, plot, plot.owner == null, null); PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } }; @@ -122,7 +122,7 @@ public class Clear extends SubCommand { @Override public void run() { final long start = System.currentTimeMillis(); - final boolean result = MainUtil.clearAsPlayer(plot, plot.owner_ == null, new Runnable() { + final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 3613a7e26..89a5ee654 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -129,9 +129,9 @@ public class Cluster extends SubCommand { // Add any existing plots to the current cluster for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster current = ClusterManager.getCluster(plot); - if (cluster.equals(current) && !cluster.hasRights(plot.owner_)) { - cluster.invited.add(plot.owner_); - DBFunc.setInvited(world, cluster, plot.owner_); + if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { + cluster.invited.add(plot.owner); + DBFunc.setInvited(world, cluster, plot.owner); } } if (!PlotSquared.isPlotWorld(world)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index d7ec5885c..76b92e195 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -123,7 +123,7 @@ public class DebugClaimTest extends SubCommand { } if (uuid != null) { MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); - plot.owner_ = uuid; + plot.owner = uuid; plot.hasChanged = true; plots.add(plot); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 71d46599a..83f52878f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -97,7 +97,7 @@ public class DebugExec extends SubCommand { for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { final Plot plot = entry.getKey(); final Long stamp = entry.getValue(); - MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner_) + " : " + stamp); + MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index fb0b65a29..9fc861387 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -113,7 +113,7 @@ public class Info extends SubCommand { return true; } String owner = "none"; - if (plot.owner_ == null) { + if (plot.owner == null) { owner = "unowned"; } else { @@ -173,7 +173,7 @@ public class Info extends SubCommand { final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = "none"; - if (plot.owner_ == null) { + if (plot.owner == null) { owner = "unowned"; } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 0b9504469..a4d3bbca3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -138,10 +138,10 @@ public class Merge extends SubCommand { boolean multiMerge = false; final HashSet multiUUID = new HashSet(); HashSet multiPlots = new HashSet<>(); - final UUID u1 = plot.owner_; + final UUID u1 = plot.owner; for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - UUID u2 = myplot.owner_; + UUID u2 = myplot.owner; if (myplot == null || u2 == null) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; @@ -190,7 +190,7 @@ public class Merge extends SubCommand { } MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.update(loc); } MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); @@ -219,7 +219,7 @@ public class Merge extends SubCommand { } MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.update(loc); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index e6327b99b..2fd574adc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -120,8 +120,8 @@ public class Purge extends SubCommand { final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { - if (plot.owner_ != null) { - final String name = UUIDHandler.getName(plot.owner_); + if (plot.owner != null) { + final String name = UUIDHandler.getName(plot.owner); if (name == null) { ids.add(plot.id); } @@ -138,7 +138,7 @@ public class Purge extends SubCommand { final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { - if (plot.owner_ == null) { + if (plot.owner == null) { ids.add(plot.id); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 913806733..0524b48e0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -222,7 +222,7 @@ public class SchematicCmd extends SubCommand { } final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final CompoundTag sch = SchematicHandler.manager.getCompoundTag(worldname, plot.id); - final String o = UUIDHandler.getName(plot.owner_); + final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); @@ -303,7 +303,7 @@ public class SchematicCmd extends SubCommand { } final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final CompoundTag sch = SchematicHandler.manager.getCompoundTag(world, plot.id); - final String o = UUIDHandler.getName(plot.owner_); + final String o = UUIDHandler.getName(plot.owner); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 0f5c4e2bf..389331aae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -52,7 +52,7 @@ public class SetOwner extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if ((plot == null) || (plot.owner_ == null)) { + if ((plot == null) || (plot.owner == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } @@ -75,9 +75,9 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - current.owner_ = uuid; + current.owner = uuid; PlotSquared.updatePlot(current); - DBFunc.setOwner(current, current.owner_); + DBFunc.setOwner(current, current.owner); } MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index aa6f2b435..e64f33fa6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -66,7 +66,7 @@ public class Swap extends SubCommand { try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || !(plot2.owner_.equals(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot2 == null) || !plot2.hasOwner() || !(plot2.owner.equals(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index fffb7226a..936ef01a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -124,14 +124,14 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } } manager.finishPlotUnlink(plotworld, ids); for (final PlotId id : ids) { final Plot myPlot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { - final String name = UUIDHandler.getName(myPlot.owner_); + final String name = UUIDHandler.getName(myPlot.owner); if (name != null) { MainUtil.setSign(name, myPlot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index d41bb5fec..d563738d9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -151,7 +151,7 @@ public class list extends SubCommand { case "unowned": { plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.owner_ == null) { + if (plot.owner == null) { plots.add(plot); } } @@ -160,10 +160,10 @@ public class list extends SubCommand { case "unknown": { plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.owner_ == null) { + if (plot.owner == null) { continue; } - if (UUIDHandler.getName(plot.owner_) == null) { + if (UUIDHandler.getName(plot.owner) == null) { plots.add(plot); } } @@ -219,7 +219,7 @@ public class list extends SubCommand { // This might work xD for (int x = (page * 12); x < max; x++) { p = (Plot) plots.toArray()[x]; - string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner_))).append("\n"); + string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.size() + "").replaceAll("%plot%", plots.size() == 1 ? "plot" : "plots")); MainUtil.sendMessage(player, string.toString()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 11a1835f5..9a2ae8931 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -263,7 +263,7 @@ public class SQLManager implements AbstractDB { stmt.setInt((i * 4) + 1, plot.id.x); stmt.setInt((i * 4) + 2, plot.id.y); try { - stmt.setString((i * 4) + 3, plot.owner_.toString()); + stmt.setString((i * 4) + 3, plot.owner.toString()); } catch (final Exception e) { stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); } @@ -299,7 +299,7 @@ public class SQLManager implements AbstractDB { stmt.setInt((i * 6) + 2, plot.id.x); stmt.setInt((i * 6) + 3, plot.id.y); try { - stmt.setString((i * 6) + 4, plot.owner_.toString()); + stmt.setString((i * 6) + 4, plot.owner.toString()); } catch (final Exception e1) { stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); } @@ -344,7 +344,7 @@ public class SQLManager implements AbstractDB { stmt = SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT); stmt.setInt(1, plot.id.x); stmt.setInt(2, plot.id.y); - stmt.setString(3, plot.owner_.toString()); + stmt.setString(3, plot.owner.toString()); stmt.setString(4, plot.world); stmt.executeUpdate(); stmt.close(); @@ -366,7 +366,7 @@ public class SQLManager implements AbstractDB { stmt = SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT); stmt.setInt(1, plot.id.x); stmt.setInt(2, plot.id.y); - stmt.setString(3, plot.owner_.toString()); + stmt.setString(3, plot.owner.toString()); stmt.setString(4, plot.world); stmt.executeUpdate(); stmt.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 909da03bd..549fed1e5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -180,7 +180,7 @@ public class PlotListener { } if ((booleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + ""); - final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner_)); + final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); if (AbstractTitle.TITLE_CLASS != null) { AbstractTitle.TITLE_CLASS.sendTitle(player, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index 8c4168ae1..9cdca9426 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -43,7 +43,7 @@ public class InfoInventory implements InventoryHolder { } public String getName(final UUID uuid) { - final String name = UUIDHandler.getName(this.plot.owner_); + final String name = UUIDHandler.getName(this.plot.owner); if (name == null) { return "unknown"; } @@ -52,7 +52,7 @@ public class InfoInventory implements InventoryHolder { public InfoInventory build() { final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player)); - final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner_), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); + final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers"); final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players"); final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index d495d29e8..e192be634 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -48,7 +48,7 @@ public class Plot implements Cloneable { /** * plot owner */ - public UUID owner_; + public UUID owner; /** * Deny Entry */ @@ -90,8 +90,8 @@ public class Plot implements Cloneable { public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList denied, final String world) { this.id = id; this.settings = new PlotSettings(this); - this.owner_ = owner; - this.deny_entry = this.owner_ == null; + this.owner = owner; + this.deny_entry = this.owner == null; this.helpers = helpers; this.denied = denied; this.trusted = new ArrayList<>(); @@ -113,8 +113,8 @@ public class Plot implements Cloneable { public Plot(final PlotId id, final UUID owner, final ArrayList helpers, final ArrayList trusted, final ArrayList denied, final String alias, final BlockLoc position, final Set flags, final String world, final boolean[] merged) { this.id = id; this.settings = new PlotSettings(this); - this.owner_ = owner; - this.deny_entry = this.owner_ != null; + this.owner = owner; + this.deny_entry = this.owner != null; this.trusted = trusted; this.helpers = helpers; this.denied = denied; @@ -136,7 +136,7 @@ public class Plot implements Cloneable { * @return false if there is no owner */ public boolean hasOwner() { - return this.owner_ != null; + return this.owner != null; } public boolean isOwner(UUID uuid) { @@ -205,7 +205,7 @@ public class Plot implements Cloneable { public Object clone() throws CloneNotSupportedException { final Plot p = (Plot) super.clone(); if (!p.equals(this) || (p != this)) { - return new Plot(this.id, this.owner_, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); + return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, this.world, this.settings.getMerged()); } return p; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java index 057a4a2c2..42127a5de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -11,7 +11,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlotHandler { public static HashSet getOwners(Plot plot) { - if (plot.owner_ == null) { + if (plot.owner == null) { return new HashSet(); } if (plot.settings.isMerged()) { @@ -19,42 +19,42 @@ public class PlotHandler { Plot top = MainUtil.getTopPlot(plot); ArrayList ids = MainUtil.getPlotSelectionIds(plot.id, top.id); for (PlotId id : ids) { - UUID owner = MainUtil.getPlot(plot.world, id).owner_; + UUID owner = MainUtil.getPlot(plot.world, id).owner; if (owner != null) { owners.add(owner); } } return owners; } - return new HashSet<>(Arrays.asList(plot.owner_)); + return new HashSet<>(Arrays.asList(plot.owner)); } public static boolean isOwner(Plot plot, UUID uuid) { - if (plot.owner_ == null) { + if (plot.owner == null) { return false; } if (plot.settings.isMerged()) { Plot top = MainUtil.getTopPlot(plot); ArrayList ids = MainUtil.getPlotSelectionIds(plot.id, top.id); for (PlotId id : ids) { - UUID owner = MainUtil.getPlot(plot.world, id).owner_; + UUID owner = MainUtil.getPlot(plot.world, id).owner; if (owner != null && owner.equals(uuid)) { return true; } } } - return plot.owner_.equals(uuid); + return plot.owner.equals(uuid); } public static boolean isOnline(Plot plot) { - if (plot.owner_ == null) { + if (plot.owner == null) { return false; } if (plot.settings.isMerged()) { Plot top = MainUtil.getTopPlot(plot); ArrayList ids = MainUtil.getPlotSelectionIds(plot.id, top.id); for (PlotId id : ids) { - UUID owner = MainUtil.getPlot(plot.world, id).owner_; + UUID owner = MainUtil.getPlot(plot.world, id).owner; if (owner != null) { if (UUIDHandler.getPlayer(owner) != null) { return true; @@ -63,11 +63,11 @@ public class PlotHandler { } return false; } - return UUIDHandler.getPlayer(plot.owner_) != null; + return UUIDHandler.getPlayer(plot.owner) != null; } public static boolean sameOwners(Plot plot1, Plot plot2) { - if (plot1.owner_ == null || plot2.owner_ == null) { + if (plot1.owner == null || plot2.owner == null) { return false; } HashSet owners = getOwners(plot1); @@ -76,7 +76,7 @@ public class PlotHandler { } public static boolean isAdded(Plot plot, final UUID uuid) { - if (plot.owner_ == null) { + if (plot.owner == null) { return false; } if (plot.denied.contains(uuid)) { 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 6852c839a..a408587d3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -116,7 +116,7 @@ public class ExpireManager { PlotSquared.log("&cDeleted expired plot: " + plot.id); PlotSquared.log("&3 - World: " + plot.world); if (plot.hasOwner()) { - PlotSquared.log("&3 - Owner: " + UUIDHandler.getName(plot.owner_)); + PlotSquared.log("&3 - Owner: " + UUIDHandler.getName(plot.owner)); } else { PlotSquared.log("&3 - Owner: Unowned"); } @@ -159,7 +159,7 @@ public class ExpireManager { final HashMap remove = new HashMap<>(); final Set keep = new HashSet<>(); for (final Plot plot : plots) { - final UUID uuid = plot.owner_; + final UUID uuid = plot.owner; if ((uuid == null) || remove.containsKey(uuid)) { Long stamp; if (uuid == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c586f59a1..6e8fbf665 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -90,7 +90,7 @@ public class MainUtil { final UUID uuid = plr.getUUID(); int count = 0; for (final Plot plot : PlotSquared.getPlots(world).values()) { - if (plot.hasOwner() && plot.owner_.equals(uuid) && plot.countsTowardsMax) { + if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { count++; } } @@ -369,10 +369,10 @@ public class MainUtil { if (plot == null) { return; } - if (plot.owner_ == null) { + if (plot.owner == null) { return; } - if (!plot.owner_.equals(uuid)) { + if (!plot.owner.equals(uuid)) { return; } ArrayList plots; @@ -427,7 +427,7 @@ public class MainUtil { final PlotId id_max = plots.get(plots.size() - 1); for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - if ((myplot == null) || myplot.owner_ == null || !(myplot.owner_.equals(uuid))) { + if ((myplot == null) || myplot.owner == null || !(myplot.owner.equals(uuid))) { return false; } final PlotId top = getTopPlot(myplot).id; @@ -770,7 +770,7 @@ public class MainUtil { for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); if (PlotSquared.getPlots(world).get(id) != null) { - if (PlotSquared.getPlots(world).get(id).owner_ != null) { + if (PlotSquared.getPlots(world).get(id).owner != null) { return false; } } @@ -782,7 +782,7 @@ public class MainUtil { public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { Plot p1 = PlotSquared.getPlots(world).get(current); Plot p2 = PlotSquared.getPlots(world).get(newPlot); - if (p1==null || p2 == null || p1.owner_ == null || !p1.owner_.equals(p2.owner_)) { + if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) { return false; } // Swap blocks @@ -807,7 +807,7 @@ public class MainUtil { final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); final Location top = MainUtil.getPlotTopLoc(world, current); final Plot currentPlot = MainUtil.getPlot(world, current); - if (currentPlot.owner_ == null) { + if (currentPlot.owner == null) { TaskManager.runTaskLater(whenDone, 1); return false; } @@ -845,7 +845,7 @@ public class MainUtil { final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); final Location top = MainUtil.getPlotTopLoc(world, current); final Plot currentPlot = MainUtil.getPlot(world, current); - if (currentPlot.owner_ == null) { + if (currentPlot.owner == null) { TaskManager.runTaskLater(whenDone, 1); return false; } @@ -862,7 +862,7 @@ public class MainUtil { for (final PlotId id : selection) { int x = id.x + offset_x; int y = id.y + offset_y; - Plot plot = createPlotAbs(currentPlot.owner_, getPlot(world, new PlotId(x, y))); + Plot plot = createPlotAbs(currentPlot.owner, getPlot(world, new PlotId(x, y))); if (currentPlot.settings.flags != null && currentPlot.settings.flags.size() > 0) { plot.settings.flags = currentPlot.settings.flags; DBFunc.setFlags(world, plot, currentPlot.settings.flags); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index e9936705f..7dde64ef3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -115,12 +115,12 @@ public class BukkitChunkManager extends ChunkManager { final Location bot = new Location(world, x1, 0, z1); Plot plot; plot = MainUtil.getPlot(bot); - if ((plot != null) && (plot.owner_ != null)) { + if ((plot != null) && (plot.owner != null)) { return plot; } final Location top = new Location(world, x2, 0, z2); plot = MainUtil.getPlot(top); - if ((plot != null) && (plot.owner_ != null)) { + if ((plot != null) && (plot.owner != null)) { return plot; } return null; From 8a63b8937f31de7811a3ea1f1881752d058ad0d5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Mar 2015 21:16:39 +1100 Subject: [PATCH 056/223] fix portal NPE --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 3 +++ 1 file changed, 3 insertions(+) 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 fa11227bc..8863e0b6b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -783,6 +783,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onTeleport(final PlayerTeleportEvent event) { + if (event.getTo() == null || event.getFrom() == null) { + return; + } final Location f = BukkitUtil.getLocation(event.getFrom()); final Location t = BukkitUtil.getLocation(event.getTo()); final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ()); From 91b7b41cfc94f16d7776bad7f80f155369dba678 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Mar 2015 23:04:48 +1100 Subject: [PATCH 057/223] Added mob cap flag --- .../com/intellectualcrafters/plot/PlotSquared.java | 4 ++++ .../plot/listeners/PlayerEvents.java | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index e7d97e31b..53399b903 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -676,6 +676,7 @@ public class PlotSquared { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); + final List intFlags = Arrays.asList("mob-cap"); for (final String flag : stringFlags) { FlagManager.addFlag(new AbstractFlag(flag)); } @@ -685,6 +686,9 @@ public class PlotSquared { for (final String flag : booleanFlags) { FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue())); } + for (final String flag : intFlags) { + FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue())); + } FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue())); 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 8863e0b6b..c8671f1be 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -90,6 +90,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -704,6 +705,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi event.setCancelled(true); return; } + Plot plot = MainUtil.getPlot(loc); + if (plot != null && plot.owner != null) { + Flag capFlag = FlagManager.getPlotFlag(plot, "mob-cap"); + if (capFlag == null) { + return; + } + int cap = ((Integer) capFlag.getValue()); + int mobs = ChunkManager.manager.countEntities(plot); + if (mobs >= cap) { + event.setCancelled(true); + } + } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) From 294c11a534e0495ce5a42043c6d836a07f422f21 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 20 Mar 2015 23:10:37 +1100 Subject: [PATCH 058/223] Fixed UnsignedInteger flag value --- .../main/java/com/intellectualcrafters/plot/flag/FlagValue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index ac7b91ed0..7a13427f0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -133,7 +133,7 @@ public abstract class FlagValue { public Integer parse(final String t) { try { final int value = Integer.parseInt(t); - if (value >= 0) { + if (value < 0) { return null; } return value; From e2f372927d36108e7ca6f9690ce73ee7fbed06d9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Mar 2015 00:09:51 +1100 Subject: [PATCH 059/223] Added animal-cap, hostile-cap, mob-cap --- .../plot/PlotSquared.java | 2 +- .../plot/commands/Merge.java | 5 +- .../plot/listeners/PlayerEvents.java | 47 ++++++++++++++--- .../plot/util/ChunkManager.java | 2 +- .../plot/util/bukkit/BukkitChunkManager.java | 50 ++++++++++++++++--- 5 files changed, 89 insertions(+), 17 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 53399b903..ab388e4a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -676,7 +676,7 @@ public class PlotSquared { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); - final List intFlags = Arrays.asList("mob-cap"); + final List intFlags = Arrays.asList("entity-cap", "animal-cap", "hostile-cap"); for (final String flag : stringFlags) { FlagManager.addFlag(new AbstractFlag(flag)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index a4d3bbca3..ceb41623c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -159,7 +159,9 @@ public class Merge extends SubCommand { } if (multiMerge) { for (final UUID uuid : multiUUID) { - CmdConfirm.addPending(UUIDHandler.getPlayer(uuid), "merge request", new Runnable() { + PlotPlayer accepter = UUIDHandler.getPlayer(uuid); + MainUtil.sendMessage(accepter, "ADDING REQUEST FOR: " + accepter.getName()); + CmdConfirm.addPending(accepter, "merge request", new Runnable() { @Override public void run() { PlotPlayer accepter = UUIDHandler.getPlayer(uuid); @@ -197,6 +199,7 @@ public class Merge extends SubCommand { } }); } + MainUtil.sendMessage(plr, "SENT MERGE REQUEST!"); return true; } final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); 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 c8671f1be..22c312b0b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -682,7 +682,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void MobSpawn(final CreatureSpawnEvent event) { - if (event.getEntity() instanceof Player) { + Entity entity = event.getEntity(); + if (entity instanceof Player) { return; } final Location loc = BukkitUtil.getLocation(event.getLocation()); @@ -707,14 +708,46 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null && plot.owner != null) { - Flag capFlag = FlagManager.getPlotFlag(plot, "mob-cap"); - if (capFlag == null) { + Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap"); + Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap"); + Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap"); + if (!(entity instanceof Creature)) { return; } - int cap = ((Integer) capFlag.getValue()); - int mobs = ChunkManager.manager.countEntities(plot); - if (mobs >= cap) { - event.setCancelled(true); + if (entityFlag == null) { + if (animalFlag == null && (entity instanceof Animals)) { + return; + } + if (monsterFlag == null && (entity instanceof Monster)) { + return; + } + } + int[] mobs = ChunkManager.manager.countEntities(plot); + if (entity instanceof Creature) { + if (entityFlag != null) { + int cap = ((Integer) entityFlag.getValue()); + if (mobs[0] >= cap) { + event.setCancelled(true); + return; + } + } + } + if (entity instanceof Animals) { + if (animalFlag != null) { + int cap = ((Integer) animalFlag.getValue()); + if (mobs[1] >= cap) { + event.setCancelled(true); + } + } + return; + } + if (entity instanceof Monster) { + if (monsterFlag != null) { + int cap = ((Integer) monsterFlag.getValue()); + if (mobs[2] >= cap) { + event.setCancelled(true); + } + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index a007f5009..3cffaf91f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -22,7 +22,7 @@ public abstract class ChunkManager { return new ChunkLoc(x, z); } - public abstract int countEntities(Plot plot); + public abstract int[] countEntities(Plot plot); public abstract boolean loadChunk(String world, ChunkLoc loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 7dde64ef3..6defeac07 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -34,6 +34,8 @@ import org.bukkit.block.Sign; import org.bukkit.block.Skull; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.Animals; +import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -867,8 +869,8 @@ public class BukkitChunkManager extends ChunkManager { } @Override - public int countEntities(Plot plot) { - int count = 0; + public int[] countEntities(Plot plot) { + int[] count = new int[3]; World world = BukkitUtil.getWorld(plot.world); Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); @@ -899,18 +901,33 @@ public class BukkitChunkManager extends ChunkManager { if (doWhole) { for (final Entity entity : entities) { + if (!(entity instanceof Creature)) { + continue; + } org.bukkit.Location loc = entity.getLocation(); Chunk chunk = loc.getChunk(); if (chunks.contains(chunk)) { int X = chunk.getX(); int Z = chunk.getX(); if (X > bx && X < tx && Z > bz && Z < tz) { - count++; + count[0]++; + if (entity instanceof Animals) { + count[1]++; + } + else { + count[2]++; + } } else { final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc)); if (plot.id.equals(id)) { - count++; + count[0]++; + if (entity instanceof Animals) { + count[1]++; + } + else { + count[2]++; + } } } } @@ -923,17 +940,36 @@ public class BukkitChunkManager extends ChunkManager { Entity[] ents = chunk.getEntities(); if (X == bx || X == tx || Z == bz || Z == tz) { for (final Entity entity : ents) { + if (!(entity instanceof Creature)) { + continue; + } final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { - count++; + count[0]++; + if (entity instanceof Animals) { + count[1]++; + } + else { + count[2]++; + } } } } else { - count += ents.length; + for (final Entity entity : ents) { + if (!(entity instanceof Creature)) { + continue; + } + count[0]++; + if (entity instanceof Animals) { + count[1]++; + } + else { + count[2]++; + } + } } } - return count; } return count; } From e50608009b3f0d50098a6d38ed46255d019ad2f7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Mar 2015 00:10:12 +1100 Subject: [PATCH 060/223] rename --- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 2 +- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index ab388e4a8..4138a6ef0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -676,7 +676,7 @@ public class PlotSquared { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); - final List intFlags = Arrays.asList("entity-cap", "animal-cap", "hostile-cap"); + final List intFlags = Arrays.asList("entity-cap", "animal-cap", "mop-cap"); for (final String flag : stringFlags) { FlagManager.addFlag(new AbstractFlag(flag)); } 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 22c312b0b..e728cc71a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -710,7 +710,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (plot != null && plot.owner != null) { Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap"); Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap"); - Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap"); + Flag monsterFlag = FlagManager.getPlotFlag(plot, "mop-cap"); if (!(entity instanceof Creature)) { return; } From c9b621ce59f11c628cefdaff0946de7acd2054a5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Mar 2015 00:14:53 +1100 Subject: [PATCH 061/223] Potential fix for merge requesting --- .../main/java/com/intellectualcrafters/plot/commands/Merge.java | 1 + 1 file changed, 1 insertion(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index ceb41623c..cff3c594b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -156,6 +156,7 @@ public class Merge extends SubCommand { } multiMerge = true; multiPlots.add(myid); + multiUUID.add(u2); } if (multiMerge) { for (final UUID uuid : multiUUID) { From ab8ece4b6d367a8138774035823020854961a84e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Mar 2015 00:43:21 +1100 Subject: [PATCH 062/223] *yet another fix --- .../java/com/intellectualcrafters/plot/commands/Merge.java | 7 +++---- .../main/java/com/intellectualcrafters/plot/config/C.java | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index cff3c594b..8977d8eb2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -161,8 +161,7 @@ public class Merge extends SubCommand { if (multiMerge) { for (final UUID uuid : multiUUID) { PlotPlayer accepter = UUIDHandler.getPlayer(uuid); - MainUtil.sendMessage(accepter, "ADDING REQUEST FOR: " + accepter.getName()); - CmdConfirm.addPending(accepter, "merge request", new Runnable() { + CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() { @Override public void run() { PlotPlayer accepter = UUIDHandler.getPlayer(uuid); @@ -170,7 +169,7 @@ public class Merge extends SubCommand { if (multiUUID.size() == 0) { PlotPlayer pp = UUIDHandler.getPlayer(u1); if (pp == null) { - sendMessage(plr, C.MERGE_NOT_VALID); + sendMessage(accepter, C.MERGE_NOT_VALID); return; } final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); @@ -200,7 +199,7 @@ public class Merge extends SubCommand { } }); } - MainUtil.sendMessage(plr, "SENT MERGE REQUEST!"); + MainUtil.sendMessage(plr, C.MERGE_REQUESTED); return true; } final PlotWorld plotWorld = PlotSquared.getPlotWorld(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index dc7a5b53d..5a003e28e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -219,6 +219,8 @@ public enum C { MERGE_NOT_VALID("$2This merge request is no longer valid."), MERGE_ACCEPTED("$2The merge request has been accepted"), SUCCESS_MERGE("$2Plots have been merged!"), + MERGE_REQUESTED("$2Successfully sent a merge request"), + MERGE_REQUEST_CONFIRM("merge request from %s"), /* * Commands */ From 1a3fe1426a4a96def27e5de496a14f706f9c37ae Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Mar 2015 00:53:24 +1100 Subject: [PATCH 063/223] Fixed NPE --- .../java/com/intellectualcrafters/plot/commands/Merge.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 8977d8eb2..731ded1bc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -141,11 +141,11 @@ public class Merge extends SubCommand { final UUID u1 = plot.owner; for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - UUID u2 = myplot.owner; - if (myplot == null || u2 == null) { + if (myplot == null || myplot.owner == null) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } + UUID u2 = myplot.owner; if (u2.equals(u1)) { continue; } From 5d917933953547357288085908916aae1ac99d11 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Mar 2015 01:01:35 +1100 Subject: [PATCH 064/223] Fixed invalid biome error --- PlotSquared/pom.xml | 2 +- .../plot/util/bukkit/BukkitUtil.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index b2d836294..aa18cace3 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.11 + 2.8.12 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index b76150681..478d8502f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -242,11 +242,16 @@ public class BukkitUtil extends BlockManager { @Override public int getBiomeFromString(final String biomeStr) { - final Biome biome = Biome.valueOf(biomeStr.toUpperCase()); - if (biome == null) { + try { + final Biome biome = Biome.valueOf(biomeStr.toUpperCase()); + if (biome == null) { + return -1; + } + return Arrays.asList(Biome.values()).indexOf(biome); + } + catch (IllegalArgumentException e) { return -1; } - return Arrays.asList(Biome.values()).indexOf(biome); } @Override From fcbfbae02ed09d131788023205e495a2ae3d24f1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Mar 2015 22:43:46 +1100 Subject: [PATCH 065/223] Fixes #214 --- .../java/com/intellectualcrafters/plot/BukkitMain.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index c9ca0e064..839cd4079 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot; import java.io.File; import java.util.Arrays; +import java.util.List; import net.milkbowl.vault.economy.Economy; @@ -36,6 +37,7 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEvents; +import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.util.BlockManager; @@ -101,6 +103,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } getServer().getPluginManager().registerEvents(new WorldEvents(), this); + List worlds = Bukkit.getWorlds(); + if (worlds.size() > 0) { + UUIDHandler.cacheAll(worlds.get(0).getName()); + for (World world : worlds) { + Bukkit.getServer().unloadWorld(world, true); + } + } } @Override From f45d1f4c0b98e77231d56d36fc358ff876eb5d5c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 00:48:02 +1100 Subject: [PATCH 066/223] Allow swapping of region --- .../com/intellectualcrafters/plot/util/ChunkManager.java | 2 ++ .../plot/util/bukkit/BukkitChunkManager.java | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index 3cffaf91f..8a36782c4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -41,4 +41,6 @@ public abstract class ChunkManager { public abstract void clearAllEntities(final Plot plot); public abstract void swap(String world, PlotId id, PlotId plotid); + + public abstract void swap(String worldname, Location bot1, Location top1, Location bot2, Location top2); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 6defeac07..3c030d7aa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -848,7 +848,14 @@ public class BukkitChunkManager extends ChunkManager { Location bot2 = MainUtil.getPlotBottomLoc(worldname, pos2).add(1, 0, 1); Location top2 = MainUtil.getPlotTopLoc(worldname, pos2); + swap(worldname, bot1, top1, bot2, top2); + clearAllEntities(MainUtil.getPlot(worldname, pos1)); + clearAllEntities(MainUtil.getPlot(worldname, pos2)); + } + + @Override + public void swap(final String worldname, final Location bot1, final Location top1, Location bot2, Location top2) { final RegionWrapper region1 = new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); final RegionWrapper region2 = new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); final World world = Bukkit.getWorld(bot1.getWorld()); @@ -863,8 +870,6 @@ public class BukkitChunkManager extends ChunkManager { swapChunk(world, chunk1, chunk2, region1, region2); } } - clearAllEntities(MainUtil.getPlot(worldname, pos1)); - clearAllEntities(MainUtil.getPlot(worldname, pos2)); // FIXME swap plots } From d9124dcfb89d2b83fc313643df62523cbee6577d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 00:49:03 +1100 Subject: [PATCH 067/223] Allow swapping only the plot data (not blocks) --- .../plot/util/MainUtil.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 6e8fbf665..0b0af1eca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -801,6 +801,27 @@ public class MainUtil { DBFunc.dbManager.swapPlots(p2, p1); return true; } + + public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { + Plot p1 = PlotSquared.getPlots(world).get(current); + Plot p2 = PlotSquared.getPlots(world).get(newPlot); + if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) { + return false; + } + // Swap cached + PlotId temp = new PlotId(p1.id.x.intValue(), p1.id.y.intValue()); + p1.id.x = p2.id.x.intValue(); + p1.id.y = p2.id.y.intValue(); + p2.id.x = temp.x; + p2.id.y = temp.y; + PlotSquared.getPlots(world).remove(p1.id); + PlotSquared.getPlots(world).remove(p2.id); + PlotSquared.getPlots(world).put(p1.id, p1); + PlotSquared.getPlots(world).put(p2.id, p2); + // Swap database + DBFunc.dbManager.swapPlots(p2, p1); + return true; + } public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current); From 96eb4af5578fd73aae4fa12a850dac819357dca5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 01:43:19 +1100 Subject: [PATCH 068/223] Recover from invalid merge --- .../intellectualcrafters/plot/util/MainUtil.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0b0af1eca..6251225db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -1095,12 +1095,21 @@ public class MainUtil { public static Plot getTopPlot(final Plot plot) { if (plot.settings.getMerged(2)) { - return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1))); + final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1)); + if (p == null) { + return plot; + } + return getTopPlot(p); } if (plot.settings.getMerged(1)) { - return getTopPlot(PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y))); + final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y)); + if (p == null) { + return plot; + } + return getTopPlot(p); } return plot; + } public static PlotId getSize(final String world, final Plot plot) { From d5d4b570a12191f0e4cf9c6a77bf966424f68205 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 22:10:20 +1100 Subject: [PATCH 069/223] Started work on multi-plot swapping --- .../plot/commands/Swap.java | 88 +++++++++++++------ .../intellectualcrafters/plot/config/C.java | 3 + 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index e64f33fa6..285a80d57 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -20,12 +20,18 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; + import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotCluster; +import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -42,6 +48,7 @@ public class Swap extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { + MainUtil.sendMessage(plr, "&cThis command has not been optimized for large selections yet. Please bug me if this becomes an issue."); if (args.length < 1) { MainUtil.sendMessage(plr, C.NEED_PLOT_ID); MainUtil.sendMessage(plr, C.SWAP_SYNTAX); @@ -56,38 +63,69 @@ public class Swap extends SubCommand { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } - if ((plot != null) && plot.settings.isMerged()) { - MainUtil.sendMessage(plr, C.UNLINK_REQUIRED); + + Plot bot1 = MainUtil.getBottomPlot(plot); + Plot top1 = MainUtil.getTopPlot(plot); + + PlotId id2 = PlotId.fromString(args[0]); + if (id2 == null) { + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } - final String id = args[0]; - PlotId plotid; final String world = loc.getWorld(); - try { - plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); - final Plot plot2 = PlotSquared.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || !(plot2.owner.equals(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { - MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); - return false; - } - } catch (final Exception e) { - MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); + Plot plot2 = MainUtil.getPlot(world, id2); + PlotId id3 = new PlotId(id2.x + top1.id.x - bot1.id.x, id2.y + top1.id.y - bot1.id.y); + Plot plot3 = MainUtil.getPlot(world, id3); + + // Getting secon selection + Plot bot2 = MainUtil.getBottomPlot(plot2); + Plot top2 = MainUtil.getTopPlot(plot3); + + // cancel swap if intersection + PlotCluster cluster1 = new PlotCluster(world, bot1.id, top1.id, null); + PlotClusterId cluster2id = new PlotClusterId(bot2.id, top2.id); + if (ClusterManager.intersects(cluster1, cluster2id)) { + MainUtil.sendMessage(plr, C.SWAP_OVERLAP); + return false; + } + + // Check dimensions + if (top1.id.x - bot1.id.x != top2.id.x - bot2.id.x || top1.id.y - bot1.id.y != top2.id.y - bot2.id.y ) { + MainUtil.sendMessage(plr, C.SWAP_DIMENSIONS, "1"); MainUtil.sendMessage(plr, C.SWAP_SYNTAX); return false; } - assert plot != null; - if (plot.id.equals(plotid)) { - MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); - MainUtil.sendMessage(plr, C.SWAP_SYNTAX); - return false; + + // Getting selections as ids + final ArrayList selection1 = MainUtil.getPlotSelectionIds(bot1.id, top1.id); + final ArrayList selection2 = MainUtil.getPlotSelectionIds(bot2.id, top2.id); + + // Getting selections as location coordinates + Location pos1 = MainUtil.getPlotBottomLocAbs(world, bot1.id).add(1, 0, 1); + Location pos2 = MainUtil.getPlotTopLocAbs(world, top1.id); + Location pos3 = MainUtil.getPlotBottomLocAbs(world, bot2.id).add(1, 0, 1); + Location pos4 = MainUtil.getPlotTopLocAbs(world, top2.id); + + // Swapping the blocks, states and entites + ChunkManager.manager.swap(world, pos1, pos2, pos3, pos4); + + // Swapping the plot data + for (int i = 0; i < selection1.size(); i++) { + final boolean last = i == selection1.size() - 1; + PlotId swaper = selection1.get(i); + PlotId swapee = selection2.get(i); + MainUtil.swapData(world, swaper, swapee, new Runnable() { + @Override + public void run() { + if (last) { + MainUtil.sendMessage(plr, C.SWAP_SUCCESS); + MainUtil.update(plr.getLocation()); + } + } + }); } - MainUtil.swap(world, plot.id, plotid, new Runnable() { - @Override - public void run() { - // FIXME not implemented yet - } - }); - MainUtil.update(plr.getLocation()); + MainUtil.sendMessage(plr, C.STARTED_SWAP); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 5a003e28e..fd0f23c9d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -95,8 +95,11 @@ public enum C { /* * Swap */ + SWAP_OVERLAP("$2The proposed areas are not allowed to overlap"), + SWAP_DIMENSIONS("$2The proposed areas must have comparable dimensions"), SWAP_SYNTAX("$2/plots swap "), SWAP_SUCCESS("$4Successfully swapped plots"), + STARTED_SWAP("$2Started plot swap task. You will be notified when it finishes"), /* * Comment */ From e5e470d124f20d0b7739ff21eb1a2383dbe72a5c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 22:15:26 +1100 Subject: [PATCH 070/223] autodetect move DB if null --- .../plot/commands/Swap.java | 2 +- .../plot/util/MainUtil.java | 40 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 285a80d57..bda380b4c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -112,7 +112,7 @@ public class Swap extends SubCommand { // Swapping the plot data for (int i = 0; i < selection1.size(); i++) { - final boolean last = i == selection1.size() - 1; + final boolean last = i == selection1.size() - 1; PlotId swaper = selection1.get(i); PlotId swapee = selection2.get(i); MainUtil.swapData(world, swaper, swapee, new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 6251225db..b4ed6baa9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -805,7 +805,18 @@ public class MainUtil { public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { Plot p1 = PlotSquared.getPlots(world).get(current); Plot p2 = PlotSquared.getPlots(world).get(newPlot); - if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) { + if (p1 == null || p1.owner == null) { + if (p2 != null && p2.owner != null) { + moveData(world, newPlot, current, whenDone); + return true; + } + return false; + } + if (p2 == null || p2.owner == null) { + if (p1 != null && p1.owner != null) { + moveData(world, current, newPlot, whenDone); + return true; + } return false; } // Swap cached @@ -823,6 +834,33 @@ public class MainUtil { return true; } + public static boolean moveData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { + final Plot currentPlot = MainUtil.getPlot(world, current); + if (currentPlot.owner == null) { + TaskManager.runTaskLater(whenDone, 1); + return false; + } + final Plot pos1 = getBottomPlot(currentPlot); + final Plot pos2 = getTopPlot(currentPlot); + final PlotId size = MainUtil.getSize(world, currentPlot); + if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { + TaskManager.runTaskLater(whenDone, 1); + return false; + } + final int offset_x = newPlot.x - pos1.id.x; + final int offset_y = newPlot.y - pos1.id.y; + final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); + for (final PlotId id : selection) { + DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); + final Plot plot = PlotSquared.getPlots(world).get(id); + PlotSquared.getPlots(world).remove(id); + plot.id.x += offset_x; + plot.id.y += offset_y; + PlotSquared.getPlots(world).put(plot.id, plot); + } + return true; + } + public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current); final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); From 05b8b8a750fd9a496f7d04c31f5d997b99b29db9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 22:22:37 +1100 Subject: [PATCH 071/223] Fix notify for swap --- .../main/java/com/intellectualcrafters/plot/util/MainUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index b4ed6baa9..8c97d9723 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -831,6 +831,7 @@ public class MainUtil { PlotSquared.getPlots(world).put(p2.id, p2); // Swap database DBFunc.dbManager.swapPlots(p2, p1); + TaskManager.runTask(whenDone); return true; } From a24aa2fccb244c96efc0dcc0cad40ab453fba9eb Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Mar 2015 22:25:06 +1100 Subject: [PATCH 072/223] Include border if possible --- .../intellectualcrafters/plot/commands/Swap.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index bda380b4c..596abad8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -102,10 +102,17 @@ public class Swap extends SubCommand { final ArrayList selection2 = MainUtil.getPlotSelectionIds(bot2.id, top2.id); // Getting selections as location coordinates - Location pos1 = MainUtil.getPlotBottomLocAbs(world, bot1.id).add(1, 0, 1); - Location pos2 = MainUtil.getPlotTopLocAbs(world, top1.id); - Location pos3 = MainUtil.getPlotBottomLocAbs(world, bot2.id).add(1, 0, 1); - Location pos4 = MainUtil.getPlotTopLocAbs(world, top2.id); + Location pos1 = MainUtil.getPlotBottomLocAbs(world, bot1.id); + Location pos2 = MainUtil.getPlotTopLocAbs(world, top1.id).subtract(1, 0, 1); + Location pos3 = MainUtil.getPlotBottomLocAbs(world, bot2.id); + Location pos4 = MainUtil.getPlotTopLocAbs(world, top2.id).subtract(1, 0, 1); + + if (MainUtil.getPlot(pos2) != null) { + pos1.add(1, 0, 1); + pos2.add(1, 0, 1); + pos3.add(1, 0, 1); + pos4.add(1, 0, 1); + } // Swapping the blocks, states and entites ChunkManager.manager.swap(world, pos1, pos2, pos3, pos4); From 49f8ffaed4e147f71a2130a6c74a259a10cfe118 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 01:16:33 +1100 Subject: [PATCH 073/223] World comparisons (working towards cross world plot moving) --- .../plot/object/PlotWorld.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 9af2659b9..345292238 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -93,6 +93,20 @@ public abstract class PlotWorld { public PlotWorld(final String worldname) { this.worldname = worldname; } + + public boolean compare(PlotWorld plotworld) { + ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds"); + for (ConfigurationNode setting : plotworld.getSettingNodes()) { + Object constant = section.get(plotworld.worldname + "." + setting.getConstant()); + if (constant == null) { + return false; + } + if (!constant.equals(section.get(this.worldname + "." + setting.getConstant()))) { + return false; + } + } + return true; + } /** * When a world is created, the following method will be called for each From 844afb018302d0933f8e161e20748c8ebda655c3 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 01:27:42 +1100 Subject: [PATCH 074/223] use equals --- .../intellectualcrafters/plot/object/PlotWorld.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 345292238..b204492be 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -94,7 +94,18 @@ public abstract class PlotWorld { this.worldname = worldname; } - public boolean compare(PlotWorld plotworld) { + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + PlotWorld plotworld = (PlotWorld) obj; ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds"); for (ConfigurationNode setting : plotworld.getSettingNodes()) { Object constant = section.get(plotworld.worldname + "." + setting.getConstant()); From b4fab94192daaa62503272973f816613c2abb0f3 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 14:11:28 +1100 Subject: [PATCH 075/223] Finish cross world plot moving [UNTESTED] --- .../intellectualcrafters/plot/BukkitMain.java | 1 - .../plot/api/PlotAPI.java | 3 - .../plot/commands/Condense.java | 4 +- .../plot/commands/Confirm.java | 1 - .../plot/commands/Home.java | 1 - .../plot/commands/Inbox.java | 1 - .../plot/commands/Info.java | 2 - .../plot/commands/Move.java | 24 +++++-- .../plot/commands/Purge.java | 1 - .../plot/commands/Rate.java | 1 - .../plot/commands/Swap.java | 2 - .../plot/commands/Unclaim.java | 1 - .../intellectualcrafters/plot/config/C.java | 3 +- .../plot/database/AbstractDB.java | 2 +- .../plot/database/DBFunc.java | 4 +- .../plot/generator/HybridGen.java | 1 - .../plot/generator/HybridPlotManager.java | 1 - .../plot/object/Plot.java | 1 - .../plot/object/PlotGenerator.java | 3 - .../plot/titles/HackTitleManager.java | 1 - .../plot/util/MainUtil.java | 63 +++++++++---------- .../plot/util/bukkit/BukkitChunkManager.java | 32 ++++++---- 22 files changed, 76 insertions(+), 77 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 839cd4079..7dcc1b543 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -37,7 +37,6 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEvents; -import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.util.BlockManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index f49f80a5f..84ca7546b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.configuration.file.YamlConfiguration; @@ -48,11 +47,9 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.PlotSquaredException; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.uuid.UUIDWrapper; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 77ba45daa..4beff2d08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -98,7 +98,7 @@ public class Condense extends SubCommand { MainUtil.sendMessage(plr, "NO PLOTS FOUND"); return false; } - MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() { + MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), new Runnable() { @Override public void run() { if (!TASK) { @@ -140,7 +140,7 @@ public class Condense extends SubCommand { return; } sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0)); - MainUtil.move(worldname, to_move.get(0), free.get(0), this); + MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), this); } }); TASK = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java index 90d0badaf..364ab5bd0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.CmdInstance; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 838ea3b0c..3daef2e5f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -27,7 +27,6 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret 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 544219a82..efce9a794 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -34,7 +34,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Inbox extends SubCommand { public Inbox() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 9fc861387..91a1fbd49 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -21,9 +21,7 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.UUID; import org.apache.commons.lang.StringUtils; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 0d50acb03..c6fd03374 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -20,11 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -55,18 +57,32 @@ public class Move extends SubCommand { return false; } final String world = loc.getWorld(); - final PlotId plot2 = MainUtil.parseId(args[0]); - if ((plot2 == null)) { + final PlotId plot2id = MainUtil.parseId(args[0]); + if ((plot2id == null)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); return false; } - if (plot1.id.equals(plot2)) { + String world2; + if (args.length == 2) { + PlotWorld other = PlotSquared.getPlotWorld(args[1]); + PlotWorld current = PlotSquared.getPlotWorld(loc.getWorld()); + if (other == null || current == null || !other.equals(current)) { + MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE); + return false; + } + world2 = other.worldname; + } + else { + world2 = world; + } + Plot plot2 = MainUtil.getPlot(world2, plot2id); + if (plot1.equals(plot2)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); return false; } - if (MainUtil.move(world, plot1.id, plot2, new Runnable() { + if (MainUtil.move(plot1, plot2, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.MOVE_SUCCESS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index 2fd574adc..45446fd33 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 9b46e38f3..dba751312 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -26,7 +26,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Rate extends SubCommand { /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 596abad8d..aadda2c06 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -34,7 +33,6 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * Created 2014-08-01 for PlotSquared diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index f4a468829..a296887dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -30,7 +30,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Unclaim extends SubCommand { public Unclaim() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index fd0f23c9d..a15aa7dd0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -32,7 +32,7 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation; /** * Captions class. * - * @author Citymonstret + * @author Citymonstret */ public enum C { /* @@ -260,6 +260,7 @@ public enum C { NOT_IN_PLOT("$2You're not in a plot"), NOT_IN_CLUSTER("$2You must be within a plot cluster to perform that action"), NOT_IN_PLOT_WORLD("$2You're not in a plot world"), + PLOTWORLD_INCOMPATIBLE("$2The two worlds must be compatible"), NOT_VALID_WORLD("$2That is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD("$2That is not a valid plot world (case sensitive)"), NO_PLOTS("$2You don't have any plots"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 4c45eb927..f5af819de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -328,5 +328,5 @@ public interface AbstractDB { public void resizeCluster(PlotCluster current, PlotClusterId resize); - public void movePlot(String world, PlotId originalPlot, PlotId newPlot); + public void movePlot(Plot originalPlot, Plot newPlot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 6c760e337..c43509403 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -50,8 +50,8 @@ public class DBFunc { */ public static AbstractDB dbManager; - public static void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { - dbManager.movePlot(world, originalPlot, newPlot); + public static void movePlot(final Plot originalPlot, final Plot newPlot) { + dbManager.movePlot(originalPlot, newPlot); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 0b7a0ab0c..9fae1fac5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -32,7 +32,6 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 4bdd53197..4a05adbd4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index e192be634..bf0056eeb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -27,7 +27,6 @@ import java.util.UUID; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * The plot class diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 3af8c37ce..7296708cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -21,10 +21,7 @@ package com.intellectualcrafters.plot.object; import java.util.List; -import java.util.Random; -import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java index 52034bfa5..53ef4af64 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/HackTitleManager.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.titles; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 8c97d9723..a8f8fef2a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -25,7 +25,6 @@ import java.util.HashMap; import java.util.UUID; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.commands.Claim; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -41,7 +40,6 @@ import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.SendChunk; /** * plot functions @@ -807,14 +805,14 @@ public class MainUtil { Plot p2 = PlotSquared.getPlots(world).get(newPlot); if (p1 == null || p1.owner == null) { if (p2 != null && p2.owner != null) { - moveData(world, newPlot, current, whenDone); + moveData(p2, p1, whenDone); return true; } return false; } if (p2 == null || p2.owner == null) { if (p1 != null && p1.owner != null) { - moveData(world, current, newPlot, whenDone); + moveData(p1, p2, whenDone); return true; } return false; @@ -835,59 +833,58 @@ public class MainUtil { return true; } - public static boolean moveData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { - final Plot currentPlot = MainUtil.getPlot(world, current); - if (currentPlot.owner == null) { + public static boolean moveData(final Plot plot1, final Plot plot2, final Runnable whenDone) { + if (plot1.owner == null) { TaskManager.runTaskLater(whenDone, 1); return false; } - final Plot pos1 = getBottomPlot(currentPlot); - final Plot pos2 = getTopPlot(currentPlot); - final PlotId size = MainUtil.getSize(world, currentPlot); - if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { + final Plot pos1 = getBottomPlot(plot1); + final Plot pos2 = getTopPlot(plot1); + final PlotId size = MainUtil.getSize(plot1.world, plot1); + if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) { TaskManager.runTaskLater(whenDone, 1); return false; } - final int offset_x = newPlot.x - pos1.id.x; - final int offset_y = newPlot.y - pos1.id.y; + final int offset_x = plot2.id.x - pos1.id.x; + final int offset_y = plot2.id.y - pos1.id.y; final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); for (final PlotId id : selection) { - DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); - final Plot plot = PlotSquared.getPlots(world).get(id); - PlotSquared.getPlots(world).remove(id); + DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); + final Plot plot = PlotSquared.getPlots(plot1.world).get(id); + PlotSquared.getPlots(plot1.world).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; - PlotSquared.getPlots(world).put(plot.id, plot); + PlotSquared.getPlots(plot2.world).put(plot.id, plot); } + TaskManager.runTaskLater(whenDone, 1); return true; } - public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) { - final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current); - final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot); - final Location top = MainUtil.getPlotTopLoc(world, current); - final Plot currentPlot = MainUtil.getPlot(world, current); - if (currentPlot.owner == null) { + public static boolean move(final Plot plot1, final Plot plot2, final Runnable whenDone) { + final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); + final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); + final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id); + if (plot1.owner == null) { TaskManager.runTaskLater(whenDone, 1); return false; } - final Plot pos1 = getBottomPlot(currentPlot); - final Plot pos2 = getTopPlot(currentPlot); - final PlotId size = MainUtil.getSize(world, currentPlot); - if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { + final Plot pos1 = getBottomPlot(plot1); + final Plot pos2 = getTopPlot(plot1); + final PlotId size = MainUtil.getSize(plot1.world, plot1); + if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) { TaskManager.runTaskLater(whenDone, 1); return false; } - final int offset_x = newPlot.x - pos1.id.x; - final int offset_y = newPlot.y - pos1.id.y; + final int offset_x = plot2.id.x - pos1.id.x; + final int offset_y = plot2.id.y - pos1.id.y; final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); for (final PlotId id : selection) { - DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y)); - final Plot plot = PlotSquared.getPlots(world).get(id); - PlotSquared.getPlots(world).remove(id); + DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); + final Plot plot = PlotSquared.getPlots(plot1.world).get(id); + PlotSquared.getPlots(plot1.world).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; - PlotSquared.getPlots(world).put(plot.id, plot); + PlotSquared.getPlots(plot2.world).put(plot.id, plot); } ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 3c030d7aa..dc5409fec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -155,28 +155,34 @@ public class BukkitChunkManager extends ChunkManager { index.increment(); final int relX = newPos.getX() - pos1.getX(); final int relZ = newPos.getZ() - pos1.getZ(); + final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - final World world = Bukkit.getWorld(pos1.getWorld()); - final Chunk c1 = world.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4); - final Chunk c2 = world.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4); - final Chunk c3 = world.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4); - final Chunk c4 = world.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4); + final World oldWorld = Bukkit.getWorld(pos1.getWorld()); + final World newWorld = Bukkit.getWorld(newPos.getWorld()); + + final Chunk c1 = newWorld.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4); + final Chunk c2 = newWorld.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4); + final Chunk c3 = newWorld.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4); + final Chunk c4 = newWorld.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4); + final int sx = pos1.getX(); final int sz = pos1.getZ(); final int ex = pos2.getX(); final int ez = pos2.getZ(); + final int c1x = c1.getX(); final int c1z = c1.getZ(); final int c2x = c2.getX(); final int c2z = c2.getZ(); final int c3x = c3.getX(); final int c3z = c3.getZ(); + final ArrayList chunks = new ArrayList<>(); final ArrayList toGenerate = new ArrayList<>(); // Load chunks for (int x = c2x; x <= c3x; x++) { for (int z = c2z; z <= c3z; z++) { - final Chunk chunk = world.getChunkAt(x, z); + final Chunk chunk = newWorld.getChunkAt(x, z); toGenerate.add(chunk); } } @@ -198,17 +204,17 @@ public class BukkitChunkManager extends ChunkManager { initMaps(); for (int x = c1x; x <= c2x; x++) { for (int z = c1z; z <= c2z; z++) { - final Chunk chunk = world.getChunkAt(x, z); + final Chunk chunk = oldWorld.getChunkAt(x, z); chunks.add(chunk); chunk.load(false); saveEntitiesIn(chunk, region); } } - restoreEntities(world, relX, relZ); + restoreEntities(newWorld, relX, relZ); // Copy blocks final MutableInt mx = new MutableInt(sx); final Integer currentIndex = index.toInteger(); - final int maxY = world.getMaxHeight(); + final int maxY = oldWorld.getMaxHeight(); final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { @@ -216,17 +222,17 @@ public class BukkitChunkManager extends ChunkManager { while ((System.currentTimeMillis() - start) < 25) { final int xv = mx.intValue(); for (int z = sz; z <= ez; z++) { - saveBlocks(world, maxY, xv, z); + saveBlocks(oldWorld, maxY, xv, z); for (int y = 1; y <= maxY; y++) { - final Block block = world.getBlockAt(xv, y, z); + final Block block = oldWorld.getBlockAt(xv, y, z); final int id = block.getTypeId(); final byte data = block.getData(); - BukkitSetBlockManager.setBlockManager.set(world, xv + relX, y, z + relZ, id, data); + BukkitSetBlockManager.setBlockManager.set(newWorld, xv + relX, y, z + relZ, id, data); } } mx.increment(); if (xv == ex) { // done! - restoreBlocks(world, relX, relZ); + restoreBlocks(newWorld, relX, relZ); BukkitSetBlockManager.setBlockManager.update(chunks); for (final Chunk chunk : chunks) { chunk.unload(true, true); From 548127dc1dc7e60680ded973727742fb349777d5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 15:34:35 +1100 Subject: [PATCH 076/223] Not sure if this will help. --- .../intellectualcrafters/plot/generator/BukkitHybridUtils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 61fda9480..5ba68da3e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -88,7 +88,6 @@ public class BukkitHybridUtils extends HybridUtils { ChunkManager.manager.unloadChunk(worldname, new ChunkLoc(x, z)); } } - BukkitSetBlockManager.setBlockManager.update(chunks2); } private static boolean UPDATE = false; @@ -123,8 +122,8 @@ public class BukkitHybridUtils extends HybridUtils { final ChunkLoc loc = chunks.get(0); PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)"); PlotSquared.log(" - Remaining: " + chunks.size()); - regenerateChunkChunk(world, loc); chunks.remove(0); + regenerateChunkChunk(world, loc); } catch (final Exception e) { final ChunkLoc loc = chunks.get(0); PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); From 98232107f9ce72b1b134c2f90c75ba51834bf4c5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 16:27:56 +1100 Subject: [PATCH 077/223] Started on #162 --- .../plot/generator/BukkitHybridUtils.java | 75 ++++++++++--------- .../plot/generator/HybridUtils.java | 2 - 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 5ba68da3e..304a8ad02 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -68,7 +68,6 @@ public class BukkitHybridUtils extends HybridUtils { return ey; } - @Override public void regenerateChunkChunk(final String worldname, final ChunkLoc loc) { final World world = BukkitUtil.getWorld(worldname); final int sx = loc.x << 5; @@ -90,59 +89,67 @@ public class BukkitHybridUtils extends HybridUtils { } } + public final ArrayList getChunks(ChunkLoc region) { + ArrayList chunks = new ArrayList(); + final int sx = region.x << 5; + final int sz = region.z << 5; + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + chunks.add(new ChunkLoc(x, z)); + } + } + return chunks; + } + private static boolean UPDATE = false; private int task; - private long LAST = 0; - private double AV = 1000; @Override public boolean scheduleRoadUpdate(final String world) { if (BukkitHybridUtils.UPDATE) { return false; } - final List chunks = ChunkManager.manager.getChunkChunks(world); + final List regions = ChunkManager.manager.getChunkChunks(world); + final List chunks = new ArrayList(); final Plugin plugin = BukkitMain.THIS; this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { - if (chunks.size() == 0) { + if (regions.size() == 0) { BukkitHybridUtils.UPDATE = false; PlotSquared.log(C.PREFIX.s() + "Finished road conversion"); Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task); return; } else { - if (LAST == 0) { - LAST = System.currentTimeMillis(); - } - long current = System.currentTimeMillis() - LAST; - AV = Math.max(current, (current + AV * 5) / 6); - LAST = System.currentTimeMillis(); - if (AV < 1500) { - try { - final ChunkLoc loc = chunks.get(0); + try { + if (chunks.size() < 1024) { + final ChunkLoc loc = regions.get(0); PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)"); - PlotSquared.log(" - Remaining: " + chunks.size()); - chunks.remove(0); - regenerateChunkChunk(world, loc); - } catch (final Exception e) { - final ChunkLoc loc = chunks.get(0); - PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); - final int sx = loc.x << 5; - final int sz = loc.z << 5; - for (int x = sx; x < (sx + 32); x++) { - for (int z = sz; z < (sz + 32); z++) { - ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z)); - } + PlotSquared.log(" - Remaining: " + regions.size()); + chunks.addAll(getChunks(regions.get(0))); + regions.remove(0); + } + if (chunks.size() > 0) { + long diff = System.currentTimeMillis() + 50; + while (System.currentTimeMillis() < diff) { + ChunkLoc chunk = chunks.get(0); + chunks.remove(0); + regenerateRoad(world, chunk); + + } + } + } catch (final Exception e) { + final ChunkLoc loc = regions.get(0); + PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)"); + final int sx = loc.x << 5; + final int sz = loc.z << 5; + for (int x = sx; x < (sx + 32); x++) { + for (int z = sz; z < (sz + 32); z++) { + ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z)); } - PlotSquared.log("&d - Potentially skipping 1024 chunks"); - PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); - } - } - else { - double tps = (20000.0/Math.min(AV, current)); - if (tps < 19) { - System.out.print("waiting for chunks to unload..."); } + PlotSquared.log("&d - Potentially skipping 1024 chunks"); + PlotSquared.log("&d - TODO: recommend chunkster if corrupt"); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index be33557cb..979b90bf7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -85,8 +85,6 @@ public abstract class HybridUtils { public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy); - public abstract void regenerateChunkChunk(final String world, final ChunkLoc loc); - public abstract boolean scheduleRoadUpdate(final String world); public boolean regenerateRoad(final String world, final ChunkLoc chunk) { From 336b22303fa5348de58230f109594f937527d6ee Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 16:55:38 +1100 Subject: [PATCH 078/223] optimizations --- .../plot/database/SQLManager.java | 8 +++--- .../plot/generator/BukkitHybridUtils.java | 1 + .../plot/util/bukkit/BukkitChunkManager.java | 25 ++++++++----------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 9a2ae8931..bea8ee590 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -802,15 +802,15 @@ public class SQLManager implements AbstractDB { } @Override - public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) { + public void movePlot(Plot original, final Plot newPlot) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { - final int id = getId(world, originalPlot); + final int id = getId(original.world, original.id); final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?"); - stmt.setInt(1, newPlot.x); - stmt.setInt(2, newPlot.y); + stmt.setInt(1, newPlot.id.x); + stmt.setInt(2, newPlot.id.y); stmt.setInt(3, id); stmt.executeUpdate(); stmt.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 304a8ad02..da5f1714a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.api.PlotAPI; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index dc5409fec..886ebbf44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -949,12 +949,12 @@ public class BukkitChunkManager extends ChunkManager { int X = chunk.getX(); int Z = chunk.getX(); Entity[] ents = chunk.getEntities(); - if (X == bx || X == tx || Z == bz || Z == tz) { - for (final Entity entity : ents) { - if (!(entity instanceof Creature)) { - continue; - } - final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); + for (final Entity entity : ents) { + if (!(entity instanceof Creature)) { + continue; + } + if (X == bx || X == tx || Z == bz || Z == tz) { + final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { count[0]++; if (entity instanceof Animals) { @@ -964,21 +964,16 @@ public class BukkitChunkManager extends ChunkManager { count[2]++; } } - } - } - else { - for (final Entity entity : ents) { - if (!(entity instanceof Creature)) { - continue; - } - count[0]++; + } + else { + count[0]++; if (entity instanceof Animals) { count[1]++; } else { count[2]++; } - } + } } } } From 86eb696df7bec865e1b1a37d19c93ff88037f95d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 24 Mar 2015 20:57:29 +1100 Subject: [PATCH 079/223] fix compile time error --- .../java/com/intellectualcrafters/plot/database/SQLManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index bea8ee590..605fd2ade 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -802,7 +802,7 @@ public class SQLManager implements AbstractDB { } @Override - public void movePlot(Plot original, final Plot newPlot) { + public void movePlot(final Plot original, final Plot newPlot) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { From abe9d9f5ace3e6afb1c73ee9d80930482cb02eaf Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 26 Mar 2015 18:09:09 +1100 Subject: [PATCH 080/223] fix chunk loading --- .../plot/util/bukkit/BukkitChunkManager.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 886ebbf44..a0f3fb1ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -162,8 +162,6 @@ public class BukkitChunkManager extends ChunkManager { final Chunk c1 = newWorld.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4); final Chunk c2 = newWorld.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4); - final Chunk c3 = newWorld.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4); - final Chunk c4 = newWorld.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4); final int sx = pos1.getX(); final int sz = pos1.getZ(); @@ -174,14 +172,12 @@ public class BukkitChunkManager extends ChunkManager { final int c1z = c1.getZ(); final int c2x = c2.getX(); final int c2z = c2.getZ(); - final int c3x = c3.getX(); - final int c3z = c3.getZ(); final ArrayList chunks = new ArrayList<>(); final ArrayList toGenerate = new ArrayList<>(); // Load chunks - for (int x = c2x; x <= c3x; x++) { - for (int z = c2z; z <= c3z; z++) { + for (int x = c1x; x <= c2x; x++) { + for (int z = c1z; z <= c2z; z++) { final Chunk chunk = newWorld.getChunkAt(x, z); toGenerate.add(chunk); } From e039bbd56aecaea901307e0fdbf3d45a21b20d38 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 26 Mar 2015 21:44:31 +1100 Subject: [PATCH 081/223] inverse pairing function --- .../plot/object/PlotId.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index 85b03f39d..ca8ef60d9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -82,6 +82,47 @@ public class PlotId { public String toString() { return this.x + ";" + this.y; } + + public PlotId unpair(int hash) { + if (hash >= 0) { + if (hash % 2 == 0) { + // + + + hash /= 2; + int i = (int) (Math.abs(-1 + Math.sqrt(1 + 8 * hash)) / 2); + int idx = hash - ((i * (1 + i)) / 2); + int idy = ((i * (3 + i)) / 2) - hash; + return new PlotId(idx, idy); + } + else { + // + - + hash -= 1; + hash /= 2; + int i = (int) (Math.abs(-1 + Math.sqrt(1 + 8 * hash)) / 2); + int idx = hash - ((i * (1 + i)) / 2); + int idy = ((i * (3 + i)) / 2) - hash; + return new PlotId(idx, -idy); + } + } + else { + if (hash % 2 == 0) { + // - + + hash /= -2; + int i = (int) (Math.abs(-1 + Math.sqrt(1 + 8 * hash)) / 2); + int idx = hash - ((i * (1 + i)) / 2); + int idy = ((i * (3 + i)) / 2) - hash; + return new PlotId(-idx, idy); + } + else { + // - - + hash += 1; + hash /= -2; + int i = (int) (Math.abs(-1 + Math.sqrt(1 + 8 * hash)) / 2); + int idx = hash - ((i * (1 + i)) / 2); + int idy = ((i * (3 + i)) / 2) - hash; + return new PlotId(-idx, -idy); + } + } + } @Override public int hashCode() { From b1aa8fdd5e65b78059447500f662a9e2ef1c4bbd Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 27 Mar 2015 18:15:41 +1100 Subject: [PATCH 082/223] Trying to make external generators easier to make. --- .../plot/commands/Copy.java | 2 +- .../plot/generator/ClassicPlotManager.java | 18 ++-- .../plot/generator/HybridGen.java | 6 +- .../plot/object/PlotGenerator.java | 89 ++++++++++++++++++- .../plot/object/PlotPopulator.java | 72 +++++++++++++++ .../plot/object/PseudoRandom.java | 10 +-- .../plot/util/ChunkManager.java | 3 + 7 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index ba31cfc75..67d9598c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -48,7 +48,7 @@ public class Copy extends SubCommand { final Location loc = plr.getLocation(); final Plot plot1 = MainUtil.getPlot(loc); if (plot1 == null) { - return !sendMessage(plr, C.NOT_IN_PLOT); + return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT); } if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN)) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index a15bad233..4b8a53554 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -61,12 +61,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final int[] zl = new int[size]; final PlotBlock[] bl = new PlotBlock[size]; int i = 0; + PseudoRandom random = new PseudoRandom(); for (x = bottom.getX(); x <= (top.getX() - 1); x++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } } @@ -76,7 +77,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } } @@ -86,7 +87,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } } @@ -96,7 +97,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } } @@ -121,12 +122,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager { int x, z; z = bottom.getZ(); int i = 0; + PseudoRandom random = new PseudoRandom(); final int y = dpw.WALL_HEIGHT + 1; for (x = bottom.getX(); x <= (top.getX() - 1); x++) { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } x = top.getX(); @@ -134,7 +136,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } z = top.getZ(); @@ -142,7 +144,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } x = bottom.getX(); @@ -150,7 +152,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { xl[i] = x; zl[i] = z; yl[i] = y; - bl[i] = blocks[PseudoRandom.random(blocks.length)]; + bl[i] = blocks[random.random(blocks.length)]; i++; } BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 9fae1fac5..3b7d1ed2a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -31,11 +31,13 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; +import org.bukkit.generator.ChunkGenerator.BiomeGrid; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.ChunkManager; @@ -217,7 +219,7 @@ public class HybridGen extends PlotGenerator { * generator */ @Override - public short[][] generateExtBlockSections(final World world, final Random random, final int cx, final int cz, final BiomeGrid biomes) { + public short[][] generateChunk(final World world, RegionWrapper plot, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result) { if (this.doState) { final int prime = 13; int h = 1; @@ -225,7 +227,6 @@ public class HybridGen extends PlotGenerator { h = (prime * h) + cz; this.state = h; } - this.result = new short[this.maxY / 16][]; if (this.plotworld.PLOT_BEDROCK) { for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { @@ -233,7 +234,6 @@ public class HybridGen extends PlotGenerator { } } } - final RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR; if (plot != null) { final int X = cx << 4; final int Z = cz << 4; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 7296708cd..0f1a447c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -20,16 +20,26 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.object; +import java.util.HashMap; import java.util.List; +import java.util.Map.Entry; +import java.util.Random; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.util.ChunkManager; public abstract class PlotGenerator extends ChunkGenerator { + private short[][] result; + private int X; + private int Z; + private PseudoRandom random = new PseudoRandom(); + @Override public List getDefaultPopulators(World world) { PlotSquared.loadWorld(world.getName(), this); @@ -54,13 +64,86 @@ public abstract class PlotGenerator extends ChunkGenerator { return getPopulators(world.getName()); } + @Override + public short[][] generateExtBlockSections(final World world, final Random r, final int cx, final int cz, final BiomeGrid biomes) { + final int prime = 13; + int h = 1; + h = (prime * h) + cx; + h = (prime * h) + cz; + this.random.state = h; + this.result = new short[256 / 16][]; + PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName()); + Biome biome = Biome.valueOf(plotworld.PLOT_BIOME); + if (ChunkManager.FORCE_PASTE) { + X = cx << 4; + Z = cz << 4; + for (short x = 0; x < 16; x++) { + for (short z = 0; z < 16; z++) { + if (biomes != null) { + biomes.setBiome(x, z, biome); + } + final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); + final HashMap blocks = ChunkManager.GENERATE_BLOCKS.get(loc); + for (final Entry entry : blocks.entrySet()) { + setBlock(x, entry.getKey(), z, entry.getValue()); + } + } + } + return this.result; + } + this.result = generateChunk(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz, biomes, result); + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + PlotLoc loc; + for (Entry> entry : ChunkManager.GENERATE_BLOCKS.entrySet()) { + for (Entry entry2 : entry.getValue().entrySet()) { + loc = entry.getKey(); + setBlock(loc.x, entry2.getKey(), loc.z, entry2.getValue()); + } + } + } + return result; + } + + private void setBlock(final int x, final int y, final int z, final short blkid) { + if (result[y >> 4] == null) { + result[y >> 4] = new short[4096]; + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; + } + + public boolean contains(final RegionWrapper plot, final int x, final int z) { + int xx = X + x; + int zz = Z + z; + return ((xx >= plot.minX) && (xx <= plot.maxX) && (zz >= plot.minZ) && (zz <= plot.maxZ)); + } + + /** + * random is a optimized random number generator.
      + * - Change the state to have the same chunk random each time it generates
      + * requiredRegion If a plot is being regenerated, you are only required to generate content in this area
      + * - use the contains(RegionWrapper, x, z) method to check if the region contains a location
      + * - You can ignore this if you do not want to further optimize your generator
      + * - will be null if no restrictions are set
      + * result is the standard 2D block data array used for generation
      + * biomes is the standard BiomeGrid used for generation + * + * @param world + * @param random + * @param cx + * @param cz + * @param requiredRegion + * @param biomes + * @param result + * @return + */ + public abstract short[][] generateChunk(final World world, RegionWrapper requiredRegion, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result); + public abstract List getPopulators(String world); public abstract void init(PlotWorld plotworld); - + public abstract PlotWorld getNewPlotWorld(final String world); public abstract PlotManager getPlotManager(); - - + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java new file mode 100644 index 000000000..03374a4af --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -0,0 +1,72 @@ +package com.intellectualcrafters.plot.object; + +import java.util.HashMap; +import java.util.Random; +import java.util.Map.Entry; + +import org.bukkit.Chunk; +import org.bukkit.World; +import org.bukkit.generator.BlockPopulator; + +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; + +public abstract class PlotPopulator extends BlockPopulator{ + + private int X; + private int Z; + private World world; + + @Override + public void populate(World world, Random rand, Chunk chunk) { + this.world = world; + this.X = chunk.getX() << 4; + this.Z = chunk.getZ() << 4; + + if (ChunkManager.FORCE_PASTE) { + for (short x = 0; x < 16; x++) { + for (short z = 0; z < 16; z++) { + final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); + final HashMap blocks = ChunkManager.GENERATE_DATA.get(loc); + for (final Entry entry : blocks.entrySet()) { + setBlock(x, entry.getKey(), z, entry.getValue()); + } + } + } + return; + } + + } + + public abstract void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz); + + /** + * Set the id and data at a location (x, y, z) must be between [0,15], [0,255], [0,15] + * @param x + * @param y + * @param z + * @param id + * @param data + */ + public void setBlock(int x, int y, int z, short id, byte data) { + BukkitUtil.setBlock(world, X + x, y, Z + z, id, data); + } + + /** + * Set the data at a location (x, y, z) must be between [0,15], [0,255], [0,15] + * @param x + * @param y + * @param z + * @param data + */ + public void setBlock(int x, int y, int z, byte data) { + world.getBlockAt(X + x, y, Z + z).setTypeId(data); + } + + public boolean contains(final RegionWrapper plot, final int x, final int z) { + int xx = X + x; + int zz = Z + z; + return ((xx >= plot.minX) && (xx <= plot.maxX) && (zz >= plot.minZ) && (zz <= plot.maxZ)); + } + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PseudoRandom.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PseudoRandom.java index 17190cefe..66e68ea2e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PseudoRandom.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PseudoRandom.java @@ -1,22 +1,22 @@ package com.intellectualcrafters.plot.object; public class PseudoRandom { - private static long state = 1; - - public static long nextLong() { + public long state = 1; + + public long nextLong() { final long a = state; state = xorShift64(a); return a; } - public static long xorShift64(long a) { + public long xorShift64(long a) { a ^= (a << 21); a ^= (a >>> 35); a ^= (a << 4); return a; } - public static int random(final int n) { + public int random(final int n) { if (n == 1) { return 0; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index 8a36782c4..6a3910552 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -11,8 +11,11 @@ import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.RegionWrapper; public abstract class ChunkManager { + public static ChunkManager manager = null; public static RegionWrapper CURRENT_PLOT_CLEAR = null; + public static boolean FORCE_PASTE = false; + public static HashMap> GENERATE_BLOCKS = new HashMap<>(); public static HashMap> GENERATE_DATA = new HashMap<>(); From 89f4cc7deca0358d996dd76c45c7b72b8422439f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 27 Mar 2015 18:36:28 +1100 Subject: [PATCH 083/223] Done, --- .../plot/generator/HybridGen.java | 23 ++----- .../plot/generator/HybridPop.java | 64 ++++++------------- .../plot/object/PlotGenerator.java | 13 +++- .../plot/object/PlotPopulator.java | 31 +++++++-- .../plot/util/BlockManager.java | 2 +- .../plot/util/MainUtil.java | 3 +- 6 files changed, 65 insertions(+), 71 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 3b7d1ed2a..a2285f6cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -36,6 +36,7 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPopulator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; @@ -197,10 +198,10 @@ public class HybridGen extends PlotGenerator { /** * Return the block populator */ - public List getPopulators(final String world) { + public List getPopulators(final String world) { // You can have as many populators as you would like, e.g. tree // populator, ore populator - return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld)); + return Arrays.asList((PlotPopulator) new HybridPop(this.plotworld)); } /** @@ -219,7 +220,7 @@ public class HybridGen extends PlotGenerator { * generator */ @Override - public short[][] generateChunk(final World world, RegionWrapper plot, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result) { + public short[][] generateChunk(final World world, RegionWrapper region, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result) { if (this.doState) { final int prime = 13; int h = 1; @@ -234,7 +235,7 @@ public class HybridGen extends PlotGenerator { } } } - if (plot != null) { + if (region != null) { final int X = cx << 4; final int Z = cz << 4; int sx = ((X) % this.size); @@ -250,7 +251,7 @@ public class HybridGen extends PlotGenerator { if (biomes != null) { biomes.setBiome(x, z, this.biome); } - if (isIn(plot, X + x, Z + z)) { + if (contains(region, x, z)) { for (short y = 1; y < this.plotheight; y++) { setBlock(this.result, x, y, z, this.filling); } @@ -262,14 +263,6 @@ public class HybridGen extends PlotGenerator { setBlock(this.result, x, this.plotheight + entry.getKey(), z, entry.getValue()); } } - } else { - final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); - final HashMap blocks = ChunkManager.GENERATE_BLOCKS.get(loc); - if (blocks != null) { - for (final Entry entry : blocks.entrySet()) { - setBlock(this.result, x, entry.getKey(), z, entry.getValue()); - } - } } } } @@ -339,8 +332,4 @@ public class HybridGen extends PlotGenerator { } return this.result; } - - public boolean isIn(final RegionWrapper plot, final int x, final int z) { - return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 5ff5d73f8..9f8292b0d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -11,7 +11,9 @@ import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotLoc; +import com.intellectualcrafters.plot.object.PlotPopulator; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.util.BlockManager; @@ -20,7 +22,7 @@ import com.intellectualcrafters.plot.util.ChunkManager; /** * @author Citymonstret */ -public class HybridPop extends BlockPopulator { +public class HybridPop extends PlotPopulator { /* * Sorry, this isn't well documented at the moment. * We advise you to take a look at a world generation tutorial for @@ -108,20 +110,11 @@ public class HybridPop extends BlockPopulator { } @Override - public void populate(final World w, final Random r, final Chunk c) { - final int cx = c.getX(), cz = c.getZ(); - if (this.doState) { - final int prime = 13; - int h = 1; - h = (prime * h) + cx; - h = (prime * h) + cz; - this.state = h; - } + public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) { this.X = cx << 4; this.Z = cz << 4; - PlotSquared.getPlotManager(w.getName()); - final RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR; - if (plot != null) { + PlotSquared.getPlotManager(world.getName()); + if (requiredRegion != null) { short sx = (short) ((this.X) % this.size); short sz = (short) ((this.Z) % this.size); if (sx < 0) { @@ -132,21 +125,21 @@ public class HybridPop extends BlockPopulator { } for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - if (isIn(plot, this.X + x, this.Z + z)) { + if (contains(requiredRegion, this.X + x, this.Z + z)) { if (this.doFilling) { for (short y = 1; y < this.plotheight; y++) { - setBlock(w, x, y, z, this.filling); + setBlock(x, y, z, this.filling); } } if (this.doFloor) { - setBlock(w, x, (short) this.plotheight, z, this.plotfloors); + setBlock(x, (short) this.plotheight, z, this.plotfloors); } if (this.plotworld.PLOT_SCHEMATIC) { final PlotLoc loc = new PlotLoc((short) (this.X + x), (short) (this.Z + z)); final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { - setBlock(w, x, (short) (this.plotheight + y), z, blocks.get(y)); + setBlock(x, (short) (this.plotheight + y), z, blocks.get(y)); } } if (this.plotworld.G_SCH_STATE != null) { @@ -158,14 +151,6 @@ public class HybridPop extends BlockPopulator { } } } - } else { - final PlotLoc loc = new PlotLoc((short) (this.X + x), (short) (this.Z + z)); - final HashMap data = ChunkManager.GENERATE_DATA.get(loc); - if (data != null) { - for (final short y : data.keySet()) { - setBlock(w, x, y, z, data.get(y).byteValue()); - } - } } } } @@ -192,18 +177,18 @@ public class HybridPop extends BlockPopulator { if (gx && gz && lx && lz) { if (this.doFilling) { for (short y = 1; y < this.plotheight; y++) { - setBlock(w, x, y, z, this.filling); + setBlock(x, y, z, this.filling); } } if (this.doFloor) { - setBlock(w, x, (short) this.plotheight, z, this.plotfloors); + setBlock(x, (short) this.plotheight, z, this.plotfloors); } if (this.plotworld.PLOT_SCHEMATIC) { final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { - setBlock(w, x, (short) (this.plotheight + y), z, blocks.get(y)); + setBlock(x, (short) (this.plotheight + y), z, blocks.get(y)); } } if (this.plotworld.G_SCH_STATE != null) { @@ -222,18 +207,18 @@ public class HybridPop extends BlockPopulator { if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { if (this.wallfilling != 0) { for (short y = 1; y <= this.wallheight; y++) { - setBlock(w, x, y, z, this.wallfilling); + setBlock(x, y, z, this.wallfilling); } } if ((this.wall != 0) && !this.plotworld.ROAD_SCHEMATIC_ENABLED) { - setBlock(w, x, (short) (this.wallheight + 1), z, this.wall); + setBlock(x, (short) (this.wallheight + 1), z, this.wall); } } // road else { if (this.roadblock != 0) { for (short y = 1; y <= this.roadheight; y++) { - setBlock(w, x, y, z, this.roadblock); + setBlock(x, y, z, this.roadblock); } } } @@ -242,7 +227,7 @@ public class HybridPop extends BlockPopulator { final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { - setBlock(w, x, (short) (this.roadheight + y), z, blocks.get(y)); + setBlock(x, (short) (this.roadheight + y), z, blocks.get(y)); } } } @@ -251,21 +236,12 @@ public class HybridPop extends BlockPopulator { } } - private void setBlock(final World w, final short x, final short y, final short z, final byte[] blkids) { + private void setBlock(final short x, final short y, final short z, final byte[] blkids) { if (blkids.length == 1) { - setBlock(w, x, y, z, blkids[0]); + setBlock(x, y, z, blkids[0]); } else { final int i = random(blkids.length); - setBlock(w, x, y, z, blkids[i]); + setBlock(x, y, z, blkids[i]); } } - - @SuppressWarnings("deprecation") - private void setBlock(final World w, final short x, final short y, final short z, final byte val) { - w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false); - } - - public boolean isIn(final RegionWrapper plot, final int x, final int z) { - return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 0f1a447c3..31c71d9b0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -40,10 +40,10 @@ public abstract class PlotGenerator extends ChunkGenerator { private int Z; private PseudoRandom random = new PseudoRandom(); + @SuppressWarnings("unchecked") @Override public List getDefaultPopulators(World world) { PlotSquared.loadWorld(world.getName(), this); -// world = Bukkit.getWorld(PlotSquared.GEN_WORLD); PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName()); if (!plotworld.MOB_SPAWNING) { if (!plotworld.SPAWN_EGGS) { @@ -61,7 +61,7 @@ public abstract class PlotGenerator extends ChunkGenerator { world.setMonsterSpawnLimit(-1); world.setWaterAnimalSpawnLimit(-1); } - return getPopulators(world.getName()); + return (List)(List) getPopulators(world.getName()); } @Override @@ -111,6 +111,13 @@ public abstract class PlotGenerator extends ChunkGenerator { result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; } + /** + * check if a region contains a location. (x, z) must be between [0,15], [0,15] + * @param plot + * @param x + * @param z + * @return + */ public boolean contains(final RegionWrapper plot, final int x, final int z) { int xx = X + x; int zz = Z + z; @@ -138,7 +145,7 @@ public abstract class PlotGenerator extends ChunkGenerator { */ public abstract short[][] generateChunk(final World world, RegionWrapper requiredRegion, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result); - public abstract List getPopulators(String world); + public abstract List getPopulators(String world); public abstract void init(PlotWorld plotworld); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index 03374a4af..e50fcced3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.object; import java.util.HashMap; +import java.util.HashSet; import java.util.Random; import java.util.Map.Entry; @@ -8,10 +9,15 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.schematic.PlotItem; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -public abstract class PlotPopulator extends BlockPopulator{ +public abstract class PlotPopulator extends BlockPopulator { + + private PseudoRandom random = new PseudoRandom(); private int X; private int Z; @@ -22,7 +28,6 @@ public abstract class PlotPopulator extends BlockPopulator{ this.world = world; this.X = chunk.getX() << 4; this.Z = chunk.getZ() << 4; - if (ChunkManager.FORCE_PASTE) { for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { @@ -35,13 +40,22 @@ public abstract class PlotPopulator extends BlockPopulator{ } return; } - + populate(world, ChunkManager.CURRENT_PLOT_CLEAR, random, X, Z); + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + PlotLoc loc; + for (Entry> entry : ChunkManager.GENERATE_DATA.entrySet()) { + for (Entry entry2 : entry.getValue().entrySet()) { + loc = entry.getKey(); + setBlock(loc.x, entry2.getKey(), loc.z, entry2.getValue()); + } + } + } } public abstract void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz); /** - * Set the id and data at a location (x, y, z) must be between [0,15], [0,255], [0,15] + * Set the id and data at a location. (x, y, z) must be between [0,15], [0,255], [0,15] * @param x * @param y * @param z @@ -53,7 +67,7 @@ public abstract class PlotPopulator extends BlockPopulator{ } /** - * Set the data at a location (x, y, z) must be between [0,15], [0,255], [0,15] + * Set the data at a location. (x, y, z) must be between [0,15], [0,255], [0,15] * @param x * @param y * @param z @@ -63,6 +77,13 @@ public abstract class PlotPopulator extends BlockPopulator{ world.getBlockAt(X + x, y, Z + z).setTypeId(data); } + /** + * check if a region contains a location. (x, z) must be between [0,15], [0,15] + * @param plot + * @param x + * @param z + * @return + */ public boolean contains(final RegionWrapper plot, final int x, final int z) { int xx = X + x; int zz = Z + z; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index ee8252014..e72b90695 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -43,7 +43,7 @@ public abstract class BlockManager { final byte[] data = new byte[blocks.length]; for (int i = 0; i < blocks.length; i++) { final PlotBlock[] current = blocks[i]; - final int n = PseudoRandom.random(current.length); + final int n = MainUtil.random.random(current.length); id[i] = current[n].id; data[i] = current[n].data; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index a8f8fef2a..7dc920c1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -54,6 +54,7 @@ public class MainUtil { static long state = 1; public static HashMap lastPlot = new HashMap<>(); public static HashMap worldBorder = new HashMap<>(); + static PseudoRandom random = new PseudoRandom(); public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { @@ -567,7 +568,7 @@ public class MainUtil { for (int y = pos1.getY(); y < pos2.getY(); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { - final int i = PseudoRandom.random(blocks.length); + final int i = random.random(blocks.length); xl[index] = x; yl[index] = y; zl[index] = z; From 2e7220e40d3997f7ac81d8bbf1e6d496a7470787 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 27 Mar 2015 19:20:19 +1100 Subject: [PATCH 084/223] Fix debugclear --- .../plot/generator/HybridGen.java | 107 ++++-------------- .../plot/object/PlotGenerator.java | 33 ++++-- .../plot/object/PlotPopulator.java | 4 +- 3 files changed, 48 insertions(+), 96 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index a2285f6cb..944792816 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -30,8 +30,6 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; -import org.bukkit.generator.BlockPopulator; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotLoc; @@ -40,7 +38,6 @@ import com.intellectualcrafters.plot.object.PlotPopulator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.ChunkManager; /** * The default generator is very messy, as we have decided to try externalize all calculations from within the loop. - @@ -78,14 +75,6 @@ public class HybridGen extends PlotGenerator { short pathWidthUpper; boolean doState = false; int maxY = 0; - /** - * result object is returned for each generated chunk, do stuff to it - */ - short[][] result; - /** - * Faster sudo-random number generator than java.util.random - */ - private long state = 13; /** * Initialize variables, and create plotworld object used in calculations @@ -131,7 +120,6 @@ public class HybridGen extends PlotGenerator { * Return the plot manager for this type of generator, or create one For square plots you may as well use the * default plot manager which comes with PlotSquared */ - @Override public PlotManager getPlotManager() { if (HybridGen.manager == null) { HybridGen.manager = new HybridPlotManager(); @@ -139,18 +127,9 @@ public class HybridGen extends PlotGenerator { return HybridGen.manager; } - /** - * Allow spawning everywhere - */ - @Override - public boolean canSpawn(final World world, final int x, final int z) { - return true; - } - /** * Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared */ - @Override public PlotWorld getNewPlotWorld(final String world) { if (this.plotworld == null) { this.plotworld = new HybridPlotWorld(world); @@ -158,43 +137,6 @@ public class HybridGen extends PlotGenerator { return this.plotworld; } - public final long nextLong() { - final long a = this.state; - this.state = xorShift64(a); - return a; - } - - public final long xorShift64(long a) { - a ^= (a << 21); - a ^= (a >>> 35); - a ^= (a << 4); - return a; - } - - public final int random(final int n) { - final long r = ((nextLong() >>> 32) * n) >> 32; - return (int) r; - } - - private void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkids) { - if (blkids.length == 1) { - setBlock(result, x, y, z, blkids[0]); - } else { - final int i = random(blkids.length); - setBlock(result, x, y, z, blkids[i]); - } - } - - /** - * Standard setblock method for world generation - */ - private void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) { - if (result[y >> 4] == null) { - result[y >> 4] = new short[4096]; - } - result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; - } - /** * Return the block populator */ @@ -207,31 +149,22 @@ public class HybridGen extends PlotGenerator { /** * Return the default spawn location for this world */ - @Override - public Location getFixedSpawnLocation(final World world, final Random random) { - if (this.plotworld == null) { - return new Location(world, 0, 128, 0); - } - return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0); - } +// public Location getFixedSpawnLocation(final World world, final Random random) { +// if (this.plotworld == null) { +// return new Location(world, 0, 128, 0); +// } +// return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0); +// } /** * This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world * generator */ - @Override - public short[][] generateChunk(final World world, RegionWrapper region, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result) { - if (this.doState) { - final int prime = 13; - int h = 1; - h = (prime * h) + cx; - h = (prime * h) + cz; - this.state = h; - } + public void generateChunk(final World world, RegionWrapper region, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes) { if (this.plotworld.PLOT_BEDROCK) { for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - setBlock(this.result, x, 0, z, (short) 7); + setBlock(x, 0, z, (short) 7); } } } @@ -253,20 +186,20 @@ public class HybridGen extends PlotGenerator { } if (contains(region, x, z)) { for (short y = 1; y < this.plotheight; y++) { - setBlock(this.result, x, y, z, this.filling); + setBlock(x, y, z, this.filling); } - setBlock(this.result, x, this.plotheight, z, this.plotfloors); + setBlock(x, this.plotheight, z, this.plotfloors); final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); final HashMap blocks = plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { - setBlock(this.result, x, this.plotheight + entry.getKey(), z, entry.getValue()); + setBlock(x, this.plotheight + entry.getKey(), z, entry.getValue()); } } } } } - return this.result; + return; } int sx = ((cx << 4) % this.size); int sz = ((cz << 4) % this.size); @@ -290,15 +223,15 @@ public class HybridGen extends PlotGenerator { // inside plot if (gx && gz && lx && lz) { for (short y = 1; y < this.plotheight; y++) { - setBlock(this.result, x, y, z, this.filling); + setBlock(x, y, z, this.filling); } - setBlock(this.result, x, this.plotheight, z, this.plotfloors); + setBlock(x, this.plotheight, z, this.plotfloors); if (this.plotworld.PLOT_SCHEMATIC) { final PlotLoc loc = new PlotLoc((short) absX, (short) absZ); final HashMap blocks = this.plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { - setBlock(this.result, x, this.plotheight + entry.getKey(), z, entry.getValue()); + setBlock(x, this.plotheight + entry.getKey(), z, entry.getValue()); } } } @@ -306,16 +239,16 @@ public class HybridGen extends PlotGenerator { // wall if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { for (short y = 1; y <= this.wallheight; y++) { - setBlock(this.result, x, y, z, this.wallfilling); + setBlock(x, y, z, this.wallfilling); } if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) { - setBlock(this.result, x, this.wallheight + 1, z, this.wall); + setBlock(x, this.wallheight + 1, z, this.wall); } } // road else { for (short y = 1; y <= this.roadheight; y++) { - setBlock(this.result, x, y, z, this.roadblock); + setBlock(x, y, z, this.roadblock); } } if (this.plotworld.ROAD_SCHEMATIC_ENABLED) { @@ -323,13 +256,13 @@ public class HybridGen extends PlotGenerator { final HashMap blocks = this.plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { - setBlock(this.result, x, this.roadheight + entry.getKey(), z, entry.getValue()); + setBlock(x, this.roadheight + entry.getKey(), z, entry.getValue()); } } } } } } - return this.result; + return; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 31c71d9b0..92f77c1ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -65,7 +65,7 @@ public abstract class PlotGenerator extends ChunkGenerator { } @Override - public short[][] generateExtBlockSections(final World world, final Random r, final int cx, final int cz, final BiomeGrid biomes) { + public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid biomes) { final int prime = 13; int h = 1; h = (prime * h) + cx; @@ -74,9 +74,9 @@ public abstract class PlotGenerator extends ChunkGenerator { this.result = new short[256 / 16][]; PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName()); Biome biome = Biome.valueOf(plotworld.PLOT_BIOME); + this.X = cx << 4; + this.Z = cz << 4; if (ChunkManager.FORCE_PASTE) { - X = cx << 4; - Z = cz << 4; for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (biomes != null) { @@ -91,26 +91,37 @@ public abstract class PlotGenerator extends ChunkGenerator { } return this.result; } - this.result = generateChunk(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz, biomes, result); + generateChunk(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz, biomes); if (ChunkManager.CURRENT_PLOT_CLEAR != null) { PlotLoc loc; for (Entry> entry : ChunkManager.GENERATE_BLOCKS.entrySet()) { for (Entry entry2 : entry.getValue().entrySet()) { loc = entry.getKey(); - setBlock(loc.x, entry2.getKey(), loc.z, entry2.getValue()); + setBlock(loc.x - X, entry2.getKey(), loc.z- Z, entry2.getValue()); } } } return result; } - private void setBlock(final int x, final int y, final int z, final short blkid) { + public void setBlock(final int x, final int y, final int z, final short blkid) { if (result[y >> 4] == null) { result[y >> 4] = new short[4096]; } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; } + public void setBlock(final int x, final int y, final int z, final short[] blkid) { + if (blkid.length == 1) { + setBlock(x, y, z, blkid[0]); + } + short id = blkid[random.random(blkid.length)]; + if (result[y >> 4] == null) { + result[y >> 4] = new short[4096]; + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = id; + } + /** * check if a region contains a location. (x, z) must be between [0,15], [0,15] * @param plot @@ -124,6 +135,14 @@ public abstract class PlotGenerator extends ChunkGenerator { return ((xx >= plot.minX) && (xx <= plot.maxX) && (zz >= plot.minZ) && (zz <= plot.maxZ)); } + /** + * Allow spawning everywhere + */ + @Override + public boolean canSpawn(final World world, final int x, final int z) { + return true; + } + /** * random is a optimized random number generator.
      * - Change the state to have the same chunk random each time it generates
      @@ -143,7 +162,7 @@ public abstract class PlotGenerator extends ChunkGenerator { * @param result * @return */ - public abstract short[][] generateChunk(final World world, RegionWrapper requiredRegion, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes, final short[][] result); + public abstract void generateChunk(final World world, RegionWrapper requiredRegion, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes); public abstract List getPopulators(String world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index e50fcced3..87e05f043 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -46,7 +46,7 @@ public abstract class PlotPopulator extends BlockPopulator { for (Entry> entry : ChunkManager.GENERATE_DATA.entrySet()) { for (Entry entry2 : entry.getValue().entrySet()) { loc = entry.getKey(); - setBlock(loc.x, entry2.getKey(), loc.z, entry2.getValue()); + setBlock(loc.x - X, entry2.getKey(), loc.z - Z, entry2.getValue()); } } } @@ -74,7 +74,7 @@ public abstract class PlotPopulator extends BlockPopulator { * @param data */ public void setBlock(int x, int y, int z, byte data) { - world.getBlockAt(X + x, y, Z + z).setTypeId(data); + world.getBlockAt(X + x, y, Z + z).setData(data); } /** From 61569d52122c9c16f605248ed1781a48c46d64ad Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 27 Mar 2015 21:14:29 +1100 Subject: [PATCH 085/223] Fixes #224 --- .../java/com/intellectualcrafters/plot/commands/Kick.java | 2 +- .../intellectualcrafters/plot/listeners/PlayerEvents.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 3de39de9f..d539629ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -42,7 +42,7 @@ public class Kick extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { + if (plot == null || ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick"))) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } 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 e728cc71a..fcd40db40 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -837,8 +837,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ()); final Player player = event.getPlayer(); if (isPlotWorld(q)) { - if (isInPlot(q)) { - final Plot plot = getCurrentPlot(q); + final Plot plot = getCurrentPlot(q); + if (plot != null) { final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.isDenied(pp.getUUID())) { if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) { @@ -854,8 +854,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else { if (leftPlot(f, t)) { - final Plot plot = getCurrentPlot(f); - plotExit(player, plot); + final Plot plot2 = getCurrentPlot(f); + plotExit(player, plot2); } } if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) { From 348fb9cb1b44ed609364f3a47acd588845c1c6d8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 27 Mar 2015 22:25:24 +1100 Subject: [PATCH 086/223] Updating chunk sending algorithm effects #210,#204,#167,#162 --- .../plot/commands/Claim.java | 1 - .../plot/commands/Copy.java | 1 - .../plot/commands/CreateRoadSchematic.java | 1 - .../plot/commands/DebugRoadRegen.java | 4 --- .../plot/commands/Merge.java | 2 -- .../plot/commands/Move.java | 1 - .../plot/commands/SchematicCmd.java | 1 - .../plot/commands/Set.java | 1 - .../plot/commands/Swap.java | 1 - .../plot/commands/Unlink.java | 1 - .../plot/generator/AugmentedPopulator.java | 8 ----- .../plot/generator/BukkitHybridUtils.java | 2 -- .../plot/generator/HybridGen.java | 2 -- .../plot/generator/HybridPop.java | 4 --- .../plot/object/PlotPopulator.java | 6 +--- .../plot/util/BlockManager.java | 1 - .../plot/util/BlockUpdateUtil.java | 4 +-- .../plot/util/ClusterManager.java | 3 -- .../plot/util/MainUtil.java | 32 ++++++++---------- .../util/bukkit/BukkitSetBlockManager.java | 6 ++-- .../plot/util/bukkit/BukkitUtil.java | 23 +++++++------ .../plot/util/bukkit/SendChunk.java | 3 +- .../plot/util/bukkit/SetBlockFast.java | 22 ++++++++++--- .../plot/util/bukkit/SetBlockFast_1_8.java | 33 ++++++++++++------- .../plot/util/bukkit/SetBlockSlow.java | 4 +-- 25 files changed, 74 insertions(+), 93 deletions(-) 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 d4210dd80..2ab38c675 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -74,7 +74,6 @@ public class Claim extends SubCommand { SchematicHandler.manager.paste(sch, plot2, 0, 0); } PlotSquared.getPlotManager(world).claimPlot(plotworld, plot); - MainUtil.update(loc); } return result; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index 67d9598c2..0be56253d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -70,7 +70,6 @@ public class Copy extends SubCommand { @Override public void run() { MainUtil.sendMessage(plr, C.COPY_SUCCESS); - MainUtil.update(plr.getLocation()); } })) { return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java index acc0b0fff..3d41ef692 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -45,7 +45,6 @@ public class CreateRoadSchematic extends SubCommand { return sendMessage(player, C.NOT_IN_PLOT_WORLD); } HybridUtils.manager.setupRoadSchematic(plot); - MainUtil.update(loc); MainUtil.sendMessage(player, "&6Saved new road schematic"); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 8ba3ee56f..046c9b775 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -43,11 +43,7 @@ public class DebugRoadRegen extends SubCommand { } final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4); final boolean result = HybridUtils.manager.regenerateRoad(world, chunk); - if (result) { - MainUtil.update(loc); - } MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); - MainUtil.update(loc); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 731ded1bc..d330383c8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -193,7 +193,6 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); - MainUtil.update(loc); } MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); } @@ -223,7 +222,6 @@ public class Merge extends SubCommand { MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); - MainUtil.update(loc); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index c6fd03374..8630cacd0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -86,7 +86,6 @@ public class Move extends SubCommand { @Override public void run() { MainUtil.sendMessage(plr, C.MOVE_SUCCESS); - MainUtil.update(plr.getLocation()); } })) { return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 0524b48e0..ce57799a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -139,7 +139,6 @@ public class SchematicCmd extends SubCommand { if (start > blen) { SchematicHandler.manager.pasteStates(schematic, plot, 0, 0); sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); - MainUtil.update(plr.getLocation()); SchematicCmd.this.running = false; PlotSquared.TASK.cancelTask(SchematicCmd.this.task); return; 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 bfaf58697..b24829271 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -246,7 +246,6 @@ public class Set extends SubCommand { } } manager.setComponent(plotworld, plot.id, component, blocks); - MainUtil.update(loc); MainUtil.sendMessage(plr, C.GENERATING_COMPONENT); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index aadda2c06..ffdd46aa7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -125,7 +125,6 @@ public class Swap extends SubCommand { public void run() { if (last) { MainUtil.sendMessage(plr, C.SWAP_SUCCESS); - MainUtil.update(plr.getLocation()); } } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 936ef01a2..00b8f64c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -70,7 +70,6 @@ public class Unlink extends SubCommand { MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return; } - MainUtil.update(plr.getLocation()); MainUtil.sendMessage(plr, C.UNLINK_SUCCESS); } }; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index b050e8a7b..9991b745f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -1,6 +1,5 @@ package com.intellectualcrafters.plot.generator; -import java.util.Arrays; import java.util.Iterator; import java.util.Random; @@ -19,9 +18,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.intellectualcrafters.plot.util.BlockUpdateUtil; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; @@ -132,7 +129,6 @@ public class AugmentedPopulator extends BlockPopulator { public void run() { populateBiome(world, x, z); chunk.unload(true, true); - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } }, 20); } else { @@ -148,7 +144,6 @@ public class AugmentedPopulator extends BlockPopulator { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); chunk.unload(true, true); - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } }, 40 + rand.nextInt(40)); } @@ -190,9 +185,6 @@ public class AugmentedPopulator extends BlockPopulator { } for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { Chunk chunk = world.getChunkAt(X, Z); - if (MainUtil.canSetFast) { - ((BukkitSetBlockManager) BlockUpdateUtil.setBlockManager).update(Arrays.asList(chunk)); - } populator.populate(world, this.r, chunk); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index da5f1714a..155f1c960 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -11,12 +11,10 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.api.PlotAPI; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 944792816..07d304dba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -24,10 +24,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import java.util.Random; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 9f8292b0d..4f8d467ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,12 +2,9 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; -import java.util.Random; -import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Biome; -import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotLoc; @@ -17,7 +14,6 @@ import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.ChunkManager; /** * @author Citymonstret diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index 87e05f043..d5f52d744 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -1,17 +1,13 @@ package com.intellectualcrafters.plot.object; import java.util.HashMap; -import java.util.HashSet; -import java.util.Random; import java.util.Map.Entry; +import java.util.Random; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.object.schematic.PlotItem; -import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index e72b90695..93c54dbc4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.schematic.PlotItem; public abstract class BlockManager { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java index 4ffb0c881..09b982afb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockUpdateUtil.java @@ -1,11 +1,11 @@ package com.intellectualcrafters.plot.util; -import java.util.List; +import java.util.Collection; import com.intellectualcrafters.plot.object.ChunkLoc; public abstract class BlockUpdateUtil { public static BlockUpdateUtil setBlockManager = null; - public abstract void update(String worldname, List chunkLocs); + public abstract void update(String worldname, Collection chunkLocs); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 27ecae543..916d660f8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Random; @@ -23,7 +22,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -277,7 +275,6 @@ public class ClusterManager { @Override public void run() { if ((populator == null) || (plotworld.TYPE == 0)) { - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); world.regenerateChunk(chunk.getX(), chunk.getZ()); chunk.unload(true, true); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 7dc920c1c..90faf6f75 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -29,7 +29,6 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; @@ -171,20 +170,20 @@ public class MainUtil { } } - public static void update(final Location loc) { - final String world = loc.getWorld(); - int ox = loc.getX() >> 4; - int oz = loc.getZ() >> 4; - final ArrayList chunks = new ArrayList<>(); - final int distance = BukkitUtil.getViewDistance(); - for (int cx = -distance; cx <= distance; cx++) { - for (int cz = -distance; cz <= distance; cz++) { - final ChunkLoc chunk = new ChunkLoc(ox + cx, oz + cz); - chunks.add(chunk); - } - } - BlockUpdateUtil.setBlockManager.update(world, chunks); - } +// public static void update(final Location loc) { +// final String world = loc.getWorld(); +// int ox = loc.getX() >> 4; +// int oz = loc.getZ() >> 4; +// final ArrayList chunks = new ArrayList<>(); +// final int distance = BukkitUtil.getViewDistance(); +// for (int cx = -distance; cx <= distance; cx++) { +// for (int cz = -distance; cz <= distance; cz++) { +// final ChunkLoc chunk = new ChunkLoc(ox + cx, oz + cz); +// chunks.add(chunk); +// } +// } +// BlockUpdateUtil.setBlockManager.update(world, chunks); +// } public static void createWorld(final String world, final String generator) { } @@ -418,7 +417,6 @@ public class MainUtil { } merge = false; } - update(getPlotHome(world, plot)); } private static boolean ownsPlots(final String world, final ArrayList plots, final UUID uuid, final int dir) { @@ -547,7 +545,6 @@ public class MainUtil { MainUtil.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); - update(location); } }; manager.clearPlot(plotworld, plot, isDelete, run); @@ -611,7 +608,6 @@ public class MainUtil { final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; final int topZ = getPlotTopLoc(world, plot.id).getZ(); BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); - update(getPlotHome(world, plot)); } public static int getHeighestBlock(final String world, final int x, final int z) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java index e9a718e43..e6e68c79e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetBlockManager.java @@ -1,7 +1,7 @@ package com.intellectualcrafters.plot.util.bukkit; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import org.bukkit.Chunk; import org.bukkit.World; @@ -14,10 +14,10 @@ public abstract class BukkitSetBlockManager extends BlockUpdateUtil { public abstract void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data); - public abstract void update(List list); + public abstract void update(Collection list); @Override - public void update(final String worldname, final List chunkLocs) { + public void update(final String worldname, final Collection chunkLocs) { final World world = BukkitUtil.getWorld(worldname); final ArrayList chunks = new ArrayList(); for (final ChunkLoc loc : chunkLocs) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 478d8502f..04be68615 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -1,6 +1,5 @@ package com.intellectualcrafters.plot.util.bukkit; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -95,17 +94,17 @@ public class BukkitUtil extends BlockManager { return world.getChunkAt(x, z); } - public static void update(final String world, final int x, final int z) { - final ArrayList chunks = new ArrayList<>(); - final int distance = Bukkit.getViewDistance(); - for (int cx = -distance; cx < distance; cx++) { - for (int cz = -distance; cz < distance; cz++) { - final Chunk chunk = getChunkAt(world, (x >> 4) + cx, (z >> 4) + cz); - chunks.add(chunk); - } - } - BukkitSetBlockManager.setBlockManager.update(chunks); - } +// public static void update(final String world, final int x, final int z) { +// final ArrayList chunks = new ArrayList<>(); +// final int distance = Bukkit.getViewDistance(); +// for (int cx = -distance; cx < distance; cx++) { +// for (int cz = -distance; cz < distance; cz++) { +// final Chunk chunk = getChunkAt(world, (x >> 4) + cx, (z >> 4) + cz); +// chunks.add(chunk); +// } +// } +// BukkitSetBlockManager.setBlockManager.update(chunks); +// } public static String getWorld(final Entity entity) { return entity.getWorld().getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java index f0b3eac37..75ec4bc8b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.bukkit.Bukkit; @@ -53,7 +54,7 @@ public class SendChunk { ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - public static void sendChunk(final List chunks) { + public static void sendChunk(final Collection chunks) { int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; for (final Chunk chunk : chunks) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index d149ce32b..e4570822b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -22,14 +22,16 @@ package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; -import java.util.List; +import java.util.Collection; +import java.util.HashMap; import org.bukkit.Chunk; -import org.bukkit.World; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; +import com.intellectualcrafters.plot.util.TaskManager; /** * SetBlockFast class
      Used to do fast world editing @@ -45,6 +47,8 @@ public class SetBlockFast extends BukkitSetBlockManager { private static RefMethod methodGetChunkAt; private static RefMethod methodA; private static RefMethod methodGetById; + + public static HashMap toUpdate = new HashMap<>(); /** * Constructor @@ -56,6 +60,15 @@ public class SetBlockFast extends BukkitSetBlockManager { methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class); methodGetById = classBlock.getMethod("getById", int.class); + TaskManager.runTaskRepeat(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + update(toUpdate.values()); + toUpdate = new HashMap<>(); + } + }, 20); } /** @@ -83,14 +96,13 @@ public class SetBlockFast extends BukkitSetBlockManager { * @param chunks list of chunks to update */ @Override - public void update(final List chunks) { + public void update(final Collection chunks) { if (chunks.size() == 0) { return; } if (!MainUtil.canSendChunk) { - final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.refreshChunk(chunk.getX(), chunk.getZ()); + chunk.unload(); chunk.load(false); } return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 8f871a61b..255456cec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -22,7 +22,8 @@ package com.intellectualcrafters.plot.util.bukkit; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; -import java.util.List; +import java.util.Collection; +import java.util.HashMap; import org.bukkit.Chunk; import org.bukkit.World; @@ -33,6 +34,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; +import com.intellectualcrafters.plot.util.TaskManager; /** * SetBlockFast class
      Used to do fast world editing @@ -52,6 +54,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { private static RefMethod methodGetByCombinedId; private static RefConstructor constructorBlockPosition; + public static HashMap toUpdate = new HashMap<>(); + /** * Constructor * @@ -63,6 +67,15 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { methodGetHandle = classCraftWorld.getMethod("getHandle"); methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData); + TaskManager.runTaskRepeat(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + update(toUpdate.values()); + toUpdate = new HashMap<>(); + } + }, 20); } private ChunkLoc lastLoc = null; @@ -270,8 +283,12 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { int Z = z >> 4; ChunkLoc loc = new ChunkLoc(X, Z); if (!loc.equals(lastLoc)) { - world.loadChunk(X, Z, false); - lastLoc = loc; + Chunk chunk = toUpdate.get(loc); + if (chunk == null) { + chunk = world.getChunkAt(X, Z); + toUpdate.put(loc, chunk); + } + chunk.load(false); } // check sign final Object w = methodGetHandle.of(world).call(); @@ -281,20 +298,14 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { methodA.of(chunk).call(pos, combined); } - /** - * Update chunks - * - * @param chunks chunks to be updated - */ @Override - public void update(final List chunks) { + public void update(final Collection chunks) { if (chunks.size() == 0) { return; } if (!MainUtil.canSendChunk) { - final World world = chunks.get(0).getWorld(); for (final Chunk chunk : chunks) { - world.refreshChunk(chunk.getX(), chunk.getZ()); + chunk.unload(); chunk.load(false); } return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java index 2f8a80697..8420a3ad2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java @@ -1,6 +1,6 @@ package com.intellectualcrafters.plot.util.bukkit; -import java.util.List; +import java.util.Collection; import org.bukkit.Chunk; import org.bukkit.World; @@ -24,7 +24,7 @@ public class SetBlockSlow extends BukkitSetBlockManager { } @Override - public void update(final List chunks) { + public void update(final Collection chunks) { // TODO Auto-generated method stub } } From 1aac1f40dafaa69fc0ab97a6f22256de85ea8dcf Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 28 Mar 2015 01:58:08 +1100 Subject: [PATCH 087/223] Experimental TNT protection --- .../intellectualcrafters/plot/BukkitMain.java | 2 + .../plot/listeners/TNTListener.java | 119 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 7dcc1b543..cb7c3b7a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.PlayerEvents; import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; +import com.intellectualcrafters.plot.listeners.TNTListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEvents; import com.intellectualcrafters.plot.titles.AbstractTitle; @@ -109,6 +110,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { Bukkit.getServer().unloadWorld(world, true); } } + getServer().getPluginManager().registerEvents(new TNTListener(), this); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java new file mode 100644 index 000000000..07e5ff535 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java @@ -0,0 +1,119 @@ +package com.intellectualcrafters.plot.listeners; + +import java.util.List; + +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.util.Vector; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; + +public class TNTListener implements Listener { + private double lastRadius; + + @EventHandler + public void onPrime(ExplosionPrimeEvent event) { + lastRadius = event.getRadius() + 1; + } + @EventHandler + public void onExplode(EntityExplodeEvent event) { + Entity entity = event.getEntity(); + World world = entity.getWorld(); + String worldname = world.getName(); + if (!PlotSquared.isPlotWorld(worldname)) { + return; + } + Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(entity)); + if (plot == null) { + return; + } + + if (!FlagManager.isPlotFlagTrue(plot, "explosion")) { + return; + } + + Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id); + Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + + List nearby = entity.getNearbyEntities(lastRadius, lastRadius, lastRadius); + for (Entity near : nearby) { + if (near instanceof TNTPrimed || near.getType() == EntityType.MINECART_TNT) { + Vector velocity = near.getVelocity(); + Location loc = BukkitUtil.getLocation(near); + Plot nearPlot = MainUtil.getPlot(loc); + if (!plot.equals(nearPlot)) { + near.setVelocity(new Vector(0, 0, 0)); + continue; + } + double vx = velocity.getX(); + double vy = velocity.getX(); + double vz = velocity.getX(); + + int dx; + int dz; + + if (vx > 0) { + dx = top.getX() - loc.getX(); + } + else { + dx = bot.getX() - loc.getX(); + } + if (vz > 0) { + dz = top.getZ() - loc.getZ(); + } + else { + dz = bot.getZ() - loc.getZ(); + } + + double s1 = dx / vx; + double s2 = dz / vz; + Vector v1 = new Vector(dx, 0, vz * s1); + Vector v2 = new Vector(vx * s2, 0, dz); + + Vector shortest; + if (v1.length() < v2.length()) { + shortest = v1; + } + else { + shortest = v2; + } + + Location landing = loc.add(shortest.getBlockX() + 1, 0, shortest.getBlockZ() + 1); + int ty = BukkitUtil.getHeighestBlock(worldname, landing.getX(), landing.getZ()); + int diff = ty - loc.getY(); + double calcDiff = getY(velocity, Math.sqrt(shortest.getBlockX() * shortest.getBlockX() + shortest.getBlockZ() * shortest.getBlockZ())); + if (calcDiff > diff) { + near.setVelocity(new Vector(0, 0, 0)); + } + } + } + event.getEntity().setVelocity(new Vector(0, 0, 0)); + } + + public double getY(Vector velocity, double x) { + + double g = 16; + double l1 = velocity.length(); + double l2 = Math.sqrt(velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ()); + + double v = l1 * 20; + double theta = Math.acos(l2/l1); + if (velocity.getY() < 0) { + theta = -theta; + } + double cos = Math.cos(theta); + double yDiff = (x * Math.tan(theta)) - ((g * x * x) / (2 * (v * v * cos * cos))); + return yDiff; + } +} From 01c640b72fcbc78cc5e5e745f3b9f7073dcd2f3e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 28 Mar 2015 02:04:07 +1100 Subject: [PATCH 088/223] change API constructor --- .../main/java/com/intellectualcrafters/plot/api/PlotAPI.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 84ca7546b..80fe3fe78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -81,6 +81,9 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; @Deprecated public PlotAPI(final JavaPlugin plugin) { } + + public PlotAPI() { + } /** * Get all plots From 38fde4eae459ab0803d222b49d44c60d8dda27f8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 28 Mar 2015 12:29:38 +1100 Subject: [PATCH 089/223] Fix compass targeting --- .../com/intellectualcrafters/plot/commands/Target.java | 2 +- .../intellectualcrafters/plot/generator/HybridGen.java | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java index 99eb8269d..6d507888b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -40,7 +40,7 @@ public class Target extends SubCommand { return false; } if (args.length == 1) { - final PlotId id = MainUtil.parseId(args[1]); + final PlotId id = MainUtil.parseId(args[0]); if (id == null) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 07d304dba..93160525c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -144,15 +144,6 @@ public class HybridGen extends PlotGenerator { return Arrays.asList((PlotPopulator) new HybridPop(this.plotworld)); } - /** - * Return the default spawn location for this world - */ -// public Location getFixedSpawnLocation(final World world, final Random random) { -// if (this.plotworld == null) { -// return new Location(world, 0, 128, 0); -// } -// return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0); -// } /** * This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world From bdcd327d9b67003c6bb86f4ba0e0d01c82c19ede Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 28 Mar 2015 12:49:12 +1100 Subject: [PATCH 090/223] Added more title entity exceptions --- .../plot/util/bukkit/SetBlockFast_1_8.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 255456cec..8c0ab884c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -93,6 +93,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { @SuppressWarnings("deprecation") @Override public void set(final World world, final int x, final int y, final int z, final int id, final byte data) { + // Start blockstate workaround // switch (id) { case 54: @@ -112,11 +113,16 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { case 68: case 323: case 117: + case 116: case 28: case 66: case 157: case 61: case 62: + case 140: + case 146: + case 149: + case 150: case 158: case 23: case 123: @@ -140,6 +146,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { return; } } + + // Start data value shortcut Block block = world.getBlockAt(x, y, z); int currentId = block.getTypeId(); if (currentId == id) { @@ -256,11 +264,16 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { case 68: case 323: case 117: + case 116: case 28: case 66: case 157: case 61: case 62: + case 140: + case 146: + case 149: + case 150: case 158: case 23: case 123: From bcc366fc3cfa5605eb1fd9687fec5f1c0912d765 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 29 Mar 2015 17:12:32 +1100 Subject: [PATCH 091/223] Fix boolean flags defaulting to false. --- .../plot/flag/FlagValue.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 7a13427f0..92ac85edf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -48,10 +48,22 @@ public abstract class FlagValue { @Override public Boolean parse(final String t) { - try { - return Boolean.parseBoolean(t); - } catch (final IllegalArgumentException e) { - return null; + switch (t.toLowerCase()) { + case "1": + case "yes": + case "allow": + case "true": { + return true; + } + case "0": + case "no": + case "deny": + case "false": { + return false; + } + default: { + return null; + } } } From c2acdc5f5c25ab09608fb80cfe5dcc27572b4747 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 14:34:18 +1100 Subject: [PATCH 092/223] Potential fix for PhanaticD --- .../intellectualcrafters/plot/generator/HybridGen.java | 6 +++--- .../plot/generator/HybridPlotWorld.java | 2 +- .../plot/object/PlotGenerator.java | 10 ++++++++-- .../com/intellectualcrafters/plot/object/PlotLoc.java | 6 +++--- .../plot/object/PlotPopulator.java | 8 +++++++- .../plot/util/bukkit/BukkitChunkManager.java | 2 +- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 93160525c..33369253c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -178,7 +178,7 @@ public class HybridGen extends PlotGenerator { setBlock(x, y, z, this.filling); } setBlock(x, this.plotheight, z, this.plotfloors); - final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); + final PlotLoc loc = new PlotLoc((X + x), (Z + z)); final HashMap blocks = plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { @@ -216,7 +216,7 @@ public class HybridGen extends PlotGenerator { } setBlock(x, this.plotheight, z, this.plotfloors); if (this.plotworld.PLOT_SCHEMATIC) { - final PlotLoc loc = new PlotLoc((short) absX, (short) absZ); + final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = this.plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { @@ -241,7 +241,7 @@ public class HybridGen extends PlotGenerator { } } if (this.plotworld.ROAD_SCHEMATIC_ENABLED) { - final PlotLoc loc = new PlotLoc((short) absX, (short) absZ); + final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = this.plotworld.G_SCH.get(loc); if (blocks != null) { for (final Entry entry : blocks.entrySet()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index 09d10a706..525e116e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -143,7 +143,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { int x = item.x; int y = item.y; int z = item.z; - PlotLoc loc = new PlotLoc((short) x, (short) z); + PlotLoc loc = new PlotLoc(x, z); if (!G_SCH_STATE.containsKey(loc)) { G_SCH_STATE.put(loc, new HashSet()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 92f77c1ea..cc38daa92 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -82,7 +82,7 @@ public abstract class PlotGenerator extends ChunkGenerator { if (biomes != null) { biomes.setBiome(x, z, biome); } - final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); + final PlotLoc loc = new PlotLoc((X + x), (Z + z)); final HashMap blocks = ChunkManager.GENERATE_BLOCKS.get(loc); for (final Entry entry : blocks.entrySet()) { setBlock(x, entry.getKey(), z, entry.getValue()); @@ -97,7 +97,13 @@ public abstract class PlotGenerator extends ChunkGenerator { for (Entry> entry : ChunkManager.GENERATE_BLOCKS.entrySet()) { for (Entry entry2 : entry.getValue().entrySet()) { loc = entry.getKey(); - setBlock(loc.x - X, entry2.getKey(), loc.z- Z, entry2.getValue()); + int xx = loc.x - X; + int zz = loc.z - Z; + if (xx >= 0 && xx < 16) { + if (zz >= 0 && zz < 16) { + setBlock(xx, entry2.getKey(), zz, entry2.getValue()); + } + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java index ec9a91002..a413f9358 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotLoc.java @@ -1,10 +1,10 @@ package com.intellectualcrafters.plot.object; public class PlotLoc { - public short x; - public short z; + public int x; + public int z; - public PlotLoc(final short x, final short z) { + public PlotLoc(final int x, final int z) { this.x = x; this.z = z; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index d5f52d744..436318eed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -42,7 +42,13 @@ public abstract class PlotPopulator extends BlockPopulator { for (Entry> entry : ChunkManager.GENERATE_DATA.entrySet()) { for (Entry entry2 : entry.getValue().entrySet()) { loc = entry.getKey(); - setBlock(loc.x - X, entry2.getKey(), loc.z - Z, entry2.getValue()); + int xx = loc.x - X; + int zz = loc.z - Z; + if (xx >= 0 && xx < 16) { + if (zz >= 0 && zz < 16) { + setBlock(xx, entry2.getKey(), zz, entry2.getValue()); + } + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index a0f3fb1ad..099339551 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -747,7 +747,7 @@ public class BukkitChunkManager extends ChunkManager { } } } - final PlotLoc loc = new PlotLoc((short) x, (short) z); + final PlotLoc loc = new PlotLoc(x, z); GENERATE_BLOCKS.put(loc, ids); GENERATE_DATA.put(loc, datas); } From dabc551cc15636a5e0ec64a7aa1df59779416d21 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 16:43:17 +1100 Subject: [PATCH 093/223] kick check --- .../java/com/intellectualcrafters/plot/commands/Kick.java | 3 ++- .../intellectualcrafters/plot/database/PlotMeConverter.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index d539629ee..8dfd92916 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -55,7 +55,8 @@ public class Kick extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - if (!player.getLocation().getWorld().equals(loc.getWorld()) || !plot.equals(MainUtil.getPlot(loc))) { + Location otherLoc = player.getLocation(); + if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlot(otherLoc))) { MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index a76b2b2c6..6cde2cfe9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -95,6 +95,7 @@ public class PlotMeConverter { final Set worlds = plotConfig.getConfigurationSection("worlds").getKeys(false); stmt = connection.createStatement(); r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); + // TODO check if r contains UUID collumn -> assign var while (r.next()) { count++; final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); @@ -110,6 +111,7 @@ public class PlotMeConverter { if (name.equals("*")) { owner = DBFunc.everyone; } else { + // TODO check PlotMe table for UUID sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); continue; } @@ -128,6 +130,7 @@ public class PlotMeConverter { if (name.equals("*")) { helper = DBFunc.everyone; } else { + // TODO check PlotMe table for UUID sendMessage("&6Could not identify helper for plot: " + id); continue; } @@ -147,6 +150,7 @@ public class PlotMeConverter { if (name.equals("*")) { denied = DBFunc.everyone; } else { + // TODO check PlotMe table for UUID sendMessage("&6Could not identify denied for plot: " + id); continue; } From 1c0c28f5b143c8528fabc9082a261c2edd8460ca Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 16:48:07 +1100 Subject: [PATCH 094/223] Fixes #226 --- .../java/com/intellectualcrafters/plot/commands/Comment.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Inbox.java | 4 ++-- .../src/main/java/com/intellectualcrafters/plot/config/C.java | 1 + .../com/intellectualcrafters/plot/database/SQLManager.java | 2 +- .../com/intellectualcrafters/plot/object/PlotComment.java | 4 +++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 80c96a598..1ee41dbde 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -53,7 +53,7 @@ public class Comment extends SubCommand { if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { if (Permissions.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); - final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); + final PlotComment comment = new PlotComment(plot.id, text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); plot.settings.addComment(comment); DBFunc.setComment(loc.getWorld(), plot, comment); return sendMessage(plr, C.COMMENT_ADDED); 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 efce9a794..41f07221f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -171,11 +171,11 @@ public class Inbox extends SubCommand { } else { final List recipients = Arrays.asList("A", "O", "H", "T", "E"); int count = 1; - final StringBuilder message = new StringBuilder(); + final StringBuilder message = new StringBuilder(C.COMMENT_HEADER.s()+"\n"); String prefix = ""; for (final PlotComment comment : comments) { message.append(prefix).append("&c[").append(count).append("]&6[").append(recipients.get(tier2 == -1 ? 0 : tier2)).append("] &7").append(comment.senderName).append("&f: ").append(comment.comment); - prefix = "\n" + C.PREFIX; + prefix = "\n" + comment.id; count++; } if (comments.size() == 0) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index a15aa7dd0..911aca4be 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -107,6 +107,7 @@ public enum C { INVALID_INBOX("$2That is not a valid inbox.\n$1Accepted values: %s"), COMMENT_REMOVED("$4Successfully deleted %s."), COMMENT_ADDED("$4A comment has been left"), + COMMENT_HEADER("$2====== Comments ======"), /* * Console */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 605fd2ade..6ca05b1ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1084,7 +1084,7 @@ public class SQLManager implements AbstractDB { while (set.next()) { final String sender = set.getString("sender"); final String msg = set.getString("comment"); - comment = new PlotComment(msg, sender, tier); + comment = new PlotComment(plot.id, msg, sender, tier); comments.add(comment); } statement.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java index 5c5409437..2e711a496 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java @@ -27,8 +27,10 @@ public class PlotComment { public final String comment; public final int tier; public final String senderName; + public final PlotId id; - public PlotComment(final String comment, final String senderName, final int tier) { + public PlotComment(final PlotId id, final String comment, final String senderName, final int tier) { + this.id = id; this.comment = comment; this.tier = tier; this.senderName = senderName; From fffead4a16663b85c85ea78ab2849d15a93ff858 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 16:51:48 +1100 Subject: [PATCH 095/223] . --- .../java/com/intellectualcrafters/plot/commands/Inbox.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 41f07221f..3c612f6ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -171,11 +171,9 @@ public class Inbox extends SubCommand { } else { final List recipients = Arrays.asList("A", "O", "H", "T", "E"); int count = 1; - final StringBuilder message = new StringBuilder(C.COMMENT_HEADER.s()+"\n"); - String prefix = ""; + final StringBuilder message = new StringBuilder(C.COMMENT_HEADER.s()); for (final PlotComment comment : comments) { - message.append(prefix).append("&c[").append(count).append("]&6[").append(recipients.get(tier2 == -1 ? 0 : tier2)).append("] &7").append(comment.senderName).append("&f: ").append(comment.comment); - prefix = "\n" + comment.id; + message.append("\n&8[&7" + comment.id + "&8]" + "&c[" + count + "]&6[" + recipients.get(tier2 == -1 ? 0 : tier2) + "] &7" + comment.senderName + "&f: " + comment.comment); count++; } if (comments.size() == 0) { From b6d86ec1e1a4c8b19cf4eb79718d9cf3c3849f9a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 17:18:05 +1100 Subject: [PATCH 096/223] Should fix #233 --- .../plot/commands/SetOwner.java | 36 ++++++++++++++++--- .../intellectualcrafters/plot/config/C.java | 2 ++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 389331aae..b35c3dbc6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -60,14 +60,37 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.NEED_USER); return false; } - if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); - return false; - } - final String world = loc.getWorld(); + final PlotId bot = MainUtil.getBottomPlot(plot).id; final PlotId top = MainUtil.getTopPlot(plot).id; final ArrayList plots = MainUtil.getPlotSelectionIds(bot, top); + + PlotPlayer other = UUIDHandler.getPlayer(args[0]); + if (other == null) { + if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + MainUtil.sendMessage(plr, C.INVALID_PLAYER); + return false; + } + } + else { + if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + int size = plots.size(); + final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), other) + size; + if (currentPlots > MainUtil.getAllowedPlots(other)) { + sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS); + return false; + } + } + } + + if (!plot.isOwner(plr.getUUID())) { + if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); + return false; + } + } + + final String world = loc.getWorld(); for (final PlotId id : plots) { final Plot current = PlotSquared.getPlots(world).get(id); final UUID uuid = getUUID(args[0]); @@ -81,6 +104,9 @@ public class SetOwner extends SubCommand { } MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); + if (other != null) { + MainUtil.sendMessage(other, C.NOW_OWNER, plot.world + ";" + plot.id); + } return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 911aca4be..b252c5292 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -213,6 +213,7 @@ public enum C { NO_PERMISSION("$2You are lacking the permission node: $1%s"), NO_PLOT_PERMS("$2You must be the plot owner to perform this action"), CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."), + CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user"), CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"), YOU_BE_DENIED("$2You are not allowed to enter this plot"), NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"), @@ -437,6 +438,7 @@ public enum C { * Set Owner */ SET_OWNER("$4You successfully set the plot owner"), + NOW_OWNER("$4You are now owner of plot %s"), /* * Signs */ From 86a7974f841830970bfddf91e0fe73174315daae Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 21:05:40 +1100 Subject: [PATCH 097/223] getSchematic feedback if selection contains non-existent chunk --- .../com/intellectualcrafters/plot/database/SQLManager.java | 4 ++++ .../plot/generator/ClassicPlotManager.java | 2 +- .../plot/util/BukkitSchematicHandler.java | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 6ca05b1ea..62e53f9e0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -66,6 +66,10 @@ public class SQLManager implements AbstractDB { private final String prefix; // Private Final private Connection connection; + + public Connection getConnection() { + return this.connection; + } /** * Constructor diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index 4b8a53554..4b09eb12b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -33,7 +33,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { } return false; } - + public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java index ceb53ae53..a6f2bfa83 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java @@ -61,12 +61,13 @@ public class BukkitSchematicHandler extends SchematicHandler { for (j = (pos1.getZ() / 16) * 16; j < (16 + ((pos2.getZ() / 16) * 16)); j += 16) { boolean result = ChunkManager.manager.loadChunk(world, new ChunkLoc(i, j)); if (!result) { + System.out.print("&cIllegal selection. Cannot save non-existent chunk at " + (i / 16) + ", " + (j / 16)); return null; } } } } catch (final Exception e) { - PlotSquared.log("&7 - Cannot save: corrupt chunk at " + (i / 16) + ", " + (j / 16)); + PlotSquared.log("&cIllegal selection. Cannot save corrupt chunk at " + (i / 16) + ", " + (j / 16)); return null; } final int width = (pos2.getX() - pos1.getX()) + 1; From 7b96bdd9077cf5f68c53776c61d9374a6aabb50a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 23:14:38 +1100 Subject: [PATCH 098/223] Experimental PlotMe UUID cache --- .../plot/PlotSquared.java | 4 ++- .../plot/config/Settings.java | 1 + .../plot/database/DBFunc.java | 26 +++++++++++++- .../plot/database/PlotMeConverter.java | 35 ++++++++++++++++--- .../plot/util/SchematicHandler.java | 1 + 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 4138a6ef0..7be29b885 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -514,7 +514,7 @@ public class PlotSquared { // Set chunk ChunkManager.manager = IMP.initChunkManager(); // PlotMe - if (Settings.CONVERT_PLOTME) { + if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -773,6 +773,7 @@ public class PlotSquared { options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); options.put("plotme-alias", Settings.USE_PLOTME_ALIAS); options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME); + options.put("plotme-convert.cache-uuids", Settings.CACHE_PLOTME); options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); options.put("UUID.offline", Settings.OFFLINE_MODE); options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); @@ -815,6 +816,7 @@ public class PlotSquared { Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login"); Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias"); Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled"); + Settings.CACHE_PLOTME = config.getBoolean("plotme-convert.cache-uuids"); Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding"); Settings.METRICS = config.getBoolean("metrics"); 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 6b62fdb4e..f1bbd125f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -39,6 +39,7 @@ public class Settings { * */ public static boolean CONVERT_PLOTME = true; + public static boolean CACHE_PLOTME = false; public static boolean USE_PLOTME_ALIAS = false; /** * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index c43509403..3261d51f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -20,6 +20,9 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.database; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -53,7 +56,28 @@ public class DBFunc { public static void movePlot(final Plot originalPlot, final Plot newPlot) { dbManager.movePlot(originalPlot, newPlot); } - + /** + * Check if a resultset contains a column + * @param rs + * @param columnName + * @return + * @throws SQLException + */ + public static boolean hasColumn(ResultSet r, String name) { + try { + ResultSetMetaData meta = r.getMetaData(); + int count = meta.getColumnCount(); + for (int x = 1; x <= count; x++) { + if (name.equals(meta.getColumnName(x))) { + return true; + } + } + return false; + } + catch (SQLException e) { + return false; + } + } /** * Set the owner of a plot * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 6cde2cfe9..7832f3100 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.database; import java.io.File; import java.io.IOException; +import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -39,9 +40,11 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -96,6 +99,9 @@ public class PlotMeConverter { stmt = connection.createStatement(); r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); // TODO check if r contains UUID collumn -> assign var + + boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); + while (r.next()) { count++; final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); @@ -110,15 +116,36 @@ public class PlotMeConverter { if (owner == null) { if (name.equals("*")) { owner = DBFunc.everyone; - } else { - // TODO check PlotMe table for UUID - sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); - continue; + } + else { + if (checkUUID){ + try { + byte[] bytes = r.getBytes("ownerid"); + if (bytes != null) { + owner = UUID.nameUUIDFromBytes(bytes); + if (owner != null) { + UUIDHandler.add(new StringWrapper(name), owner); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + if (owner == null) { + sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + continue; + } } } final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); plots.get(world).put(id, plot); } + + if (!Settings.CONVERT_PLOTME) { + return; + } + sendMessage(" - plotmeAllowed"); r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`"); while (r.next()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index ce35aab44..ff82d9fe3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -214,6 +214,7 @@ public abstract class SchematicHandler { } try { final File tmp = new File(path); + System.out.print("ABS: " + tmp.getAbsolutePath()); tmp.getParentFile().mkdirs(); final OutputStream stream = new FileOutputStream(path); final NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream)); From fc4cfb63195cd21d1fc9b6735cfd0a36be70aa6d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 23:37:01 +1100 Subject: [PATCH 099/223] Incremented version number --- PlotSquared/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index aa18cace3..f30790593 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.8.12 + 2.9.0 PlotSquared jar From 331898c081a1403131d136ebd6a891a507af8346 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 31 Mar 2015 23:55:34 +1100 Subject: [PATCH 100/223] typo --- .../java/com/intellectualcrafters/plot/commands/SetOwner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index b35c3dbc6..c3326e0cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -68,7 +68,7 @@ public class SetOwner extends SubCommand { PlotPlayer other = UUIDHandler.getPlayer(args[0]); if (other == null) { if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } } From 3477132cf22c9be39decf59b9fe572b4a6825635 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 08:00:09 +1100 Subject: [PATCH 101/223] Fix custom explosions not workin --- .../intellectualcrafters/plot/listeners/PlayerEvents.java | 5 +++-- .../com/intellectualcrafters/plot/listeners/TNTListener.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) 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 fcd40db40..483484031 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -203,7 +203,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi plotEntry(player, plot); } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public static void PlayerMove(final PlayerMoveEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); final Location t = BukkitUtil.getLocation(event.getTo()); @@ -252,7 +252,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!plot.equals(getCurrentPlot(f))) { plotEntry(player, plot); } - } else if (leftPlot(f, t)) { + } + else if (leftPlot(f, t)) { plot = getCurrentPlot(f); plotExit(player, plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java index 07e5ff535..768d235f0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/TNTListener.java @@ -29,6 +29,9 @@ public class TNTListener implements Listener { @EventHandler public void onExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); + if (entity == null) { + return; + } World world = entity.getWorld(); String worldname = world.getName(); if (!PlotSquared.isPlotWorld(worldname)) { From 8b62ba9d6509516df1afb946de6a7a80473a160a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 11:52:22 +1100 Subject: [PATCH 102/223] more efficient plot diff calculations --- .../plot/database/PlotMeConverter.java | 1 - .../plot/generator/BukkitHybridUtils.java | 76 ++++++++++++++++++- .../plot/generator/HybridUtils.java | 33 +------- .../plot/util/TaskManager.java | 6 ++ .../plot/util/bukkit/BukkitChunkManager.java | 33 ++++---- 5 files changed, 96 insertions(+), 53 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 7832f3100..df9fc0035 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.database; import java.io.File; import java.io.IOException; -import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 155f1c960..8595105e9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -1,8 +1,11 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; @@ -13,14 +16,82 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { + + public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone) { + TaskManager.index.increment(); + + final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + + int bx = bot.getX() >> 4; + int bz = bot.getZ() >> 4; + + int tx = top.getX() >> 4; + int tz = top.getZ() >> 4; + + int size = (tx-bx) << 4; + World world = BukkitUtil.getWorld(plot.world); + + final HashSet chunks = new HashSet<>(); + for (int X = bx; X <= tx; X++) { + for (int Z = bz; Z <= tz; Z++) { + chunks.add(world.getChunkAt(X,Z)); + } + } + + PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); + if (!(plotworld instanceof ClassicPlotWorld)) { + TaskManager.runTaskLater(whenDone, 1); + return; + } + + final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld; + + final MutableInt count = new MutableInt(0); + + final Integer currentIndex = TaskManager.index.toInteger(); + final Integer task = TaskManager.runTaskRepeat(new Runnable() { + @Override + public void run() { + if (count.intValue() >= requiredChanges) { + TaskManager.runTaskLater(whenDone, 1); + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + return; + } + if (chunks.size() == 0) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + return; + } + final Chunk chunk = chunks.iterator().next(); + int bx = Math.max(chunk.getX() >> 4, bot.getX()); + int bz = Math.max(chunk.getZ() >> 4, bot.getZ()); + int ex = Math.max((chunk.getX() >> 4) + 15, top.getX()); + int ez = Math.max((chunk.getZ() >> 4) + 15, top.getZ()); + // count changes + count.add(checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK)); + count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK)); + } + }, 1); + TaskManager.tasks.put(currentIndex, task); + + } @Override - public int checkModified(final int threshhold, final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { + public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) { final World world = BukkitUtil.getWorld(worldname); int count = 0; for (int y = y1; y <= y2; y++) { @@ -37,9 +108,6 @@ public class BukkitHybridUtils extends HybridUtils { } if (!same) { count++; - if (count > threshhold) { - return -1; - } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index 979b90bf7..b6dc94eb5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -16,41 +16,14 @@ import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public abstract class HybridUtils { public static HybridUtils manager; + + public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed); - public boolean checkModified(final Plot plot, int requiredChanges) { - final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); - final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); - final int botx = bottom.getX(); - final int botz = bottom.getZ(); - final int topx = top.getX(); - final int topz = top.getZ(); - final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(plot.world); - final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }; - int changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK); - if (changes == -1) { - return true; - } - requiredChanges -= changes; - changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air); - if (changes == -1) { - return true; - } - requiredChanges -= changes; - changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 2, BukkitUtil.getMaxHeight(plot.world) - 1, botz, topz, air); - if (changes == -1) { - return true; - } - requiredChanges -= changes; - changes = checkModified(requiredChanges, plot.world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK); - return changes == -1; - } - - public abstract int checkModified(final int threshhold, final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); + public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); public boolean setupRoadSchematic(final Plot plot) { final String world = plot.world; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java index 8986fa2ba..526eec67c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -1,11 +1,17 @@ package com.intellectualcrafters.plot.util; +import java.util.HashMap; import java.util.HashSet; +import org.apache.commons.lang.mutable.MutableInt; + import com.intellectualcrafters.plot.PlotSquared; public abstract class TaskManager { public static HashSet TELEPORT_QUEUE = new HashSet<>(); + + public static MutableInt index = new MutableInt(0); + public static HashMap tasks = new HashMap<>(); public abstract int taskRepeat(final Runnable r, int interval); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 099339551..ffd46cbde 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -59,9 +59,6 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitChunkManager extends ChunkManager { - public static MutableInt index = new MutableInt(0); - public static HashMap tasks = new HashMap<>(); - @Override public ArrayList getChunkChunks(final String world) { final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region"; @@ -152,7 +149,7 @@ public class BukkitChunkManager extends ChunkManager { */ @Override public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { - index.increment(); + TaskManager.index.increment(); final int relX = newPos.getX() - pos1.getX(); final int relZ = newPos.getZ() - pos1.getZ(); @@ -183,19 +180,19 @@ public class BukkitChunkManager extends ChunkManager { } } final Plugin plugin = BukkitMain.THIS; - final Integer currentIndex = index.toInteger(); + final Integer currentIndex = TaskManager.index.toInteger(); final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { final long start = System.currentTimeMillis(); while ((System.currentTimeMillis() - start) < 25) { if (toGenerate.size() == 0) { - Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); - tasks.remove(currentIndex); + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); TaskManager.runTask(new Runnable() { @Override public void run() { - index.increment(); + TaskManager.index.increment(); // Copy entities initMaps(); for (int x = c1x; x <= c2x; x++) { @@ -209,7 +206,7 @@ public class BukkitChunkManager extends ChunkManager { restoreEntities(newWorld, relX, relZ); // Copy blocks final MutableInt mx = new MutableInt(sx); - final Integer currentIndex = index.toInteger(); + final Integer currentIndex = TaskManager.index.toInteger(); final int maxY = oldWorld.getMaxHeight(); final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override @@ -234,14 +231,14 @@ public class BukkitChunkManager extends ChunkManager { chunk.unload(true, true); } TaskManager.runTask(whenDone); - Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); - tasks.remove(currentIndex); + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); return; } } }; }, 1, 1); - tasks.put(currentIndex, task); + TaskManager.tasks.put(currentIndex, task); } }); return; @@ -253,13 +250,13 @@ public class BukkitChunkManager extends ChunkManager { } } }, 1l, 1l); - tasks.put(currentIndex, loadTask); + TaskManager.tasks.put(currentIndex, loadTask); return true; } @Override public boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone) { - index.increment(); + TaskManager.index.increment(); final Plugin plugin = BukkitMain.THIS; final World world = Bukkit.getWorld(pos1.getWorld()); final Chunk c1 = world.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4); @@ -282,14 +279,14 @@ public class BukkitChunkManager extends ChunkManager { } } final int maxY = world.getMaxHeight(); - final Integer currentIndex = index.toInteger(); + final Integer currentIndex = TaskManager.index.toInteger(); final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { if (chunks.size() == 0) { TaskManager.runTaskLater(whenDone, 1); - Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); - tasks.remove(currentIndex); + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); return; } CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); @@ -346,7 +343,7 @@ public class BukkitChunkManager extends ChunkManager { CURRENT_PLOT_CLEAR = null; } }, 1, 1); - tasks.put(currentIndex, task); + TaskManager.tasks.put(currentIndex, task); return true; } From 6927351bfb7bae2c4c3a475bdf3be568049286df Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 19:13:05 +1100 Subject: [PATCH 103/223] PlotMe cache for offline-mode --- PlotSquared/pom.xml | 2 +- .../plot/database/PlotMeConverter.java | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index f30790593..1a9532c40 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.0 + 2.9.1 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index df9fc0035..0bb8a36e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -75,8 +75,10 @@ public class PlotMeConverter { if (!plotMeFile.exists()) { return; } + sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'"); sendMessage("Connecting to PlotMe DB"); + final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile); int count = 0; Connection connection; @@ -90,6 +92,7 @@ public class PlotMeConverter { } sendMessage("Collecting plot data"); sendMessage(" - plotmePlots"); + ResultSet r; Statement stmt; final HashMap plotSize = new HashMap<>(); @@ -97,8 +100,7 @@ public class PlotMeConverter { final Set worlds = plotConfig.getConfigurationSection("worlds").getKeys(false); stmt = connection.createStatement(); r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); - // TODO check if r contains UUID collumn -> assign var - + boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); while (r.next()) { @@ -137,6 +139,9 @@ public class PlotMeConverter { } } } + else { + UUIDHandler.add(new StringWrapper(name), owner); + } final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); plots.get(world).put(id, plot); } @@ -156,7 +161,6 @@ public class PlotMeConverter { if (name.equals("*")) { helper = DBFunc.everyone; } else { - // TODO check PlotMe table for UUID sendMessage("&6Could not identify helper for plot: " + id); continue; } @@ -176,7 +180,6 @@ public class PlotMeConverter { if (name.equals("*")) { denied = DBFunc.everyone; } else { - // TODO check PlotMe table for UUID sendMessage("&6Could not identify denied for plot: " + id); continue; } @@ -302,26 +305,28 @@ public class PlotMeConverter { sendMessage("Reloading generator for world: '" + actualWorldName + "'..."); PlotSquared.removePlotWorld(actualWorldName); if (MV) { - // unload + // unload world with MV Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName); try { Thread.sleep(1000); } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); } - // load + // load world with MV Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared"); } else if (MW) { - // unload + // unload world with MW Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName); try { Thread.sleep(1000); } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); } - // load + // load world with MW Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared"); } else { + // Load using Bukkit API + // - User must set generator manually Bukkit.getServer().unloadWorld(world, true); final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld(); myworld.save(); From 6005501320bb661388273118c3eb09ab235ce823 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 19:25:58 +1100 Subject: [PATCH 104/223] Optional disable of TNT Listener --- .../intellectualcrafters/plot/BukkitMain.java | 7 ++++++- .../com/intellectualcrafters/plot/IPlotMain.java | 2 ++ .../intellectualcrafters/plot/PlotSquared.java | 9 ++------- .../plot/config/Settings.java | 16 ++++++---------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index cb7c3b7a0..323e81446 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -110,8 +110,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { Bukkit.getServer().unloadWorld(world, true); } } - getServer().getPluginManager().registerEvents(new TNTListener(), this); } + @Override public void onDisable() { @@ -371,4 +371,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public EventUtil initEventUtil() { return new BukkitEventUtil(); } + + @Override + public void registerTNTListener() { + getServer().getPluginManager().registerEvents(new TNTListener(), this); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index f2387d0b1..fce6ee906 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -38,6 +38,8 @@ public interface IPlotMain { public void registerForceFieldEvents(); public void registerWorldEditEvents(); + + public void registerTNTListener(); public Economy getEconomy(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 7be29b885..f2ad55392 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -763,12 +763,10 @@ public class PlotSquared { final Map options = new HashMap<>(); options.put("teleport.delay", 0); options.put("auto_update", false); - options.put("confirmation.clear", Settings.CONFIRM_CLEAR); options.put("confirmation.delete", Settings.CONFIRM_DELETE); options.put("confirmation.unlink", Settings.CONFIRM_UNLINK); - - + options.put("protection.tnt-listener.enabled", Settings.TNT_LISTENER); options.put("clusters.enabled", Settings.ENABLE_CLUSTERS); options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); options.put("plotme-alias", Settings.USE_PLOTME_ALIAS); @@ -788,9 +786,7 @@ public class PlotSquared { options.put("max_plots", Settings.MAX_PLOTS); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK); - options.put("cache.permissions", Settings.PERMISSION_CACHING); - options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); @@ -804,13 +800,12 @@ public class PlotSquared { if (Settings.DEBUG) { log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } - + Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled"); Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete"); Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink"); Settings.FAST_CLEAR = config.getBoolean("clear.fastmode"); - Settings.TELEPORT_DELAY = config.getInt("teleport.delay"); Settings.CONSOLE_COLOR = config.getBoolean("console.color"); Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login"); 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 f1bbd125f..8e8e4510a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -36,13 +36,17 @@ public class Settings { public static boolean PERMISSION_CACHING = false; public static boolean UUID_FROM_DISK = false; /** - * + * PlotMe settings */ public static boolean CONVERT_PLOTME = true; public static boolean CACHE_PLOTME = false; public static boolean USE_PLOTME_ALIAS = false; /** - * + * TNT listener + */ + public static boolean TNT_LISTENER = false; + /** + * Max auto claiming size */ public static int MAX_AUTO_SIZE = 4; /** @@ -61,14 +65,6 @@ public class Settings { * Teleport to path on login */ public static boolean TELEPORT_ON_LOGIN = false; - /** - * Mob Cap Enabled - */ - // public static boolean MOB_CAP_ENABLED = false; - /** - * The Mob Cap - */ - // public static int MOB_CAP = 20; /** * Display titles */ From 33256e0ea4be49314329376454a7b939eb08bec1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 22:14:00 +1100 Subject: [PATCH 105/223] Fix move command --- .../com/intellectualcrafters/plot/commands/Command.java | 1 + .../java/com/intellectualcrafters/plot/commands/Move.java | 6 +++++- .../java/com/intellectualcrafters/plot/util/MainUtil.java | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 4e861414c..c2a120566 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -34,6 +34,7 @@ public enum Command { // (Rating system) (ratings can be stored as the average, and number of // ratings) // - /plot rate + MOVE("move", ""), FLAG("flag", "f"), TARGET("target"), CLUSTER("cluster", "clusters"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 8630cacd0..29e20489f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -37,7 +38,7 @@ import com.intellectualcrafters.plot.util.Permissions; */ public class Move extends SubCommand { public Move() { - super("debugmove", "plots.move", "Move a plot", "move", "", CommandCategory.ACTIONS, true); + super(Command.MOVE, "Move a plot", "debugmove", CommandCategory.ACTIONS, true); } @Override @@ -77,6 +78,9 @@ public class Move extends SubCommand { world2 = world; } Plot plot2 = MainUtil.getPlot(world2, plot2id); + + System.out.print(plot1 + " | " + plot2); + if (plot1.equals(plot2)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 90faf6f75..fe1bb8fbd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -859,7 +859,7 @@ public class MainUtil { public static boolean move(final Plot plot1, final Plot plot2, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); - final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); + final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot1.id); final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id); if (plot1.owner == null) { TaskManager.runTaskLater(whenDone, 1); @@ -883,6 +883,9 @@ public class MainUtil { plot.id.y += offset_y; PlotSquared.getPlots(plot2.world).put(plot.id, plot); } + System.out.print("BOT: " + bot1); + System.out.print("TOP: " + top); + System.out.print(" -> " + bot2); ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { @Override public void run() { From 57e8563b31b99175c548ed1616da5b062cd19742 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 23:36:46 +1100 Subject: [PATCH 106/223] Multiple fixe --- .../plot/commands/Move.java | 2 - .../plot/generator/HybridGen.java | 6 +-- .../plot/generator/HybridPop.java | 42 +++++++------------ .../plot/object/BukkitPlayer.java | 3 -- .../plot/object/PlotGenerator.java | 4 +- .../plot/object/PlotPopulator.java | 4 +- .../plot/util/BukkitSchematicHandler.java | 2 +- .../plot/util/MainUtil.java | 9 ++-- .../plot/util/SchematicHandler.java | 1 - .../plot/util/bukkit/BukkitChunkManager.java | 11 ++++- 10 files changed, 37 insertions(+), 47 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 29e20489f..20b322201 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -79,8 +79,6 @@ public class Move extends SubCommand { } Plot plot2 = MainUtil.getPlot(world2, plot2id); - System.out.print(plot1 + " | " + plot2); - if (plot1.equals(plot2)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 33369253c..10a6b5991 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -111,7 +111,6 @@ public class HybridGen extends PlotGenerator { if (this.maxY == 0) { this.maxY = 256; } - } /** @@ -190,14 +189,15 @@ public class HybridGen extends PlotGenerator { } return; } - int sx = ((cx << 4) % this.size); - int sz = ((cz << 4) % this.size); + int sx = (short) ((this.X) % this.size); + int sz = (short) ((this.Z) % this.size); if (sx < 0) { sx += this.size; } if (sz < 0) { sz += this.size; } + for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (biomes != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 4f8d467ef..f0e056e6d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; +import java.util.Map.Entry; import org.bukkit.World; import org.bukkit.block.Biome; @@ -39,8 +40,6 @@ public class HybridPop extends PlotPopulator { final short pathWidthLower; final short pathWidthUpper; Biome biome; - private int X; - private int Z; private long state; private boolean doFilling = false; private boolean doFloor = false; @@ -107,8 +106,6 @@ public class HybridPop extends PlotPopulator { @Override public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) { - this.X = cx << 4; - this.Z = cz << 4; PlotSquared.getPlotManager(world.getName()); if (requiredRegion != null) { short sx = (short) ((this.X) % this.size); @@ -119,6 +116,7 @@ public class HybridPop extends PlotPopulator { if (sz < 0) { sz += this.size; } + for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (contains(requiredRegion, this.X + x, this.Z + z)) { @@ -152,33 +150,29 @@ public class HybridPop extends PlotPopulator { } return; } - short sx = (short) ((this.X) % this.size); - short sz = (short) ((this.Z) % this.size); + int sx = (short) ((this.X) % this.size); + int sz = (short) ((this.Z) % this.size); if (sx < 0) { sx += this.size; } if (sz < 0) { sz += this.size; } - // Setting biomes + for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - final short absX = (short) ((sx + x) % this.size); - final short absZ = (short) ((sz + z) % this.size); + final int absX = ((sx + x) % this.size); + final int absZ = ((sz + z) % this.size); final boolean gx = absX > this.pathWidthLower; final boolean gz = absZ > this.pathWidthLower; final boolean lx = absX < this.pathWidthUpper; final boolean lz = absZ < this.pathWidthUpper; // inside plot if (gx && gz && lx && lz) { - if (this.doFilling) { - for (short y = 1; y < this.plotheight; y++) { - setBlock(x, y, z, this.filling); - } - } - if (this.doFloor) { - setBlock(x, (short) this.plotheight, z, this.plotfloors); + for (short y = 1; y < this.plotheight; y++) { + setBlock(x, y, z, this.filling); } + setBlock(x, (short) this.plotheight, z, this.plotfloors); if (this.plotworld.PLOT_SCHEMATIC) { final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); @@ -201,21 +195,17 @@ public class HybridPop extends PlotPopulator { } else { // wall if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { - if (this.wallfilling != 0) { - for (short y = 1; y <= this.wallheight; y++) { - setBlock(x, y, z, this.wallfilling); - } + for (short y = 1; y <= this.wallheight; y++) { + setBlock(x, y, z, this.wallfilling); } - if ((this.wall != 0) && !this.plotworld.ROAD_SCHEMATIC_ENABLED) { - setBlock(x, (short) (this.wallheight + 1), z, this.wall); + if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) { + setBlock(x, this.wallheight + 1, z, this.wall); } } // road else { - if (this.roadblock != 0) { - for (short y = 1; y <= this.roadheight; y++) { - setBlock(x, y, z, this.roadblock); - } + for (short y = 1; y <= this.roadheight; y++) { + setBlock(x, y, z, this.roadblock); } } if (this.plotworld.ROAD_SCHEMATIC_ENABLED) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 5cc267c79..dc7c85592 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -23,9 +23,6 @@ public class BukkitPlayer implements PlotPlayer { * @param player */ public BukkitPlayer(final Player player) { - if (player == null) { - System.out.print("=================== NULL PLAYER ========================="); - } this.player = player; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index cc38daa92..f38c8731e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -36,8 +36,8 @@ import com.intellectualcrafters.plot.util.ChunkManager; public abstract class PlotGenerator extends ChunkGenerator { private short[][] result; - private int X; - private int Z; + public int X; + public int Z; private PseudoRandom random = new PseudoRandom(); @SuppressWarnings("unchecked") diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index 436318eed..15852aea6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -15,8 +15,8 @@ public abstract class PlotPopulator extends BlockPopulator { private PseudoRandom random = new PseudoRandom(); - private int X; - private int Z; + public int X; + public int Z; private World world; @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java index a6f2bfa83..f7c8ede99 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java @@ -61,7 +61,7 @@ public class BukkitSchematicHandler extends SchematicHandler { for (j = (pos1.getZ() / 16) * 16; j < (16 + ((pos2.getZ() / 16) * 16)); j += 16) { boolean result = ChunkManager.manager.loadChunk(world, new ChunkLoc(i, j)); if (!result) { - System.out.print("&cIllegal selection. Cannot save non-existent chunk at " + (i / 16) + ", " + (j / 16)); + PlotSquared.log("&cIllegal selection. Cannot save non-existent chunk at " + (i / 16) + ", " + (j / 16)); return null; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index fe1bb8fbd..28848045d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -859,7 +859,7 @@ public class MainUtil { public static boolean move(final Plot plot1, final Plot plot2, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); - final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot1.id); + final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot2.id); final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id); if (plot1.owner == null) { TaskManager.runTaskLater(whenDone, 1); @@ -876,16 +876,15 @@ public class MainUtil { final int offset_y = plot2.id.y - pos1.id.y; final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); for (final PlotId id : selection) { - DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); + String worldOriginal = plot1.world; + PlotId idOriginal = new PlotId(id.x, id.y); final Plot plot = PlotSquared.getPlots(plot1.world).get(id); PlotSquared.getPlots(plot1.world).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; PlotSquared.getPlots(plot2.world).put(plot.id, plot); + DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); } - System.out.print("BOT: " + bot1); - System.out.print("TOP: " + top); - System.out.print(" -> " + bot2); ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index ff82d9fe3..ce35aab44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -214,7 +214,6 @@ public abstract class SchematicHandler { } try { final File tmp = new File(path); - System.out.print("ABS: " + tmp.getAbsolutePath()); tmp.getParentFile().mkdirs(); final OutputStream stream = new FileOutputStream(path); final NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index ffd46cbde..de33208f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -200,10 +200,8 @@ public class BukkitChunkManager extends ChunkManager { final Chunk chunk = oldWorld.getChunkAt(x, z); chunks.add(chunk); chunk.load(false); - saveEntitiesIn(chunk, region); } } - restoreEntities(newWorld, relX, relZ); // Copy blocks final MutableInt mx = new MutableInt(sx); final Integer currentIndex = TaskManager.index.toInteger(); @@ -225,7 +223,16 @@ public class BukkitChunkManager extends ChunkManager { } mx.increment(); if (xv == ex) { // done! + for (int x = c1x; x <= c2x; x++) { + for (int z = c1z; z <= c2z; z++) { + final Chunk chunk = oldWorld.getChunkAt(x, z); + chunks.add(chunk); + chunk.load(false); + saveEntitiesIn(chunk, region); + } + } restoreBlocks(newWorld, relX, relZ); + restoreEntities(newWorld, relX, relZ); BukkitSetBlockManager.setBlockManager.update(chunks); for (final Chunk chunk : chunks) { chunk.unload(true, true); From 424e032be40a956d11d37ab42a17b6319cd1d2c8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 23:41:11 +1100 Subject: [PATCH 107/223] I'll do this later. --- .../plot/database/PlotMeConverter.java | 174 +++++++++++------- 1 file changed, 107 insertions(+), 67 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 0bb8a36e8..c4c554815 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -25,10 +25,12 @@ import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; +import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Map.Entry; import java.util.Set; import java.util.UUID; @@ -62,6 +64,91 @@ public class PlotMeConverter { private void sendMessage(final String message) { PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message); } + + public String getPlotMePath() { + return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator; + } + + public FileConfiguration getPlotMeConfig(String dataFolder) { + final File plotMeFile = new File(dataFolder + "config.yml"); + if (!plotMeFile.exists()) { + return null; + } + return YamlConfiguration.loadConfiguration(plotMeFile); + } + + public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) { + try { + if (plotConfig.getBoolean("usemySQL")) { + final String user = plotConfig.getString("mySQLuname"); + final String password = plotConfig.getString("mySQLpass"); + final String con = plotConfig.getString("mySQLconn"); + return DriverManager.getConnection(con, user, password); + } else { + return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection(); + } + } + catch (SQLException | ClassNotFoundException e) {} + return null; + } + + public Set getPlotMeWorlds(FileConfiguration plotConfig) { + return plotConfig.getConfigurationSection("worlds").getKeys(false); + } + + public HashMap> getPlotMePlots(Connection connection) throws SQLException { + ResultSet r; + Statement stmt; + final HashMap plotSize = new HashMap<>(); + final HashMap> plots = new HashMap<>(); + stmt = connection.createStatement(); + r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); + + boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); + + while (r.next()) { + final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); + final String name = r.getString("owner"); + final String world = getWorld(r.getString("world")); + if (!plotSize.containsKey(world)) { + final int size = r.getInt("topZ") - r.getInt("bottomZ"); + plotSize.put(world, size); + plots.put(world, new HashMap()); + } + UUID owner = UUIDHandler.getUUID(name); + if (owner == null) { + if (name.equals("*")) { + owner = DBFunc.everyone; + } + else { + if (checkUUID){ + try { + byte[] bytes = r.getBytes("ownerid"); + if (bytes != null) { + owner = UUID.nameUUIDFromBytes(bytes); + if (owner != null) { + UUIDHandler.add(new StringWrapper(name), owner); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + if (owner == null) { + sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + continue; + } + } + } + else { + UUIDHandler.add(new StringWrapper(name), owner); + } + final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); + plots.get(world).put(id, plot); + } + return plots; + } public void runAsync() throws Exception { // We have to make it wait a couple of seconds @@ -69,81 +156,32 @@ public class PlotMeConverter { @Override public void run() { try { - final ArrayList createdPlots = new ArrayList<>(); - final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator; - final File plotMeFile = new File(dataFolder + "config.yml"); - if (!plotMeFile.exists()) { + String dataFolder = getPlotMePath(); + FileConfiguration plotConfig = getPlotMeConfig(dataFolder); + + if (plotConfig == null) { return; } + Connection connection = getPlotMeConnection(plotConfig, dataFolder); + + if (connection == null) { + sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue"); + } + sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'"); sendMessage("Connecting to PlotMe DB"); - final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile); - int count = 0; - Connection connection; - if (plotConfig.getBoolean("usemySQL")) { - final String user = plotConfig.getString("mySQLuname"); - final String password = plotConfig.getString("mySQLpass"); - final String con = plotConfig.getString("mySQLconn"); - connection = DriverManager.getConnection(con, user, password); - } else { - connection = new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection(); - } + int plotCount = 0; + final ArrayList createdPlots = new ArrayList<>(); + sendMessage("Collecting plot data"); sendMessage(" - plotmePlots"); - ResultSet r; - Statement stmt; - final HashMap plotSize = new HashMap<>(); - final HashMap> plots = new HashMap<>(); - final Set worlds = plotConfig.getConfigurationSection("worlds").getKeys(false); - stmt = connection.createStatement(); - r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); - - boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); - - while (r.next()) { - count++; - final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); - final String name = r.getString("owner"); - final String world = getWorld(r.getString("world")); - if (!plotSize.containsKey(world)) { - final int size = r.getInt("topZ") - r.getInt("bottomZ"); - plotSize.put(world, size); - plots.put(world, new HashMap()); - } - UUID owner = UUIDHandler.getUUID(name); - if (owner == null) { - if (name.equals("*")) { - owner = DBFunc.everyone; - } - else { - if (checkUUID){ - try { - byte[] bytes = r.getBytes("ownerid"); - if (bytes != null) { - owner = UUID.nameUUIDFromBytes(bytes); - if (owner != null) { - UUIDHandler.add(new StringWrapper(name), owner); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - if (owner == null) { - sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); - continue; - } - } - } - else { - UUIDHandler.add(new StringWrapper(name), owner); - } - final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); - plots.get(world).put(id, plot); + final Set worlds = getPlotMeWorlds(plotConfig); + HashMap> plots = getPlotMePlots(connection); + for (Entry> entry : plots.entrySet()) { + plotCount += entry.getValue().size(); } if (!Settings.CONVERT_PLOTME) { @@ -151,6 +189,8 @@ public class PlotMeConverter { } sendMessage(" - plotmeAllowed"); + ResultSet r; + Statement stmt = connection.createStatement(); r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`"); while (r.next()) { final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); @@ -188,7 +228,7 @@ public class PlotMeConverter { plots.get(world).get(id).denied.add(denied); } } - sendMessage("Collected " + count + " plots from PlotMe"); + sendMessage("Collected " + plotCount + " plots from PlotMe"); for (final String world : plots.keySet()) { sendMessage("Copying config for: " + world); try { From b03c428ca432139d305f0814b333878cf3ef79e5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Apr 2015 00:20:28 +1100 Subject: [PATCH 108/223] Reload will now attempt to reload all worlds. --- .../src/main/java/com/intellectualcrafters/plot/BukkitMain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 323e81446..b145d76ab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -107,7 +107,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (worlds.size() > 0) { UUIDHandler.cacheAll(worlds.get(0).getName()); for (World world : worlds) { - Bukkit.getServer().unloadWorld(world, true); + Bukkit.getServer().unloadWorld(world, false); } } } From b0384f40741d194e4a60e56a2eed066d8c96313f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Apr 2015 11:56:34 +1100 Subject: [PATCH 109/223] Various other fixes --- PlotSquared/pom.xml | 2 +- .../intellectualcrafters/plot/BukkitMain.java | 7 +------ .../plot/generator/AugmentedPopulator.java | 6 ++++-- .../plot/generator/BukkitHybridUtils.java | 2 +- .../plot/util/ClusterManager.java | 3 ++- .../plot/util/MainUtil.java | 8 +++++-- .../plot/util/bukkit/BukkitChunkManager.java | 5 +---- .../plot/util/bukkit/BukkitSetupUtils.java | 4 ++-- .../plot/util/bukkit/SendChunk.java | 21 ++++++++++++++++--- .../plot/util/bukkit/SetBlockFast.java | 21 ++++++++++++++++--- .../plot/util/bukkit/SetBlockFast_1_8.java | 6 +++--- .../plot/util/bukkit/SetBlockSlow.java | 16 +++++++++++++- 12 files changed, 72 insertions(+), 29 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 1a9532c40..44fae6f26 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.1 + 2.9.2 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index b145d76ab..2e2654d73 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -289,12 +289,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { BlockUpdateUtil.setBlockManager = BukkitSetBlockManager.setBlockManager; try { new SendChunk(); - if (checkVersion(1, 7, 10) && !checkVersion(1, 7, 11)) { - MainUtil.canSendChunk = false; - } - else { - MainUtil.canSendChunk = true; - } + MainUtil.canSendChunk = true; } catch (final Throwable e) { MainUtil.canSendChunk = false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index 9991b745f..fe284fdcb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -11,6 +11,7 @@ import org.bukkit.generator.BlockPopulator; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.BlockWrapper; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotGenerator; @@ -19,6 +20,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; @@ -128,7 +130,7 @@ public class AugmentedPopulator extends BlockPopulator { @Override public void run() { populateBiome(world, x, z); - chunk.unload(true, true); + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } }, 20); } else { @@ -143,7 +145,7 @@ public class AugmentedPopulator extends BlockPopulator { public void run() { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); - chunk.unload(true, true); + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } }, 40 + rand.nextInt(40)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 8595105e9..fa40e9da6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -151,7 +151,7 @@ public class BukkitHybridUtils extends HybridUtils { final Chunk chunk = world.getChunkAt(x, z); chunks2.add(chunk); regenerateRoad(worldname, new ChunkLoc(x, z)); - ChunkManager.manager.unloadChunk(worldname, new ChunkLoc(x, z)); + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 916d660f8..519d01fa6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; @@ -276,7 +277,7 @@ public class ClusterManager { public void run() { if ((populator == null) || (plotworld.TYPE == 0)) { world.regenerateChunk(chunk.getX(), chunk.getZ()); - chunk.unload(true, true); + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } else { populator.populate(world, rand, chunk); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 28848045d..0981e0b10 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.UUID; @@ -29,6 +30,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; @@ -170,6 +172,10 @@ public class MainUtil { } } + public static void update(String world, ChunkLoc loc) { + BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc)); + } + // public static void update(final Location loc) { // final String world = loc.getWorld(); // int ox = loc.getX() >> 4; @@ -862,14 +868,12 @@ public class MainUtil { final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot2.id); final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id); if (plot1.owner == null) { - TaskManager.runTaskLater(whenDone, 1); return false; } final Plot pos1 = getBottomPlot(plot1); final Plot pos2 = getTopPlot(plot1); final PlotId size = MainUtil.getSize(plot1.world, plot1); if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) { - TaskManager.runTaskLater(whenDone, 1); return false; } final int offset_x = plot2.id.x - pos1.id.x; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index de33208f7..4235c01e1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -234,9 +234,6 @@ public class BukkitChunkManager extends ChunkManager { restoreBlocks(newWorld, relX, relZ); restoreEntities(newWorld, relX, relZ); BukkitSetBlockManager.setBlockManager.update(chunks); - for (final Chunk chunk : chunks) { - chunk.unload(true, true); - } TaskManager.runTask(whenDone); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); @@ -344,7 +341,7 @@ public class BukkitChunkManager extends ChunkManager { restoreBlocks(world, 0, 0); restoreEntities(world, 0, 0); } - chunk.unload(true, true); + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } CURRENT_PLOT_CLEAR = null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 96aeb94f3..3ec8fe1e9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -32,9 +32,9 @@ public class BukkitSetupUtils extends SetupUtils { final String name = plugin.getDescription().getName(); if (generator instanceof PlotGenerator) { final PlotGenerator pgen = (PlotGenerator) generator; - if (pgen.getPlotManager() instanceof SquarePlotManager) { +// if (pgen.getPlotManager() instanceof SquarePlotManager) { SetupUtils.generators.put(name, pgen); - } +// } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java index 75ec4bc8b..9c4bb056f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java @@ -10,6 +10,7 @@ import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; +import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; @@ -22,6 +23,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; * @author Empire92 */ public class SendChunk { + + private static boolean v1_7_10 = BukkitMain.checkVersion(1, 7, 10) && !BukkitMain.checkVersion(1, 8, 0); // Ref Class private static final RefClass classWorld = getRefClass("{nms}.World"); private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); @@ -58,6 +61,7 @@ public class SendChunk { int diffx, diffz; final int view = Bukkit.getServer().getViewDistance() << 4; for (final Chunk chunk : chunks) { + boolean unload = true; final Object c = methodGetHandle.of(chunk).call(); final Object w = world.of(c).get(); final Object p = players.of(w).get(); @@ -67,11 +71,22 @@ public class SendChunk { diffx = Math.abs(x - (chunk.getX() << 4)); diffz = Math.abs(z - (chunk.getZ() << 4)); if ((diffx <= view) && (diffz <= view)) { - final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ()); - final Object pq = chunkCoordIntPairQueue.of(ep).get(); - ((List) pq).add(pair); + unload = false; + if (v1_7_10) { + chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ()); + chunk.load(true); + } + else { + final Object pair = ChunkCoordIntPairCon.create(chunk.getX(), chunk.getZ()); + final Object pq = chunkCoordIntPairQueue.of(ep).get(); + ((List) pq).add(pair); + } } } + if (unload) { + chunk.unload(true, true); + System.out.print("UNLOADING CHUNK"); + } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java index e4570822b..e79f658e1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast.java @@ -71,6 +71,8 @@ public class SetBlockFast extends BukkitSetBlockManager { }, 20); } + private ChunkLoc lastLoc = null; + /** * Set the block at the location * @@ -84,6 +86,19 @@ public class SetBlockFast extends BukkitSetBlockManager { */ @Override public void set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) { + + int X = x >> 4; + int Z = z >> 4; + ChunkLoc loc = new ChunkLoc(X, Z); + if (!loc.equals(lastLoc)) { + Chunk chunk = toUpdate.get(loc); + if (chunk == null) { + chunk = world.getChunkAt(X, Z); + toUpdate.put(loc, chunk); + } + chunk.load(false); + } + final Object w = methodGetHandle.of(world).call(); final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); final Object block = methodGetById.of(null).call(blockId); @@ -101,9 +116,9 @@ public class SetBlockFast extends BukkitSetBlockManager { return; } if (!MainUtil.canSendChunk) { - for (final Chunk chunk : chunks) { - chunk.unload(); - chunk.load(false); + for (Chunk chunk : chunks) { + chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ()); + chunk.load(true); } return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java index 8c0ab884c..a40b153fa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockFast_1_8.java @@ -317,9 +317,9 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { return; } if (!MainUtil.canSendChunk) { - for (final Chunk chunk : chunks) { - chunk.unload(); - chunk.load(false); + for (Chunk chunk : chunks) { + chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ()); + chunk.load(true); } return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java index 8420a3ad2..720ae38c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SetBlockSlow.java @@ -6,6 +6,8 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Block; +import com.intellectualcrafters.plot.util.MainUtil; + public class SetBlockSlow extends BukkitSetBlockManager { @Override public void set(final World world, final int x, final int y, final int z, final int id, final byte data) { @@ -25,6 +27,18 @@ public class SetBlockSlow extends BukkitSetBlockManager { @Override public void update(final Collection chunks) { - // TODO Auto-generated method stub + if (MainUtil.canSendChunk) { + try { + SendChunk.sendChunk(chunks); + } catch (final Throwable e) { + MainUtil.canSendChunk = false; + } + } + else { + for (Chunk chunk : chunks) { + chunk.unload(); + chunk.load(true); + } + } } } From 93e6a2d87c4f61b9c1b2a02a4be9d843e719745d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Apr 2015 14:52:14 +1100 Subject: [PATCH 110/223] Fixed template creation --- PlotSquared/pom.xml | 2 +- .../plot/commands/Template.java | 4 ++++ .../plot/util/SetupUtils.java | 3 +++ .../plot/util/bukkit/BukkitSetupUtils.java | 24 +++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 44fae6f26..4a207dfc6 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.2 + 2.9.3 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java index b83d30bd0..7bdab70c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -178,6 +178,10 @@ public class Template extends SubCommand { public static byte[] getBytes(PlotWorld plotworld) { ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds." + plotworld.worldname); YamlConfiguration config = new YamlConfiguration(); + String generator = SetupUtils.manager.getGenerator(plotworld); + if (generator != null) { + config.set("generator.plugin", generator); + } for (String key : section.getKeys(true)) { config.set(key, section.get(key)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index 7a860d778..f93617e8c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; public abstract class SetupUtils { @@ -15,5 +16,7 @@ public abstract class SetupUtils { public abstract void updateGenerators(); + public abstract String getGenerator(PlotWorld plotworld); + public abstract String setupWorld(final SetupObject object); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 3ec8fe1e9..2e2f04ae1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -1,11 +1,14 @@ package com.intellectualcrafters.plot.util.bukkit; import java.io.IOException; +import java.util.List; +import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; +import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; @@ -13,6 +16,7 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; @@ -85,4 +89,24 @@ public class BukkitSetupUtils extends SetupUtils { return object.world; } + @Override + public String getGenerator(PlotWorld plotworld) { + if (SetupUtils.generators.size() == 0) { + updateGenerators(); + } + World world = Bukkit.getWorld(plotworld.worldname); + if (world == null) { + return null; + } + ChunkGenerator generator = world.getGenerator(); + if (!(generator instanceof PlotGenerator)) { + return null; + } + for (Entry entry : generators.entrySet()) { + if (entry.getValue().getClass().getName().equals(generator.getClass().getName())) { + return entry.getKey(); + } + } + return null; + } } From 922ef04bdf5939a18bfcec1df99ceead15bcea25 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Apr 2015 19:56:20 +1100 Subject: [PATCH 111/223] Remove legacy (no one is using those versions anymore) --- .../plot/database/SQLManager.java | 155 +++++++++++++----- .../plot/util/bukkit/SendChunk.java | 1 - 2 files changed, 110 insertions(+), 46 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 62e53f9e0..1eef437ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -28,11 +28,13 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map.Entry; import java.util.Set; import java.util.UUID; @@ -134,6 +136,9 @@ public class SQLManager implements AbstractDB { @Override public void createAllSettingsAndHelpers(final ArrayList mylist) { + + // TODO create settings + final int size = mylist.size(); int packet; if (PlotSquared.getMySQL() != null) { @@ -233,6 +238,104 @@ public class SQLManager implements AbstractDB { } } } + + public void createSettings(final ArrayList mylist) { + final int size = mylist.size(); + int packet; + if (PlotSquared.getMySQL() != null) { + packet = Math.min(size, 50000); + } else { + packet = Math.min(size, 50); + } + final int amount = size / packet; + for (int j = 0; j <= amount; j++) { + final List ids = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); + if (ids.size() == 0) { + return; + } + final StringBuilder statement = new StringBuilder(this.CREATE_SETTINGS); + for (int i = 0; i < (ids.size() - 1); i++) { + statement.append("(?),"); + } + statement.append("(?)"); + PreparedStatement stmt = null; + try { + stmt = this.connection.prepareStatement(statement.toString()); + for (int i = 0; i < ids.size(); i++) { + final Integer id = ids.get(i); + stmt.setInt((i * 1) + 1, id); + } + stmt.executeUpdate(); + stmt.close(); + } catch (final Exception e) { + try { + + /* + * (" + " `plot_plot_id` INT(11) NOT NULL," + " + * `biome` VARCHAR(45) DEFAULT 'FOREST'," + " + * `rain` INT(1) DEFAULT 0," + " + * `custom_time` TINYINT(1) DEFAULT '0'," + " + * `time` INT(11) DEFAULT '8000'," + " + * `deny_entry` TINYINT(1) DEFAULT '0'," + " + * `alias` VARCHAR(50) DEFAULT NULL," + " + * `flags` VARCHAR(512) DEFAULT NULL," + " + * `merged` INT(11) DEFAULT NULL," + " + * `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + + * " PRIMARY KEY (`plot_plot_id`)," + " + * UNIQUE KEY `unique_alias` (`alias`)" + ") + * ENGINE=InnoDB DEFAULT CHARSET=utf8") + * + * plot_plot_id - nn + * biome - FOREST + * rain - 0 + * custom_time 0 + * time + */ + + StringBuilder unionstmt = new StringBuilder("INSERT INTO `" + this.prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` "); + for (int i = 0; i < (ids.size() - 2); i++) { + unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); + } + unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); + stmt = this.connection.prepareStatement(unionstmt.toString()); + for (int i = 0; i < ids.size(); i++) { + Integer id = ids.get(i); + stmt.setInt((i * 10) + 1, id); + stmt.setNull((i * 10) + 2, 4); + stmt.setNull((i * 10) + 3, 4); + stmt.setNull((i * 10) + 4, 4); + stmt.setNull((i * 10) + 5, 4); + stmt.setNull((i * 10) + 6, 4); + stmt.setNull((i * 10) + 7, 4); + stmt.setNull((i * 10) + 8, 4); + stmt.setNull((i * 10) + 9, 4); + stmt.setString((i * 10) + 10, "DEFAULT"); + } + stmt.executeUpdate(); + stmt.close(); + } + catch (Exception e2) { + e2.printStackTrace(); + PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower..."); + try { + for (final Integer id : ids) { + try { + stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"); + stmt.setInt(1, id); + stmt.executeUpdate(); + stmt.close(); + } catch (final Exception e3) { + PlotSquared.log("&c[ERROR] " + "Failed to save plot setting: " + id); + } + } + } catch (final Exception e4) { + e4.printStackTrace(); + PlotSquared.log("&c[ERROR] " + "Failed to save plot settings!"); + } + } + } + } + } /** * Create a plot @@ -277,20 +380,6 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { try { - // TODO UNION - - /* - - INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values - - INSERT INTO 'tablename' - SELECT 'data1' AS 'column1', 'data2' AS 'column2' - UNION SELECT 'data3', 'data4' - UNION SELECT 'data5', 'data6' - UNION SELECT 'data7', 'data8' - - - */ StringBuilder unionstmt = new StringBuilder("INSERT INTO `" + this.prefix + "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` "); for (int i = 0; i < (plots.size() - 2); i++) { unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ? "); @@ -522,31 +611,6 @@ public class SQLManager implements AbstractDB { @Override public LinkedHashMap> getPlots() { final LinkedHashMap> newplots = new LinkedHashMap<>(); - try { - final DatabaseMetaData data = this.connection.getMetaData(); - ResultSet rs = data.getColumns(null, null, this.prefix + "plot", "plot_id"); - final boolean execute = rs.next(); - if (execute) { - final Statement statement = this.connection.createStatement(); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot` ADD `plot_id_x` int(11) DEFAULT 0"); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot` ADD `plot_id_z` int(11) DEFAULT 0"); - statement.addBatch("UPDATE `" + this.prefix + "plot` SET\n" + " `plot_id_x` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`" + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )"); - statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `plot_id`"); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL"); - statement.executeBatch(); - statement.close(); - } - rs = data.getColumns(null, null, this.prefix + "plot_settings", "merged"); - if (!rs.next()) { - final Statement statement = this.connection.createStatement(); - statement.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD `merged` int(11) DEFAULT NULL"); - statement.executeBatch(); - rs.close(); - statement.close(); - } - } catch (final Exception e) { - e.printStackTrace(); - } final HashMap plots = new HashMap<>(); Statement stmt = null; try { @@ -648,6 +712,11 @@ public class SQLManager implements AbstractDB { id = r.getInt("plot_plot_id"); final Plot plot = plots.get(id); if (plot != null) { + plots.remove(id); + if (!newplots.containsKey(plot.world)) { + newplots.put(plot.world, new HashMap()); + } + newplots.get(plot.world).put(plot.id, plot); final String b = r.getString("biome"); if (b != null) { for (final Biome mybiome : Biome.values()) { @@ -724,12 +793,8 @@ public class SQLManager implements AbstractDB { } stmt.close(); r.close(); - for (final Plot plot : plots.values()) { - final String world = plot.world; - if (!newplots.containsKey(world)) { - newplots.put(world, new HashMap()); - } - newplots.get(world).put(plot.id, plot); + if (plots.keySet().size() > 0) { + createSettings(new ArrayList(plots.keySet())); } boolean invalidPlot = false; for (final String worldname : noExist.keySet()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java index 9c4bb056f..6c4d8a1af 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/SendChunk.java @@ -85,7 +85,6 @@ public class SendChunk { } if (unload) { chunk.unload(true, true); - System.out.print("UNLOADING CHUNK"); } } } From 1b11590d60f86f046c263a411397194a7852127a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Apr 2015 22:18:08 +1100 Subject: [PATCH 112/223] Fixed setowner --- .../com/intellectualcrafters/plot/database/SQLManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 1eef437ee..fcdb58afe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -86,7 +86,7 @@ public class SQLManager implements AbstractDB { // Set timout // setTimout(); // Public final - this.SET_OWNER = "UPDATE `" + this.prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ?"; + this.SET_OWNER = "UPDATE `" + this.prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND `world` = ?"; this.GET_ALL_PLOTS = "SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `" + this.prefix + "plot`"; this.CREATE_PLOTS = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values "; this.CREATE_SETTINGS = "INSERT INTO `" + this.prefix + "plot_settings` (`plot_plot_id`) values "; @@ -124,6 +124,7 @@ public class SQLManager implements AbstractDB { statement.setString(1, uuid.toString()); statement.setInt(2, plot.id.x); statement.setInt(3, plot.id.y); + statement.setString(4, plot.world); statement.executeUpdate(); statement.close(); } catch (final SQLException e) { From 288b84bd6a791dc2e7aa23374a5364b39e92ba0f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 2 Apr 2015 22:39:11 +1100 Subject: [PATCH 113/223] isAdded now checks owner --- PlotSquared/pom.xml | 2 +- .../java/com/intellectualcrafters/plot/object/PlotHandler.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 4a207dfc6..d47a65424 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.3 + 2.9.4 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java index 42127a5de..ecf722302 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -79,6 +79,9 @@ public class PlotHandler { if (plot.owner == null) { return false; } + if (isOwner(plot, uuid)) { + return true; + } if (plot.denied.contains(uuid)) { return false; } From c76536b8b07afe6d3ce0f602fabb9c0fe9e8acbf Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Apr 2015 13:42:49 +1100 Subject: [PATCH 114/223] Fixed home plot sorting --- .../intellectualcrafters/jnbt/ListTag.java | 2 -- .../plot/PlotSquared.java | 22 ++++++++++++++++--- .../plot/commands/BukkitCommand.java | 2 +- .../plot/commands/Home.java | 2 +- .../plot/commands/MainCommand.java | 2 +- .../plot/commands/Visit.java | 2 +- .../plot/generator/BukkitHybridUtils.java | 3 ++- .../plot/generator/HybridUtils.java | 2 +- 8 files changed, 26 insertions(+), 11 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java index 614a86af4..5a0cd5faf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTag.java @@ -6,7 +6,6 @@ import java.util.Collections; import java.util.List; import java.util.NoSuchElementException; -import javax.annotation.Nullable; /** * The {@code TAG_List} tag. @@ -74,7 +73,6 @@ public final class ListTag extends Tag { * * @return the tag or null */ - @Nullable public Tag getIfExists(final int index) { try { return this.value.get(index); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index f2ad55392..c720ba90b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -181,9 +181,11 @@ public class PlotSquared { } } } - for (Entry> entry : PlotSquared.plots.entrySet()) { - if (!entry.getKey().equals(priorityWorld)) { - for (Plot plot : entry.getValue().values()) { + ArrayList worlds = new ArrayList<>(PlotSquared.plots.keySet()); + Collections.sort(worlds); + for (String world : worlds) { + if (!world.equals(priorityWorld)) { + for (Plot plot : PlotSquared.plots.get(world).values()) { if (plots.contains(plot)) { newPlots.add(plot); } @@ -192,6 +194,20 @@ public class PlotSquared { } return newPlots; } + + public static ArrayList sortPlotsByWorld(Collection plots) { + ArrayList newPlots = new ArrayList<>(); + ArrayList worlds = new ArrayList<>(PlotSquared.plots.keySet()); + Collections.sort(worlds); + for (String world : worlds) { + for (Plot plot : PlotSquared.plots.get(world).values()) { + if (plots.contains(plot)) { + newPlots.add(plot); + } + } + } + return newPlots; + } public static Set getPlots(final String world, final String player) { final UUID uuid = UUIDHandler.getUUID(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java index 0e05fefe0..f9e375390 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -51,7 +51,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { if (cmd.permission.hasPermission(player)) { if (cmd.cmd.startsWith(arg)) { tabOptions.add(cmd.cmd); - } else if (cmd.alias.get(0).startsWith(arg)) { + } else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) { tabOptions.add(cmd.alias.get(0)); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 3daef2e5f..b1e1953b9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -47,7 +47,7 @@ public class Home extends SubCommand { @Override public boolean execute(final PlotPlayer plr, String... args) { - final ArrayList plots = PlotSquared.sortPlots(PlotSquared.getPlots(plr), plr.getLocation().getWorld()); + final ArrayList plots = PlotSquared.sortPlotsByWorld(PlotSquared.getPlots(plr)); if (plots.size() == 1) { MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 9b8b18724..a35372d32 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -40,7 +40,7 @@ public class MainCommand { /** * Main Permission Node */ - private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm(), new Copy() }; + private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm(), new Copy(), new WE_Anywhere() }; public final static ArrayList subCommands = new ArrayList() { { addAll(Arrays.asList(_subCommands)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index 1fe36383e..efeca0826 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -55,7 +55,7 @@ public class Visit extends SubCommand { final UUID uuid = UUIDHandler.getUUID(username); List plots = null; if (uuid != null) { - plots = PlotSquared.sortPlots(getPlots(uuid), plr.getLocation().getWorld()); + plots = PlotSquared.sortPlotsByWorld(getPlots(uuid)); } if ((uuid == null) || plots.isEmpty()) { return sendMessage(plr, C.FOUND_NO_PLOTS); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index fa40e9da6..8ccb66eaa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { - public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone) { + public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone, final Runnable ifFailed) { TaskManager.index.increment(); final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); @@ -72,6 +72,7 @@ public class BukkitHybridUtils extends HybridUtils { return; } if (chunks.size() == 0) { + TaskManager.runTaskLater(ifFailed, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index b6dc94eb5..a561df522 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -21,7 +21,7 @@ public abstract class HybridUtils { public static HybridUtils manager; - public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed); + public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed, Runnable ifFailed); public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); From 1c7f7a2dfc82fc06bc2ace78854f53cfcd6063f6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Apr 2015 18:30:27 +1100 Subject: [PATCH 115/223] Various fixes Fixed issue with augmented plot world and mob / entity interaction Fixed an issue with async plot diff calculation including upper chunks outside of plot in result PlotMeConverter will now try a force save of the PS configuration right away Incremented version number Tweaked behaviour of plot list command --- PlotSquared/pom.xml | 2 +- .../plot/commands/list.java | 12 +++++++++--- .../plot/database/PlotMeConverter.java | 2 ++ .../plot/generator/BukkitHybridUtils.java | 19 ++++++++----------- .../plot/generator/HybridUtils.java | 3 ++- .../plot/listeners/PlayerEvents.java | 3 +++ .../plot/listeners/PlayerEvents_1_8.java | 3 +++ .../plot/object/RunnableVal.java | 7 +++++++ 8 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index d47a65424..7dc265d95 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.4 + 2.9.5 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index d563738d9..26974a642 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -192,12 +192,18 @@ public class list extends SubCommand { return false; } - displayPlots(plr, plots, page); + displayPlots(plr, plots, page, world); return true; } - public void displayPlots(PlotPlayer player, Collection oldPlots, int page) { - ArrayList plots = PlotSquared.sortPlots(oldPlots); + public void displayPlots(PlotPlayer player, Collection oldPlots, int page, String world) { + ArrayList plots; + if (world != null) { + plots = PlotSquared.sortPlots(oldPlots, world); + } + else { + plots = PlotSquared.sortPlots(oldPlots); + } if (page < 0) { page = 0; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index c4c554815..c7c9c927a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -250,6 +250,7 @@ public class PlotMeConverter { height = 64; } PlotSquared.config.set("worlds." + world + ".road.height", height); + PlotSquared.config.save(PlotSquared.configFile); } catch (final Exception e) { sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } @@ -300,6 +301,7 @@ public class PlotMeConverter { PlotSquared.config.set("worlds." + world + ".road.height", height); PlotSquared.config.set("worlds." + world + ".plot.height", height); PlotSquared.config.set("worlds." + world + ".wall.height", height); + PlotSquared.config.save(PlotSquared.configFile); } } catch (final Exception e) { } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 8ccb66eaa..683863e6b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -21,6 +21,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; @@ -29,7 +30,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { - public void checkModified(final Plot plot, final int requiredChanges, final Runnable whenDone, final Runnable ifFailed) { + public void checkModified(final Plot plot, final RunnableVal whenDone) { TaskManager.index.increment(); final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); @@ -41,7 +42,6 @@ public class BukkitHybridUtils extends HybridUtils { int tx = top.getX() >> 4; int tz = top.getZ() >> 4; - int size = (tx-bx) << 4; World world = BukkitUtil.getWorld(plot.world); final HashSet chunks = new HashSet<>(); @@ -53,6 +53,7 @@ public class BukkitHybridUtils extends HybridUtils { PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); if (!(plotworld instanceof ClassicPlotWorld)) { + whenDone.value = -1; TaskManager.runTaskLater(whenDone, 1); return; } @@ -65,23 +66,19 @@ public class BukkitHybridUtils extends HybridUtils { final Integer task = TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { - if (count.intValue() >= requiredChanges) { - TaskManager.runTaskLater(whenDone, 1); - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); - TaskManager.tasks.remove(currentIndex); - return; - } if (chunks.size() == 0) { - TaskManager.runTaskLater(ifFailed, 1); + whenDone.value = 0; + TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); return; } final Chunk chunk = chunks.iterator().next(); + chunks.iterator().remove(); int bx = Math.max(chunk.getX() >> 4, bot.getX()); int bz = Math.max(chunk.getZ() >> 4, bot.getZ()); - int ex = Math.max((chunk.getX() >> 4) + 15, top.getX()); - int ez = Math.max((chunk.getZ() >> 4) + 15, top.getZ()); + int ex = Math.min((chunk.getX() >> 4) + 15, top.getX()); + int ez = Math.min((chunk.getZ() >> 4) + 15, top.getZ()); // count changes count.add(checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK)); count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index a561df522..464ab3b5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; @@ -21,7 +22,7 @@ public abstract class HybridUtils { public static HybridUtils manager; - public abstract void checkModified(Plot plot, int requiredChanges, Runnable ifPassed, Runnable ifFailed); + public abstract void checkModified(final Plot plot, final RunnableVal whenDone); public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks); 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 483484031..f359d9e45 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -1060,6 +1060,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!isInPlot(l)) { + if (!isPlotArea(l)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 074f4be4d..f2651086e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -23,6 +23,9 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); if (!isInPlot(l)) { + if (!isPlotArea(l)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); e.setCancelled(true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java new file mode 100644 index 000000000..3a4c41241 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/RunnableVal.java @@ -0,0 +1,7 @@ +package com.intellectualcrafters.plot.object; + +public abstract class RunnableVal implements Runnable { + public Object value; + + public abstract void run(); +} From 87776c5b157f1c0428a708c215807da5d9ec3fd6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Apr 2015 20:34:53 +1100 Subject: [PATCH 116/223] Added redstone flag Courtesy of @jpresent --- .../plot/PlotSquared.java | 2 +- .../plot/listeners/PlayerEvents.java | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index c720ba90b..a895ecfc5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -689,7 +689,7 @@ public class PlotSquared { } public static void setupDefaultFlags() { - final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit"); + final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); final List intFlags = Arrays.asList("entity-cap", "animal-cap", "mop-cap"); 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 f359d9e45..51b0d4fb4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -39,9 +39,11 @@ import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -107,6 +109,75 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; */ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { + public void onRedstoneEvent(BlockRedstoneEvent event) { + Block block = event.getBlock(); + Location loc = BukkitUtil.getLocation(block.getLocation()); + if (!isPlotWorld(loc.getWorld())) { + return; + } + Plot plot = MainUtil.getPlot(loc); + Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); + if (redstone == null || (Boolean) redstone.getValue()) { + return; + } + if (!isPlotArea(loc)) { + return; + } + switch (block.getType()) { + case REDSTONE_LAMP_OFF: + case REDSTONE_LAMP_ON: + case PISTON_BASE: + case PISTON_STICKY_BASE: + case IRON_DOOR_BLOCK: + case LEVER: + case WOODEN_DOOR: + case FENCE_GATE: + case WOOD_BUTTON: + case STONE_BUTTON: + case IRON_PLATE: + case WOOD_PLATE: + case STONE_PLATE: + case GOLD_PLATE: + case SPRUCE_DOOR: + case BIRCH_DOOR: + case JUNGLE_DOOR: + case ACACIA_DOOR: + case DARK_OAK_DOOR: + case IRON_TRAPDOOR: + case SPRUCE_FENCE_GATE: + case BIRCH_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case ACACIA_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case POWERED_RAIL: { + event.setNewCurrent(0); + } + } + } + + public void onPhysicsEvent(BlockPhysicsEvent event) { + Block block = event.getBlock(); + Location loc = BukkitUtil.getLocation(block.getLocation()); + if (!isPlotWorld(loc.getWorld())) { + return; + } + Plot plot = MainUtil.getPlot(loc); + Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); + if (redstone == null || (Boolean) redstone.getValue()) { + return; + } + if (!isPlotArea(loc)) { + return; + } + switch (block.getType()) { + case REDSTONE_COMPARATOR_OFF: + case REDSTONE_COMPARATOR_ON: { + event.setCancelled(true); + } + } + } + + @EventHandler public void onProjectileHit(ProjectileHitEvent event) { Projectile entity = (Projectile) event.getEntity(); From 17ed04e94516efd0c5335e305175b151faa9c1af Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Apr 2015 20:40:13 +1100 Subject: [PATCH 117/223] + this --- .../intellectualcrafters/plot/listeners/PlayerEvents.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 51b0d4fb4..b598d03e0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -116,6 +116,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return; + } Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); if (redstone == null || (Boolean) redstone.getValue()) { return; @@ -162,6 +165,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return; + } Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); if (redstone == null || (Boolean) redstone.getValue()) { return; From 1667fcdf437cc26d5e16484da0084ef659306e92 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Apr 2015 22:20:08 +1100 Subject: [PATCH 118/223] I've got my own thank you very much. closes #240 --- .../intellectualcrafters/plot/listeners/PlayerEvents.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 b598d03e0..f8d5e39b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -109,6 +109,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; */ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { + @EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) { Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); @@ -153,11 +154,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi case ACACIA_FENCE_GATE: case DARK_OAK_FENCE_GATE: case POWERED_RAIL: { - event.setNewCurrent(0); + return; } } + event.setNewCurrent(0); } + @EventHandler public void onPhysicsEvent(BlockPhysicsEvent event) { Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); From 866ddc9648863f84606bdc004fbb8458d6196aa6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 4 Apr 2015 00:12:10 +1100 Subject: [PATCH 119/223] Fixed killallentities task --- .../com/intellectualcrafters/plot/PlotSquared.java | 10 ++++++---- .../plot/listeners/PlayerEvents.java | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index a895ecfc5..79b3ec360 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -501,15 +501,16 @@ public class PlotSquared { log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance"); } TASK = IMP.getTaskManager(); - if (Settings.KILL_ROAD_MOBS) { - IMP.runEntityTask(); - } if (C.ENABLED.s().length() > 0) { log(C.ENABLED.s()); } setupConfigs(); setupDefaultFlags(); setupDatabase(); + // Tasks + if (Settings.KILL_ROAD_MOBS) { + IMP.runEntityTask(); + } // Events IMP.registerCommands(); IMP.registerPlayerEvents(); @@ -550,6 +551,7 @@ public class PlotSquared { // Copy files copyFile("town.template"); copyFile("skyblock.template"); + showDebug(); } public void copyFile(String file) { @@ -595,7 +597,7 @@ public class PlotSquared { connection.close(); mySQL.closeConnection(); } catch (NullPointerException | SQLException e) { - if (connection != null) { + if (mySQL != null) { log("&cCould not close mysql connection!"); } } 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 f8d5e39b2..c16d1cfab 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -110,7 +110,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { @EventHandler - public void onRedstoneEvent(BlockRedstoneEvent event) { + public static void onRedstoneEvent(BlockRedstoneEvent event) { Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); if (!isPlotWorld(loc.getWorld())) { @@ -159,9 +159,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } event.setNewCurrent(0); } - + @EventHandler - public void onPhysicsEvent(BlockPhysicsEvent event) { + public static void onPhysicsEvent(BlockPhysicsEvent event) { Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); if (!isPlotWorld(loc.getWorld())) { From d01b506443935520c51c70769c36d20e87e461ea Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 4 Apr 2015 01:05:38 +1100 Subject: [PATCH 120/223] Fixes #241 --- .../intellectualcrafters/plot/generator/HybridPlotWorld.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index 525e116e3..f73e2ced3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -224,6 +224,8 @@ public class HybridPlotWorld extends ClassicPlotWorld { return true; case 65: return true; + case 67: + return true; case 68: return true; case 71: From 9195c2271c36949eb2b7b8a909e5892616f19596 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 5 Apr 2015 02:20:26 +1000 Subject: [PATCH 121/223] Fix augmented for road size = 0 --- .../plot/generator/HybridGen.java | 20 ++++++++++++------- .../plot/generator/HybridPop.java | 18 +++++++++++------ .../plot/generator/SquarePlotManager.java | 13 ++++++++---- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 10a6b5991..26154df34 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -98,12 +98,18 @@ public class HybridGen extends PlotGenerator { this.wallheight = this.plotworld.WALL_HEIGHT; this.roadheight = this.plotworld.ROAD_HEIGHT; this.plotheight = this.plotworld.PLOT_HEIGHT; - if ((this.pathsize % 2) == 0) { - this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1); - } else { - this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); + if (this.pathsize == 0) { + this.pathWidthLower = (short) -1; + this.pathWidthUpper = (short) (this.plotsize + 1); + } + else { + if ((this.pathsize % 2) == 0) { + this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1); + } else { + this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); + } + this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); } - this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); this.biome = Biome.valueOf(this.plotworld.PLOT_BIOME); try { this.maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight(); @@ -129,7 +135,7 @@ public class HybridGen extends PlotGenerator { */ public PlotWorld getNewPlotWorld(final String world) { if (this.plotworld == null) { - this.plotworld = new HybridPlotWorld(world); + this.plotworld = new HybridPlotWorld(world); } return this.plotworld; } @@ -224,7 +230,7 @@ public class HybridGen extends PlotGenerator { } } } - } else { + } else if (pathsize != 0) { // wall if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { for (short y = 1; y <= this.wallheight; y++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index f0e056e6d..677d4b099 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -78,12 +78,18 @@ public class HybridPop extends PlotPopulator { this.wallheight = this.plotworld.WALL_HEIGHT; this.roadheight = this.plotworld.ROAD_HEIGHT; this.plotheight = this.plotworld.PLOT_HEIGHT; - if ((this.pathsize % 2) == 0) { - this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1); - } else { - this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); + if (this.pathsize == 0) { + this.pathWidthLower = (short) -1; + this.pathWidthUpper = (short) (this.plotsize + 1); + } + else { + if ((this.pathsize % 2) == 0) { + this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1); + } else { + this.pathWidthLower = (short) (Math.floor(this.pathsize / 2)); + } + this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); } - this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1); } public final long nextLong() { @@ -192,7 +198,7 @@ public class HybridPop extends PlotPopulator { } } } - } else { + } else if (pathsize != 0) { // wall if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { for (short y = 1; y <= this.wallheight; y++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 7a6ffbc03..71eca688d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -35,10 +35,15 @@ public abstract class SquarePlotManager extends GridPlotManager { public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); int pathWidthLower; - if ((dpw.ROAD_WIDTH % 2) == 0) { - pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1; - } else { - pathWidthLower = dpw.ROAD_WIDTH / 2; + if (dpw.ROAD_WIDTH == 0) { + pathWidthLower = -1; + } + else { + if ((dpw.ROAD_WIDTH % 2) == 0) { + pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1; + } else { + pathWidthLower = dpw.ROAD_WIDTH / 2; + } } final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; int idx; From 7850644ab1a42f222731324c8a23fbd1a3a6277e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 5 Apr 2015 14:01:31 +1000 Subject: [PATCH 122/223] *actually fixed it --- .../plot/generator/SquarePlotManager.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 71eca688d..eb59a889c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -35,8 +35,10 @@ public abstract class SquarePlotManager extends GridPlotManager { public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) { final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); int pathWidthLower; + int end; if (dpw.ROAD_WIDTH == 0) { pathWidthLower = -1; + end = dpw.PLOT_WIDTH; } else { if ((dpw.ROAD_WIDTH % 2) == 0) { @@ -44,6 +46,7 @@ public abstract class SquarePlotManager extends GridPlotManager { } else { pathWidthLower = dpw.ROAD_WIDTH / 2; } + end = pathWidthLower + dpw.PLOT_WIDTH; } final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; int idx; @@ -64,7 +67,6 @@ public abstract class SquarePlotManager extends GridPlotManager { idz = (z/size) + 1; z = (z % size); } - final int end = pathWidthLower + dpw.PLOT_WIDTH; final boolean northSouth = (z <= pathWidthLower) || (z > end); final boolean eastWest = (x <= pathWidthLower) || (x > end); if (northSouth || eastWest) { @@ -81,10 +83,18 @@ public abstract class SquarePlotManager extends GridPlotManager { } final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; int pathWidthLower; - if ((dpw.ROAD_WIDTH % 2) == 0) { - pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1; - } else { - pathWidthLower = dpw.ROAD_WIDTH / 2; + final int end; + if (dpw.ROAD_WIDTH == 0) { + pathWidthLower = -1; + end = dpw.PLOT_WIDTH; + } + else { + if ((dpw.ROAD_WIDTH % 2) == 0) { + pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1; + } else { + pathWidthLower = dpw.ROAD_WIDTH / 2; + } + end = pathWidthLower + dpw.PLOT_WIDTH; } int dx; int dz; @@ -106,7 +116,6 @@ public abstract class SquarePlotManager extends GridPlotManager { dz = (z/size) + 1; rz = (z % size); } - final int end = pathWidthLower + dpw.PLOT_WIDTH; final boolean northSouth = (rz <= pathWidthLower) || (rz > end); final boolean eastWest = (rx <= pathWidthLower) || (rx > end); if (northSouth && eastWest) { From e61a5f450509c962bba9c68c788b55d8745d7687 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 00:59:56 +1000 Subject: [PATCH 123/223] Comment stuff --- PlotSquared/pom.xml | 2 +- .../plot/commands/Comment.java | 2 +- .../plot/commands/Inbox.java | 2 +- .../plot/database/AbstractDB.java | 2 +- .../plot/database/DBFunc.java | 2 +- .../plot/database/SQLManager.java | 2 +- .../plot/generator/BukkitHybridUtils.java | 17 +++++---- .../plot/object/PlotSettings.java | 7 ++-- .../plot/object/comment/CommentInbox.java | 27 +++++++++++++ .../object/{ => comment}/PlotComment.java | 12 ++++-- .../plot/object/comment/ReportInbox.java | 38 +++++++++++++++++++ 11 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java rename PlotSquared/src/main/java/com/intellectualcrafters/plot/object/{ => comment}/PlotComment.java (88%) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 7dc265d95..04480a58e 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.5 + 2.9.6 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 1ee41dbde..f94a46343 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -29,8 +29,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; 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 3c612f6ca..55b50833d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -29,8 +29,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index f5af819de..0f93c6e23 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -32,8 +32,8 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; -import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.comment.PlotComment; /** * @author Citymonstret diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 3261d51f7..82660fc9f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -34,8 +34,8 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; -import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.comment.PlotComment; /** * DB Functions diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index fcdb58afe..37df1215e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -48,8 +48,8 @@ import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; -import com.intellectualcrafters.plot.object.PlotComment; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.TaskManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 683863e6b..95d58aafd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import org.apache.commons.lang.mutable.MutableInt; @@ -67,21 +68,23 @@ public class BukkitHybridUtils extends HybridUtils { @Override public void run() { if (chunks.size() == 0) { - whenDone.value = 0; + whenDone.value = count.intValue(); TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); return; } - final Chunk chunk = chunks.iterator().next(); - chunks.iterator().remove(); - int bx = Math.max(chunk.getX() >> 4, bot.getX()); - int bz = Math.max(chunk.getZ() >> 4, bot.getZ()); - int ex = Math.min((chunk.getX() >> 4) + 15, top.getX()); - int ez = Math.min((chunk.getZ() >> 4) + 15, top.getZ()); + Iterator iter = chunks.iterator(); + final Chunk chunk = iter.next(); + iter.remove(); + int bx = Math.max(chunk.getX() << 4, bot.getX()); + int bz = Math.max(chunk.getZ() << 4, bot.getZ()); + int ex = Math.min((chunk.getX() << 4) + 15, top.getX()); + int ez = Math.min((chunk.getZ() << 4) + 15, top.getZ()); // count changes count.add(checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK)); count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK)); + count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) })); } }, 1); TaskManager.tasks.put(currentIndex, task); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index c0103b9cb..860c7e541 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -25,6 +25,7 @@ import java.util.Set; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; @@ -160,9 +161,9 @@ public class PlotSettings { return null; } for (final PlotComment comment : this.comments) { - if (comment.tier == tier) { - c.add(comment); - } +// if (comment.tier == tier) { +// c.add(comment); +// } } return c; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java new file mode 100644 index 000000000..a17096eb4 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java @@ -0,0 +1,27 @@ +package com.intellectualcrafters.plot.object.comment; + +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; + +public abstract class CommentInbox { + public abstract boolean canRead(Plot plot, PlotPlayer player); + + public abstract boolean canWrite(Plot plot, PlotPlayer player); + + public abstract boolean canModify(Plot plot, PlotPlayer player); + + /** + * The plot may be null if the user is not standing in a plot. Return false if this is not a plot-less inbox. + *
      + * The `whenDone` parameter should be executed when it's done fetching the comments. + * The value should be set to List of comments + * + * @param plot + * @param whenDone + * @return + */ + public abstract boolean getComments(Plot plot, RunnableVal whenDone); + + public abstract boolean addComment(Plot plot, PlotComment comment); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java similarity index 88% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java index 2e711a496..f4d5c474d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotComment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java @@ -18,21 +18,25 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.object; +package com.intellectualcrafters.plot.object.comment; + +import com.intellectualcrafters.plot.object.PlotId; /** * @author Empire92 */ public class PlotComment { public final String comment; - public final int tier; + public final String inbox; public final String senderName; public final PlotId id; + public final long timestamp; - public PlotComment(final PlotId id, final String comment, final String senderName, final int tier) { + public PlotComment(final PlotId id, final String comment, final String senderName, final String inbox, final long timestamp) { this.id = id; this.comment = comment; - this.tier = tier; this.senderName = senderName; + this.inbox = inbox; + this.timestamp = timestamp; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java new file mode 100644 index 000000000..3aa8c0141 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java @@ -0,0 +1,38 @@ +package com.intellectualcrafters.plot.object.comment; + +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; + +public class ReportInbox extends CommentInbox { + + @Override + public boolean canRead(Plot plot, PlotPlayer player) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canWrite(Plot plot, PlotPlayer player) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canModify(Plot plot, PlotPlayer player) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean getComments(Plot plot, RunnableVal whenDone) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean addComment(Plot plot, PlotComment comment) { + // TODO Auto-generated method stub + return false; + } +} From ade657b1af3f0859435bf8795199e9f28d4c718d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 01:02:06 +1000 Subject: [PATCH 124/223] Added inbox manager --- .../plot/object/comment/InboxManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java new file mode 100644 index 000000000..f13944466 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java @@ -0,0 +1,12 @@ +package com.intellectualcrafters.plot.object.comment; + +import java.util.HashMap; + + +public class InboxManager { + public static HashMap inboxes = new HashMap<>(); + + public static void addInbox(String name, CommentInbox inbox) { + inboxes.put(name.toLowerCase(), inbox); + } +} From b9c36965d8b533c933d832825326180add3e029b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 19:59:22 +1000 Subject: [PATCH 125/223] New comment system --- .../plot/PlotSquared.java | 2 + .../plot/commands/Comment.java | 60 +++-- .../plot/commands/Inbox.java | 254 +++++++++--------- .../plot/commands/Move.java | 1 - .../intellectualcrafters/plot/config/C.java | 9 +- .../plot/database/AbstractDB.java | 9 +- .../plot/database/DBFunc.java | 8 +- .../plot/database/SQLManager.java | 115 ++++---- .../plot/generator/BukkitHybridUtils.java | 3 - .../plot/generator/HybridPop.java | 1 - .../plot/object/Plot.java | 16 -- .../plot/object/PlotSettings.java | 8 +- .../plot/object/comment/CommentInbox.java | 8 + .../plot/object/comment/CommentManager.java | 18 ++ .../plot/object/comment/InboxManager.java | 12 - .../plot/object/comment/InboxOwner.java | 93 +++++++ .../plot/object/comment/InboxPublic.java | 91 +++++++ .../plot/object/comment/InboxReport.java | 80 ++++++ .../plot/object/comment/PlotComment.java | 4 +- .../plot/object/comment/ReportInbox.java | 38 --- .../plot/util/bukkit/BukkitSetupUtils.java | 3 - 21 files changed, 553 insertions(+), 280 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 79b3ec360..10c6df3a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -57,6 +57,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ClusterManager; @@ -507,6 +508,7 @@ public class PlotSquared { setupConfigs(); setupDefaultFlags(); setupDatabase(); + CommentManager.registerDefaultInboxes(); // Tasks if (Settings.KILL_ROAD_MOBS) { IMP.runEntityTask(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index f94a46343..025351ce0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -21,18 +21,18 @@ package com.intellectualcrafters.plot.commands; import java.util.Arrays; -import java.util.List; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.comment.CommentInbox; +import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; public class Comment extends SubCommand { public Comment() { @@ -40,27 +40,45 @@ public class Comment extends SubCommand { } @Override - public boolean execute(final PlotPlayer plr, final String... args) { - final Location loc = plr.getLocation(); - final Plot plot = MainUtil.getPlot(loc); - if (plot == null) { - return sendMessage(plr, C.NOT_IN_PLOT); + public boolean execute(final PlotPlayer player, final String... args) { + if (args.length < 2) { + sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|")); + return false; } - if (!plot.hasOwner()) { - return sendMessage(plr, C.NOT_IN_PLOT); + CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase()); + if (inbox == null) { + sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|")); + return false; } - final List recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone"); - if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) { - if (Permissions.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) { - final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); - final PlotComment comment = new PlotComment(plot.id, text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); - plot.settings.addComment(comment); - DBFunc.setComment(loc.getWorld(), plot, comment); - return sendMessage(plr, C.COMMENT_ADDED); - } else { - return sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase()); + Plot plot; + Location loc = player.getLocation(); + PlotId id = PlotId.fromString(args[1]); + int index; + if (id != null) { + if (args.length < 4) { + sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|")); + return false; } + index = 2; + plot = MainUtil.getPlot(loc.getWorld(), id); } - return sendMessage(plr, C.COMMENT_SYNTAX); + else { + index = 1; + plot = MainUtil.getPlot(loc); + } + if (!inbox.canWrite(plot, player)) { + sendMessage(player, C.NO_PERM_INBOX, ""); + return false; + } + String message = StringUtils.join(Arrays.copyOfRange(args,index, args.length), " "); + PlotComment comment = new PlotComment(loc.getWorld(), id, message, player.getName(), inbox.toString(), System.currentTimeMillis()); + boolean result = inbox.addComment(plot, comment); + if (!result) { + sendMessage(player, C.NO_PLOT_INBOX, ""); + sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|")); + return false; + } + sendMessage(player, C.COMMENT_ADDED); + return true; } } 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 55b50833d..7b4cd9272 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -25,11 +25,16 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; +import org.apache.commons.lang.StringUtils; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.comment.CommentInbox; +import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -37,152 +42,141 @@ import com.intellectualcrafters.plot.util.TaskManager; public class Inbox extends SubCommand { public Inbox() { - super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true); + super(Command.INBOX, "Review the comments for a plot", "inbox [delete |clear|page]", CommandCategory.ACTIONS, true); + } + + public void displayComments(PlotPlayer player, List oldComments, int page) { + PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]); + if (page < 0) { + page = 0; + } + // Get the total pages + // int totalPages = ((int) Math.ceil(12 * + final int totalPages = (int) Math.ceil(comments.length / 12); + if (page > totalPages) { + page = totalPages; + } + // Only display 12 per page + int max = (page * 12) + 12; + if (max > comments.length) { + max = comments.length; + } + final StringBuilder string = new StringBuilder(); + string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("plot","review").replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n"); + PlotComment c; + // This might work xD + for (int x = (page * 12); x < max; x++) { + c = comments[x]; + String color; + if (player.getName().equals(c.senderName)) { + color = "&a"; + } + else { + color = "&7"; + } + string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&7#" + c.senderName + "&8]" + color + c.senderName +"&7 : " + color + c.comment + "\n"); + } + MainUtil.sendMessage(player, string.toString()); } @Override - public boolean execute(final PlotPlayer plr, final String... args) { - boolean report = false; - if (args.length == 1) { - if (args[0].equalsIgnoreCase("reports")) { - report = true; + public boolean execute(final PlotPlayer player, final String... args) { + final Plot plot = MainUtil.getPlot(player.getLocation()); + if (args.length < 1) { + sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [delete |clear|page]"); + for (CommentInbox inbox : CommentManager.inboxes.values()) { + if (inbox.canRead(plot, player)) { + sendMessage(player, C.INBOX_ITEM, inbox.toString()); + } } - } - final Location loc = plr.getLocation(); - final Plot plot = MainUtil.getPlot(loc); - if ((plot == null) && !report) { - return !sendMessage(plr, C.NOT_IN_PLOT); - } - if ((plot != null) && !plot.hasOwner()) { - MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } - Integer tier; - final UUID uuid = plr.getUUID(); - if (Permissions.hasPermission(plr, "plots.comment.admin")) { - tier = 0; - } else if ((plot != null) && plot.isOwner(uuid)) { - tier = 1; - } else if ((plot != null) && plot.helpers.contains(uuid)) { - tier = 2; - } else if ((plot != null) && plot.trusted.contains(uuid)) { - tier = 3; - } else { - tier = 4; + final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase()); + if (inbox == null) { + sendMessage(player, C.INVALID_INBOX, StringUtils.join(CommentManager.inboxes.keySet(),", ")); + return false; } - final boolean below; - if (args.length > 0) { - below = false; - switch (args[0].toLowerCase()) { - case "admin": - if (tier <= 0) { - tier = 0; - } else { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); - return false; + final int page; + if (args.length > 1) { + switch (args[1].toLowerCase()) { + case "delete": { + if (!inbox.canModify(plot, player)) { + sendMessage(player, C.NO_PERM_INBOX_MODIFY); } - break; - case "owner": - if (tier <= 1) { - tier = 1; - } else { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner"); - return false; + if (args.length != 3) { + sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete "); } - break; - case "helper": - if (tier <= 2) { - tier = 2; - } else { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper"); - return false; - } - break; - case "trusted": - if (tier <= 3) { - tier = 3; - } else { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted"); - return false; - } - break; - case "everyone": - if (tier <= 4) { - tier = 4; - } else { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone"); - return false; - } - break; - case "reports": - if (tier <= 0) { - tier = -1; - } else { - MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin"); - return false; - } - break; - default: - MainUtil.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4)); - return false; - } - } else { - below = true; - } - final String world = loc.getWorld(); - final int tier2 = tier; - TaskManager.runTaskAsync(new Runnable() { - @Override - public void run() { - ArrayList comments = null; - if (tier2 == -1) { - comments = DBFunc.getComments(world, null, 0, false); - } else { - comments = plot.settings.getComments(tier2); - } - if (comments == null) { - comments = DBFunc.getComments(world, plot, tier2, below); - plot.settings.setComments(comments); - } - if (args.length == 2) { - final String[] split = args[1].toLowerCase().split(":"); - if (!split[0].equals("clear")) { - MainUtil.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]"); - return; - } - if (split.length > 1) { - try { - final int index = Integer.parseInt(split[1]); - final PlotComment comment = comments.get(index - 1); - DBFunc.removeComment(world, plot, comment); - plot.settings.removeComment(comment); - MainUtil.sendMessage(plr, C.COMMENT_REMOVED, "1 comment"); - return; - } catch (final Exception e) { - MainUtil.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]"); - return; + final int index; + try { + index = Integer.parseInt(args[2]); + if (index < 1) { + sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + ""); + return false; } } - for (final PlotComment comment : comments) { - DBFunc.removeComment(world, plot, comment); + catch (NumberFormatException e) { + sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete "); + return false; } - plot.settings.removeComments(comments); - MainUtil.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); - } else { - final List recipients = Arrays.asList("A", "O", "H", "T", "E"); - int count = 1; - final StringBuilder message = new StringBuilder(C.COMMENT_HEADER.s()); - for (final PlotComment comment : comments) { - message.append("\n&8[&7" + comment.id + "&8]" + "&c[" + count + "]&6[" + recipients.get(tier2 == -1 ? 0 : tier2) + "] &7" + comment.senderName + "&f: " + comment.comment); - count++; + + if (!inbox.getComments(plot, new RunnableVal() { + @Override + public void run() { + List comments = (List) value; + if (index > comments.size()) { + sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + ""); + } + PlotComment comment = comments.get(index - 1); + inbox.removeComment(plot, comment); + plot.settings.removeComment(comment); + MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment); + } + })) { + sendMessage(player, C.NOT_IN_PLOT); + return false; } - if (comments.size() == 0) { - message.append("&cNo messages."); + return true; + } + case "clear": { + if (!inbox.canModify(plot, player)) { + sendMessage(player, C.NO_PERM_INBOX_MODIFY); } - MainUtil.sendMessage(plr, message.toString()); + inbox.clearInbox(plot); + ArrayList comments = plot.settings.getComments(inbox.toString()); + if (comments != null) { + plot.settings.removeComments(comments); + } + MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*"); + return true; + } + default: { + try { + page = Integer.parseInt(args[1]) ; + } + catch (NumberFormatException e) { + sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [delete |clear|page]"); + return false; + }; } } - }); + } + else { + page = 1; + } + if (!inbox.canRead(plot, player)) { + sendMessage(player, C.NO_PERM_INBOX); + return false; + } + if (!inbox.getComments(plot, new RunnableVal() { + @Override + public void run() { + List comments = (List) value; + displayComments(player, comments, page); + } + })) { + sendMessage(player, C.NOT_IN_PLOT); + return false; + } return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 20b322201..6ea615e2d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index b252c5292..7abbab226 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -103,9 +103,14 @@ public enum C { /* * Comment */ - COMMENT_SYNTAX("$2Use /plots comment "), + NOT_VALID_INBOX_INDEX("$2No comment at index %s"), + INBOX_ITEM("$2 - $4%s"), + COMMENT_SYNTAX("$2Use /plots comment [X;Z] <%s> "), INVALID_INBOX("$2That is not a valid inbox.\n$1Accepted values: %s"), - COMMENT_REMOVED("$4Successfully deleted %s."), + NO_PERM_INBOX("$2You do not have permission for that inbox"), + NO_PERM_INBOX_MODIFY("$2You do not have permission to modify that inbox"), + NO_PLOT_INBOX("$2You must stand in or supply a plot argument"), + COMMENT_REMOVED("$4Successfully deleted comment/s:n$2 - '$3%s$2'"), COMMENT_ADDED("$4A comment has been left"), COMMENT_HEADER("$2====== Comments ======"), /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 0f93c6e23..4f4153519 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -301,6 +301,13 @@ public interface AbstractDB { * @param comment Comment to remove */ public void removeComment(final String world, final Plot plot, final PlotComment comment); + + /** + * Clear an inbox + * @param plot + * @param inbox + */ + public void clearInbox(Plot plot, String inbox); /** * Set a plot comment @@ -320,7 +327,7 @@ public interface AbstractDB { * * @return Plot Comments within the specified tier */ - public ArrayList getComments(final String world, final Plot plot, final int tier, boolean below); + public ArrayList getComments(final String world, final Plot plot, final String inbox); public void createPlotAndSettings(Plot plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 82660fc9f..6f4106e40 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -237,6 +237,10 @@ public class DBFunc { public static void removeComment(final String world, final Plot plot, final PlotComment comment) { dbManager.removeComment(world, plot, comment); } + + public static void clearInbox(final Plot plot, final String inbox) { + dbManager.clearInbox(plot, inbox); + } /** * @param plot @@ -249,8 +253,8 @@ public class DBFunc { /** * @param plot */ - public static ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) { - return dbManager.getComments(world, plot, tier, below); + public static ArrayList getComments(final String world, final Plot plot, final String inbox) { + return dbManager.getComments(world, plot, inbox); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 37df1215e..bc2571ff9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -28,13 +28,11 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map.Entry; import java.util.Set; import java.util.UUID; @@ -137,9 +135,6 @@ public class SQLManager implements AbstractDB { @Override public void createAllSettingsAndHelpers(final ArrayList mylist) { - - // TODO create settings - final int size = mylist.size(); int packet; if (PlotSquared.getMySQL() != null) { @@ -270,29 +265,6 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { try { - - /* - * (" + " `plot_plot_id` INT(11) NOT NULL," + " - * `biome` VARCHAR(45) DEFAULT 'FOREST'," + " - * `rain` INT(1) DEFAULT 0," + " - * `custom_time` TINYINT(1) DEFAULT '0'," + " - * `time` INT(11) DEFAULT '8000'," + " - * `deny_entry` TINYINT(1) DEFAULT '0'," + " - * `alias` VARCHAR(50) DEFAULT NULL," + " - * `flags` VARCHAR(512) DEFAULT NULL," + " - * `merged` INT(11) DEFAULT NULL," + " - * `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + - * " PRIMARY KEY (`plot_plot_id`)," + " - * UNIQUE KEY `unique_alias` (`alias`)" + ") - * ENGINE=InnoDB DEFAULT CHARSET=utf8") - * - * plot_plot_id - nn - * biome - FOREST - * rain - 0 - * custom_time 0 - * time - */ - StringBuilder unionstmt = new StringBuilder("INSERT INTO `" + this.prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` "); for (int i = 0; i < (ids.size() - 2); i++) { unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); @@ -490,7 +462,13 @@ public class SQLManager implements AbstractDB { stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + + "`plot_plot_id` INT(11) NOT NULL," + + "`comment` VARCHAR(40) NOT NULL," + + "`inbox` VARCHAR(40) NOT NULL," + + "`timestamp` INT(11) NOT NULL," + + "`sender` VARCHAR(40) NOT NULL" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); @@ -506,7 +484,7 @@ public class SQLManager implements AbstractDB { stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")"); @@ -605,6 +583,22 @@ public class SQLManager implements AbstractDB { } return Integer.MAX_VALUE; } + + public void updateTables() { + try { + final DatabaseMetaData data = this.connection.getMetaData(); + ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_id"); + if (!rs.next()) { + final Statement statement = this.connection.createStatement(); + statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`"); + statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0"); + statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`"); + statement.executeBatch(); + statement.close(); + } + } + catch (SQLException e) {} + } /** * Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap @@ -1114,47 +1108,77 @@ public class SQLManager implements AbstractDB { try { PreparedStatement statement; if (plot != null) { - statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `tier` = ? AND `sender` = ?"); + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `inbox` = ? AND `sender` = ?"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, comment.comment); - statement.setInt(3, comment.tier); + statement.setString(3, comment.inbox); statement.setString(4, comment.senderName); } else { - statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `tier` = ? AND `sender` = ?"); + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `inbox` = ? AND `sender` = ?"); statement.setString(1, comment.comment); - statement.setInt(2, comment.tier); + statement.setString(2, comment.inbox); statement.setString(3, comment.senderName); } statement.executeUpdate(); statement.close(); } catch (final SQLException e) { e.printStackTrace(); - PlotSquared.log("&7[WARN] " + "Failed to remove helper for plot " + plot.id); + PlotSquared.log("&7[WARN] " + "Failed to remove comment for plot " + plot.id); + } + } + }); + } + + @Override + public void clearInbox(final Plot plot, final String inbox) { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + try { + PreparedStatement statement; + if (plot != null) { + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `inbox` = ?"); + statement.setInt(1, getId(plot.world, plot.id)); + statement.setString(2, inbox); + } else { + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` `inbox` = ?"); + statement.setString(1, inbox); + } + statement.executeUpdate(); + statement.close(); + } catch (final SQLException e) { + e.printStackTrace(); + PlotSquared.log("&7[WARN] " + "Failed to remove comment for plot " + plot.id); } } }); } @Override - public ArrayList getComments(final String world, final Plot plot, final int tier, final boolean below) { + public ArrayList getComments(final String world, final Plot plot, final String inbox) { final ArrayList comments = new ArrayList(); try { final PreparedStatement statement; - final String comparison = below ? ">=" : "="; if (plot != null) { - statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?"); + statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `inbox` = ?"); statement.setInt(1, getId(plot.world, plot.id)); - statement.setInt(2, tier); + statement.setString(2, inbox); } else { - statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `tier` " + comparison + " ?"); - statement.setInt(1, tier); + statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `inbox` = ?"); + statement.setString(1, inbox); } final ResultSet set = statement.executeQuery(); PlotComment comment; while (set.next()) { final String sender = set.getString("sender"); final String msg = set.getString("comment"); - comment = new PlotComment(plot.id, msg, sender, tier); + final int timestamp = set.getInt("timestamp"); + if (plot != null) { + comment = new PlotComment(plot.world, plot.id, msg, sender, inbox, timestamp); + } + else { + comment = new PlotComment(null, null, msg, sender, inbox, timestamp); + } comments.add(comment); } statement.close(); @@ -1172,11 +1196,12 @@ public class SQLManager implements AbstractDB { @Override public void run() { try { - final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_comments` (`plot_plot_id`, `comment`, `tier`, `sender`) VALUES(?,?,?,?)"); + final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_comments` (`plot_plot_id`, `comment`, `inbox`, `timestamp`, `sender`) VALUES(?,?,?,?,?)"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, comment.comment); - statement.setInt(3, comment.tier); - statement.setString(4, comment.senderName); + statement.setString(3, comment.inbox); + statement.setInt(4, (int) (comment.timestamp / 1000)); + statement.setString(5, comment.senderName); statement.executeUpdate(); statement.close(); } catch (final SQLException e) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 95d58aafd..307e6075b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -21,12 +20,10 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 677d4b099..7637417e0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; -import java.util.Map.Entry; import org.bukkit.World; import org.bukkit.block.Biome; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index bf0056eeb..dc465c000 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -172,22 +172,6 @@ public class Plot implements Cloneable { return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); } - /** - * Get the UUID of the owner - */ -// public UUID getOwner() { -// return this.owner_; -// } - - /** - * Set the owner - * - * @param uuid - */ -// public void setOwner(final UUID uuid) { -// this.owner_ = uuid; -// } - /** * Get the plot ID */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 860c7e541..4ad70fd4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -155,15 +155,15 @@ public class PlotSettings { return ""; } - public ArrayList getComments(final int tier) { + public ArrayList getComments(final String inbox) { final ArrayList c = new ArrayList<>(); if (this.comments == null) { return null; } for (final PlotComment comment : this.comments) { -// if (comment.tier == tier) { -// c.add(comment); -// } + if (comment.inbox.equals(inbox)) { + c.add(comment); + } } return c; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java index a17096eb4..43dca0965 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentInbox.java @@ -5,6 +5,10 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal; public abstract class CommentInbox { + + @Override + public abstract String toString(); + public abstract boolean canRead(Plot plot, PlotPlayer player); public abstract boolean canWrite(Plot plot, PlotPlayer player); @@ -24,4 +28,8 @@ public abstract class CommentInbox { public abstract boolean getComments(Plot plot, RunnableVal whenDone); public abstract boolean addComment(Plot plot, PlotComment comment); + + public abstract boolean removeComment(Plot plot, PlotComment comment); + + public abstract boolean clearInbox(Plot plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java new file mode 100644 index 000000000..2bad8e179 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java @@ -0,0 +1,18 @@ +package com.intellectualcrafters.plot.object.comment; + +import java.util.HashMap; + + +public class CommentManager { + public static HashMap inboxes = new HashMap<>(); + + public static void addInbox(CommentInbox inbox) { + inboxes.put(inbox.toString().toLowerCase(), inbox); + } + + public static void registerDefaultInboxes() { + addInbox(new InboxReport()); + addInbox(new InboxPublic()); + addInbox(new InboxOwner()); + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java deleted file mode 100644 index f13944466..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxManager.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.intellectualcrafters.plot.object.comment; - -import java.util.HashMap; - - -public class InboxManager { - public static HashMap inboxes = new HashMap<>(); - - public static void addInbox(String name, CommentInbox inbox) { - inboxes.put(name.toLowerCase(), inbox); - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java new file mode 100644 index 000000000..a3be6f3b9 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java @@ -0,0 +1,93 @@ +package com.intellectualcrafters.plot.object.comment; + +import java.util.ArrayList; + +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.TaskManager; + +public class InboxOwner extends CommentInbox { + + @Override + public boolean canRead(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.read." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other"))); + } + + @Override + public boolean canWrite(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.write." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write." + toString() + ".other"))); + } + + @Override + public boolean canModify(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.modify." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other"))); + } + + @Override + public boolean getComments(final Plot plot, final RunnableVal whenDone) { + if (plot == null || plot.owner == null) { + return false; + } + ArrayList comments = plot.settings.getComments(toString()); + if (comments != null) { + whenDone.value = comments; + TaskManager.runTask(whenDone); + } + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + ArrayList comments = DBFunc.getComments(plot.world, plot, toString()); + whenDone.value = comments; + plot.settings.setComments(comments); + TaskManager.runTask(whenDone); + } + }); + return true; + } + + @Override + public boolean addComment(Plot plot, PlotComment comment) { + if (plot == null || plot.owner == null) { + return false; + } + plot.settings.addComment(comment); + DBFunc.setComment(plot.world, plot, comment); + return true; + } + + @Override + public String toString() { + return "owner"; + } + + @Override + public boolean removeComment(Plot plot, PlotComment comment) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.removeComment(plot.world, plot, comment); + return false; + } + + @Override + public boolean clearInbox(Plot plot) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.clearInbox(plot, toString()); + return false; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java new file mode 100644 index 000000000..beaba1b1e --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java @@ -0,0 +1,91 @@ +package com.intellectualcrafters.plot.object.comment; + +import java.util.ArrayList; + +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.TaskManager; + +public class InboxPublic extends CommentInbox { + + @Override + public boolean canRead(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.read." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other"))); + } + + @Override + public boolean canWrite(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.write." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write." + toString() + ".other"))); + } + + @Override + public boolean canModify(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.modify." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other"))); + } + + @Override + public boolean getComments(final Plot plot, final RunnableVal whenDone) { + if (plot == null || plot.owner == null) { + return false; + } + ArrayList comments = plot.settings.getComments(toString()); + if (comments != null) { + whenDone.value = comments; + TaskManager.runTask(whenDone); + } + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + whenDone.value = DBFunc.getComments(plot.world, plot, toString()); + TaskManager.runTask(whenDone); + } + }); + return true; + } + + @Override + public boolean addComment(Plot plot, PlotComment comment) { + if (plot == null || plot.owner == null) { + return false; + } + plot.settings.addComment(comment); + DBFunc.setComment(plot.world, plot, comment); + return true; + } + + @Override + public String toString() { + return "public"; + } + + @Override + public boolean removeComment(Plot plot, PlotComment comment) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.removeComment(plot.world, plot, comment); + return false; + } + + @Override + public boolean clearInbox(Plot plot) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.clearInbox(plot, toString()); + return false; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java new file mode 100644 index 000000000..a7cb7083e --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java @@ -0,0 +1,80 @@ +package com.intellectualcrafters.plot.object.comment; + +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotHandler; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.TaskManager; + +public class InboxReport extends CommentInbox { + + @Override + public boolean canRead(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.read." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.read." + toString() + ".other"))); + } + + @Override + public boolean canWrite(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.write." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write." + toString() + ".other"))); + } + + @Override + public boolean canModify(Plot plot, PlotPlayer player) { + if (plot == null) { + return Permissions.hasPermission(player, "plots.inbox.modify." + toString()); + } + return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (PlotHandler.isOwner(plot, player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + toString() + ".other"))); + } + + @Override + public boolean getComments(final Plot plot, final RunnableVal whenDone) { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + whenDone.value = DBFunc.getComments(null, null, toString()); + TaskManager.runTask(whenDone); + } + }); + return true; + } + + @Override + public boolean addComment(Plot plot, PlotComment comment) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.setComment(plot.world, plot, comment); + return true; + } + + @Override + public String toString() { + return "report"; + } + + @Override + public boolean removeComment(Plot plot, PlotComment comment) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.removeComment(plot.world, plot, comment); + return false; + } + + @Override + public boolean clearInbox(Plot plot) { + if (plot == null || plot.owner == null) { + return false; + } + DBFunc.clearInbox(plot, toString()); + return false; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java index f4d5c474d..cd52aa9b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/PlotComment.java @@ -30,9 +30,11 @@ public class PlotComment { public final String inbox; public final String senderName; public final PlotId id; + public final String world; public final long timestamp; - public PlotComment(final PlotId id, final String comment, final String senderName, final String inbox, final long timestamp) { + public PlotComment(final String world, final PlotId id, final String comment, final String senderName, final String inbox, final long timestamp) { + this.world = world; this.id = id; this.comment = comment; this.senderName = senderName; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java deleted file mode 100644 index 3aa8c0141..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/ReportInbox.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.intellectualcrafters.plot.object.comment; - -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.RunnableVal; - -public class ReportInbox extends CommentInbox { - - @Override - public boolean canRead(Plot plot, PlotPlayer player) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canWrite(Plot plot, PlotPlayer player) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canModify(Plot plot, PlotPlayer player) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean getComments(Plot plot, RunnableVal whenDone) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean addComment(Plot plot, PlotComment comment) { - // TODO Auto-generated method stub - return false; - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 2e2f04ae1..727593950 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -1,20 +1,17 @@ package com.intellectualcrafters.plot.util.bukkit; import java.io.IOException; -import java.util.List; import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; -import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.ConfigurationNode; -import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; From 53b8f8a0d05930d080f538634d33953446501eed Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 22:16:24 +1000 Subject: [PATCH 126/223] fixes for comment system --- .../plot/commands/Comment.java | 3 + .../plot/commands/Inbox.java | 41 ++++-- .../plot/commands/Move.java | 1 + .../plot/database/AbstractDB.java | 3 +- .../plot/database/DBFunc.java | 5 +- .../plot/database/SQLManager.java | 133 ++++++++++-------- .../plot/generator/BukkitHybridUtils.java | 3 + .../plot/generator/HybridPop.java | 1 + .../plot/object/BukkitPlayer.java | 8 ++ .../plot/object/PlotId.java | 2 +- .../plot/object/PlotPlayer.java | 3 + .../plot/object/PlotSettings.java | 7 +- .../plot/object/comment/InboxOwner.java | 12 +- .../plot/object/comment/InboxPublic.java | 10 +- .../plot/object/comment/InboxReport.java | 6 +- .../plot/util/bukkit/BukkitSetupUtils.java | 3 + 16 files changed, 157 insertions(+), 84 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 025351ce0..f07484902 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -21,10 +21,12 @@ package com.intellectualcrafters.plot.commands; import java.util.Arrays; +import java.util.List; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -33,6 +35,7 @@ import com.intellectualcrafters.plot.object.comment.CommentInbox; import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; public class Comment extends SubCommand { public Comment() { 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 7b4cd9272..a4b93782f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -21,15 +21,11 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.UUID; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal; @@ -37,8 +33,6 @@ import com.intellectualcrafters.plot.object.comment.CommentInbox; import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.TaskManager; public class Inbox extends SubCommand { public Inbox() { @@ -62,7 +56,7 @@ public class Inbox extends SubCommand { max = comments.length; } final StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("plot","review").replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n"); + string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("plot","comment").replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n"); PlotComment c; // This might work xD for (int x = (page * 12); x < max; x++) { @@ -74,6 +68,7 @@ public class Inbox extends SubCommand { else { color = "&7"; } + System.out.print("PLOT INBOX: " +c.id); string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&7#" + c.senderName + "&8]" + color + c.senderName +"&7 : " + color + c.comment + "\n"); } MainUtil.sendMessage(player, string.toString()); @@ -82,11 +77,30 @@ public class Inbox extends SubCommand { @Override public boolean execute(final PlotPlayer player, final String... args) { final Plot plot = MainUtil.getPlot(player.getLocation()); - if (args.length < 1) { + if (args.length == 0) { sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [delete |clear|page]"); - for (CommentInbox inbox : CommentManager.inboxes.values()) { + for (final CommentInbox inbox : CommentManager.inboxes.values()) { if (inbox.canRead(plot, player)) { - sendMessage(player, C.INBOX_ITEM, inbox.toString()); + if (!inbox.getComments(plot, new RunnableVal() { + @Override + public void run() { + if (value != null) { + int count = 0; + for (PlotComment comment : (ArrayList) value) { + if (comment.timestamp > player.getPreviousLogin()) { + count++; + } + } + if (count > 0) { + sendMessage(player, C.INBOX_ITEM, "&c" + inbox.toString() + " (" + count + ")"); + return; + } + } + sendMessage(player, C.INBOX_ITEM, inbox.toString()); + } + })) { + sendMessage(player, C.INBOX_ITEM, inbox.toString()); + } } } return false; @@ -174,7 +188,12 @@ public class Inbox extends SubCommand { displayComments(player, comments, page); } })) { - sendMessage(player, C.NOT_IN_PLOT); + if (plot == null) { + sendMessage(player, C.NOT_IN_PLOT); + } + else { + sendMessage(player, C.PLOT_UNOWNED); + } return false; } return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 6ea615e2d..20b322201 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 4f4153519..55d22898f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.comment.PlotComment; /** @@ -327,7 +328,7 @@ public interface AbstractDB { * * @return Plot Comments within the specified tier */ - public ArrayList getComments(final String world, final Plot plot, final String inbox); + public void getComments(final String world, final Plot plot, final String inbox, RunnableVal whenDone); public void createPlotAndSettings(Plot plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 6f4106e40..c15e4be08 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.comment.PlotComment; /** @@ -253,8 +254,8 @@ public class DBFunc { /** * @param plot */ - public static ArrayList getComments(final String world, final Plot plot, final String inbox) { - return dbManager.getComments(world, plot, inbox); + public static void getComments(final String world, final Plot plot, final String inbox, RunnableVal whenDone) { + dbManager.getComments(world, plot, inbox, whenDone); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index bc2571ff9..fe02c8da2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -47,6 +47,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.TaskManager; @@ -104,6 +105,7 @@ public class SQLManager implements AbstractDB { } }, 11000); } + updateTables(); } /** @@ -462,13 +464,7 @@ public class SQLManager implements AbstractDB { stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + - "`plot_plot_id` INT(11) NOT NULL," + - "`comment` VARCHAR(40) NOT NULL," + - "`inbox` VARCHAR(40) NOT NULL," + - "`timestamp` INT(11) NOT NULL," + - "`sender` VARCHAR(40) NOT NULL" + - ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); @@ -484,7 +480,7 @@ public class SQLManager implements AbstractDB { stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")"); @@ -587,17 +583,24 @@ public class SQLManager implements AbstractDB { public void updateTables() { try { final DatabaseMetaData data = this.connection.getMetaData(); - ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_id"); + ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); if (!rs.next()) { + rs.close(); final Statement statement = this.connection.createStatement(); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`"); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0"); - statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`"); + statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); + if (PlotSquared.getMySQL() != null) { + statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + } + else { + statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); + } statement.executeBatch(); statement.close(); } } - catch (SQLException e) {} + catch (SQLException e) { + e.printStackTrace(); + } } /** @@ -1108,11 +1111,12 @@ public class SQLManager implements AbstractDB { try { PreparedStatement statement; if (plot != null) { - statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `comment` = ? AND `inbox` = ? AND `sender` = ?"); - statement.setInt(1, getId(world, plot.id)); - statement.setString(2, comment.comment); - statement.setString(3, comment.inbox); - statement.setString(4, comment.senderName); + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `comment` = ? AND `inbox` = ? AND `sender` = ?"); + statement.setString(1, plot.world); + statement.setInt(2, plot.id.hashCode()); + statement.setString(3, comment.comment); + statement.setString(4, comment.inbox); + statement.setString(5, comment.senderName); } else { statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `comment` = ? AND `inbox` = ? AND `sender` = ?"); statement.setString(1, comment.comment); @@ -1137,9 +1141,10 @@ public class SQLManager implements AbstractDB { try { PreparedStatement statement; if (plot != null) { - statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `inbox` = ?"); - statement.setInt(1, getId(plot.world, plot.id)); - statement.setString(2, inbox); + statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `inbox` = ?"); + statement.setString(1, plot.world); + statement.setInt(2, plot.id.hashCode()); + statement.setString(3, inbox); } else { statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` `inbox` = ?"); statement.setString(1, inbox); @@ -1155,39 +1160,50 @@ public class SQLManager implements AbstractDB { } @Override - public ArrayList getComments(final String world, final Plot plot, final String inbox) { - final ArrayList comments = new ArrayList(); - try { - final PreparedStatement statement; - if (plot != null) { - statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `inbox` = ?"); - statement.setInt(1, getId(plot.world, plot.id)); - statement.setString(2, inbox); - } else { - statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `inbox` = ?"); - statement.setString(1, inbox); - } - final ResultSet set = statement.executeQuery(); - PlotComment comment; - while (set.next()) { - final String sender = set.getString("sender"); - final String msg = set.getString("comment"); - final int timestamp = set.getInt("timestamp"); - if (plot != null) { - comment = new PlotComment(plot.world, plot.id, msg, sender, inbox, timestamp); + public void getComments(final String world, final Plot plot, final String inbox, final RunnableVal whenDone) { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + final ArrayList comments = new ArrayList(); + try { + final PreparedStatement statement; + if (plot != null) { + statement = connection.prepareStatement("SELECT * FROM `" + prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ? AND `inbox` = ?"); + statement.setString(1, plot.world); + statement.setInt(2, plot.id.hashCode()); + statement.setString(3, inbox); + } else { + statement = connection.prepareStatement("SELECT * FROM `" + prefix + "plot_comments` WHERE `inbox` = ?"); + statement.setString(1, inbox); + } + final ResultSet set = statement.executeQuery(); + PlotComment comment; + while (set.next()) { + final String sender = set.getString("sender"); + final String world = set.getString("world"); + final int hash = set.getInt("hashcode"); + PlotId id; + if (hash != 0) { + id = PlotId.unpair(hash); + } + else { + id = null; + } + final String msg = set.getString("comment"); + final long timestamp = set.getInt("timestamp") * 1000; + comment = new PlotComment(world, id, msg, sender, inbox, timestamp); + comments.add(comment); + whenDone.value = comments; + TaskManager.runTask(whenDone); + } + statement.close(); + set.close(); + } catch (final SQLException e) { + PlotSquared.log("&7[WARN] " + "Failed to fetch comment"); + e.printStackTrace(); } - else { - comment = new PlotComment(null, null, msg, sender, inbox, timestamp); - } - comments.add(comment); } - statement.close(); - set.close(); - } catch (final SQLException e) { - PlotSquared.log("&7[WARN] " + "Failed to fetch comment"); - e.printStackTrace(); - } - return comments; + }); } @Override @@ -1196,12 +1212,13 @@ public class SQLManager implements AbstractDB { @Override public void run() { try { - final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_comments` (`plot_plot_id`, `comment`, `inbox`, `timestamp`, `sender`) VALUES(?,?,?,?,?)"); - statement.setInt(1, getId(world, plot.id)); - statement.setString(2, comment.comment); - statement.setString(3, comment.inbox); - statement.setInt(4, (int) (comment.timestamp / 1000)); - statement.setString(5, comment.senderName); + final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_comments` (`world`, `hashcode`, `comment`, `inbox`, `timestamp`, `sender`) VALUES(?,?,?,?,?,?)"); + statement.setString(1, plot.world); + statement.setInt(2, plot.id.hashCode()); + statement.setString(3, comment.comment); + statement.setString(4, comment.inbox); + statement.setInt(5, (int) (comment.timestamp / 1000)); + statement.setString(6, comment.senderName); statement.executeUpdate(); statement.close(); } catch (final SQLException e) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 307e6075b..95d58aafd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -20,10 +21,12 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 7637417e0..677d4b099 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; +import java.util.Map.Entry; import org.bukkit.World; import org.bukkit.block.Biome; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index dc7c85592..eb3f83359 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -17,6 +17,7 @@ public class BukkitPlayer implements PlotPlayer { public HashSet hasPerm = new HashSet<>(); public HashSet noPerm = new HashSet<>(); private int op = 0; + private long last = 0; /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. @@ -25,6 +26,13 @@ public class BukkitPlayer implements PlotPlayer { public BukkitPlayer(final Player player) { this.player = player; } + + public long getPreviousLogin() { + if (last == 0) { + last = player.getLastPlayed(); + } + return last; + } @Override public Location getLocation() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index ca8ef60d9..5ff26a5ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -83,7 +83,7 @@ public class PlotId { return this.x + ";" + this.y; } - public PlotId unpair(int hash) { + public static PlotId unpair(int hash) { if (hash >= 0) { if (hash % 2 == 0) { // + + diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 7cb9597c6..cb75aa726 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -8,6 +8,9 @@ import java.util.UUID; * @author Citymonstret */ public interface PlotPlayer { + + public long getPreviousLogin(); + public Location getLocation(); public Location getLocationFull(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 4ad70fd4e..b908e7812 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; +import java.util.List; import java.util.Set; import com.intellectualcrafters.plot.flag.Flag; @@ -52,7 +53,7 @@ public class PlotSettings { /** * Comments */ - private ArrayList comments = null; + private List comments = null; /** * Flags */ @@ -168,7 +169,7 @@ public class PlotSettings { return c; } - public void setComments(final ArrayList comments) { + public void setComments(final List comments) { this.comments = comments; } @@ -178,7 +179,7 @@ public class PlotSettings { } } - public void removeComments(final ArrayList comments) { + public void removeComments(final List comments) { for (final PlotComment comment : comments) { removeComment(comment); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java index a3be6f3b9..af17285ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java @@ -45,13 +45,17 @@ public class InboxOwner extends CommentInbox { if (comments != null) { whenDone.value = comments; TaskManager.runTask(whenDone); + return true; } - TaskManager.runTaskAsync(new Runnable() { + DBFunc.getComments(plot.world, plot, toString(), new RunnableVal() { @Override public void run() { - ArrayList comments = DBFunc.getComments(plot.world, plot, toString()); - whenDone.value = comments; - plot.settings.setComments(comments); + whenDone.value = value; + if (value != null) { + for (PlotComment comment : (ArrayList) value) { + plot.settings.addComment(comment); + } + } TaskManager.runTask(whenDone); } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java index beaba1b1e..d2668271e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java @@ -45,11 +45,17 @@ public class InboxPublic extends CommentInbox { if (comments != null) { whenDone.value = comments; TaskManager.runTask(whenDone); + return true; } - TaskManager.runTaskAsync(new Runnable() { + DBFunc.getComments(plot.world, plot, toString(), new RunnableVal() { @Override public void run() { - whenDone.value = DBFunc.getComments(plot.world, plot, toString()); + whenDone.value = value; + if (value != null) { + for (PlotComment comment : (ArrayList) value) { + plot.settings.addComment(comment); + } + } TaskManager.runTask(whenDone); } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java index a7cb7083e..f2af870b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java @@ -1,5 +1,7 @@ package com.intellectualcrafters.plot.object.comment; +import java.util.ArrayList; + import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotHandler; @@ -36,10 +38,10 @@ public class InboxReport extends CommentInbox { @Override public boolean getComments(final Plot plot, final RunnableVal whenDone) { - TaskManager.runTaskAsync(new Runnable() { + DBFunc.getComments(null, null, toString(), new RunnableVal() { @Override public void run() { - whenDone.value = DBFunc.getComments(null, null, toString()); + whenDone.value = value; TaskManager.runTask(whenDone); } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 727593950..2e2f04ae1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -1,17 +1,20 @@ package com.intellectualcrafters.plot.util.bukkit; import java.io.IOException; +import java.util.List; import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; +import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; From 715c4ceaabc69d6647022232a40982b71d052f3c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 22:20:24 +1000 Subject: [PATCH 127/223] * --- .../main/java/com/intellectualcrafters/plot/commands/Inbox.java | 1 - .../java/com/intellectualcrafters/plot/database/SQLManager.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) 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 a4b93782f..d7b5b5bf5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -68,7 +68,6 @@ public class Inbox extends SubCommand { else { color = "&7"; } - System.out.print("PLOT INBOX: " +c.id); string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&7#" + c.senderName + "&8]" + color + c.senderName +"&7 : " + color + c.comment + "\n"); } MainUtil.sendMessage(player, string.toString()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index fe02c8da2..78cf61f14 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1194,8 +1194,8 @@ public class SQLManager implements AbstractDB { comment = new PlotComment(world, id, msg, sender, inbox, timestamp); comments.add(comment); whenDone.value = comments; - TaskManager.runTask(whenDone); } + TaskManager.runTask(whenDone); statement.close(); set.close(); } catch (final SQLException e) { From c71c2142d3c5587b2917c1373e3d09092268f59e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 22:27:32 +1000 Subject: [PATCH 128/223] Display message count by list --- .../plot/commands/Inbox.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) 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 d7b5b5bf5..2f74f8ac1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.MainUtil; public class Inbox extends SubCommand { public Inbox() { - super(Command.INBOX, "Review the comments for a plot", "inbox [delete |clear|page]", CommandCategory.ACTIONS, true); + super(Command.INBOX, "Review the comments for a plot", "inbox [inbox] [delete |clear|page]", CommandCategory.ACTIONS, true); } public void displayComments(PlotPlayer player, List oldComments, int page) { @@ -77,21 +77,30 @@ public class Inbox extends SubCommand { public boolean execute(final PlotPlayer player, final String... args) { final Plot plot = MainUtil.getPlot(player.getLocation()); if (args.length == 0) { - sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [delete |clear|page]"); + sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete |clear|page]"); for (final CommentInbox inbox : CommentManager.inboxes.values()) { if (inbox.canRead(plot, player)) { if (!inbox.getComments(plot, new RunnableVal() { @Override public void run() { if (value != null) { - int count = 0; + int total = 0; + int unread = 0; for (PlotComment comment : (ArrayList) value) { + total++; if (comment.timestamp > player.getPreviousLogin()) { - count++; + unread++; } } - if (count > 0) { - sendMessage(player, C.INBOX_ITEM, "&c" + inbox.toString() + " (" + count + ")"); + if (total != 0) { + String color; + if (unread > 0) { + color = "&c"; + } + else { + color = ""; + } + sendMessage(player, C.INBOX_ITEM, color + inbox.toString() + " (" + total + "/" + unread + ")"); return; } } @@ -167,7 +176,7 @@ public class Inbox extends SubCommand { page = Integer.parseInt(args[1]) ; } catch (NumberFormatException e) { - sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [delete |clear|page]"); + sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete |clear|page]"); return false; }; } From f0cd6fa0ec57beddbee2ee7be0647486eb08c7b9 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 6 Apr 2015 22:28:45 +1000 Subject: [PATCH 129/223] Fix typo --- .../main/java/com/intellectualcrafters/plot/commands/Inbox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2f74f8ac1..c4e274004 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -68,7 +68,7 @@ public class Inbox extends SubCommand { else { color = "&7"; } - string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&7#" + c.senderName + "&8]" + color + c.senderName +"&7 : " + color + c.comment + "\n"); + string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&6" + c.senderName + "&8]" + color + c.comment + "\n"); } MainUtil.sendMessage(player, string.toString()); } From 3a40614bb2ed4097ed56a2dc7390449d1457b8d5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 16:19:16 +1000 Subject: [PATCH 130/223] Added default home location optiom --- .../plot/database/SQLManager.java | 28 +++++---- .../plot/object/PlotWorld.java | 25 ++++++++ .../plot/util/MainUtil.java | 57 +++++++------------ .../plot/util/bukkit/BukkitChunkManager.java | 2 +- 4 files changed, 64 insertions(+), 48 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 78cf61f14..1c8c0fece 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -583,20 +583,24 @@ public class SQLManager implements AbstractDB { public void updateTables() { try { final DatabaseMetaData data = this.connection.getMetaData(); - ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); - if (!rs.next()) { - rs.close(); - final Statement statement = this.connection.createStatement(); - statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); - if (PlotSquared.getMySQL() != null) { - statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot"); + if (rs.next()) { + rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); + if (!rs.next()) { + rs.close(); + final Statement statement = this.connection.createStatement(); + statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); + if (PlotSquared.getMySQL() != null) { + statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + } + else { + statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); + } + statement.executeBatch(); + statement.close(); } - else { - statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); - } - statement.executeBatch(); - statement.close(); } + rs.close(); } catch (SQLException e) { e.printStackTrace(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index b204492be..a5305e1ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -89,6 +89,8 @@ public abstract class PlotWorld { public boolean WORLD_BORDER; public int TYPE = 0; public int TERRAIN = 0; + public boolean HOME_ALLOW_NONMEMBER; + public PlotLoc DEFAULT_HOME; public PlotWorld(final String worldname) { this.worldname = worldname; @@ -143,6 +145,25 @@ public abstract class PlotWorld { this.SELL_PRICE = config.getDouble("economy.prices.sell"); this.PLOT_CHAT = config.getBoolean("chat.enabled"); this.WORLD_BORDER = config.getBoolean("world.border"); + + this.HOME_ALLOW_NONMEMBER = config.getBoolean("home.allow-nonmembers"); + String homeDefault = config.getString("home.default"); + if (homeDefault.equalsIgnoreCase("side")) { + DEFAULT_HOME = null; + } + else if (homeDefault.equalsIgnoreCase("center")) { + DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); + } + else { + try { + String[] split = homeDefault.split(","); + DEFAULT_HOME = new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } + catch (Exception e) { + DEFAULT_HOME = null; + } + } + List flags = config.getStringList("flags.default"); if (flags == null || flags.size() == 0) { flags = config.getStringList("flags"); @@ -201,6 +222,10 @@ public abstract class PlotWorld { options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT); options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT); options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT); + + options.put("home.default", "side"); + options.put("home.allow-nonmembers", false); + if (Settings.ENABLE_CLUSTERS && (this.TYPE != 0)) { options.put("generator.terrain", this.TERRAIN); options.put("generator.type", this.TYPE); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0981e0b10..eb56cfe9f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -97,7 +97,25 @@ public class MainUtil { return count; } - public static Location getPlotFront(Plot plot) { + public static Location getDefaultHome(Plot plot) { + PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); + if (plotworld.DEFAULT_HOME != null) { + final Location bot = getPlotBottomLoc(plot.world, plot.id); + final PlotManager manager = PlotSquared.getPlotManager(plot.world); + final int x; + final int z; + if (plotworld.DEFAULT_HOME.x == Integer.MAX_VALUE && plotworld.DEFAULT_HOME.z == Integer.MAX_VALUE) { + final Location top = getPlotTopLoc(plot.world, plot.id); + x = ((top.getX() - bot.getX()) / 2) + bot.getX(); + z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ(); + } + else { + x = bot.getX() + plotworld.DEFAULT_HOME.x; + z = bot.getZ() + plotworld.DEFAULT_HOME.z; + } + final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY()); + return new Location(plot.world, x, y, z); + } final Location top = getPlotTopLoc(plot.world, plot.id); final Location bot = getPlotBottomLoc(plot.world, plot.id); final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); @@ -110,18 +128,15 @@ public class MainUtil { public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) { final Plot bot = MainUtil.getBottomPlot(plot); - // TODO - // boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); boolean result = EventUtil.manager.callTeleport(player, from, plot); - // TOOD ^ remove that if (result) { final Location location; - if (plot.isAdded(player.getUUID())) { + if (PlotSquared.getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) { location = MainUtil.getPlotHome(bot.world, bot); } else { - location = getPlotFront(plot); + location = getDefaultHome(plot); } if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { sendMessage(player, C.TELEPORTED_TO_PLOT); @@ -531,7 +546,6 @@ public class MainUtil { h = (prime * h) + pos1.getZ(); state = h; System.currentTimeMillis(); - final Location location = MainUtil.getPlotHomeDefault(plot); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); runners.put(plot, 1); if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { @@ -622,16 +636,6 @@ public class MainUtil { return 64; } return result; - // for (int i = 1; i < world.getMaxHeight(); i++) { - // id = world.getBlockAt(x, i, z).getTypeId(); - // if (id == 0) { - // if (safe) { - // return i; - // } - // safe = true; - // } - // } - // return 64; } /** @@ -648,30 +652,13 @@ public class MainUtil { final Location bot = getPlotBottomLoc(w, plotid); final PlotManager manager = PlotSquared.getPlotManager(w); if ((home == null) || ((home.x == 0) && (home.z == 0))) { - final Location top = getPlotTopLoc(w, plotid); - final int x = ((top.getX() - bot.getX()) / 2) + bot.getX(); - final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ(); - final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(w), plot).getY()); - return new Location(w, x, y, z); + return getDefaultHome(plot); } else { final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y); return bot.add(home.x, y, home.z); } } - /** - * Retrieve the location of the default plot home position - * - * @param plot Plot - * - * @return the location - */ - public static Location getPlotHomeDefault(final Plot plot) { - final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0); - l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ())); - return l; - } - /** * Get the plot home * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 4235c01e1..1cea1bed0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -770,7 +770,7 @@ public class BukkitChunkManager extends ChunkManager { if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - BukkitUtil.getPlayer(player).teleport(MainUtil.getPlotFront(plot)); + BukkitUtil.getPlayer(player).teleport(MainUtil.getDefaultHome(plot)); PlotListener.plotExit(player, plot); } else { entity.remove(); From da4bf3b8b97bf00eb6ccc5a7244dceedee222a73 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 17:57:07 +1000 Subject: [PATCH 131/223] Fixes #162 --- .../plot/generator/BukkitHybridUtils.java | 42 +++++++++++++++---- .../plot/listeners/PlayerEvents.java | 2 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 95d58aafd..7e17e0aaa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -171,13 +171,19 @@ public class BukkitHybridUtils extends HybridUtils { private static boolean UPDATE = false; private int task; + private long last; @Override public boolean scheduleRoadUpdate(final String world) { if (BukkitHybridUtils.UPDATE) { return false; } + BukkitHybridUtils.UPDATE = true; final List regions = ChunkManager.manager.getChunkChunks(world); + return scheduleRoadUpdate(world, regions); + } + + public boolean scheduleRoadUpdate(final String world, final List regions) { final List chunks = new ArrayList(); final Plugin plugin = BukkitMain.THIS; this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @@ -196,15 +202,37 @@ public class BukkitHybridUtils extends HybridUtils { PlotSquared.log(" - Remaining: " + regions.size()); chunks.addAll(getChunks(regions.get(0))); regions.remove(0); + System.gc(); } if (chunks.size() > 0) { - long diff = System.currentTimeMillis() + 50; - while (System.currentTimeMillis() < diff) { - ChunkLoc chunk = chunks.get(0); - chunks.remove(0); - regenerateRoad(world, chunk); - + long diff = System.currentTimeMillis() + 25; + if (System.currentTimeMillis() - last > 1000 && last != 0) { + last = 0; + PlotSquared.log(C.PREFIX.s() + "Detected low TPS. Rescheduling in 1 minute"); + while (chunks.size() > 0) { + ChunkLoc chunk = chunks.get(0); + chunks.remove(0); + regenerateRoad(world, chunk); + ChunkManager.manager.unloadChunk(world, chunk); + } + Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task); + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + scheduleRoadUpdate(world, regions); + } + }, 1200); + return; } + if (System.currentTimeMillis() - last < 50) { + while (System.currentTimeMillis() < diff) { + ChunkLoc chunk = chunks.get(0); + chunks.remove(0); + regenerateRoad(world, chunk); + ChunkManager.manager.unloadChunk(world, chunk); + } + } + last = System.currentTimeMillis(); } } catch (final Exception e) { final ChunkLoc loc = regions.get(0); @@ -221,7 +249,7 @@ public class BukkitHybridUtils extends HybridUtils { } } } - }, 20, 20); + }, 1, 1); return true; } 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 c16d1cfab..b821783a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -277,7 +277,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (Settings.TELEPORT_ON_LOGIN) { - BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot)); + MainUtil.teleportPlayer(pp, pp.getLocation(), plot); MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD); } plotEntry(player, plot); From 81f195ac2b2d6a013a83b339793896796d4b326f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 18:01:03 +1000 Subject: [PATCH 132/223] 30s works better. --- .../plot/generator/BukkitHybridUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 7e17e0aaa..981ed154a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -208,7 +208,7 @@ public class BukkitHybridUtils extends HybridUtils { long diff = System.currentTimeMillis() + 25; if (System.currentTimeMillis() - last > 1000 && last != 0) { last = 0; - PlotSquared.log(C.PREFIX.s() + "Detected low TPS. Rescheduling in 1 minute"); + PlotSquared.log(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s"); while (chunks.size() > 0) { ChunkLoc chunk = chunks.get(0); chunks.remove(0); @@ -221,7 +221,7 @@ public class BukkitHybridUtils extends HybridUtils { public void run() { scheduleRoadUpdate(world, regions); } - }, 1200); + }, 600); return; } if (System.currentTimeMillis() - last < 50) { From 15df5619611c122ad0053e353fa0ebe1c47a3d98 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 19:47:12 +1000 Subject: [PATCH 133/223] Remove message --- .../java/com/intellectualcrafters/plot/commands/FlagCmd.java | 1 - 1 file changed, 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 7a6f58fe2..e1fb81ce1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -93,7 +93,6 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); // Flag type description MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); - MainUtil.sendMessage(player, "&cNot implemented."); } case "set": { if (!Permissions.hasPermission(player, "plots.set.flag")) { From e8fa39004df6d3e29096bc196b8e1be5162e60d0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 19:59:34 +1000 Subject: [PATCH 134/223] Fixes #249 (You may need to update your translation file afterwards) --- .../src/main/java/com/intellectualcrafters/plot/config/C.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 7abbab226..abee75367 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -401,7 +401,7 @@ public enum C { */ DENIED_REMOVED("$4You successfully undenied the player from this plot"), DENIED_ADDED("$4You successfully denied the player from this plot"), - DENIED_NEED_ARGUMENT("$2Arguments are missing. $1/plot denied add $2or $1/plot helpers remove "), + DENIED_NEED_ARGUMENT("$2Arguments are missing. $1/plot denied add $2or $1/plot denied remove "), WAS_NOT_DENIED("$2That player was not denied on this plot"), /* * Rain From 0c3919b365b07e1ae460a02c65465de65217c89d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 22:17:04 +1000 Subject: [PATCH 135/223] Added experimental chunk processing: If enabled: - Detects laggy chunks based on a configured threshold - Removes all sources of lag from the chunk If the threshold is set too low, normal levels of blocks and entities will be considered "sources of lag", so just be careful when using this experimental feature. --- PlotSquared/pom.xml | 2 +- .../intellectualcrafters/plot/BukkitMain.java | 7 +++ .../plot/PlotSquared.java | 8 ++++ .../plot/config/Settings.java | 6 +++ .../plot/listeners/ChunkListener.java | 44 +++++++++++++++++++ .../plot/object/BukkitPlayer.java | 18 ++++++++ .../plot/object/PlotPlayer.java | 4 ++ 7 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 04480a58e..a6d8e7024 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.6 + 2.9.7 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 2e2654d73..4e2abc5c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.listeners.ChunkListener; import com.intellectualcrafters.plot.listeners.ForceFieldListener; import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.PlayerEvents; @@ -103,6 +104,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } getServer().getPluginManager().registerEvents(new WorldEvents(), this); + + // Experimental + if (Settings.CHUNK_PROCESSOR) { + getServer().getPluginManager().registerEvents(new ChunkListener(), this); + } + List worlds = Bukkit.getWorlds(); if (worlds.size() > 0) { UUIDHandler.cacheAll(worlds.get(0).getName()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 10c6df3a1..e9ca0d807 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -810,6 +810,11 @@ public class PlotSquared { options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); + + options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR); + options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES); + options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES); + for (final Entry node : options.entrySet()) { if (!config.contains(node.getKey())) { config.set(node.getKey(), node.getValue()); @@ -820,6 +825,9 @@ public class PlotSquared { if (Settings.DEBUG) { log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } + + Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled"); + Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled"); Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); 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 8e8e4510a..ca7fbbbcc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -41,6 +41,12 @@ public class Settings { public static boolean CONVERT_PLOTME = true; public static boolean CACHE_PLOTME = false; public static boolean USE_PLOTME_ALIAS = false; + /** + * Chunk processor + */ + public static boolean CHUNK_PROCESSOR = false; + public static int CHUNK_PROCESSOR_MAX_BLOCKSTATES = 4096; + public static int CHUNK_PROCESSOR_MAX_ENTITIES = 512; /** * TNT listener */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java new file mode 100644 index 000000000..b40529317 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -0,0 +1,44 @@ +package com.intellectualcrafters.plot.listeners; + +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Entity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.world.ChunkLoadEvent; +import org.bukkit.event.world.ChunkUnloadEvent; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.Settings; + +public class ChunkListener implements Listener { + + @EventHandler + public void onChunkUnload(ChunkUnloadEvent event) { + processChunk(event.getChunk()); + } + + @EventHandler + public void onChunkLoad(ChunkLoadEvent event) { + processChunk(event.getChunk()); + } + + public void processChunk(Chunk chunk) { + if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) { + return; + } + Entity[] entities = chunk.getEntities(); + BlockState[] tiles = chunk.getTileEntities(); + if (tiles.length > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) { + for (BlockState tile : tiles) { + tile.getBlock().setType(Material.AIR, false); + } + } + if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + for (Entity ent : entities) { + ent.remove(); + } + } + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index eb3f83359..dd1594ebe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.plot.object; +import java.util.HashMap; import java.util.HashSet; import java.util.UUID; @@ -18,6 +19,7 @@ public class BukkitPlayer implements PlotPlayer { public HashSet noPerm = new HashSet<>(); private int op = 0; private long last = 0; + private HashMap tmpData = null; /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. @@ -119,4 +121,20 @@ public class BukkitPlayer implements PlotPlayer { return BukkitUtil.getLocationFull(this.player); } + @Override + public void setTmpData(String key, Object value) { + if (tmpData == null) { + tmpData = new HashMap<>(); + } + tmpData.put(key, value); + } + + @Override + public Object getTmpData(String key) { + if (tmpData == null) { + return null; + } + return tmpData.get(key); + } + } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index cb75aa726..24776994e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -9,6 +9,10 @@ import java.util.UUID; */ public interface PlotPlayer { + public void setTmpData(String key, Object value); + + public Object getTmpData(String key); + public long getPreviousLogin(); public Location getLocation(); From 214cd1dbf8fe4b15dc26ccd94c4217f83f249302 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 23:21:51 +1000 Subject: [PATCH 136/223] Added claim restrictions for clusters --- .../plot/commands/Auto.java | 6 +-- .../plot/commands/Claim.java | 2 +- .../plot/commands/Cluster.java | 12 ++--- .../plot/object/PlotCluster.java | 4 +- .../plot/object/PlotHologram.java | 49 ------------------- .../plot/util/MainUtil.java | 32 ++++++++++++ 6 files changed, 44 insertions(+), 61 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index ef40badde..ffe3e2f68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -179,7 +179,7 @@ public class Auto extends SubCommand { for (int i = 0; i <= max; i++) { final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); final Plot current = MainUtil.getPlot(worldname, currentId); - if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { + if (MainUtil.canClaim(plr, current) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { Claim.claimPlot(plr, current, true, true); return true; } @@ -193,7 +193,7 @@ public class Auto extends SubCommand { if ((size_x == 1) && (size_z == 1)) { while (!br) { final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname)); - if ((plot.owner == null)) { + if (MainUtil.canClaim(plr, plot)) { Claim.claimPlot(plr, plot, true, true); br = true; } @@ -213,7 +213,7 @@ public class Auto extends SubCommand { lastPlot = false; } final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1); - if (MainUtil.isUnowned(worldname, start, end)) { + if (MainUtil.canClaim(plr, worldname, start, end)) { for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j)); 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 2ab38c675..d13b7e63f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -93,7 +93,7 @@ public class Claim extends SubCommand { if (currentPlots >= MainUtil.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } - if (plot.hasOwner()) { + if (!MainUtil.canClaim(plr, plot)) { return sendMessage(plr, C.PLOT_IS_CLAIMED); } final PlotWorld world = PlotSquared.getPlotWorld(plot.world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 89a5ee654..da65e9fbc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -129,7 +129,7 @@ public class Cluster extends SubCommand { // Add any existing plots to the current cluster for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster current = ClusterManager.getCluster(plot); - if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { + if (cluster.equals(current) && !cluster.isAdded(plot.owner)) { cluster.invited.add(plot.owner); DBFunc.setInvited(world, cluster, plot.owner); } @@ -302,7 +302,7 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); return false; } - if (!cluster.hasRights(uuid)) { + if (!cluster.isAdded(uuid)) { // add the user if not added cluster.invited.add(uuid); final String world = plr.getLocation().getWorld(); @@ -344,7 +344,7 @@ public class Cluster extends SubCommand { return false; } // Can't kick if the player is yourself, the owner, or not added to the cluster - if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.hasRights(uuid)) { + if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.isAdded(uuid)) { MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName()); return false; } @@ -393,7 +393,7 @@ public class Cluster extends SubCommand { } } final UUID uuid = UUIDHandler.getUUID(plr); - if (!cluster.hasRights(uuid)) { + if (!cluster.isAdded(uuid)) { MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED); return false; } @@ -466,7 +466,7 @@ public class Cluster extends SubCommand { return false; } final UUID uuid = UUIDHandler.getUUID(plr); - if (!cluster.hasRights(uuid)) { + if (!cluster.isAdded(uuid)) { if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other"); return false; @@ -508,7 +508,7 @@ public class Cluster extends SubCommand { } final String name = cluster.getName(); final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1); - final String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + ""; + final String rights = cluster.isAdded(UUIDHandler.getUUID(plr)) + ""; String message = C.CLUSTER_INFO.s(); message = message.replaceAll("%id%", id); message = message.replaceAll("%owner%", owner); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java index 65cd4c8ac..81a1a7539 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotCluster.java @@ -29,7 +29,7 @@ public class PlotCluster { public void setP2(final PlotId id) { this.pos2 = id; } - + public PlotCluster(final String world, final PlotId pos1, final PlotId pos2, final UUID owner) { this.world = world; this.pos1 = pos1; @@ -38,7 +38,7 @@ public class PlotCluster { this.settings = new PlotSettings(null); } - public boolean hasRights(final UUID uuid) { + public boolean isAdded(final UUID uuid) { return (this.owner.equals(uuid) || this.invited.contains(uuid) || this.invited.contains(DBFunc.everyone) || this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java deleted file mode 100644 index 99953d5a0..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHologram.java +++ /dev/null @@ -1,49 +0,0 @@ -//package com.intellectualcrafters.plot.object; -// -//import java.util.Collection; -// -//import org.bukkit.Bukkit; -//import org.bukkit.plugin.java.JavaPlugin; -// -//import com.gmail.filoghost.holographicdisplays.api.Hologram; -//import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; -//import com.intellectualcrafters.plot.PlotSquared; -//import com.intellectualcrafters.plot.util.PlotHelper; -// -///** -// * Created 2015-02-14 for PlotSquared -// * -// * @author Citymonstret -// */ -//public class PlotHologram { -// -// private static JavaPlugin plugin; -// private final PlotId id; -// private final String world; -// private Hologram hologram; -// -// public PlotHologram(final String world, final PlotId id) { -// this.id = id; -// this.world = world; -// this.hologram = createHologram(PlotSquared.getPlotManager(world).getSignLoc(Bukkit.getWorld(world), PlotSquared.getPlotWorld(world), PlotHelper.getPlot(Bukkit.getWorld(world), id))); -// } -// -// public static Hologram createHologram(final org.bukkit.Location location) { -// return HologramsAPI.createHologram(getPlugin(), location); -// } -// -// public static JavaPlugin getPlugin() { -// if (plugin == null) { -// plugin = JavaPlugin.getPlugin(PlotSquared.class); -// } -// return plugin; -// } -// -// public static void removeAll() { -// final Collection holograms = HologramsAPI.getHolograms(getPlugin()); -// for (final Hologram h : holograms) { -// h.delete(); -// } -// } -// -//} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index eb56cfe9f..dbd7c3390 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -753,6 +754,37 @@ public class MainUtil { return manager.getPlotBottomLocAbs(plotworld, id); } + public static boolean canClaim(PlotPlayer player, String world, final PlotId pos1, final PlotId pos2) { + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final PlotId id = new PlotId(x, y); + Plot plot = getPlot(world, id); + if (!canClaim(player, plot)) { + return false; + } + } + } + return true; + } + + public static boolean canClaim(PlotPlayer player, Plot plot) { + if (plot == null) { + return false; + } + if (Settings.ENABLE_CLUSTERS) { + PlotCluster cluster = ClusterManager.getCluster(plot); + if (cluster != null) { + if (!cluster.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.claim")) { + return false; + } + } + } + if (plot.owner != null) { + return false; + } + return true; + } + public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { From 8cc5949050acb54a366fb373809dee2ca4cc4996 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 7 Apr 2015 23:28:41 +1000 Subject: [PATCH 137/223] Fixed cluster typo --- .../java/com/intellectualcrafters/plot/commands/Cluster.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index da65e9fbc..5aad2d0d9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -299,7 +299,7 @@ public class Cluster extends SubCommand { // check uuid final UUID uuid = UUIDHandler.getUUID(args[1]); if (uuid == null) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]); return false; } if (!cluster.isAdded(uuid)) { @@ -435,7 +435,7 @@ public class Cluster extends SubCommand { } final UUID uuid = UUIDHandler.getUUID(args[2]); if (uuid == null) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]); return false; } if (args[1].toLowerCase().equals("add")) { From 86c46f7ec0572d0770c30a9271fa0d9b58532910 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 8 Apr 2015 00:47:02 +1000 Subject: [PATCH 138/223] Optimized chunk processor --- PlotSquared/pom.xml | 2 +- .../plot/listeners/ChunkListener.java | 66 +++++++++++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index a6d8e7024..abb846454 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.7 + 2.9.8 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index b40529317..dda9e29fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.plot.listeners; +import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.block.BlockState; @@ -11,34 +12,91 @@ import org.bukkit.event.world.ChunkUnloadEvent; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.util.TaskManager; public class ChunkListener implements Listener { @EventHandler public void onChunkUnload(ChunkUnloadEvent event) { - processChunk(event.getChunk()); + if (!forceUnload) { + if (processChunk(event.getChunk(), true)) { + event.setCancelled(true); + } + } } @EventHandler public void onChunkLoad(ChunkLoadEvent event) { - processChunk(event.getChunk()); + processChunk(event.getChunk(), false); + } + + public void cleanChunk(final Chunk chunk) { + TaskManager.index.increment(); + final Integer currentIndex = TaskManager.index.toInteger(); + final Integer task = TaskManager.runTaskRepeat(new Runnable() { + @Override + public void run() { + if (!chunk.isLoaded()) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + PlotSquared.log("&aSuccessfully processed and unloaded chunk!"); + chunk.unload(true, true); + return; + } + BlockState[] tiles = chunk.getTileEntities(); + if (tiles.length == 0) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + PlotSquared.log("&aSuccessfully processed and unloaded chunk!"); + chunk.unload(true, true); + return; + } + long start = System.currentTimeMillis(); + int i = 0; + while (System.currentTimeMillis() - start < 50) { + if (i >= tiles.length) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + PlotSquared.log("&aSuccessfully processed and unloaded chunk!"); + chunk.unload(true, true); + return; + } + tiles[i].getBlock().setType(Material.AIR, false); + i++; + } + } + }, 1); + TaskManager.tasks.put(currentIndex, task); } - public void processChunk(Chunk chunk) { + private boolean forceUnload = false; + + public boolean processChunk(Chunk chunk, boolean unload) { if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) { - return; + return false; } Entity[] entities = chunk.getEntities(); BlockState[] tiles = chunk.getTileEntities(); if (tiles.length > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) { + if (unload) { + PlotSquared.log("&cPlotSquared detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); + cleanChunk(chunk); + return true; + } for (BlockState tile : tiles) { tile.getBlock().setType(Material.AIR, false); } } if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + if (unload) { + System.out.print("FORCE UNLOAD"); + chunk.load(true); + return false; + } for (Entity ent : entities) { ent.remove(); } } + return false; } } From 9ca5ba812d340dfca15f734d051be30275f2cc35 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 9 Apr 2015 15:41:14 +1000 Subject: [PATCH 139/223] fix plot delete (among other things) --- .../intellectualcrafters/plot/BukkitMain.java | 7 +++++ .../intellectualcrafters/plot/IPlotMain.java | 3 ++ .../plot/PlotSquared.java | 12 +++++-- .../intellectualcrafters/plot/config/C.java | 2 +- .../plot/config/Settings.java | 4 +++ .../plot/database/SQLManager.java | 5 +-- .../plot/listeners/ChunkListener.java | 31 +++++++------------ .../plot/listeners/PlayerEvents.java | 12 +++---- .../plot/object/BukkitPlayer.java | 18 ----------- .../plot/object/PlotPlayer.java | 4 --- .../plot/object/comment/CommentManager.java | 31 ++++++++++++++++++- .../plot/object/comment/InboxReport.java | 2 -- .../plot/util/EventUtil.java | 10 ++++++ 13 files changed, 85 insertions(+), 56 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 4e2abc5c9..e3cb41578 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -39,11 +39,13 @@ import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.TNTListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEvents; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockUpdateUtil; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; @@ -378,4 +380,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public void registerTNTListener() { getServer().getPluginManager().registerEvents(new TNTListener(), this); } + + @Override + public void unregister(PlotPlayer player) { + BukkitUtil.removePlayer(player.getName()); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index fce6ee906..907cb05ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -7,6 +7,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.EventUtil; @@ -56,6 +57,8 @@ public interface IPlotMain { public UUIDWrapper initUUIDHandler(); public boolean initPlotMeConverter(); + + public void unregister(PlotPlayer player); public ChunkGenerator getGenerator(String world, String name); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index e9ca0d807..6279999e2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -550,6 +550,11 @@ public class PlotSquared { if (Settings.AUTO_CLEAR) { ExpireManager.runTask(); } + + if (Settings.COMMENT_NOTIFICATION_INTERVAL > 0) { + CommentManager.runTask(); + } + // Copy files copyFile("town.template"); copyFile("skyblock.template"); @@ -780,6 +785,7 @@ public class PlotSquared { public static void setupConfig() { config.set("version", VERSION); + final Map options = new HashMap<>(); options.put("teleport.delay", 0); options.put("auto_update", false); @@ -810,11 +816,10 @@ public class PlotSquared { options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); - options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR); options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES); options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES); - + options.put("comments.notifications.interval", Settings.COMMENT_NOTIFICATION_INTERVAL); for (final Entry node : options.entrySet()) { if (!config.contains(node.getKey())) { config.set(node.getKey(), node.getValue()); @@ -826,7 +831,10 @@ public class PlotSquared { log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } + Settings.COMMENT_NOTIFICATION_INTERVAL = config.getInt("comments.notifications.interval"); Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled"); + Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES = config.getInt("chunk-processor.max-blockstates"); + Settings.CHUNK_PROCESSOR_MAX_ENTITIES= config.getInt("chunk-processor.max-entities"); Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled"); Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index abee75367..9485dbb5c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -387,7 +387,7 @@ public enum C { /* * PlotMe */ - NOT_USING_PLOTME("$2This server uses the $1PlotSquared $2plot management system. Please use the $1/plots $2instead"), + NOT_USING_PLOTME("$2This server uses the $1PlotSquared $2plot management system. Please use the $1/ps &2or $1/p2 $2or $1/plots $2instead"), /* * Wait */ 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 ca7fbbbcc..857ca68fc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -41,6 +41,10 @@ public class Settings { public static boolean CONVERT_PLOTME = true; public static boolean CACHE_PLOTME = false; public static boolean USE_PLOTME_ALIAS = false; + /** + * Comment system + */ + public static int COMMENT_NOTIFICATION_INTERVAL = -1; /** * Chunk processor */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 1c8c0fece..6c7b3e9bd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -519,8 +519,9 @@ public class SQLManager implements AbstractDB { stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); - stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `plot_plot_id` = ?"); - stmt.setInt(1, id); + stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ?"); + stmt.setString(1, world); + stmt.setInt(2, plot.hashCode()); stmt.executeUpdate(); stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot` WHERE `id` = ?"); stmt.setInt(1, id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index dda9e29fe..e6a9da956 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -7,6 +7,7 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; @@ -18,13 +19,11 @@ public class ChunkListener implements Listener { @EventHandler public void onChunkUnload(ChunkUnloadEvent event) { - if (!forceUnload) { - if (processChunk(event.getChunk(), true)) { - event.setCancelled(true); - } + if (processChunk(event.getChunk(), true)) { + event.setCancelled(true); } } - + @EventHandler public void onChunkLoad(ChunkLoadEvent event) { processChunk(event.getChunk(), false); @@ -53,7 +52,7 @@ public class ChunkListener implements Listener { } long start = System.currentTimeMillis(); int i = 0; - while (System.currentTimeMillis() - start < 50) { + while (System.currentTimeMillis() - start < 250) { if (i >= tiles.length) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); @@ -65,18 +64,22 @@ public class ChunkListener implements Listener { i++; } } - }, 1); + }, 5); TaskManager.tasks.put(currentIndex, task); } - private boolean forceUnload = false; - public boolean processChunk(Chunk chunk, boolean unload) { if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) { return false; } Entity[] entities = chunk.getEntities(); BlockState[] tiles = chunk.getTileEntities(); + if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + for (Entity ent : entities) { + ent.remove(); + } + PlotSquared.log("&aPlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); + } if (tiles.length > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) { if (unload) { PlotSquared.log("&cPlotSquared detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); @@ -87,16 +90,6 @@ public class ChunkListener implements Listener { tile.getBlock().setType(Material.AIR, false); } } - if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { - if (unload) { - System.out.print("FORCE UNLOAD"); - chunk.load(true); - return false; - } - for (Entity ent : entities) { - ent.remove(); - } - } return false; } } 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 b821783a5..da9238f94 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -92,8 +92,10 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.CmdConfirm; +import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SetupUtils; @@ -997,14 +999,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public static void onLeave(final PlayerQuitEvent event) { - final String name = event.getPlayer().getName(); - if (SetupUtils.setupMap.containsKey(name)) { - SetupUtils.setupMap.remove(name); - } - CmdConfirm.removePending(name); - BukkitUtil.removePlayer(name); + PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); + EventUtil.unregisterPlayer(pp); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { - final Collection plots = PlotSquared.getPlots(name).values(); + final Collection plots = PlotSquared.getPlots(pp.getName()).values(); for (final Plot plot : plots) { final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); final PlotManager manager = PlotSquared.getPlotManager(plot.world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index dd1594ebe..3dd04a064 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -19,7 +19,6 @@ public class BukkitPlayer implements PlotPlayer { public HashSet noPerm = new HashSet<>(); private int op = 0; private long last = 0; - private HashMap tmpData = null; /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. @@ -120,21 +119,4 @@ public class BukkitPlayer implements PlotPlayer { public Location getLocationFull() { return BukkitUtil.getLocationFull(this.player); } - - @Override - public void setTmpData(String key, Object value) { - if (tmpData == null) { - tmpData = new HashMap<>(); - } - tmpData.put(key, value); - } - - @Override - public Object getTmpData(String key) { - if (tmpData == null) { - return null; - } - return tmpData.get(key); - } - } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 24776994e..cb75aa726 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -9,10 +9,6 @@ import java.util.UUID; */ public interface PlotPlayer { - public void setTmpData(String key, Object value); - - public Object getTmpData(String key); - public long getPreviousLogin(); public Location getLocation(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java index 2bad8e179..baf427a02 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java @@ -2,10 +2,39 @@ package com.intellectualcrafters.plot.object.comment; import java.util.HashMap; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.TaskManager; + public class CommentManager { public static HashMap inboxes = new HashMap<>(); + private static HashMap timestamps = new HashMap<>(); + + public static void runTask() { +// TaskManager.runTaskRepeat(new Runnable() { +// +// @Override +// public void run() { +// +// } +// }, Settings.COMMENT_NOTIFICATION_INTERVAL * 1200); + } + + public static long getTimestamp(PlotPlayer player) { + Long time = timestamps.get(player.getName()); + if (time == null) { + time = player.getPreviousLogin(); + timestamps.put(player.getName(), time); + } + return time; + } + + public static void setTime(PlotPlayer player) { + timestamps.put(player.getName(), System.currentTimeMillis()); + } + public static void addInbox(CommentInbox inbox) { inboxes.put(inbox.toString().toLowerCase(), inbox); } @@ -15,4 +44,4 @@ public class CommentManager { addInbox(new InboxPublic()); addInbox(new InboxOwner()); } -} +} \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java index f2af870b7..e80e1f31a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java @@ -1,7 +1,5 @@ package com.intellectualcrafters.plot.object.comment; -import java.util.ArrayList; - import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotHandler; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index 560493dfc..9d0a07469 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; import java.util.UUID; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -13,6 +14,15 @@ public abstract class EventUtil { public static EventUtil manager = null; + public static void unregisterPlayer(PlotPlayer player) { + String name = player.getName(); + if (SetupUtils.setupMap.containsKey(name)) { + SetupUtils.setupMap.remove(name); + } + CmdConfirm.removePending(name); + PlotSquared.IMP.unregister(player); + } + public abstract boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto); public abstract boolean callTeleport(final PlotPlayer player, Location from, final Plot plot); From 635a4bd7a482c607d7d058c461f60579b2de24e0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 9 Apr 2015 22:21:25 +1000 Subject: [PATCH 140/223] Fixes #250 --- PlotSquared/pom.xml | 2 +- .../plot/commands/Kick.java | 2 +- .../plot/listeners/PlayerEvents.java | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index abb846454..f996a821e 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.8 + 2.9.9 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 8dfd92916..73bed1336 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -57,7 +57,7 @@ public class Kick extends SubCommand { } Location otherLoc = player.getLocation(); if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlot(otherLoc))) { - MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); + MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } player.teleport(BlockManager.manager.getSpawn(loc.getWorld())); 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 da9238f94..0dba51427 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -169,20 +169,20 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!isPlotWorld(loc.getWorld())) { return; } - Plot plot = MainUtil.getPlot(loc); - if (plot == null) { - return; - } - Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); - if (redstone == null || (Boolean) redstone.getValue()) { - return; - } - if (!isPlotArea(loc)) { - return; - } switch (block.getType()) { case REDSTONE_COMPARATOR_OFF: case REDSTONE_COMPARATOR_ON: { + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return; + } + Flag redstone = FlagManager.getPlotFlag(plot, "redstone"); + if (redstone == null || (Boolean) redstone.getValue()) { + return; + } + if (!isPlotArea(loc)) { + return; + } event.setCancelled(true); } } From b0050dd2e88c8830b972adec7d0409c4941c1309 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 9 Apr 2015 22:25:09 +1000 Subject: [PATCH 141/223] Optimize move event --- .../plot/listeners/WorldEditListener.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) 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 2098afbe4..7808dfd46 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -193,30 +193,27 @@ public class WorldEditListener implements Listener { PWE.removeMask(pp); } } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent e) { final Location t = e.getTo(); - if (!isPlotWorld(t)) { - return; - } final Location f = e.getFrom(); - if ((f.getX() == t.getX()) && (f.getZ() == t.getZ())) { - return; - } - final Player p = e.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - if (!PWE.hasMask(pp)) { - return; - } - } final com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f); final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) { + final Player p = e.getPlayer(); + final PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!isPlotWorld(t)) { + return; + } final PlotId idF = MainUtil.getPlotId(locf); final PlotId idT = MainUtil.getPlotId(loct); if ((idT != null) && !(idF == idT)) { + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + if (!PWE.hasMask(pp)) { + return; + } + } PWE.setMask(pp, loct, false); } } From 6ec4668177f6c771c170695714ed12b0ea5b5eb7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 9 Apr 2015 23:12:35 +1000 Subject: [PATCH 142/223] Fixed piston --- .../plot/listeners/PlayerEvents.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 0dba51427..fde99b687 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -18,6 +18,7 @@ import org.bukkit.entity.Animals; import org.bukkit.entity.Arrow; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Fireball; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LargeFireball; @@ -662,7 +663,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (plot != null) { BlockFace face = event.getDirection(); Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); - for (final Block b : event.getBlocks()) { + List blocks = event.getBlocks(); + for (final Block b : blocks) { Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative)); Plot newPlot = MainUtil.getPlot(bloc); if (!plot.equals(newPlot)) { @@ -670,6 +672,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } + org.bukkit.Location lastLoc; + if (blocks.size() > 0) { + lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative); + } + else { + lastLoc = event.getBlock().getLocation().add(relative); + } + Entity[] ents = lastLoc.getChunk().getEntities(); + for (Entity entity : ents) { + if (entity instanceof FallingBlock) { + org.bukkit.Location eloc = entity.getLocation(); + if (eloc.distanceSquared(lastLoc) < 2) { + event.setCancelled(true); + return; + } + } + } } } From 09424c30b4ba52a659a4a89fd01df4a5fcac57d7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 11 Apr 2015 14:07:19 +1000 Subject: [PATCH 143/223] fixes #251 --- PlotSquared/pom.xml | 2 +- .../java/com/intellectualcrafters/plot/PlotSquared.java | 8 ++++++++ .../com/intellectualcrafters/plot/commands/Denied.java | 2 +- .../intellectualcrafters/plot/database/SQLManager.java | 4 ++-- .../com/intellectualcrafters/plot/flag/FlagManager.java | 3 +-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index f996a821e..ff65a06fc 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.9 + 2.9.11 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 6279999e2..6eb055a9c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -146,6 +146,14 @@ public class PlotSquared { return new LinkedHashSet<>(newplots); } + public static Set getPlotsRaw() { + final ArrayList newplots = new ArrayList<>(); + for (final Entry> entry : plots.entrySet()) { + newplots.addAll(entry.getValue().values()); + } + return new LinkedHashSet<>(newplots); + } + public static ArrayList sortPlots(Collection plots) { ArrayList newPlots = new ArrayList<>(); newPlots.addAll(plots); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 9fbe31017..5b0bce5d5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -90,7 +90,7 @@ public class Denied extends SubCommand { } final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { - final Plot pl = MainUtil.getPlot(loc); + final Plot pl = MainUtil.getPlot(player.getLocation()); if ((pl != null) && pl.id.equals(plot.id)) { MainUtil.sendMessage(player, C.YOU_BE_DENIED); player.teleport(BlockManager.manager.getSpawn(loc.getWorld())); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 6c7b3e9bd..07a2a518c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -584,9 +584,9 @@ public class SQLManager implements AbstractDB { public void updateTables() { try { final DatabaseMetaData data = this.connection.getMetaData(); - ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot"); + ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id"); if (rs.next()) { - rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); + rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); if (!rs.next()) { rs.close(); final Statement statement = this.connection.createStatement(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 2ac43e608..31777b2cf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -67,7 +67,7 @@ public class FlagManager { } } if (PlotSquared.getAllPlotsRaw() != null) { - for (final Plot plot : PlotSquared.getPlots()) { + for (final Plot plot : PlotSquared.getPlotsRaw()) { for (final Flag flag : plot.settings.flags) { if (flag.getAbstractFlag().getKey().equals(af.getKey())) { flag.setKey(af); @@ -319,7 +319,6 @@ public class FlagManager { public static AbstractFlag getFlag(final String string, final boolean create) { if ((getFlag(string) == null) && create) { final AbstractFlag flag = new AbstractFlag(string); - addFlag(flag); return flag; } return getFlag(string); From b9abe5b5a899eeeb4d8fa3e9f7a8cf14813d5f72 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 11 Apr 2015 15:41:01 +1000 Subject: [PATCH 144/223] Fixes #252 --- .../plot/listeners/PlayerEvents_1_8.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index f2651086e..634f7ee65 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -2,6 +2,8 @@ package com.intellectualcrafters.plot.listeners; import java.util.UUID; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -18,6 +20,10 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class PlayerEvents_1_8 extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onInteract(final PlayerInteractAtEntityEvent e) { + Entity entity = e.getRightClicked(); + if (!(entity instanceof ArmorStand)) { + return; + } final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); if (isPlotWorld(l)) { e.getPlayer(); From da5db1678dc3020473a02c70e201f80b76797b6a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 11 Apr 2015 19:58:46 +1000 Subject: [PATCH 145/223] Fixed typo --- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 2 +- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 6eb055a9c..f134c9f80 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -709,7 +709,7 @@ public class PlotSquared { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); - final List intFlags = Arrays.asList("entity-cap", "animal-cap", "mop-cap"); + final List intFlags = Arrays.asList("entity-cap", "animal-cap", "mob-cap"); for (final String flag : stringFlags) { FlagManager.addFlag(new AbstractFlag(flag)); } 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 fde99b687..485831b52 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -812,7 +812,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (plot != null && plot.owner != null) { Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap"); Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap"); - Flag monsterFlag = FlagManager.getPlotFlag(plot, "mop-cap"); + Flag monsterFlag = FlagManager.getPlotFlag(plot, "mob-cap"); if (!(entity instanceof Creature)) { return; } From 9a9e00670cc4202947946ae4543339d5e551605d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 11 Apr 2015 21:34:00 +1000 Subject: [PATCH 146/223] Allow for larger flag values. --- .../main/java/com/intellectualcrafters/plot/flag/Flag.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index c31c4456b..bee4a7270 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -44,8 +44,8 @@ public class Flag { if (!StringUtils.isAlphanumericSpace(tempValue)) { throw new IllegalArgumentException("Flag must be alphanumerical (colours and some special characters are allowed)"); } - if (value.length() > 48) { - throw new IllegalArgumentException("Value must be <= 48 characters"); + if (value.length() > 128) { + throw new IllegalArgumentException("Value must be <= 128 characters"); } this.key = key; this.value = key.parseValueRaw(value); From a205156ba3b599298618e04e419ed87f8c08749e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 11 Apr 2015 22:05:15 +1000 Subject: [PATCH 147/223] Fixes #265 --- .../plot/commands/Denied.java | 13 +++++++++---- .../plot/commands/Helpers.java | 13 +++++++++---- .../plot/commands/Trusted.java | 15 ++++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 5b0bce5d5..4cca27500 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -100,17 +100,22 @@ public class Denied extends SubCommand { return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { - final UUID uuid = DBFunc.everyone; - if (!plot.denied.contains(uuid)) { + if (plot.denied.size() == 0) { MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); return true; } - plot.removeDenied(uuid); - DBFunc.removeDenied(loc.getWorld(), plot, uuid); + for (UUID uuid : plot.denied) { + plot.removeDenied(uuid); + DBFunc.removeDenied(loc.getWorld(), plot, uuid); + } MainUtil.sendMessage(plr, C.DENIED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); + if (!plot.denied.contains(uuid)) { + MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); + return true; + } plot.removeDenied(uuid); DBFunc.removeDenied(loc.getWorld(), plot, uuid); EventUtil.manager.callDenied(plr, plot, uuid, false); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index b1d5c880d..93d81cab2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -91,17 +91,22 @@ public class Helpers extends SubCommand { return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { - final UUID uuid = DBFunc.everyone; - if (!plot.helpers.contains(uuid)) { + if (plot.helpers.size() == 0) { MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); return true; } - plot.removeHelper(uuid); - DBFunc.removeHelper(loc.getWorld(), plot, uuid); + for (UUID uuid : plot.helpers) { + plot.removeHelper(uuid); + DBFunc.removeHelper(loc.getWorld(), plot, uuid); + } MainUtil.sendMessage(plr, C.HELPER_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); + if (!plot.helpers.contains(uuid)) { + MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); + return false; + } plot.removeHelper(uuid); DBFunc.removeHelper(loc.getWorld(), plot, uuid); EventUtil.manager.callHelper(plr, plot, uuid, false); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 04a6f78e6..b4a181d0e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -92,17 +92,22 @@ public class Trusted extends SubCommand { return true; } else if (args[0].equalsIgnoreCase("remove")) { if (args[1].equalsIgnoreCase("*")) { - final UUID uuid = DBFunc.everyone; - if (!plot.trusted.contains(uuid)) { - MainUtil.sendMessage(plr, C.T_WAS_NOT_ADDED); + if (plot.trusted.size() == 0) { + MainUtil.sendMessage(plr, C.WAS_NOT_ADDED); return true; } - plot.removeTrusted(uuid); - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); + for (UUID uuid : plot.trusted) { + plot.removeTrusted(uuid); + DBFunc.removeTrusted(loc.getWorld(), plot, uuid); + } MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); return true; } final UUID uuid = UUIDHandler.getUUID(args[1]); + if (!plot.trusted.contains(uuid)) { + MainUtil.sendMessage(plr, C.T_WAS_NOT_ADDED); + return true; + } plot.removeTrusted(uuid); DBFunc.removeTrusted(loc.getWorld(), plot, uuid); EventUtil.manager.callTrusted(plr, plot, uuid, false); From 9fa0b51b943b8d6e565704b3cd832eb9404d29ec Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 12 Apr 2015 15:22:03 +1000 Subject: [PATCH 148/223] optimized WorldEdit masking with multi plot mask regions. --- .../intellectualcrafters/plot/BukkitMain.java | 8 +- .../plot/PlotSquared.java | 6 +- .../plot/commands/Comment.java | 3 - .../plot/commands/Move.java | 1 - .../plot/commands/WE_Anywhere.java | 20 +- .../intellectualcrafters/plot/config/C.java | 2 + .../plot/config/Settings.java | 1 + .../plot/generator/BukkitHybridUtils.java | 3 - .../plot/generator/HybridPop.java | 1 - .../plot/listeners/ChunkListener.java | 1 - .../plot/listeners/PlayerEvents.java | 6 +- .../plot/listeners/WorldEditListener.java | 266 ------------------ .../plot/listeners/worldedit/NullExtent.java | 75 +++++ .../plot/listeners/worldedit/WEExtent.java | 48 ++++ .../plot/listeners/worldedit/WEListener.java | 165 +++++++++++ .../plot/object/BukkitPlayer.java | 1 - .../plot/object/comment/CommentManager.java | 2 - .../plot/util/bukkit/BukkitSetupUtils.java | 3 - .../plot/util/bukkit/PWE.java | 132 --------- .../plot/uuid/LowerOfflineUUIDWrapper.java | 106 +++++++ 20 files changed, 419 insertions(+), 431 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/NullExtent.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/LowerOfflineUUIDWrapper.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index e3cb41578..66951e06c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -37,15 +37,14 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents; import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.TNTListener; -import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEvents; +import com.intellectualcrafters.plot.listeners.worldedit.WEListener; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockUpdateUtil; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; @@ -66,6 +65,7 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @@ -260,7 +260,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { log("&cPlease use WorldEdit 6+ for masking support"); log("&c - http://builds.enginehub.org/job/worldedit"); } else { - getServer().getPluginManager().registerEvents(new WorldEditListener(), this); + WEListener weClass = new WEListener(); + WorldEdit.getInstance().getEventBus().register(weClass); + getServer().getPluginManager().registerEvents(weClass, this); MainCommand.subCommands.add(new WE_Anywhere()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index f134c9f80..af8fa900f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -808,6 +808,7 @@ public class PlotSquared { options.put("plotme-convert.cache-uuids", Settings.CACHE_PLOTME); options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); options.put("UUID.offline", Settings.OFFLINE_MODE); + options.put("UUID.force-lowercase", Settings.UUID_LOWERCASE); options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); options.put("console.color", Settings.CONSOLE_COLOR); @@ -819,7 +820,6 @@ public class PlotSquared { options.put("clear.on.ban", false); options.put("max_plots", Settings.MAX_PLOTS); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); - options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK); options.put("cache.permissions", Settings.PERMISSION_CACHING); options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); @@ -871,6 +871,7 @@ public class PlotSquared { } Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); Settings.OFFLINE_MODE = config.getBoolean("UUID.offline"); + Settings.UUID_LOWERCASE = config.getBoolean("UUID.force-lowercase"); Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk"); Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); } @@ -959,9 +960,6 @@ public class PlotSquared { Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban"); - Settings.API_URL = config.getString("uuid.api.location"); - Settings.CUSTOM_API = config.getBoolean("uuid.api.custom"); - Settings.UUID_FECTHING = config.getBoolean("uuid.fetching"); } public static void showDebug() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index f07484902..025351ce0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -21,12 +21,10 @@ package com.intellectualcrafters.plot.commands; import java.util.Arrays; -import java.util.List; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -35,7 +33,6 @@ import com.intellectualcrafters.plot.object.comment.CommentInbox; import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; public class Comment extends SubCommand { public Comment() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 20b322201..6ea615e2d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 89fac3f85..fd57d2203 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -21,14 +21,15 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.listeners.worldedit.WEListener; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.PWE; public class WE_Anywhere extends SubCommand { public WE_Anywhere() { - super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true); + super("weanywhere", "plots.worldedit.bypass", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true); } @Override @@ -37,12 +38,15 @@ public class WE_Anywhere extends SubCommand { MainUtil.sendMessage(plr, "&cWorldEdit is not enabled on this server"); return false; } - if (Permissions.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) { - PWE.removeMask(plr); - MainUtil.sendMessage(plr, "&6Cleared your WorldEdit mask"); - } else { - PWE.setMask(plr, plr.getLocation(), true); - MainUtil.sendMessage(plr, "&6Updated your WorldEdit mask"); + if (Permissions.hasPermission(plr, "plots.worldedit.bypass")) { + if (WEListener.bypass.contains(plr.getName())) { + WEListener.bypass.remove(plr.getName()); + MainUtil.sendMessage(plr, C.WORLDEDIT_RESTRICTED); + } + else { + WEListener.bypass.add(plr.getName()); + MainUtil.sendMessage(plr, C.WORLDEDIT_UNMASKED); + } } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 9485dbb5c..22e023156 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -86,6 +86,8 @@ public enum C { * WorldEdit masks */ REQUIRE_SELECTION_IN_MASK("$2%s of your selection is not within your plot mask. You can only make edits within your plot."), + WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted."), + WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted."), /* * Records */ 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 857ca68fc..1d6067d44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -145,6 +145,7 @@ public class Settings { * Use offline mode storage */ public static boolean OFFLINE_MODE = false; + public static boolean UUID_LOWERCASE = false; /** * Command confirmation */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 981ed154a..b1287eba0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -1,7 +1,6 @@ package com.intellectualcrafters.plot.generator; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -21,12 +20,10 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 677d4b099..7637417e0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,7 +2,6 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; -import java.util.Map.Entry; import org.bukkit.World; import org.bukkit.block.Biome; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index e6a9da956..c8976b10f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -7,7 +7,6 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; 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 485831b52..0972694e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -83,6 +83,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.listeners.worldedit.WEListener; import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -93,13 +94,10 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -461,6 +459,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onWorldChanged(final PlayerChangedWorldEvent event) { final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); + WEListener.bypass.remove(player.getName()); ((BukkitPlayer) player).hasPerm = new HashSet<>(); ((BukkitPlayer) player).noPerm = new HashSet<>(); } @@ -1020,6 +1019,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi public static void onLeave(final PlayerQuitEvent event) { PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); EventUtil.unregisterPlayer(pp); + WEListener.bypass.remove(pp.getName()); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PlotSquared.getPlots(pp.getName()).values(); for (final Plot plot : plots) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java deleted file mode 100644 index 7808dfd46..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ /dev/null @@ -1,266 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.listeners; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerPortalEvent; -import org.bukkit.event.player.PlayerTeleportEvent; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotHandler; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.PWE; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.bukkit.selections.Selection; -import com.sk89q.worldedit.function.mask.Mask; - -/** - * @author Citymonstret - * @author Empire92 - */ -public class WorldEditListener implements Listener { - final List monitored = Arrays.asList(new String[] { "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "move", "stack", "naturalize", "paste", "count", "regen", "copy", "cut", "" }); - public final Set blockedcmds = new HashSet<>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); - public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); - - private boolean isPlotWorld(final Location l) { - return (PlotSquared.isPlotWorld(l.getWorld().getName())); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onDelete(final PlotDeleteEvent e) { - final String world = e.getWorld(); - final PlotId id = e.getPlotId(); - final Plot plot = PlotSquared.getPlots(world).get(id); - if (plot == null) { - return; - } - HashSet members = PlotHandler.getOwners(plot); - if (members == null) { - return; - } - members.addAll(plot.helpers); - for (UUID member : members) { - final PlotPlayer player = UUIDHandler.getPlayer(member); - if (player == null) { - continue; - } - if (!world.equals(player.getLocation().getWorld())) { - return; - } - if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { - return; - } - PWE.setNoMask(player); - } - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onInteract(final PlayerInteractEvent e) { - final Block b = e.getClickedBlock(); - if (b == null) { - return; - } - final Player p = e.getPlayer(); - final Location l = b.getLocation(); - if (!isPlotWorld(l)) { - return; - } - p.getItemInHand(); - if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) { - return; - } - final PlotPlayer pp = BukkitUtil.getPlayer(p); - final com.intellectualcrafters.plot.object.Location loc = pp.getLocation(); - final Plot plot = MainUtil.getPlot(loc); - if (plot != null) { - if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { - PWE.setMask(BukkitUtil.getPlayer(p), loc, false); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { - final Player p = e.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - return; - } - String cmd = e.getMessage().toLowerCase(); - if (cmd.contains(" ")) { - cmd = cmd.substring(0, cmd.indexOf(" ")); - } - if (this.restrictedcmds.contains(cmd)) { - final Plot plot = MainUtil.getPlot(pp.getLocation()); - if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { - e.setCancelled(true); - } - return; - } else if (this.blockedcmds.contains(cmd)) { - e.setCancelled(true); - return; - } - if (!Settings.REQUIRE_SELECTION) { - return; - } - for (final String c : this.monitored) { - if (cmd.equals("//" + c) || cmd.equals("/" + c) || cmd.equals("/worldedit:/" + c)) { - final Selection selection = PlotSquared.worldEdit.getSelection(p); - if (selection == null) { - return; - } - final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); - final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); - final LocalSession session = PlotSquared.worldEdit.getSession(p); - final Mask mask = session.getMask(); - if (mask == null) { - MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Both points"); - return; - } - if (!mask.test(pos1)) { - e.setCancelled(true); - MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); - } - if (!mask.test(pos2)) { - e.setCancelled(true); - MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); - } - } - } - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerJoin(final PlayerJoinEvent e) { - final Player p = e.getPlayer(); - final Location l = p.getLocation(); - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - if (isPlotWorld(l)) { - PWE.removeMask(pp); - } - return; - } - if (isPlotWorld(l)) { - final com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(l); - PWE.setMask(pp, loc, false); - } else { - PWE.removeMask(pp); - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerMove(final PlayerMoveEvent e) { - final Location t = e.getTo(); - final Location f = e.getFrom(); - final com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f); - final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); - if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) { - final Player p = e.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!isPlotWorld(t)) { - return; - } - final PlotId idF = MainUtil.getPlotId(locf); - final PlotId idT = MainUtil.getPlotId(loct); - if ((idT != null) && !(idF == idT)) { - if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - if (!PWE.hasMask(pp)) { - return; - } - } - PWE.setMask(pp, loct, false); - } - } - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPortal(final PlayerPortalEvent e) { - final Player p = e.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - return; - } - final Location t = e.getTo(); - final Location f = e.getFrom(); - if (t == null) { - PWE.removeMask(pp); - return; - } - if (isPlotWorld(t)) { - final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); - PWE.setMask(pp, loct, false); - return; - } - if ((f != null) && isPlotWorld(f)) { - PWE.removeMask(pp); - } - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onTeleport(final PlayerTeleportEvent e) { - final Player p = e.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - if (!PWE.hasMask(pp)) { - return; - } - } - final Location t = e.getTo(); - final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t); - final Location f = e.getFrom(); - if (!PlotSquared.isPlotWorld(loct.getWorld())) { - if (isPlotWorld(f)) { - PWE.removeMask(pp); - } - return; - } - - PWE.setMask(pp, loct, false); - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/NullExtent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/NullExtent.java new file mode 100644 index 000000000..2da67a910 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/NullExtent.java @@ -0,0 +1,75 @@ +package com.intellectualcrafters.plot.listeners.worldedit; + +import java.util.ArrayList; +import java.util.List; + +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.Vector2D; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.biome.BaseBiome; + +public class NullExtent implements Extent { + + @Override + public BaseBiome getBiome(Vector2D arg0) { + return null; + } + + @Override + public BaseBlock getBlock(Vector arg0) { + return null; + } + + @Override + public BaseBlock getLazyBlock(Vector arg0) { + return null; + } + + @Override + public Operation commit() { + return null; + } + + @Override + public boolean setBiome(Vector2D arg0, BaseBiome arg1) { + return false; + } + + @Override + public boolean setBlock(Vector arg0, BaseBlock arg1) throws WorldEditException { + return false; + } + + @Override + public Entity createEntity(Location arg0, BaseEntity arg1) { + return null; + } + + @Override + public List getEntities() { + return new ArrayList<>(); + } + + @Override + public List getEntities(Region arg0) { + return new ArrayList<>(); + } + + @Override + public Vector getMaximumPoint() { + return new Vector(0, 0, 0); + } + + @Override + public Vector getMinimumPoint() { + return new Vector(0, 0, 0); + } + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java new file mode 100644 index 000000000..5bdc38187 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java @@ -0,0 +1,48 @@ +package com.intellectualcrafters.plot.listeners.worldedit; + +import java.util.HashSet; + +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.Vector2D; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extent.AbstractDelegateExtent; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.biome.BaseBiome; + +public class WEExtent extends AbstractDelegateExtent { + private final HashSet mask; + + public WEExtent(HashSet mask, Extent extent) { + super(extent); + this.mask = mask; + } + + @Override + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { + if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + return super.setBlock(location, block); + } + return false; + } + + @Override + public Entity createEntity(Location location, BaseEntity entity) { + if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + return super.createEntity(location, entity); + } + return null; + } + + @Override + public boolean setBiome(Vector2D position, BaseBiome biome) { + if (WEListener.maskContains(mask, position.getBlockX(), position.getBlockZ())) { + return super.setBiome(position, biome); + } + return false; + } +} \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java new file mode 100644 index 000000000..86d14c20d --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -0,0 +1,165 @@ +package com.intellectualcrafters.plot.listeners.worldedit; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.IncompleteRegionException; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.selections.Selection; +import com.sk89q.worldedit.event.extent.EditSessionEvent; +import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.util.eventbus.EventHandler.Priority; +import com.sk89q.worldedit.util.eventbus.Subscribe; + +public class WEListener implements Listener { + + public static HashSet bypass = new HashSet<>(); + + final List monitored = Arrays.asList(new String[] { "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "move", "stack", "naturalize", "paste", "count", "regen", "copy", "cut", "" }); + public final Set blockedcmds = new HashSet<>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); + public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); + + @Subscribe(priority=Priority.VERY_EARLY) + public void onEditSession(EditSessionEvent event) { + String world = event.getWorld().getName(); + if (!PlotSquared.isPlotWorld(world)) { + return; + } + Actor actor = event.getActor(); + if (actor != null && actor.isPlayer()) { + String name = actor.getName(); + if (bypass.contains(name)) { + return; + } + + PlotPlayer player = UUIDHandler.getPlayer(actor.getName()); + HashSet mask = getMask(player); + if (mask.size() == 0) { + event.setExtent(new NullExtent()); + return; + } + try { + Region selection = WorldEdit.getInstance().getSession(player.getName()).getSelection(event.getWorld()); + Vector pos1 = selection.getMinimumPoint(); + Vector pos2 = selection.getMaximumPoint(); + RegionWrapper regionSelection = new RegionWrapper(Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockZ(), pos2.getBlockZ()), Math.max(pos1.getBlockZ(), pos2.getBlockZ())); + if (!regionContains(regionSelection, mask)) { + event.setExtent(new NullExtent()); + return; + } + } catch (IncompleteRegionException e) {} + event.setExtent(new WEExtent(mask, event.getExtent())); + } + } + + public static boolean maskContains(HashSet mask, int x, int z) { + for (RegionWrapper region : mask) { + if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) { + return true; + } + } + return false; + } + + public static boolean intersects(RegionWrapper region1, RegionWrapper region2) { + if ((region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ)) { + return true; + } + return false; + } + + public static boolean regionContains(RegionWrapper selection, HashSet mask) { + for (RegionWrapper region : mask) { + if (intersects(region, selection)) { + return true; + } + } + return false; + } + + public HashSet getMask(PlotPlayer player) { + HashSet regions = new HashSet<>(); + for (Plot plot : PlotSquared.getPlots(player)) { + if (!plot.settings.getMerged(1) && !plot.settings.getMerged(2)) { + Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); + regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); + } + } + return regions; + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { + final Player p = e.getPlayer(); + final PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + return; + } + String cmd = e.getMessage().toLowerCase(); + if (cmd.contains(" ")) { + cmd = cmd.substring(0, cmd.indexOf(" ")); + } + if (this.restrictedcmds.contains(cmd)) { + final Plot plot = MainUtil.getPlot(pp.getLocation()); + if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { + e.setCancelled(true); + } + return; + } else if (this.blockedcmds.contains(cmd)) { + e.setCancelled(true); + return; + } + if (!Settings.REQUIRE_SELECTION) { + return; + } + for (final String c : this.monitored) { + if (cmd.equals("//" + c) || cmd.equals("/" + c) || cmd.equals("/worldedit:/" + c)) { + final Selection selection = PlotSquared.worldEdit.getSelection(p); + if (selection == null) { + return; + } + final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); + final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); + + HashSet mask = getMask(pp); + if (mask.size() == 0) { + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Both points"); + return; + } + if (!maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) { + e.setCancelled(true); + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); + } + if (!maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) { + e.setCancelled(true); + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); + } + } + } + } +} + diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 3dd04a064..5fa4db1f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -1,6 +1,5 @@ package com.intellectualcrafters.plot.object; -import java.util.HashMap; import java.util.HashSet; import java.util.UUID; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java index baf427a02..91dc35edb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java @@ -2,9 +2,7 @@ package com.intellectualcrafters.plot.object.comment; import java.util.HashMap; -import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.TaskManager; public class CommentManager { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 2e2f04ae1..727593950 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -1,20 +1,17 @@ package com.intellectualcrafters.plot.util.bukkit; import java.io.IOException; -import java.util.List; import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; -import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.ConfigurationNode; -import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java deleted file mode 100644 index 1d21f0994..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ /dev/null @@ -1,132 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.util.bukkit; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.BukkitPlayer; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotHandler; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.MainUtil; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.LocalWorld; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.RegionMask; -import com.sk89q.worldedit.regions.CuboidRegion; - -/** - * @author Citymonstret - * @author Empire92 - */ -public class PWE { - - public static LocalSession getSession(PlotPlayer p) { - if (PlotSquared.worldEdit == null) { - return WorldEdit.getInstance().getSession(p.getName()); - } else { - return PlotSquared.worldEdit.getSession(((BukkitPlayer) p).player); - } - } - - public static void setMask(final PlotPlayer p, final Location l, final boolean force) { - try { - LocalSession s = getSession(p); - if (!PlotSquared.isPlotWorld(l.getWorld())) { - removeMask(p); - } - final PlotId id = MainUtil.getPlotId(l); - if (id != null) { - final Plot plot = PlotSquared.getPlots(l.getWorld()).get(id); - if (plot != null) { - if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) { - return; - } - final boolean r = (PlotHandler.isOwner(plot, p.getUUID())) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUUID()); - if (r) { - final String w = l.getWorld(); - final Location bloc = MainUtil.getPlotBottomLoc(w, plot.id); - final Location tloc = MainUtil.getPlotTopLoc(w, plot.id); - final Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1); - final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ()); - - // FIXME unchecked casting - final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player).getWorld(); - final CuboidRegion region = new CuboidRegion(lw, bvec, tvec); - final RegionMask mask = new RegionMask(region); - s.setMask(mask); - return; - } - } - } - if (force ^ (noMask(s) && !p.hasPermission("plots.worldedit.bypass"))) { - // FIXME unchecked casting - final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); - final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); - s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); - } - } catch (final Exception e) { - e.printStackTrace(); - } - } - - public static boolean hasMask(final PlotPlayer p) { - LocalSession s = getSession(p); - return !noMask(s); - } - - public static boolean noMask(final LocalSession s) { - return s.getMask() == null; - } - - @SuppressWarnings("deprecation") - public static void setNoMask(final PlotPlayer p) { - try { - LocalSession s = getSession(p); - final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player); - final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); - s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); - } catch (final Exception e) { - // - } - } - - public static void removeMask(final PlotPlayer p, final LocalSession s) { - final Mask mask = null; - s.setMask(mask); - } - - public static void removeMask(final PlotPlayer p) { - try { - LocalSession s = getSession(p); - removeMask(p, s); - } catch (final Exception e) { - // throw new - // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, - // "WorldEdit == Null?"); - } - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/LowerOfflineUUIDWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/LowerOfflineUUIDWrapper.java new file mode 100644 index 000000000..847320f42 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/uuid/LowerOfflineUUIDWrapper.java @@ -0,0 +1,106 @@ +package com.intellectualcrafters.plot.uuid; + +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.Server; +import org.bukkit.entity.Player; + +import com.google.common.base.Charsets; +import com.google.common.collect.BiMap; +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; +import com.intellectualcrafters.plot.object.OfflinePlotPlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class LowerOfflineUUIDWrapper extends UUIDWrapper { + private Method getOnline = null; + private final Object[] arg = new Object[0]; + + public LowerOfflineUUIDWrapper() { + try { + this.getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]); + } catch (final NoSuchMethodException e) { + e.printStackTrace(); + } catch (final SecurityException e) { + e.printStackTrace(); + } + } + + @Override + public UUID getUUID(final PlotPlayer player) { + return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8)); + } + + @Override + public UUID getUUID(final OfflinePlotPlayer player) { + return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8)); + } + + public UUID getUUID(final OfflinePlayer player) { + return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName().toLowerCase() ).getBytes(Charsets.UTF_8)); + } + + @Override + public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) { + final BiMap map = UUIDHandler.getUuidMap().inverse(); + String name; + try { + name = map.get(uuid).value; + } catch (final NullPointerException e) { + name = null; + } + if (name != null) { + final OfflinePlayer op = Bukkit.getOfflinePlayer(name); + if (op.hasPlayedBefore()) { + return new BukkitOfflinePlayer(op); + } + } + for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) { + if (getUUID(player).equals(uuid)) { + return new BukkitOfflinePlayer(player); + } + } + return null; + } + + public Player[] getOnlinePlayers() { + if (this.getOnline == null) { + return Bukkit.getOnlinePlayers().toArray(new Player[0]); + } + try { + final Object players = this.getOnline.invoke(Bukkit.getServer(), this.arg); + if (players instanceof Player[]) { + return (Player[]) players; + } else { + @SuppressWarnings("unchecked") + final Collection p = (Collection) players; + return p.toArray(new Player[0]); + } + } catch (final Exception e) { + PlotSquared.log("Failed to resolve online players"); + this.getOnline = null; + return Bukkit.getOnlinePlayers().toArray(new Player[0]); + } + } + + @Override + public UUID getUUID(final String name) { + return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8)); + } + + @Override + public OfflinePlotPlayer[] getOfflinePlayers() { + OfflinePlayer[] ops = Bukkit.getOfflinePlayers(); + BukkitOfflinePlayer[] toReturn = new BukkitOfflinePlayer[ops.length] ; + for (int i = 0; i < ops.length; i++) { + toReturn[i] = new BukkitOfflinePlayer(ops[i]); + } + return toReturn; + } +} From f3af61fe3c69917353b7af938d70ad804da82900 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 12 Apr 2015 15:24:54 +1000 Subject: [PATCH 149/223] Finished adding new lowercase UUID mode (mostly for Offline servers) --- .../com/intellectualcrafters/plot/BukkitMain.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 66951e06c..2731a76f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -63,6 +63,7 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.sk89q.worldedit.WorldEdit; @@ -351,13 +352,23 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { AbstractTitle.TITLE_CLASS = new DefaultTitle(); } if (Settings.OFFLINE_MODE) { - UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + if (Settings.UUID_LOWERCASE) { + UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper(); + } + else { + UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + } Settings.OFFLINE_MODE = true; } else if (checkVersion) { UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); Settings.OFFLINE_MODE = false; } else { - UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + if (Settings.UUID_LOWERCASE) { + UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper(); + } + else { + UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + } Settings.OFFLINE_MODE = true; } if (Settings.OFFLINE_MODE) { From 23b9b408b4699293badc83e105d325a895ccc007 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 12 Apr 2015 15:31:17 +1000 Subject: [PATCH 150/223] Fix helpers --- .../plot/listeners/worldedit/WEListener.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index 86d14c20d..5f52965d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -102,11 +103,14 @@ public class WEListener implements Listener { public HashSet getMask(PlotPlayer player) { HashSet regions = new HashSet<>(); - for (Plot plot : PlotSquared.getPlots(player)) { + UUID uuid = player.getUUID(); + for (Plot plot : PlotSquared.getPlots(player.getLocation().getWorld()).values()) { if (!plot.settings.getMerged(1) && !plot.settings.getMerged(2)) { - Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); - Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); - regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); + if (plot.isOwner(uuid) || plot.helpers.contains(uuid)) { + Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); + regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); + } } } return regions; From 550cf87adf8269fe2b29d097debbda00c9fb8d35 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 12 Apr 2015 15:41:14 +1000 Subject: [PATCH 151/223] Added optional WorldEdit processing to reduce likelyhood of server crashes --- .../worldedit/ProcessedWEExtent.java | 105 ++++++++++++++++++ .../plot/listeners/worldedit/WEListener.java | 7 +- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java new file mode 100644 index 000000000..0c7087a68 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java @@ -0,0 +1,105 @@ +package com.intellectualcrafters.plot.listeners.worldedit; + +import java.util.HashSet; + +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.Vector2D; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extent.AbstractDelegateExtent; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.biome.BaseBiome; + +public class ProcessedWEExtent extends AbstractDelegateExtent { + private final HashSet mask; + int BScount = 0; + int Ecount = 0; + boolean BSblocked = false; + boolean Eblocked = false; + + public ProcessedWEExtent(HashSet mask, Extent extent) { + super(extent); + this.mask = mask; + } + + @Override + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { + switch (block.getType()) { + case 54: + case 130: + case 142: + case 27: + case 137: + case 52: + case 154: + case 84: + case 25: + case 144: + case 138: + case 176: + case 177: + case 63: + case 68: + case 323: + case 117: + case 116: + case 28: + case 66: + case 157: + case 61: + case 62: + case 140: + case 146: + case 149: + case 150: + case 158: + case 23: + case 123: + case 124: + case 29: + case 33: + case 151: + case 178: { + if (BSblocked) { + return false; + } + BScount++; + if (BScount > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) { + BSblocked = true; + } + } + } + if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + return super.setBlock(location, block); + } + return false; + } + + @Override + public Entity createEntity(Location location, BaseEntity entity) { + if (Eblocked) { + return null; + } + Ecount++; + if (Ecount > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + Eblocked = true; + } + if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + return super.createEntity(location, entity); + } + return null; + } + + @Override + public boolean setBiome(Vector2D position, BaseBiome biome) { + if (WEListener.maskContains(mask, position.getBlockX(), position.getBlockZ())) { + return super.setBiome(position, biome); + } + return false; + } +} \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index 5f52965d1..78c6a20f0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -72,7 +72,12 @@ public class WEListener implements Listener { return; } } catch (IncompleteRegionException e) {} - event.setExtent(new WEExtent(mask, event.getExtent())); + if (Settings.CHUNK_PROCESSOR) { + event.setExtent(new ProcessedWEExtent(mask, event.getExtent())); + } + else { + event.setExtent(new WEExtent(mask, event.getExtent())); + } } } From 6c096b852875abe037314dd08f4d182c465c7a71 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 12 Apr 2015 15:48:32 +1000 Subject: [PATCH 152/223] Console notifications --- .../plot/listeners/worldedit/ProcessedWEExtent.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java index 0c7087a68..fc23006c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.listeners.worldedit; import java.util.HashSet; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.RegionWrapper; import com.sk89q.worldedit.Vector; @@ -71,6 +72,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { BScount++; if (BScount > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) { BSblocked = true; + PlotSquared.log("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ())); } } } @@ -88,6 +90,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { Ecount++; if (Ecount > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { Eblocked = true; + PlotSquared.log("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ())); } if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { return super.createEntity(location, entity); From bef18aa9f64361332f20e82409b918b6e113f46c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 12 Apr 2015 17:07:09 +1000 Subject: [PATCH 153/223] 2.9.12 --- PlotSquared/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index ff65a06fc..8cd4d82de 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.11 + 2.9.12 PlotSquared jar From b9732ccd1a58554903b5c3687afdc7c7e18cb768 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 13 Apr 2015 00:06:13 +1000 Subject: [PATCH 154/223] misc fixes --- PlotSquared/pom.xml | 2 +- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Denied.java | 3 ++- .../java/com/intellectualcrafters/plot/commands/Helpers.java | 3 ++- .../java/com/intellectualcrafters/plot/commands/Trusted.java | 3 ++- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 4 ++-- .../plot/listeners/worldedit/WEListener.java | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 8cd4d82de..fd3477722 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.12 + 2.9.13 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index af8fa900f..9b67552ed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -709,7 +709,7 @@ public class PlotSquared { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); - final List intFlags = Arrays.asList("entity-cap", "animal-cap", "mob-cap"); + final List intFlags = Arrays.asList("mob-cap", "animal-cap", "hostile-cap"); for (final String flag : stringFlags) { FlagManager.addFlag(new AbstractFlag(flag)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 4cca27500..5262419ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.UUID; import com.intellectualcrafters.plot.config.C; @@ -105,9 +106,9 @@ public class Denied extends SubCommand { return true; } for (UUID uuid : plot.denied) { - plot.removeDenied(uuid); DBFunc.removeDenied(loc.getWorld(), plot, uuid); } + plot.denied = new ArrayList<>(); MainUtil.sendMessage(plr, C.DENIED_REMOVED); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 93d81cab2..585c4582c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.UUID; import com.intellectualcrafters.plot.config.C; @@ -96,9 +97,9 @@ public class Helpers extends SubCommand { return true; } for (UUID uuid : plot.helpers) { - plot.removeHelper(uuid); DBFunc.removeHelper(loc.getWorld(), plot, uuid); } + plot.helpers = new ArrayList<>(); MainUtil.sendMessage(plr, C.HELPER_REMOVED); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index b4a181d0e..ea74aba5c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.UUID; import com.intellectualcrafters.plot.config.C; @@ -97,9 +98,9 @@ public class Trusted extends SubCommand { return true; } for (UUID uuid : plot.trusted) { - plot.removeTrusted(uuid); DBFunc.removeTrusted(loc.getWorld(), plot, uuid); } + plot.trusted = new ArrayList<>(); MainUtil.sendMessage(plr, C.TRUSTED_REMOVED); return true; } 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 0972694e8..ef7f498a9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -809,9 +809,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null && plot.owner != null) { - Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap"); + Flag entityFlag = FlagManager.getPlotFlag(plot, "mob-cap"); Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap"); - Flag monsterFlag = FlagManager.getPlotFlag(plot, "mob-cap"); + Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap"); if (!(entity instanceof Creature)) { return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index 78c6a20f0..2a59831aa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -110,7 +110,7 @@ public class WEListener implements Listener { HashSet regions = new HashSet<>(); UUID uuid = player.getUUID(); for (Plot plot : PlotSquared.getPlots(player.getLocation().getWorld()).values()) { - if (!plot.settings.getMerged(1) && !plot.settings.getMerged(2)) { + if (!plot.settings.getMerged(0) && !plot.settings.getMerged(3)) { if (plot.isOwner(uuid) || plot.helpers.contains(uuid)) { Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); From c8498fdb213f03bd8651398286b0f771733d1e1e Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 14 Apr 2015 02:32:19 -0700 Subject: [PATCH 155/223] Add keep flag for preventing plots from expiring. Closes #259 --- .../java/com/intellectualcrafters/plot/PlotSquared.java | 2 +- .../com/intellectualcrafters/plot/util/ExpireManager.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 9b67552ed..78296a479 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -706,7 +706,7 @@ public class PlotSquared { } public static void setupDefaultFlags() { - final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone"); + final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone", "keep"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); final List intFlags = Arrays.asList("mob-cap", "animal-cap", "hostile-cap"); 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 a408587d3..ab83c26b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -18,6 +18,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.flag.Flag; +import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotHandler; @@ -159,6 +161,10 @@ public class ExpireManager { final HashMap remove = new HashMap<>(); final Set keep = new HashSet<>(); for (final Plot plot : plots) { + final Flag keepFlag = FlagManager.getPlotFlag(plot, "keep"); + if (keepFlag != null && (Boolean) keepFlag.getValue()) { + continue; + } final UUID uuid = plot.owner; if ((uuid == null) || remove.containsKey(uuid)) { Long stamp; From ba64bf37deb684f3601505d795049ae554a33dd1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 14 Apr 2015 22:24:25 +1000 Subject: [PATCH 156/223] yml --- PlotSquared/src/main/resources/plugin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/PlotSquared/src/main/resources/plugin.yml b/PlotSquared/src/main/resources/plugin.yml index 3720eac38..b95a552f8 100644 --- a/PlotSquared/src/main/resources/plugin.yml +++ b/PlotSquared/src/main/resources/plugin.yml @@ -6,6 +6,7 @@ description: > Easy, yet powerful Plot World generation and management. authors: [Citymonstret, Empire92] softdepend: [WorldEdit, BarAPI, CameraAPI, Vault] +loadbefore: [MultiWorld, Multiverse-Core] database: false commands: plots: From 352423cf93278ccbf66b295fcb006f7f2b64d05f Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 14 Apr 2015 06:47:12 -0700 Subject: [PATCH 157/223] Allow global plot limit across all worlds. Closes #261 --- .../java/com/intellectualcrafters/plot/PlotSquared.java | 2 ++ .../java/com/intellectualcrafters/plot/commands/Auto.java | 2 +- .../java/com/intellectualcrafters/plot/commands/Buy.java | 3 ++- .../com/intellectualcrafters/plot/commands/Claim.java | 3 ++- .../com/intellectualcrafters/plot/commands/SetOwner.java | 3 ++- .../com/intellectualcrafters/plot/config/Settings.java | 4 ++++ .../java/com/intellectualcrafters/plot/util/MainUtil.java | 8 ++++++++ 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 78296a479..c28951a04 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -828,6 +828,7 @@ public class PlotSquared { options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES); options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES); options.put("comments.notifications.interval", Settings.COMMENT_NOTIFICATION_INTERVAL); + options.put("global_limit", Settings.GLOBAL_LIMIT); for (final Entry node : options.entrySet()) { if (!config.contains(node.getKey())) { config.set(node.getKey(), node.getValue()); @@ -874,6 +875,7 @@ public class PlotSquared { Settings.UUID_LOWERCASE = config.getBoolean("UUID.force-lowercase"); Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk"); Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); + Settings.GLOBAL_LIMIT = config.getBoolean("global_limit"); } public static void setupConfigs() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index ffe3e2f68..c217057c1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -119,7 +119,7 @@ public class Auto extends SubCommand { MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + ""); return false; } - final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); + final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr); final int diff = currentPlots - MainUtil.getAllowedPlots(plr); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index d9b4ff159..e1ef9ae5d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; @@ -68,7 +69,7 @@ public class Buy extends SubCommand { if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - final int currentPlots = MainUtil.getPlayerPlotCount(world, plr); + final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr); if (currentPlots >= MainUtil.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } 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 d13b7e63f..970ba937a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -89,7 +90,7 @@ public class Claim extends SubCommand { if (plot == null) { return sendMessage(plr, C.NOT_IN_PLOT); } - final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr); + final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr); if (currentPlots >= MainUtil.getAllowedPlots(plr)) { return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index c3326e0cb..7c58b275f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -25,6 +25,7 @@ import java.util.UUID; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -75,7 +76,7 @@ public class SetOwner extends SubCommand { else { if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { int size = plots.size(); - final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), other) + size; + final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr)) + size; if (currentPlots > MainUtil.getAllowedPlots(other)) { sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS); 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 1d6067d44..baf6b6e09 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -152,6 +152,10 @@ public class Settings { public static boolean CONFIRM_CLEAR = true; public static boolean CONFIRM_DELETE = true; public static boolean CONFIRM_UNLINK = true; + /** + * Use global plot limit? + */ + public static boolean GLOBAL_LIMIT = false; /** * Database settings diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index dbd7c3390..ed8b3d62c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -97,6 +97,14 @@ public class MainUtil { } return count; } + + public static int getPlayerPlotCount(final PlotPlayer plr) { + int count = 0; + for (final String world : PlotSquared.getPlotWorldsString()) { + count += getPlayerPlotCount(world, plr); + } + return count; + } public static Location getDefaultHome(Plot plot) { PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); From 8f09a19a06f95fb0263a38592bed44be8c740e06 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 14 Apr 2015 23:55:00 +1000 Subject: [PATCH 158/223] Should fix #267 --- .../com/intellectualcrafters/plot/commands/Set.java | 6 ++++++ .../intellectualcrafters/plot/util/BlockManager.java | 2 ++ .../plot/util/SchematicHandler.java | 11 +++++++++++ .../plot/util/bukkit/BukkitUtil.java | 11 +++++++++++ 4 files changed, 30 insertions(+) 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 b24829271..b90d2193f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -240,6 +240,12 @@ public class Set extends SubCommand { return true; } blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) }; + for (PlotBlock block : blocks) { + if (!BlockManager.manager.isBlockSolid(block)) { + MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); + return false; + } + } } catch (final Exception e2) { MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 93c54dbc4..ebaea69c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -6,6 +6,8 @@ import com.intellectualcrafters.plot.object.schematic.PlotItem; public abstract class BlockManager { public static BlockManager manager; + + public abstract boolean isBlockSolid(PlotBlock block); public abstract String[] getBiomeList(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index ce35aab44..9bc3b5c7f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -183,6 +183,17 @@ public abstract class SchematicHandler { } } final File file = new File(PlotSquared.IMP.getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); + return getSchematic(file); + } + + /** + * Get a schematic + * + * @param name to check + * + * @return schematic if found, else null + */ + public Schematic getSchematic(File file) { if (!file.exists()) { PlotSquared.log(file.toString() + " doesn't exist"); return null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 04be68615..9312ebbee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -293,4 +293,15 @@ public class BukkitUtil extends BlockManager { return false; } + + @Override + public boolean isBlockSolid(PlotBlock block) { + try { + Material material = Material.getMaterial(block.id); + return material.isBlock() && material.isSolid() && material.isOccluding() && !material.hasGravity(); + } + catch (Exception e) { + return false; + } + } } From 230102ef1fafb89c735af33d422520d4a9989992 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 15 Apr 2015 00:07:28 +1000 Subject: [PATCH 159/223] fixes #268 --- .../java/com/intellectualcrafters/plot/commands/Visit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index efeca0826..ffc9dbd22 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -70,10 +70,10 @@ public class Visit extends SubCommand { } catch (final Exception e) { return sendMessage(plr, C.NOT_VALID_NUMBER); } - if ((i < 0) || (i >= plots.size())) { + if ((i < 1) || (i > plots.size())) { return sendMessage(plr, C.NOT_VALID_NUMBER); } - MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i)); + MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i - 1)); return true; } } From ae9ae154f20d85e2fb3345525564dd50ec8d36e4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 15 Apr 2015 00:09:25 +1000 Subject: [PATCH 160/223] Shorter title message. --- .../src/main/java/com/intellectualcrafters/plot/config/C.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 22e023156..37d8226ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -170,7 +170,7 @@ public enum C { /* * Title Stuff */ - TITLE_ENTERED_PLOT("You entered plot %world%;%x%;%z%"), + TITLE_ENTERED_PLOT("Plot: %world%;%x%;%z%"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB("Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), From 964fd0f5e94257333b07354ca6c2f183c3d122d4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 15 Apr 2015 00:33:57 +1000 Subject: [PATCH 161/223] Fixes #266 --- .../plot/PlotSquared.java | 2 +- .../plot/listeners/PlayerEvents.java | 51 +++++++++++++------ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index c28951a04..7b4d09ce6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -709,7 +709,7 @@ public class PlotSquared { final List booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone", "keep"); final List intervalFlags = Arrays.asList("feed", "heal"); final List stringFlags = Arrays.asList("greeting", "farewell"); - final List intFlags = Arrays.asList("mob-cap", "animal-cap", "hostile-cap"); + final List intFlags = Arrays.asList("entity-cap", "mob-cap", "animal-cap", "hostile-cap", "vehicle-cap"); for (final String flag : stringFlags) { FlagManager.addFlag(new AbstractFlag(flag)); } 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 ef7f498a9..e733c916b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -28,6 +28,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.SmallFireball; import org.bukkit.entity.Tameable; import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.Vehicle; import org.bukkit.entity.minecart.RideableMinecart; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -809,9 +810,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(loc); if (plot != null && plot.owner != null) { - Flag entityFlag = FlagManager.getPlotFlag(plot, "mob-cap"); + Flag entityFlag = FlagManager.getPlotFlag(plot, "entity-cap"); Flag animalFlag = FlagManager.getPlotFlag(plot, "animal-cap"); Flag monsterFlag = FlagManager.getPlotFlag(plot, "hostile-cap"); + Flag mobFlag = FlagManager.getPlotFlag(plot, "mob-cap"); + Flag vehicleFlag = FlagManager.getPlotFlag(plot, "vehicle-cap"); if (!(entity instanceof Creature)) { return; } @@ -824,7 +827,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } int[] mobs = ChunkManager.manager.countEntities(plot); - if (entity instanceof Creature) { + if (entity instanceof Creature || entity instanceof Vehicle) { if (entityFlag != null) { int cap = ((Integer) entityFlag.getValue()); if (mobs[0] >= cap) { @@ -832,21 +835,39 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - } - if (entity instanceof Animals) { - if (animalFlag != null) { - int cap = ((Integer) animalFlag.getValue()); - if (mobs[1] >= cap) { - event.setCancelled(true); + if (entity instanceof Creature) { + if (mobFlag != null) { + int cap = ((Integer) mobFlag.getValue()); + if (mobs[3] >= cap) { + event.setCancelled(true); + return; + } + } + if (entity instanceof Animals) { + if (animalFlag != null) { + int cap = ((Integer) animalFlag.getValue()); + if (mobs[1] >= cap) { + event.setCancelled(true); + } + } + return; + } + else if (entity instanceof Monster) { + if (monsterFlag != null) { + int cap = ((Integer) monsterFlag.getValue()); + if (mobs[2] >= cap) { + event.setCancelled(true); + } + } } } - return; - } - if (entity instanceof Monster) { - if (monsterFlag != null) { - int cap = ((Integer) monsterFlag.getValue()); - if (mobs[2] >= cap) { - event.setCancelled(true); + else { + if (vehicleFlag != null) { + int cap = ((Integer) vehicleFlag.getValue()); + if (mobs[4] >= cap) { + event.setCancelled(true); + return; + } } } } From e93634622cf86554792af4b7061549c0cbcf44e8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 15 Apr 2015 00:35:01 +1000 Subject: [PATCH 162/223] Fixes #266 --- .../plot/util/bukkit/BukkitChunkManager.java | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 1cea1bed0..bc79915c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -39,6 +39,7 @@ import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; @@ -878,7 +879,7 @@ public class BukkitChunkManager extends ChunkManager { @Override public int[] countEntities(Plot plot) { - int[] count = new int[3]; + int[] count = new int[5]; World world = BukkitUtil.getWorld(plot.world); Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); @@ -909,7 +910,7 @@ public class BukkitChunkManager extends ChunkManager { if (doWhole) { for (final Entity entity : entities) { - if (!(entity instanceof Creature)) { + if (!(entity instanceof Creature || entity instanceof Vehicle)) { continue; } org.bukkit.Location loc = entity.getLocation(); @@ -918,24 +919,12 @@ public class BukkitChunkManager extends ChunkManager { int X = chunk.getX(); int Z = chunk.getX(); if (X > bx && X < tx && Z > bz && Z < tz) { - count[0]++; - if (entity instanceof Animals) { - count[1]++; - } - else { - count[2]++; - } + count(count, entity); } else { final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc)); if (plot.id.equals(id)) { - count[0]++; - if (entity instanceof Animals) { - count[1]++; - } - else { - count[2]++; - } + count(count, entity); } } } @@ -947,33 +936,38 @@ public class BukkitChunkManager extends ChunkManager { int Z = chunk.getX(); Entity[] ents = chunk.getEntities(); for (final Entity entity : ents) { - if (!(entity instanceof Creature)) { + if (!(entity instanceof Creature || entity instanceof Vehicle)) { continue; } if (X == bx || X == tx || Z == bz || Z == tz) { final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity)); if (plot.id.equals(id)) { - count[0]++; - if (entity instanceof Animals) { - count[1]++; - } - else { - count[2]++; - } + count(count, entity); } } else { - count[0]++; - if (entity instanceof Animals) { - count[1]++; - } - else { - count[2]++; - } + count(count, entity); } } } } return count; } + + private void count(int[] count, Entity entity) { + count[0]++; + if (entity instanceof Creature) { + count[3]++; + if (entity instanceof Animals) { + count[1]++; + } + else { + count[2]++; + } + } + else { + count[4]++; + } + } + } From 04df6cefe2109a100bf8a6c843a9129a774cc2bf Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 14 Apr 2015 11:13:16 -0700 Subject: [PATCH 163/223] Fix incorrect plot count being used in setowner --- .../java/com/intellectualcrafters/plot/commands/SetOwner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 7c58b275f..e5f289226 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -76,7 +76,7 @@ public class SetOwner extends SubCommand { else { if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) { int size = plots.size(); - final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr)) + size; + final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(other) : MainUtil.getPlayerPlotCount(loc.getWorld(), other)) + size; if (currentPlots > MainUtil.getAllowedPlots(other)) { sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS); return false; From fcb0b084d9428077af27efe818efe1f2c74e8993 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 14 Apr 2015 12:21:47 -0700 Subject: [PATCH 164/223] Add permissions for plot list filters. Closes #262 --- .../plot/commands/list.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 26974a642..55f099a5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -112,6 +113,10 @@ public class list extends SubCommand { if (plr == null) { break; } + if (!Permissions.hasPermission(plr, "plots.list.mine")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine"); + return false; + } plots = PlotSquared.getPlots(plr); break; } @@ -119,6 +124,10 @@ public class list extends SubCommand { if (plr == null) { break; } + if (!Permissions.hasPermission(plr, "plots.list.shared")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared"); + return false; + } plots = new ArrayList(); for (Plot plot : PlotSquared.getPlots()) { if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) { @@ -128,14 +137,30 @@ public class list extends SubCommand { break; } case "world": { + if (!Permissions.hasPermission(plr, "plots.list.world")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world"); + return false; + } + if (!Permissions.hasPermission(plr, "plots.list.world." + world)) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world); + return false; + } plots = PlotSquared.getPlots(world).values(); break; } case "all": { + if (!Permissions.hasPermission(plr, "plots.list.all")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all"); + return false; + } plots = PlotSquared.getPlots(); break; } case "forsale": { + if (!Permissions.hasPermission(plr, "plots.list.forsale")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale"); + return false; + } if (PlotSquared.economy == null) { break; } @@ -149,6 +174,10 @@ public class list extends SubCommand { break; } case "unowned": { + if (!Permissions.hasPermission(plr, "plots.list.unowned")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned"); + return false; + } plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { if (plot.owner == null) { @@ -158,6 +187,10 @@ public class list extends SubCommand { break; } case "unknown": { + if (!Permissions.hasPermission(plr, "plots.list.unknown")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown"); + return false; + } plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { if (plot.owner == null) { @@ -171,11 +204,23 @@ public class list extends SubCommand { } default: { if (PlotSquared.isPlotWorld(args[0])) { + if (!Permissions.hasPermission(plr, "plots.list.world")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world"); + return false; + } + if (!Permissions.hasPermission(plr, "plots.list.world." + args[0])) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]); + return false; + } plots = PlotSquared.getPlots(args[0]).values(); break; } UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { + if (!Permissions.hasPermission(plr, "plots.list.player")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player"); + return false; + } plots = PlotSquared.getPlots(uuid); break; } From 75a499df0b39de6391e87f76e2ddd03b1f66934a Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 14 Apr 2015 22:24:54 -0700 Subject: [PATCH 165/223] Allow falling block check during piston extend to be configurable --- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 2 ++ .../java/com/intellectualcrafters/plot/config/Settings.java | 4 ++++ .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 7b4d09ce6..0d7ad5464 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -801,6 +801,7 @@ public class PlotSquared { options.put("confirmation.delete", Settings.CONFIRM_DELETE); options.put("confirmation.unlink", Settings.CONFIRM_UNLINK); options.put("protection.tnt-listener.enabled", Settings.TNT_LISTENER); + options.put("protection.piston.falling-blocks", Settings.PISTON_FALLING_BLOCK_CHECK); options.put("clusters.enabled", Settings.ENABLE_CLUSTERS); options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); options.put("plotme-alias", Settings.USE_PLOTME_ALIAS); @@ -846,6 +847,7 @@ public class PlotSquared { Settings.CHUNK_PROCESSOR_MAX_ENTITIES= config.getInt("chunk-processor.max-entities"); Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled"); + Settings.PISTON_FALLING_BLOCK_CHECK = config.getBoolean("protection.piston.falling-blocks"); Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete"); 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 baf6b6e09..57395be97 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -55,6 +55,10 @@ public class Settings { * TNT listener */ public static boolean TNT_LISTENER = false; + /** + * Check for falling blocks when pistons extend? + */ + public static boolean PISTON_FALLING_BLOCK_CHECK = true; /** * Max auto claiming size */ 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 e733c916b..d0e380d0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -672,6 +672,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } + if (!Settings.PISTON_FALLING_BLOCK_CHECK) { + return; + } org.bukkit.Location lastLoc; if (blocks.size() > 0) { lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative); From be8db522fd37c33cc599ced2d0134770c47d9725 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 15 Apr 2015 17:42:28 +1000 Subject: [PATCH 166/223] Added IsPlotFlagFalse to FlagManager --- .../intellectualcrafters/plot/flag/FlagManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 31777b2cf..4a342eb6b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -115,6 +115,17 @@ public class FlagManager { } return false; } + + public static boolean isPlotFlagFalse(final Plot plot, final String strFlag) { + final Flag flag = getPlotFlag(plot, strFlag); + if (flag == null) { + return false; + } + if (flag.getValue() instanceof Boolean) { + return !(boolean) flag.getValue(); + } + return false; + } /** * Get the value of a flag for a plot (ignores flag defaults) From e239a49be1e76806adb0ea9ead8a1eeb6fbd7d84 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 16 Apr 2015 14:04:11 +1000 Subject: [PATCH 167/223] Simplified mass schematic export --- .../plot/commands/SchematicCmd.java | 110 +++++------------- .../plot/util/SchematicHandler.java | 72 ++++++++++++ 2 files changed, 104 insertions(+), 78 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index ce57799a0..c36ef959f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -20,8 +20,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PlotSquared; @@ -45,7 +47,6 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SchematicCmd extends SubCommand { private int counter = 0; private boolean running = false; - private Plot[] plots; private int task; public SchematicCmd() { @@ -196,52 +197,24 @@ public class SchematicCmd extends SubCommand { } final HashMap plotmap = PlotSquared.getPlots(args[1]); if ((plotmap == null) || (plotmap.size() == 0)) { - MainUtil.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall "); + MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall "); return false; } - if (this.running) { - MainUtil.sendMessage(null, "&cTask is already running."); + Collection plots = plotmap.values(); + boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(plr, "&aFinished mass export"); + } + }); + if (!result) { + MainUtil.sendMessage(plr, "&cTask is already running."); return false; } - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); - final String worldname = args[1]; - final Collection values = plotmap.values(); - this.plots = values.toArray(new Plot[values.size()]); - this.running = true; - this.counter = 0; - this.task = TaskManager.runTaskRepeat(new Runnable() { - @Override - public void run() { - if (SchematicCmd.this.counter >= SchematicCmd.this.plots.length) { - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); - SchematicCmd.this.running = false; - PlotSquared.TASK.cancelTask(SchematicCmd.this.task); - return; - } - final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; - final CompoundTag sch = SchematicHandler.manager.getCompoundTag(worldname, plot.id); - final String o = UUIDHandler.getName(plot.owner); - final String owner = o == null ? "unknown" : o; - if (sch == null) { - MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); - } else { - TaskManager.runTaskAsync(new Runnable() { - @Override - public void run() { - MainUtil.sendMessage(null, "&6ID: " + plot.id); - final boolean result = SchematicHandler.manager.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic"); - if (!result) { - MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id); - } else { - MainUtil.sendMessage(null, "&7 - &a success: " + plot.id); - } - } - }); - } - SchematicCmd.this.counter++; - } - }, 20); + else { + PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); + PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots..."); + } break; } case "export": @@ -288,41 +261,22 @@ public class SchematicCmd extends SubCommand { return false; } } - this.plots = new Plot[] { p2 }; - this.running = true; - this.counter = 0; - this.task = TaskManager.runTaskRepeat(new Runnable() { - @Override - public void run() { - if (SchematicCmd.this.counter >= SchematicCmd.this.plots.length) { - PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!"); - SchematicCmd.this.running = false; - PlotSquared.TASK.cancelTask(SchematicCmd.this.task); - return; - } - final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; - final CompoundTag sch = SchematicHandler.manager.getCompoundTag(world, plot.id); - final String o = UUIDHandler.getName(plot.owner); - final String owner = o == null ? "unknown" : o; - if (sch == null) { - MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); - } else { - TaskManager.runTaskAsync(new Runnable() { - @Override - public void run() { - MainUtil.sendMessage(plr, "&6ID: " + plot.id); - final boolean result = SchematicHandler.manager.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + world + "," + owner.trim() + ".schematic"); - if (!result) { - MainUtil.sendMessage(plr, "&7 - Failed to save &c" + plot.id); - } else { - MainUtil.sendMessage(plr, "&7 - &aExport success: " + plot.id); - } - } - }); - } - SchematicCmd.this.counter++; - } - }, 60); + + Collection plots = new ArrayList(); + plots.add(p2); + boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(plr, "&aFinished export"); + } + }); + if (!result) { + MainUtil.sendMessage(plr, "&cTask is already running."); + return false; + } + else { + MainUtil.sendMessage(plr, "&7Starting export..."); + } break; } default: { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 9bc3b5c7f..16f2eced5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -6,12 +6,16 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +import org.bukkit.Bukkit; + import com.intellectualcrafters.jnbt.ByteArrayTag; import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.jnbt.IntTag; @@ -21,16 +25,84 @@ import com.intellectualcrafters.jnbt.NBTOutputStream; import com.intellectualcrafters.jnbt.ShortTag; import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.commands.SchematicCmd; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.object.schematic.StateWrapper; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public abstract class SchematicHandler { public static SchematicHandler manager = new BukkitSchematicHandler(); + private boolean exportAll = false; + + public boolean exportAll(final Collection plots, final File outputDir, final String namingScheme, final Runnable ifSuccess) { + if (exportAll) { + return false; + } + if (plots.size() == 0) { + return false; + } + exportAll = true; + TaskManager.index.increment(); + final Integer currentIndex = TaskManager.index.toInteger(); + final int task = TaskManager.runTaskRepeat(new Runnable() { + @Override + public void run() { + if (plots.size() == 0) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + TaskManager.runTask(ifSuccess); + return; + } + Iterator i = plots.iterator(); + final Plot plot = i.next(); + i.remove(); + final CompoundTag sch = SchematicHandler.manager.getCompoundTag(plot.world, plot.id); + String o = UUIDHandler.getName(plot.owner); + if (o == null) { + o = "unknown"; + } + final String name; + if (namingScheme == null) { + name = plot.id.x + ";" + plot.id.y + "," + plot.world + "," + o; + } + else { + name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.id.toString()).replaceAll("%idx%", plot.id.x + "").replaceAll("%idy%", plot.id.y + "").replaceAll("%world%", plot.world); + } + final String directory; + if (outputDir == null) { + directory = Settings.SCHEMATIC_SAVE_PATH; + } + else { + directory = outputDir.getPath(); + } + if (sch == null) { + MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); + } else { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(null, "&6ID: " + plot.id); + final boolean result = SchematicHandler.manager.save(sch, directory + File.separator + name + ".schematic"); + if (!result) { + MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id); + } else { + MainUtil.sendMessage(null, "&7 - &a success: " + plot.id); + } + } + }); + } + } + }, 20); + TaskManager.tasks.put(currentIndex, task); + return true; + } + /** * Paste a schematic * From d650c3dd8617b856a76d817227ad4404724230a2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 16 Apr 2015 21:25:02 +1000 Subject: [PATCH 168/223] block queue --- .../plot/object/PlotGenerator.java | 2 +- .../plot/util/bukkit/DebugSetBlockQueue.java | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index f38c8731e..9bff22155 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -71,7 +71,7 @@ public abstract class PlotGenerator extends ChunkGenerator { h = (prime * h) + cx; h = (prime * h) + cz; this.random.state = h; - this.result = new short[256 / 16][]; + this.result = new short[16][]; PlotWorld plotworld = PlotSquared.getPlotWorld(world.getName()); Biome biome = Biome.valueOf(plotworld.PLOT_BIOME); this.X = cx << 4; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java new file mode 100644 index 000000000..63bb91970 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java @@ -0,0 +1,83 @@ +package com.intellectualcrafters.plot.util.bukkit; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.World; + +import com.intellectualcrafters.plot.util.TaskManager; + +public class DebugSetBlockQueue { + + private HashMap blocks; + private int allocate = 100; + + public void allocate(int t) { + this.allocate = t; + } + + public DebugSetBlockQueue() { + blocks = new HashMap<>(); + TaskManager.index.increment(); + final int current = TaskManager.index.intValue(); + int task = TaskManager.runTaskRepeat(new Runnable() { + @Override + public void run() { + if (blocks.size() == 0) { + blocks = null; + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(current)); + return; + } + long start = System.currentTimeMillis() + allocate; + Iterator> i = blocks.entrySet().iterator(); + while (System.currentTimeMillis() < start && i.hasNext()) { + Entry n = i.next(); + i.remove(); + Chunk chunk = n.getKey(); + int X = chunk.getX() << 4; + int Z = chunk.getZ() << 4; + short[][] blocks = n.getValue(); + World world = chunk.getWorld(); + for (int j = 0; j < blocks.length; j++) { + short[] blocksj = blocks[j]; + if (blocksj != null) { + for (int k = 0; k < blocksj.length; k++) { + short id = blocksj[k]; + if (id != 0) { + final int y = (j << 4) + (k >> 8); + final int a = (k - ((y & 0xF) << 8)); + final int z = (a >> 4); + final int x = a - (z << 4); + BukkitSetBlockManager.setBlockManager.set(world, X + x, y, Z + z, id, (byte) 0); + } + } + } + } + } + } + }, 20); + TaskManager.tasks.put(current, task); + } + + + + public void setBlock(final World world, int x, final int y, int z, final short blkid) { + int X = x >> 4; + int Z = z >> 4; + x -= X << 4; + z -= Z << 4; + Chunk chunk = world.getChunkAt(X, Z); + short[][] result = blocks.get(chunk); + if (!blocks.containsKey(chunk)) { + result = new short[16][]; + blocks.put(chunk, result); + } + if (result[y >> 4] == null) { + result[y >> 4] = new short[4096]; + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; + } +} From 2335708e115d9d5375cef218a8a4f48405a87eff Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 16 Apr 2015 21:28:55 +1000 Subject: [PATCH 169/223] This may also be useful --- .../plot/util/bukkit/DebugSetBlockQueue.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java index 63bb91970..fc0d3e192 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java @@ -19,7 +19,7 @@ public class DebugSetBlockQueue { this.allocate = t; } - public DebugSetBlockQueue() { + public DebugSetBlockQueue(final Runnable whenDone) { blocks = new HashMap<>(); TaskManager.index.increment(); final int current = TaskManager.index.intValue(); @@ -29,6 +29,7 @@ public class DebugSetBlockQueue { if (blocks.size() == 0) { blocks = null; Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(current)); + TaskManager.runTask(whenDone); return; } long start = System.currentTimeMillis() + allocate; From 689583334d77b6bcc5580c0d487fd54a0284e240 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 16 Apr 2015 22:21:04 +1000 Subject: [PATCH 170/223] async --- .../plot/util/bukkit/DebugSetBlockQueue.java | 182 +++++++++++++----- 1 file changed, 132 insertions(+), 50 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java index fc0d3e192..8cc2317e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java @@ -1,84 +1,166 @@ package com.intellectualcrafters.plot.util.bukkit; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; import org.bukkit.Bukkit; -import org.bukkit.Chunk; import org.bukkit.World; import com.intellectualcrafters.plot.util.TaskManager; public class DebugSetBlockQueue { - private HashMap blocks; - private int allocate = 100; + private volatile static HashMap blocks; + private volatile static int allocate = 50; + private volatile static boolean running = false; + private volatile static boolean locked = false; + private volatile static HashSet runnables; - public void allocate(int t) { - this.allocate = t; + public synchronized static void allocate(int t) { + allocate = t; } - public DebugSetBlockQueue(final Runnable whenDone) { - blocks = new HashMap<>(); - TaskManager.index.increment(); - final int current = TaskManager.index.intValue(); - int task = TaskManager.runTaskRepeat(new Runnable() { - @Override - public void run() { - if (blocks.size() == 0) { - blocks = null; - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(current)); - TaskManager.runTask(whenDone); - return; - } - long start = System.currentTimeMillis() + allocate; - Iterator> i = blocks.entrySet().iterator(); - while (System.currentTimeMillis() < start && i.hasNext()) { - Entry n = i.next(); - i.remove(); - Chunk chunk = n.getKey(); - int X = chunk.getX() << 4; - int Z = chunk.getZ() << 4; - short[][] blocks = n.getValue(); - World world = chunk.getWorld(); - for (int j = 0; j < blocks.length; j++) { - short[] blocksj = blocks[j]; - if (blocksj != null) { - for (int k = 0; k < blocksj.length; k++) { - short id = blocksj[k]; - if (id != 0) { - final int y = (j << 4) + (k >> 8); - final int a = (k - ((y & 0xF) << 8)); - final int z = (a >> 4); - final int x = a - (z << 4); - BukkitSetBlockManager.setBlockManager.set(world, X + x, y, Z + z, id, (byte) 0); + public synchronized static void addNotify(Runnable whenDone) { + if (runnables == null) { + TaskManager.runTask(whenDone); + } + else { + runnables.add(whenDone); + } + } + + public synchronized static void init() { + if (blocks == null) { + blocks = new HashMap<>(); + runnables = new HashSet<>(); + } + if (!running) { + TaskManager.index.increment(); + final int current = TaskManager.index.intValue(); + int task = TaskManager.runTaskRepeat(new Runnable() { + @Override + public void run() { + if (locked) { + return; + } + if (blocks.size() == 0) { + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(current)); + for (Runnable runnable : runnables) { + TaskManager.runTask(runnable); + } + runnables = null; + blocks = null; + running = false; + return; + } + long start = System.currentTimeMillis() + allocate; + Iterator> i = blocks.entrySet().iterator(); + while (System.currentTimeMillis() < start && i.hasNext()) { + if (locked) { + return; + } + Entry n = i.next(); + i.remove(); + ChunkWrapper chunk = n.getKey(); + int X = chunk.x << 4; + int Z = chunk.z << 4; + short[][] blocks = n.getValue(); + World world = chunk.world; + for (int j = 0; j < blocks.length; j++) { + short[] blocksj = blocks[j]; + if (blocksj != null) { + for (int k = 0; k < blocksj.length; k++) { + short id = blocksj[k]; + if (id != 0) { + final int y = (j << 4) + (k >> 8); + final int a = (k - ((y & 0xF) << 8)); + final int z = (a >> 4); + final int x = a - (z << 4); + BukkitSetBlockManager.setBlockManager.set(world, X + x, y, Z + z, id, (byte) 0); + } } } } } } - } - }, 20); - TaskManager.tasks.put(current, task); + }, 5); + TaskManager.tasks.put(current, task); + running = true; + } } - - - - public void setBlock(final World world, int x, final int y, int z, final short blkid) { + + public static void setBlock(final World world, int x, final int y, int z, final short blkid) { + locked = true; + if (!running) { + init(); + } int X = x >> 4; int Z = z >> 4; x -= X << 4; z -= Z << 4; - Chunk chunk = world.getChunkAt(X, Z); - short[][] result = blocks.get(chunk); - if (!blocks.containsKey(chunk)) { + + ChunkWrapper wrap = new ChunkWrapper(world, X, Z); + short[][] result = blocks.get(wrap); + if (!blocks.containsKey(wrap)) { result = new short[16][]; - blocks.put(chunk, result); + blocks.put(wrap, result); } if (result[y >> 4] == null) { result[y >> 4] = new short[4096]; } result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; + locked = false; + } + + public static class ChunkWrapper { + final int x; + final int z; + final World world; + + public ChunkWrapper(World world, int x, int z) { + this.world = world; + this.x = x; + this.z = z; + } + + @Override + public int hashCode() { + int result; + if (this.x >= 0) { + if (this.z >= 0) { + result = (this.x * this.x) + (3 * this.x) + (2 * this.x * this.z) + this.z + (this.z * this.z); + } else { + final int y1 = -this.z; + result = (this.x * this.x) + (3 * this.x) + (2 * this.x * y1) + y1 + (y1 * y1) + 1; + } + } else { + final int x1 = -this.x; + if (this.z >= 0) { + result = -((x1 * x1) + (3 * x1) + (2 * x1 * this.z) + this.z + (this.z * this.z)); + } else { + final int y1 = -this.z; + result = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1); + } + } + result = result * 31 + world.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ChunkWrapper other = (ChunkWrapper) obj; + return ((this.x == other.x) && (this.z == other.z) && (this.world.equals(other.world))); + } } } From c44bf77f3253c9d2c35caba1b5b30c35fa2254d5 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 16 Apr 2015 23:37:50 +1000 Subject: [PATCH 171/223] Fixed comment update --- .../plot/database/SQLManager.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 07a2a518c..1fc0388ec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -589,16 +589,26 @@ public class SQLManager implements AbstractDB { rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); if (!rs.next()) { rs.close(); - final Statement statement = this.connection.createStatement(); - statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); - if (PlotSquared.getMySQL() != null) { - statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + try { + final Statement statement = this.connection.createStatement(); + statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`"); + statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0"); + statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`"); + statement.executeBatch(); + statement.close(); } - else { - statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); + catch (SQLException e) { + final Statement statement = this.connection.createStatement(); + statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); + if (PlotSquared.getMySQL() != null) { + statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + } + else { + statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")"); + } + statement.executeBatch(); + statement.close(); } - statement.executeBatch(); - statement.close(); } } rs.close(); From cb68c415ba35d9f9d755d12c4479e3d50ef64403 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Thu, 16 Apr 2015 16:24:22 -0700 Subject: [PATCH 172/223] Allow owners and helpers to use WorldEdit //up in their plots --- .../plot/listeners/worldedit/WEListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index 2a59831aa..0410d5f85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -134,7 +134,7 @@ public class WEListener implements Listener { } if (this.restrictedcmds.contains(cmd)) { final Plot plot = MainUtil.getPlot(pp.getLocation()); - if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(pp.getUUID()))) { + if ((plot == null) || (!plot.isOwner(pp.getUUID()) && !plot.helpers.contains(DBFunc.everyone) && !plot.helpers.contains(pp.getUUID()))) { e.setCancelled(true); } return; From 956899cb6735a5217f737c400ad225dbb0483f10 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 17 Apr 2015 16:39:45 +1000 Subject: [PATCH 173/223] Fixeds #276 --- PlotSquared/pom.xml | 2 +- .../plot/database/SQLManager.java | 17 ++-- .../plot/object/entity/ArmorStandStats.java | 15 +++ .../plot/object/entity/EntityWrapper.java | 91 +++++++++++++++++++ 4 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index fd3477722..2e2e4be89 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.13 + 2.9.15 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 1fc0388ec..748a8d5ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -586,18 +586,11 @@ public class SQLManager implements AbstractDB { final DatabaseMetaData data = this.connection.getMetaData(); ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id"); if (rs.next()) { + rs.close(); rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode"); if (!rs.next()) { rs.close(); try { - final Statement statement = this.connection.createStatement(); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`"); - statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0"); - statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`"); - statement.executeBatch(); - statement.close(); - } - catch (SQLException e) { final Statement statement = this.connection.createStatement(); statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); if (PlotSquared.getMySQL() != null) { @@ -609,6 +602,14 @@ public class SQLManager implements AbstractDB { statement.executeBatch(); statement.close(); } + catch (SQLException e) { + final Statement statement = this.connection.createStatement(); + statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `inbox` VARCHAR(11) DEFAULT `public`"); + statement.addBatch("ALTER IGNORE TABLE `" + this.prefix + "plot_comments` ADD `timestamp` INT(11) DEFAULT 0"); + statement.addBatch("ALTER TABLE `" + this.prefix + "plot` DROP `tier`"); + statement.executeBatch(); + statement.close(); + } } } rs.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java new file mode 100644 index 000000000..35b78e539 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java @@ -0,0 +1,15 @@ +package com.intellectualcrafters.plot.object.entity; + +public class ArmorStandStats { + float[] head = new float[3]; + float[] body = new float[3]; + float[] leftLeg = new float[3]; + float[] rightLeg = new float[3]; + float[] leftArm = new float[3]; + float[] rightArm = new float[3]; + public boolean noarms; + public boolean noplate; + public boolean nogravity; + public boolean invisible; + public boolean small; +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java index cf42da852..e2711689b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java @@ -28,6 +28,7 @@ import org.bukkit.entity.Tameable; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; import com.intellectualcrafters.plot.PlotSquared; @@ -51,6 +52,7 @@ public class EntityWrapper { public AgeableStats aged; public TameableStats tamed; private HorseStats horse; + private ArmorStandStats stand; public void storeInventory(final InventoryHolder held) { this.inventory = held.getInventory().getContents().clone(); @@ -317,6 +319,56 @@ public class EntityWrapper { final ArmorStand stand = (ArmorStand) entity; this.inventory = new ItemStack[] { stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(), stand.getLeggings().clone(), stand.getBoots().clone() }; storeLiving((LivingEntity) entity); + this.stand = new ArmorStandStats(); + + EulerAngle head = stand.getHeadPose(); + this.stand.head[0] = (float) head.getX(); + this.stand.head[1] = (float) head.getY(); + this.stand.head[2] = (float) head.getZ(); + + EulerAngle body = stand.getBodyPose(); + this.stand.body[0] = (float) body.getX(); + this.stand.body[1] = (float) body.getY(); + this.stand.body[2] = (float) body.getZ(); + + EulerAngle leftLeg = stand.getLeftLegPose(); + this.stand.leftLeg[0] = (float) leftLeg.getX(); + this.stand.leftLeg[1] = (float) leftLeg.getY(); + this.stand.leftLeg[2] = (float) leftLeg.getZ(); + + EulerAngle rightLeg = stand.getRightLegPose(); + this.stand.rightLeg[0] = (float) rightLeg.getX(); + this.stand.rightLeg[1] = (float) rightLeg.getY(); + this.stand.rightLeg[2] = (float) rightLeg.getZ(); + + EulerAngle leftArm = stand.getLeftArmPose(); + this.stand.leftArm[0] = (float) leftArm.getX(); + this.stand.leftArm[1] = (float) leftArm.getY(); + this.stand.leftArm[2] = (float) leftArm.getZ(); + + EulerAngle rightArm = stand.getRightArmPose(); + this.stand.rightArm[0] = (float) rightArm.getX(); + this.stand.rightArm[1] = (float) rightArm.getY(); + this.stand.rightArm[2] = (float) rightArm.getZ(); + + if (!stand.hasArms()) { + this.stand.noarms = true; + } + if (!stand.hasBasePlate()) { + this.stand.noplate = true; + } + if (!stand.hasGravity()) { + this.stand.nogravity = true; + } + if (!stand.isVisible()) { + this.stand.invisible = true; + } + if (stand.isSmall()) { + this.stand.small = true; + } + + + return; } case ENDERMITE: // NEW @@ -530,6 +582,45 @@ public class EntityWrapper { if (this.inventory[4] != null) { stand.setBoots(this.inventory[4]); } + if (this.stand.head[0] != 0 || this.stand.head[1] != 0 || this.stand.head[2] != 0) { + EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]); + stand.setHeadPose(pose); + } + if (this.stand.body[0] != 0 || this.stand.body[1] != 0 || this.stand.body[2] != 0) { + EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]); + stand.setBodyPose(pose); + } + if (this.stand.leftLeg[0] != 0 || this.stand.leftLeg[1] != 0 || this.stand.leftLeg[2] != 0) { + EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]); + stand.setLeftLegPose(pose); + } + if (this.stand.rightLeg[0] != 0 || this.stand.rightLeg[1] != 0 || this.stand.rightLeg[2] != 0) { + EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]); + stand.setRightLegPose(pose); + } + if (this.stand.leftArm[0] != 0 || this.stand.leftArm[1] != 0 || this.stand.leftArm[2] != 0) { + EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]); + stand.setLeftArmPose(pose); + } + if (this.stand.rightArm[0] != 0 || this.stand.rightArm[1] != 0 || this.stand.rightArm[2] != 0) { + EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]); + stand.setRightArmPose(pose); + } + if (this.stand.invisible) { + stand.setVisible(false); + } + if (this.stand.noarms) { + stand.setArms(false); + } + if (this.stand.nogravity) { + stand.setGravity(false); + } + if (this.stand.noplate) { + stand.setBasePlate(false); + } + if (this.stand.small) { + stand.setSmall(true); + } restoreLiving((LivingEntity) entity); return entity; } From 36ac4a4b943c935b60b5f8020a24055d281ec701 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 17 Apr 2015 16:41:41 +1000 Subject: [PATCH 174/223] *Fixed arms --- .../plot/object/entity/ArmorStandStats.java | 2 +- .../plot/object/entity/EntityWrapper.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java index 35b78e539..ad4a88b24 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/ArmorStandStats.java @@ -7,7 +7,7 @@ public class ArmorStandStats { float[] rightLeg = new float[3]; float[] leftArm = new float[3]; float[] rightArm = new float[3]; - public boolean noarms; + public boolean arms; public boolean noplate; public boolean nogravity; public boolean invisible; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java index e2711689b..de04c1ff8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/entity/EntityWrapper.java @@ -351,8 +351,8 @@ public class EntityWrapper { this.stand.rightArm[1] = (float) rightArm.getY(); this.stand.rightArm[2] = (float) rightArm.getZ(); - if (!stand.hasArms()) { - this.stand.noarms = true; + if (stand.hasArms()) { + this.stand.arms = true; } if (!stand.hasBasePlate()) { this.stand.noplate = true; @@ -609,8 +609,8 @@ public class EntityWrapper { if (this.stand.invisible) { stand.setVisible(false); } - if (this.stand.noarms) { - stand.setArms(false); + if (this.stand.arms) { + stand.setArms(true); } if (this.stand.nogravity) { stand.setGravity(false); From 779123f419dbf42596053ffe4a7c77ff8908cf4f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 18 Apr 2015 23:47:13 +1000 Subject: [PATCH 175/223] Fixes --- PlotSquared/pom.xml | 27 +- .../intellectualcrafters/plot/BukkitMain.java | 6 +- .../plot/PlotSquared.java | 145 +++++--- .../plot/commands/WE_Anywhere.java | 8 +- .../intellectualcrafters/plot/config/C.java | 4 + .../plot/config/Settings.java | 3 +- .../plot/listeners/ChunkListener.java | 48 ++- .../plot/listeners/PlayerEvents.java | 9 +- .../worldedit/ProcessedWEExtent.java | 6 +- .../plot/listeners/worldedit/WEExtent.java | 6 +- .../plot/listeners/worldedit/WEListener.java | 311 ++++++++++++------ .../plot/listeners/worldedit/WEManager.java | 55 ++++ .../listeners/worldedit/WESubscriber.java | 43 +++ 13 files changed, 495 insertions(+), 176 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 2e2e4be89..515148488 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.15 + 2.9.16 PlotSquared jar @@ -16,23 +16,20 @@ src/main/java - . true + + skyblock.template + town.template + ${basedir}/src/main/resources/ + + + false - - plugin.yml - - - LICENSE - - - town.template - - - skyblock.template - - + skyblock.template + town.template + + ${basedir}/src/main/resources/ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 2731a76f9..94e0171db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -39,6 +39,7 @@ import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.TNTListener; import com.intellectualcrafters.plot.listeners.WorldEvents; import com.intellectualcrafters.plot.listeners.worldedit.WEListener; +import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.DefaultTitle; @@ -261,9 +262,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { log("&cPlease use WorldEdit 6+ for masking support"); log("&c - http://builds.enginehub.org/job/worldedit"); } else { - WEListener weClass = new WEListener(); - WorldEdit.getInstance().getEventBus().register(weClass); - getServer().getPluginManager().registerEvents(weClass, this); + getServer().getPluginManager().registerEvents(new WEListener(), this); + WorldEdit.getInstance().getEventBus().register(new WESubscriber()); MainCommand.subCommands.add(new WE_Anywhere()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 0d7ad5464..0205052d4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -795,89 +795,156 @@ public class PlotSquared { config.set("version", VERSION); final Map options = new HashMap<>(); - options.put("teleport.delay", 0); - options.put("auto_update", false); + // Command confirmation options.put("confirmation.clear", Settings.CONFIRM_CLEAR); options.put("confirmation.delete", Settings.CONFIRM_DELETE); options.put("confirmation.unlink", Settings.CONFIRM_UNLINK); + + // Protection options.put("protection.tnt-listener.enabled", Settings.TNT_LISTENER); options.put("protection.piston.falling-blocks", Settings.PISTON_FALLING_BLOCK_CHECK); + + // Clusters options.put("clusters.enabled", Settings.ENABLE_CLUSTERS); - options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); + + // PlotMe options.put("plotme-alias", Settings.USE_PLOTME_ALIAS); options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME); options.put("plotme-convert.cache-uuids", Settings.CACHE_PLOTME); - options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); + + // UUID options.put("UUID.offline", Settings.OFFLINE_MODE); options.put("UUID.force-lowercase", Settings.UUID_LOWERCASE); + options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK); + + // Mob stuff options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); - options.put("console.color", Settings.CONSOLE_COLOR); - options.put("metrics", true); - options.put("debug", true); + + // Clearing + Expiry options.put("clear.auto.enabled", false); options.put("clear.auto.days", 365); options.put("clear.check-disk", Settings.AUTO_CLEAR_CHECK_DISK); options.put("clear.on.ban", false); - options.put("max_plots", Settings.MAX_PLOTS); + options.put("clear.fastmode", Settings.ENABLE_CLUSTERS); + + // Schematics options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); + + // Caching options.put("cache.permissions", Settings.PERMISSION_CACHING); + + // Titles options.put("titles", Settings.TITLES); + + // Teleportation options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); + options.put("teleport.delay", 0); + + // WorldEdit options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); + options.put("worldedit.max-volume", Settings.WE_MAX_VOLUME); + options.put("worldedit.max-iterations", Settings.WE_MAX_ITERATIONS); + + // Chunk processor options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR); options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES); options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES); + + // Comments options.put("comments.notifications.interval", Settings.COMMENT_NOTIFICATION_INTERVAL); + + // Plot limits options.put("global_limit", Settings.GLOBAL_LIMIT); + options.put("max_plots", Settings.MAX_PLOTS); + options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE); + + // Misc + options.put("console.color", Settings.CONSOLE_COLOR); + options.put("metrics", true); + options.put("debug", true); + options.put("auto_update", false); + for (final Entry node : options.entrySet()) { if (!config.contains(node.getKey())) { config.set(node.getKey(), node.getValue()); } } - Settings.ENABLE_CLUSTERS = config.getBoolean("clusters.enabled"); - Settings.DEBUG = config.getBoolean("debug"); - if (Settings.DEBUG) { - log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); - } - Settings.COMMENT_NOTIFICATION_INTERVAL = config.getInt("comments.notifications.interval"); + // Command confirmation + Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); + Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete"); + Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink"); + + // Protection + Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled"); + Settings.PISTON_FALLING_BLOCK_CHECK = config.getBoolean("protection.piston.falling-blocks"); + + // Clusters + Settings.ENABLE_CLUSTERS = config.getBoolean("clusters.enabled"); + + // PlotMe + Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias"); + Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled"); + Settings.CACHE_PLOTME = config.getBoolean("plotme-convert.cache-uuids"); + + // UUID + Settings.OFFLINE_MODE = config.getBoolean("UUID.offline"); + Settings.UUID_LOWERCASE = config.getBoolean("UUID.force-lowercase"); + Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk"); + + // Mob stuff + Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); + Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding"); + + // Clearing + Expiry + Settings.FAST_CLEAR = config.getBoolean("clear.fastmode"); + Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); + Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk"); + Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); + + // Schematics + Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); + + // Caching + Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); + + // Titles + Settings.TITLES = config.getBoolean("titles"); + + // Teleportation + Settings.TELEPORT_DELAY = config.getInt("teleport.delay"); + Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login"); + + // WorldEdit + Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); + Settings.WE_MAX_VOLUME = config.getLong("worldedit.max-volume"); + Settings.WE_MAX_ITERATIONS = config.getLong("worldedit.max-iterations"); + + // Chunk processor Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled"); Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES = config.getInt("chunk-processor.max-blockstates"); Settings.CHUNK_PROCESSOR_MAX_ENTITIES= config.getInt("chunk-processor.max-entities"); - Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled"); - Settings.PISTON_FALLING_BLOCK_CHECK = config.getBoolean("protection.piston.falling-blocks"); - Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions"); - Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear"); - Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete"); - Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink"); - Settings.FAST_CLEAR = config.getBoolean("clear.fastmode"); - Settings.TELEPORT_DELAY = config.getInt("teleport.delay"); - Settings.CONSOLE_COLOR = config.getBoolean("console.color"); - Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login"); - Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias"); - Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled"); - Settings.CACHE_PLOTME = config.getBoolean("plotme-convert.cache-uuids"); - Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); - Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding"); - Settings.METRICS = config.getBoolean("metrics"); - Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); - Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk"); + // Comments + Settings.COMMENT_NOTIFICATION_INTERVAL = config.getInt("comments.notifications.interval"); + + // Plot limits Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area"); - Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); - Settings.TITLES = config.getBoolean("titles"); Settings.MAX_PLOTS = config.getInt("max_plots"); if (Settings.MAX_PLOTS > 32767) { log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large."); Settings.MAX_PLOTS = 32767; } - Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); - Settings.OFFLINE_MODE = config.getBoolean("UUID.offline"); - Settings.UUID_LOWERCASE = config.getBoolean("UUID.force-lowercase"); - Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk"); - Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); Settings.GLOBAL_LIMIT = config.getBoolean("global_limit"); + + // Misc + Settings.DEBUG = config.getBoolean("debug"); + if (Settings.DEBUG) { + log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); + } + Settings.CONSOLE_COLOR = config.getBoolean("console.color"); + Settings.METRICS = config.getBoolean("metrics"); } public static void setupConfigs() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index fd57d2203..06ba35ccf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -23,6 +23,8 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.listeners.worldedit.WEListener; +import com.intellectualcrafters.plot.listeners.worldedit.WEManager; +import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; @@ -39,12 +41,12 @@ public class WE_Anywhere extends SubCommand { return false; } if (Permissions.hasPermission(plr, "plots.worldedit.bypass")) { - if (WEListener.bypass.contains(plr.getName())) { - WEListener.bypass.remove(plr.getName()); + if (WEManager.bypass.contains(plr.getName())) { + WEManager.bypass.remove(plr.getName()); MainUtil.sendMessage(plr, C.WORLDEDIT_RESTRICTED); } else { - WEListener.bypass.add(plr.getName()); + WEManager.bypass.add(plr.getName()); MainUtil.sendMessage(plr, C.WORLDEDIT_UNMASKED); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 37d8226ef..1666968da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -86,6 +86,10 @@ public enum C { * WorldEdit masks */ REQUIRE_SELECTION_IN_MASK("$2%s of your selection is not within your plot mask. You can only make edits within your plot."), + WORLDEDIT_VOLUME("$2You cannot select a volume of %current%. The maximum volume you can modify is %max%."), + WORLDEDIT_ITERATIONS("$2You cannot iterate %current% times. The maximum number of iterations allowed is %max%."), + WORLDEDIT_UNSAFE("$2Access to that command has been blocked"), + WORLDEDIT_BYPASS("$2&oTo bypass your restrictions use $3/plot wea"), WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted."), WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted."), /* 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 57395be97..e12d5a8e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -32,7 +32,6 @@ public class Settings { /** * Default UUID_FECTHING: false */ - public static boolean UUID_FECTHING = false; public static boolean PERMISSION_CACHING = false; public static boolean UUID_FROM_DISK = false; /** @@ -67,6 +66,8 @@ public class Settings { * Default worldedit-require-selection-in-mask: false */ public static boolean REQUIRE_SELECTION = true; + public static long WE_MAX_VOLUME = 500000; + public static long WE_MAX_ITERATIONS = 1000; /** * Default kill road mobs: true */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index c8976b10f..e337aa9f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -3,10 +3,15 @@ package com.intellectualcrafters.plot.listeners; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; @@ -27,6 +32,39 @@ public class ChunkListener implements Listener { public void onChunkLoad(ChunkLoadEvent event) { processChunk(event.getChunk(), false); } + + private int count = 0; + private Chunk lastChunk = null; + + @EventHandler + public void onItemSpawn(ItemSpawnEvent event) { + count++; + if (count < Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + lastChunk = null; + return; + } + Item entity = event.getEntity(); + Chunk chunk = entity.getLocation().getChunk(); + if (chunk == lastChunk) { + event.getEntity().remove(); + event.setCancelled(true); + return; + } + if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) { + return; + } + Entity[] entities = chunk.getEntities(); + if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + PlotSquared.log("[PlotSquared] &cDetected unsafe entity creation (" + (chunk.getX() << 4) + "," + (chunk.getX() << 4) + "). Mitigating threat."); + event.getEntity().remove(); + event.setCancelled(true); + lastChunk = chunk; + } + else { + count = 0; + lastChunk = null; + } + } public void cleanChunk(final Chunk chunk) { TaskManager.index.increment(); @@ -37,7 +75,7 @@ public class ChunkListener implements Listener { if (!chunk.isLoaded()) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); - PlotSquared.log("&aSuccessfully processed and unloaded chunk!"); + PlotSquared.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!"); chunk.unload(true, true); return; } @@ -45,7 +83,7 @@ public class ChunkListener implements Listener { if (tiles.length == 0) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); - PlotSquared.log("&aSuccessfully processed and unloaded chunk!"); + PlotSquared.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!"); chunk.unload(true, true); return; } @@ -55,7 +93,7 @@ public class ChunkListener implements Listener { if (i >= tiles.length) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); - PlotSquared.log("&aSuccessfully processed and unloaded chunk!"); + PlotSquared.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!"); chunk.unload(true, true); return; } @@ -77,11 +115,11 @@ public class ChunkListener implements Listener { for (Entity ent : entities) { ent.remove(); } - PlotSquared.log("&aPlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); + PlotSquared.log("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); } if (tiles.length > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) { if (unload) { - PlotSquared.log("&cPlotSquared detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); + PlotSquared.log("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); cleanChunk(chunk); return true; } 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 d0e380d0c..8e168fca0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -85,6 +85,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.listeners.worldedit.WEListener; +import com.intellectualcrafters.plot.listeners.worldedit.WEManager; import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -460,7 +461,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public static void onWorldChanged(final PlayerChangedWorldEvent event) { final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); - WEListener.bypass.remove(player.getName()); + if (PlotSquared.worldEdit != null) { + WEManager.bypass.remove(player.getName()); + } ((BukkitPlayer) player).hasPerm = new HashSet<>(); ((BukkitPlayer) player).noPerm = new HashSet<>(); } @@ -1043,7 +1046,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi public static void onLeave(final PlayerQuitEvent event) { PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); EventUtil.unregisterPlayer(pp); - WEListener.bypass.remove(pp.getName()); + if (PlotSquared.worldEdit != null) { + WEManager.bypass.remove(pp.getName()); + } if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PlotSquared.getPlots(pp.getName()).values(); for (final Plot plot : plots) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java index fc23006c6..91f834c88 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/ProcessedWEExtent.java @@ -76,7 +76,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { } } } - if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) { return super.setBlock(location, block); } return false; @@ -92,7 +92,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { Eblocked = true; PlotSquared.log("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ())); } - if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) { return super.createEntity(location, entity); } return null; @@ -100,7 +100,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { @Override public boolean setBiome(Vector2D position, BaseBiome biome) { - if (WEListener.maskContains(mask, position.getBlockX(), position.getBlockZ())) { + if (WEManager.maskContains(mask, position.getBlockX(), position.getBlockZ())) { return super.setBiome(position, biome); } return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java index 5bdc38187..1f3eb35c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEExtent.java @@ -24,7 +24,7 @@ public class WEExtent extends AbstractDelegateExtent { @Override public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { - if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) { return super.setBlock(location, block); } return false; @@ -32,7 +32,7 @@ public class WEExtent extends AbstractDelegateExtent { @Override public Entity createEntity(Location location, BaseEntity entity) { - if (WEListener.maskContains(mask, location.getBlockX(), location.getBlockZ())) { + if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) { return super.createEntity(location, entity); } return null; @@ -40,7 +40,7 @@ public class WEExtent extends AbstractDelegateExtent { @Override public boolean setBiome(Vector2D position, BaseBiome biome) { - if (WEListener.maskContains(mask, position.getBlockX(), position.getBlockZ())) { + if (WEManager.maskContains(mask, position.getBlockX(), position.getBlockZ())) { return super.setBiome(position, biome); } return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index 0410d5f85..cf100dd69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -7,6 +7,7 @@ import java.util.Set; import java.util.UUID; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -31,144 +32,250 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.selections.Selection; import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.eventbus.EventHandler.Priority; import com.sk89q.worldedit.util.eventbus.Subscribe; public class WEListener implements Listener { - public static HashSet bypass = new HashSet<>(); + public final HashSet rad1 = new HashSet<>(Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size")); + public final HashSet rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove")); + public final HashSet rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl")); + public final HashSet rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid")); + public final HashSet rad2_3 = new HashSet<>(Arrays.asList("brush smooth")); + public final HashSet rad3_1 = new HashSet<>(Arrays.asList("brush gravity")); + public final HashSet rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder")); - final List monitored = Arrays.asList(new String[] { "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "move", "stack", "naturalize", "paste", "count", "regen", "copy", "cut", "" }); - public final Set blockedcmds = new HashSet<>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); - public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); + public final HashSet region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr", "regen", "copy", "cut", "green", "setbiome")); + public final HashSet regionExtend = new HashSet<>(Arrays.asList("stack")); + public final HashSet unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem")); + public final HashSet unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "gmask", "mask", "restore", "snapshot", "delchunks", "listchunks", "sel poly")); + public final HashSet unsafe2 = new HashSet<>(Arrays.asList("sel poly", "worldedit reload")); + public final HashSet restricted = new HashSet<>(Arrays.asList("up")); - @Subscribe(priority=Priority.VERY_EARLY) - public void onEditSession(EditSessionEvent event) { - String world = event.getWorld().getName(); - if (!PlotSquared.isPlotWorld(world)) { - return; - } - Actor actor = event.getActor(); - if (actor != null && actor.isPlayer()) { - String name = actor.getName(); - if (bypass.contains(name)) { - return; - } - - PlotPlayer player = UUIDHandler.getPlayer(actor.getName()); - HashSet mask = getMask(player); - if (mask.size() == 0) { - event.setExtent(new NullExtent()); - return; - } - try { - Region selection = WorldEdit.getInstance().getSession(player.getName()).getSelection(event.getWorld()); - Vector pos1 = selection.getMinimumPoint(); - Vector pos2 = selection.getMaximumPoint(); - RegionWrapper regionSelection = new RegionWrapper(Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockZ(), pos2.getBlockZ()), Math.max(pos1.getBlockZ(), pos2.getBlockZ())); - if (!regionContains(regionSelection, mask)) { - event.setExtent(new NullExtent()); - return; - } - } catch (IncompleteRegionException e) {} - if (Settings.CHUNK_PROCESSOR) { - event.setExtent(new ProcessedWEExtent(mask, event.getExtent())); - } - else { - event.setExtent(new WEExtent(mask, event.getExtent())); - } - } - } +// public final HashSet allowSingleSlash = new HashSet<>(Arrays.asList("sel", ".s", "cs", "restore", "brush", "fixwater", "fixlava", "up", "worldedit", "mask", "gmask", "snapshot", "schem", "schematic", "remove", "fill", "pumpkins", "forestgen", "removenear", "ex", "butcher", "size", "snow")); - public static boolean maskContains(HashSet mask, int x, int z) { - for (RegionWrapper region : mask) { - if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) { + public boolean checkCommand(List list, String cmd) { + for (String identifier : list) { + if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) { return true; } } return false; } - public static boolean intersects(RegionWrapper region1, RegionWrapper region2) { - if ((region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ)) { + public String reduceCmd(String cmd, boolean single) { + if (cmd.startsWith("/worldedit:/")) { + return cmd.substring(12); + } + if (cmd.startsWith("/worldedit:")) { + return cmd.substring(11); + } + if (cmd.startsWith("//")) { + return cmd.substring(2); + } + if (single && cmd.startsWith("/")) { + return cmd.substring(1); + } + return cmd; + } + + public int getInt(String s) { + try { + int max = 0; + String[] split = s.split(","); + for (String rad : split) { + int val = Integer.parseInt(rad); + if (val > max) { + max = val; + } + } + return max; + } + catch (NumberFormatException e) { + e.printStackTrace(); + return 0; + } + } + + public boolean checkVolume(PlotPlayer player, long volume, long max, Cancellable e) { + if (volume > max) { + MainUtil.sendMessage(player, C.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + "")); + e.setCancelled(true); + } + if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { + MainUtil.sendMessage(player, C.WORLDEDIT_BYPASS); + } + return true; + } + + public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) { + final Selection selection = PlotSquared.worldEdit.getSelection(p); + if (selection == null) { return true; } - return false; - } - - public static boolean regionContains(RegionWrapper selection, HashSet mask) { - for (RegionWrapper region : mask) { - if (intersects(region, selection)) { + final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); + final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); + HashSet mask = WEManager.getMask(pp); + if (Settings.REQUIRE_SELECTION) { + String arg = null; + if (mask.size() == 0) { + arg = "pos1 + pos2"; + } + if (!WEManager.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) { + arg = "pos1"; + } + if (!WEManager.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) { + arg = "pos2"; + } + if (arg != null) { + e.setCancelled(true); + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, arg); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); + } return true; } } - return false; - } - - public HashSet getMask(PlotPlayer player) { - HashSet regions = new HashSet<>(); - UUID uuid = player.getUUID(); - for (Plot plot : PlotSquared.getPlots(player.getLocation().getWorld()).values()) { - if (!plot.settings.getMerged(0) && !plot.settings.getMerged(3)) { - if (plot.isOwner(uuid) || plot.helpers.contains(uuid)) { - Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); - Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); - regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); - } + RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ()); + if (!WEManager.regionContains(region, mask)) { + MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "pos1 + pos2"); + e.setCancelled(true); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); } + return true; } - return regions; + long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier; + return checkVolume(pp, volume, max, e); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerCommand(final PlayerCommandPreprocessEvent e) { + public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) { final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - return; + return true; } String cmd = e.getMessage().toLowerCase(); - if (cmd.contains(" ")) { - cmd = cmd.substring(0, cmd.indexOf(" ")); + boolean single = true; + String[] split = cmd.split(" "); + + long maxVolume = Settings.WE_MAX_VOLUME; + long maxIterations = Settings.WE_MAX_ITERATIONS; + + if (WEManager.bypass.contains(pp.getName())) { + return true; } - if (this.restrictedcmds.contains(cmd)) { - final Plot plot = MainUtil.getPlot(pp.getLocation()); - if ((plot == null) || (!plot.isOwner(pp.getUUID()) && !plot.helpers.contains(DBFunc.everyone) && !plot.helpers.contains(pp.getUUID()))) { + if (split.length >= 2) { + String reduced = reduceCmd(split[0], single); + String reduced2 = reduceCmd(split[0] + " " + split[1], single); + if (rad1.contains(reduced)) { + long volume = getInt(split[1]) * 256; + return checkVolume(pp, volume, maxVolume, e); + } + if (rad2.contains(reduced)) { + if (split.length >= 3) { + long volume = getInt(split[2]) * 256; + return checkVolume(pp, volume, maxVolume, e); + } + return true; + } + if (rad2_1.contains(reduced)) { + if (split.length >= 4) { + long volume = getInt(split[2]) * getInt(split[3]); + return checkVolume(pp, volume, maxVolume, e); + } + return true; + } + if (rad2_2.contains(reduced)) { + if (split.length >= 3) { + long radius = getInt(split[2]); + long volume = radius * radius; + return checkVolume(pp, volume, maxVolume, e); + } + return true; + } + if (rad2_3.contains(reduced2)) { + if (split.length >= 3) { + if (split.length == 4) { + int iterations = getInt(split[3]); + if (iterations > maxIterations) { + MainUtil.sendMessage(pp, C.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + "")); + e.setCancelled(true); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); + } + return true; + } + } + long radius = getInt(split[2]); + long volume = radius * radius; + return checkVolume(pp, volume, maxVolume, e); + } + return true; + } + if (rad3_1.contains(reduced2)) { + if (split.length >= 3) { + int i = 2; + if (split[i].equalsIgnoreCase("-h")) { + i = 3; + } + long radius = getInt(split[i]); + long volume = radius * radius; + return checkVolume(pp, volume, maxVolume, e); + } + return true; + } + if (rad3_2.contains(reduced2)) { + if (split.length >= 4) { + int i = 3; + if (split[i].equalsIgnoreCase("-h")) { + i = 4; + } + long radius = getInt(split[i]); + long volume = radius * radius; + return checkVolume(pp, volume, maxVolume, e); + } + return true; + } + if (unsafe2.contains(reduced)) { + MainUtil.sendMessage(pp, C.WORLDEDIT_UNSAFE); e.setCancelled(true); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); + } + return true; } - return; - } else if (this.blockedcmds.contains(cmd)) { + if (regionExtend.contains(reduced)) { + return checkSelection(p, pp, getInt(split[1]), maxVolume, e); + } + } + String reduced = reduceCmd(split[0], single); + if (unsafe1.contains(reduced)) { + MainUtil.sendMessage(pp, C.WORLDEDIT_UNSAFE); e.setCancelled(true); - return; - } - if (!Settings.REQUIRE_SELECTION) { - return; - } - for (final String c : this.monitored) { - if (cmd.equals("//" + c) || cmd.equals("/" + c) || cmd.equals("/worldedit:/" + c)) { - final Selection selection = PlotSquared.worldEdit.getSelection(p); - if (selection == null) { - return; - } - final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); - final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); - - HashSet mask = getMask(pp); - if (mask.size() == 0) { - MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Both points"); - return; - } - if (!maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) { - e.setCancelled(true); - MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 1"); - } - if (!maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) { - e.setCancelled(true); - MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "Position 2"); - } + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); } } + if (restricted.contains(reduced)) { + Plot plot = MainUtil.getPlot(pp.getLocation()); + if (plot != null && plot.isAdded(pp.getUUID())) { + return true; + } + e.setCancelled(true); + MainUtil.sendMessage(pp, C.NO_PLOT_PERMS); + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); + } + return true; + } + if (region.contains(reduced)) { + return checkSelection(p, pp, 1, maxVolume, e); + } + return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java new file mode 100644 index 000000000..3ce548c36 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEManager.java @@ -0,0 +1,55 @@ +package com.intellectualcrafters.plot.listeners.worldedit; + +import java.util.HashSet; +import java.util.UUID; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.MainUtil; + +public class WEManager { + public static HashSet bypass = new HashSet<>(); + + public static boolean maskContains(HashSet mask, int x, int z) { + for (RegionWrapper region : mask) { + if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) { + return true; + } + } + return false; + } + + public static HashSet getMask(PlotPlayer player) { + HashSet regions = new HashSet<>(); + UUID uuid = player.getUUID(); + for (Plot plot : PlotSquared.getPlots(player.getLocation().getWorld()).values()) { + if (!plot.settings.getMerged(0) && !plot.settings.getMerged(3)) { + if (plot.isOwner(uuid) || plot.helpers.contains(uuid)) { + Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); + regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); + } + } + } + return regions; + } + + public static boolean intersects(RegionWrapper region1, RegionWrapper region2) { + if ((region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ)) { + return true; + } + return false; + } + + public static boolean regionContains(RegionWrapper selection, HashSet mask) { + for (RegionWrapper region : mask) { + if (intersects(region, selection)) { + return true; + } + } + return false; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java new file mode 100644 index 000000000..d8fc66a1a --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java @@ -0,0 +1,43 @@ +package com.intellectualcrafters.plot.listeners.worldedit; + +import java.util.HashSet; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.sk89q.worldedit.event.extent.EditSessionEvent; +import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.util.eventbus.EventHandler.Priority; +import com.sk89q.worldedit.util.eventbus.Subscribe; + +public class WESubscriber { + @Subscribe(priority=Priority.VERY_EARLY) + public void onEditSession(EditSessionEvent event) { + String world = event.getWorld().getName(); + if (!PlotSquared.isPlotWorld(world)) { + return; + } + Actor actor = event.getActor(); + if (actor != null && actor.isPlayer()) { + String name = actor.getName(); + if (WEManager.bypass.contains(name)) { + return; + } + + PlotPlayer player = UUIDHandler.getPlayer(actor.getName()); + HashSet mask = WEManager.getMask(player); + if (mask.size() == 0) { + event.setExtent(new NullExtent()); + return; + } + if (Settings.CHUNK_PROCESSOR) { + event.setExtent(new ProcessedWEExtent(mask, event.getExtent())); + } + else { + event.setExtent(new WEExtent(mask, event.getExtent())); + } + } + } +} From 5ca5ff1198a6c6b632601eebd5c28f8746b66080 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 19 Apr 2015 10:44:11 +1000 Subject: [PATCH 176/223] Fixed fastclear --- PlotSquared/pom.xml | 2 +- .../java/com/intellectualcrafters/plot/generator/HybridPop.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 515148488..97e95c67e 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.16 + 2.9.17 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 7637417e0..2f5a2282c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -124,7 +124,7 @@ public class HybridPop extends PlotPopulator { for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - if (contains(requiredRegion, this.X + x, this.Z + z)) { + if (contains(requiredRegion, x, z)) { if (this.doFilling) { for (short y = 1; y < this.plotheight; y++) { setBlock(x, y, z, this.filling); From d8fbd90c52f4863484fc7496d051b7249019aaed Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 19 Apr 2015 23:42:55 +1000 Subject: [PATCH 177/223] Biome update --- .../listeners/worldedit/WESubscriber.java | 6 ++++ .../plot/util/MainUtil.java | 34 +++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java index d8fc66a1a..402e6fd37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WESubscriber.java @@ -3,9 +3,12 @@ package com.intellectualcrafters.plot.listeners.worldedit; import java.util.HashSet; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.extension.platform.Actor; @@ -29,6 +32,9 @@ public class WESubscriber { PlotPlayer player = UUIDHandler.getPlayer(actor.getName()); HashSet mask = WEManager.getMask(player); if (mask.size() == 0) { + if (Permissions.hasPermission(player, "plots.worldedit.bypass")) { + MainUtil.sendMessage(player, C.WORLDEDIT_BYPASS); + } event.setExtent(new NullExtent()); return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index ed8b3d62c..319b80df4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -200,20 +200,25 @@ public class MainUtil { BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc)); } -// public static void update(final Location loc) { -// final String world = loc.getWorld(); -// int ox = loc.getX() >> 4; -// int oz = loc.getZ() >> 4; -// final ArrayList chunks = new ArrayList<>(); -// final int distance = BukkitUtil.getViewDistance(); -// for (int cx = -distance; cx <= distance; cx++) { -// for (int cz = -distance; cz <= distance; cz++) { -// final ChunkLoc chunk = new ChunkLoc(ox + cx, oz + cz); -// chunks.add(chunk); -// } -// } -// BlockUpdateUtil.setBlockManager.update(world, chunks); -// } + public static void update(final Plot plot) { + Location bot = getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + Location top = getPlotBottomLoc(plot.world, plot.id); + + int bx = bot.getX() >> 4; + int bz = bot.getZ() >> 4; + + int tx = 1 + (top.getX() >> 4); + int tz = 1 + (top.getZ() >> 4); + + ArrayList chunks = new ArrayList<>(); + + for (int x = bx; x <= tx; x++) { + for (int z = bz; z <= tz; z++) { + chunks.add(new ChunkLoc(x, z)); + } + } + BlockUpdateUtil.setBlockManager.update(plot.world, chunks); + } public static void createWorld(final String world, final String generator) { } @@ -637,6 +642,7 @@ public class MainUtil { final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; final int topZ = getPlotTopLoc(world, plot.id).getZ(); BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); + update(plot); } public static int getHeighestBlock(final String world, final int x, final int z) { From 5c58f14d1a707bd7ff20b5c02169e92e61207ba6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 19 Apr 2015 23:55:01 +1000 Subject: [PATCH 178/223] Worldedit mask --- .../java/com/intellectualcrafters/plot/config/C.java | 2 +- .../plot/listeners/worldedit/WEListener.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 1666968da..7539ad60f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -89,7 +89,7 @@ public enum C { WORLDEDIT_VOLUME("$2You cannot select a volume of %current%. The maximum volume you can modify is %max%."), WORLDEDIT_ITERATIONS("$2You cannot iterate %current% times. The maximum number of iterations allowed is %max%."), WORLDEDIT_UNSAFE("$2Access to that command has been blocked"), - WORLDEDIT_BYPASS("$2&oTo bypass your restrictions use $3/plot wea"), + WORLDEDIT_BYPASS("$2&oTo bypass your restrictions use $4/plot wea"), WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted."), WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted."), /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index cf100dd69..a1182c30d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -118,15 +118,16 @@ public class WEListener implements Listener { final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector(); final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector(); HashSet mask = WEManager.getMask(pp); + RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ()); if (Settings.REQUIRE_SELECTION) { String arg = null; - if (mask.size() == 0) { + if (!WEManager.regionContains(region, mask)) { arg = "pos1 + pos2"; } - if (!WEManager.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) { + else if (!WEManager.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) { arg = "pos1"; } - if (!WEManager.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) { + else if (!WEManager.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) { arg = "pos2"; } if (arg != null) { @@ -138,7 +139,6 @@ public class WEListener implements Listener { return true; } } - RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ()); if (!WEManager.regionContains(region, mask)) { MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "pos1 + pos2"); e.setCancelled(true); @@ -155,7 +155,7 @@ public class WEListener implements Listener { public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) { final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!PlotSquared.isPlotWorld(p.getWorld().getName()) || Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + if (!PlotSquared.isPlotWorld(p.getWorld().getName())) { return true; } String cmd = e.getMessage().toLowerCase(); From eb7c6df42af24976baea8519a781777cdd9b502e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 21 Apr 2015 22:48:18 +1000 Subject: [PATCH 179/223] Working on fixing plot setup --- .../plot/PlotSquared.java | 11 +- .../plot/commands/Setup.java | 70 ++++- .../intellectualcrafters/plot/config/C.java | 2 +- .../plot/object/PlotGenerator.java | 3 +- .../plot/object/SetupObject.java | 45 ++- .../plot/util/SetBlockQueue.java | 198 ++++++++++++++ .../plot/util/SetupUtils.java | 6 +- .../plot/util/bukkit/BukkitSetupUtils.java | 23 +- PlotSquared/src/main/resources/german.yml | 233 ++++++++++++++++ PlotSquared/src/main/resources/s_chinese.yml | 257 ++++++++++++++++++ .../main/resources/s_chinese_unescaped.yml | 257 ++++++++++++++++++ 11 files changed, 1074 insertions(+), 31 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java create mode 100644 PlotSquared/src/main/resources/german.yml create mode 100644 PlotSquared/src/main/resources/s_chinese.yml create mode 100644 PlotSquared/src/main/resources/s_chinese_unescaped.yml diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 0205052d4..70b848e1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -564,19 +564,22 @@ public class PlotSquared { } // Copy files - copyFile("town.template"); - copyFile("skyblock.template"); + copyFile("town.template", "templates"); + copyFile("skyblock.template", "templates"); + copyFile("german.yml", "translations"); + copyFile("s_chinese_unescaped.yml", "translations"); + copyFile("s_chinese.yml", "translations"); showDebug(); } - public void copyFile(String file) { + public void copyFile(String file, String folder) { try { byte[] buffer = new byte[2048]; File output = PlotSquared.IMP.getDirectory(); if (!output.exists()) { output.mkdirs(); } - File newFile = new File((output + File.separator + "templates" + File.separator + file)); + File newFile = new File((output + File.separator + folder + File.separator + file)); if (newFile.exists()) { return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index d93203c31..f55dc2513 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -20,14 +20,19 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map.Entry; import org.apache.commons.lang.StringUtils; +import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.BlockManager; @@ -38,6 +43,25 @@ public class Setup extends SubCommand { public Setup() { super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true); } + + public void displayGenerators(PlotPlayer plr) { + MainUtil.sendMessage(plr, "&6What generator do you want?"); + for (Entry entry : SetupUtils.generators.entrySet()) { +// + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared") + if (entry.getKey().equals("PlotSquared")) { + MainUtil.sendMessage(plr, "\n&8 - &2" + entry.getKey() + "(Hybrid Generator)"); + } + else if (entry.getValue() instanceof HybridGen) { + MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Hybrid Generator)"); + } + else if (entry.getValue() instanceof PlotGenerator) { + MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Plot Generator)"); + } + else { + MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Unknown structure)"); + } + } + } @Override public boolean execute(final PlotPlayer plr, final String... args) { @@ -47,9 +71,8 @@ public class Setup extends SubCommand { final SetupObject object = new SetupObject(); SetupUtils.setupMap.put(name, object); SetupUtils.manager.updateGenerators(); - final String prefix = "\n&8 - &7"; sendMessage(plr, C.SETUP_INIT); - MainUtil.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")); + displayGenerators(plr); return false; } if (args.length == 1) { @@ -80,28 +103,49 @@ public class Setup extends SubCommand { sendMessage(plr, C.SETUP_INIT); return false; } - object.generator = args[0]; + object.setupGenerator = args[0]; object.current++; final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : ""; MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial); break; } case 1: { // choose world type - List types; + List allTypes = Arrays.asList(new String[] { "default", "augmented", "partial" }); + ArrayList types = new ArrayList<>(); + if (SetupUtils.generators.get(object.setupGenerator) instanceof PlotGenerator) { + types.add("default"); + } + types.add("augmented"); if (Settings.ENABLE_CLUSTERS) { - types = Arrays.asList(new String[] { "default", "augmented", "partial" }); - } else { - types = Arrays.asList(new String[] { "default", "augmented" }); + types.add("partial"); } if ((args.length != 1) || !types.contains(args[0].toLowerCase())) { MainUtil.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); return false; } - object.type = types.indexOf(args[0].toLowerCase()); + object.type = allTypes.indexOf(args[0].toLowerCase()); if (object.type == 0) { object.current++; if (object.step == null) { - object.step = SetupUtils.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); + ChunkGenerator gen = SetupUtils.generators.get(object.setupGenerator); + if (gen instanceof PlotGenerator) { + object.plotManager = object.setupGenerator; + object.step = ((PlotGenerator) SetupUtils.generators.get(object.setupGenerator)).getNewPlotWorld(null).getSettingNodes(); + ((PlotGenerator) gen).processSetup(object, plr); + } + else { + + + MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as PlotGenerator"); + MainUtil.sendMessage(plr, "&7Searching for a configuration script..."); + + boolean script = false; + // TODO allow external configuration scripts + + MainUtil.sendMessage(plr, "&cNo script has been found:"); + MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin"); + object.step = ((PlotGenerator) SetupUtils.generators.get("PlotSquared")).getNewPlotWorld(null).getSettingNodes(); + } } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); @@ -166,7 +210,13 @@ public class Setup extends SubCommand { } object.world = args[0]; SetupUtils.setupMap.remove(plr.getName()); - final String world = SetupUtils.manager.setupWorld(object); + final String world; + if (object.manager == null) { + world = SetupUtils.manager.setupWorld(object); + } + else { + + } try { plr.teleport(BlockManager.manager.getSpawn(world)); } catch (final Exception e) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 7539ad60f..7458b41d2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -187,7 +187,7 @@ public enum C { /* * Core Stuff */ - PREFIX("$3[$1P\u00B2$3] "), + PREFIX("$3[$1P2$3] "), ENABLED("$1PlotSquared is now enabled"), EXAMPLE_MESSAGE("$2This is an example message &k!!!"), /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 9bff22155..368e15eee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -177,5 +177,6 @@ public abstract class PlotGenerator extends ChunkGenerator { public abstract PlotWorld getNewPlotWorld(final String world); public abstract PlotManager getPlotManager(); - + + public void processSetup(SetupObject object, PlotPlayer player) {}; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java index f809c99ef..6e8cdbacd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/SetupObject.java @@ -1,13 +1,52 @@ package com.intellectualcrafters.plot.object; import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.util.SetupUtils; public class SetupObject { + + /** + * Specify a SetupUtils object here to override the existing + */ + public SetupUtils setupManager; + + /** + * The current state + */ public int current = 0; + + /** + * The index in generator specific settings + */ public int setup_index = 0; + + /** + * The name of the world + */ public String world = null; - public String generator = null; - public int type = 0; - public int terrain = 0; + + /** + * The name of the plot manager + */ + public String plotManager = null; + + /** + * The name of the generator to use for world creation + */ + public String setupGenerator = null; + + /** + * The management type + */ + public int type; + + /** + * The terrain type + */ + public int terrain; + + /** + * Generator specific configuration steps + */ public ConfigurationNode[] step = null; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java new file mode 100644 index 000000000..0a89424dc --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -0,0 +1,198 @@ +package com.intellectualcrafters.plot.util; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map.Entry; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.util.TaskManager; + +public class SetBlockQueue { + + private volatile static HashMap blocks; + private volatile static int allocate = 50; + private volatile static boolean running = false; + private volatile static boolean locked = false; + private volatile static HashSet runnables; + + public synchronized static void allocate(int t) { + allocate = t; + } + + public synchronized static void addNotify(Runnable whenDone) { + if (runnables == null) { + TaskManager.runTask(whenDone); + } + else { + runnables.add(whenDone); + } + } + + public synchronized static void init() { + if (blocks == null) { + blocks = new HashMap<>(); + runnables = new HashSet<>(); + } + if (!running) { + TaskManager.index.increment(); + final int current = TaskManager.index.intValue(); + int task = TaskManager.runTaskRepeat(new Runnable() { + @Override + public void run() { + if (locked) { + return; + } + if (blocks.size() == 0) { + PlotSquared.TASK.cancelTask(TaskManager.tasks.get(current)); + for (Runnable runnable : runnables) { + TaskManager.runTask(runnable); + } + runnables = null; + blocks = null; + running = false; + return; + } + long start = System.currentTimeMillis() + allocate; + Iterator> i = blocks.entrySet().iterator(); + while (System.currentTimeMillis() < start && i.hasNext()) { + if (locked) { + return; + } + Entry n = i.next(); + i.remove(); + ChunkWrapper chunk = n.getKey(); + int X = chunk.x << 4; + int Z = chunk.z << 4; + PlotBlock[][] blocks = n.getValue(); + String world = chunk.world; + for (int j = 0; j < blocks.length; j++) { + PlotBlock[] blocksj = blocks[j]; + if (blocksj != null) { + for (int k = 0; k < blocksj.length; k++) { + PlotBlock block = blocksj[k]; + if (block != null) { + final int y = (j << 4) + (k >> 8); + final int a = (k - ((y & 0xF) << 8)); + final int z = (a >> 4); + final int x = a - (z << 4); + BlockManager.manager.functionSetBlock(world, X + x, y, Z + z, block.id, block.data); + } + } + } + } + } + } + }, 5); + TaskManager.tasks.put(current, task); + running = true; + } + } + + public static void setBlock(final String world, int x, final int y, int z, final PlotBlock block) { + locked = true; + if (!running) { + init(); + } + int X = x >> 4; + int Z = z >> 4; + x -= X << 4; + z -= Z << 4; + + ChunkWrapper wrap = new ChunkWrapper(world, X, Z); + PlotBlock[][] result = blocks.get(wrap); + if (!blocks.containsKey(wrap)) { + result = new PlotBlock[16][]; + blocks.put(wrap, result); + } + if (result[y >> 4] == null) { + result[y >> 4] = new PlotBlock[4096]; + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = block; + locked = false; + } + + private static int lastInt = 0; + private static PlotBlock lastBlock = new PlotBlock((short) 0, (byte) 0); + + public static void setBlock(final String world, int x, final int y, int z, final int id) { + locked = true; + if (!running) { + init(); + } + int X = x >> 4; + int Z = z >> 4; + x -= X << 4; + z -= Z << 4; + + ChunkWrapper wrap = new ChunkWrapper(world, X, Z); + PlotBlock[][] result = blocks.get(wrap); + if (!blocks.containsKey(wrap)) { + result = new PlotBlock[16][]; + blocks.put(wrap, result); + } + if (result[y >> 4] == null) { + result[y >> 4] = new PlotBlock[4096]; + } + if (id == lastInt) { + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = lastBlock; + } + else { + lastInt = id; + lastBlock = new PlotBlock((short) id, (byte) 0); + } + result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = lastBlock; + locked = false; + } + + public static class ChunkWrapper { + final int x; + final int z; + final String world; + + public ChunkWrapper(String world, int x, int z) { + this.world = world; + this.x = x; + this.z = z; + } + + @Override + public int hashCode() { + int result; + if (this.x >= 0) { + if (this.z >= 0) { + result = (this.x * this.x) + (3 * this.x) + (2 * this.x * this.z) + this.z + (this.z * this.z); + } else { + final int y1 = -this.z; + result = (this.x * this.x) + (3 * this.x) + (2 * this.x * y1) + y1 + (y1 * y1) + 1; + } + } else { + final int x1 = -this.x; + if (this.z >= 0) { + result = -((x1 * x1) + (3 * x1) + (2 * x1 * this.z) + this.z + (this.z * this.z)); + } else { + final int y1 = -this.z; + result = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1); + } + } + result = result * 31 + world.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ChunkWrapper other = (ChunkWrapper) obj; + return ((this.x == other.x) && (this.z == other.z) && (this.world.equals(other.world))); + } + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index f93617e8c..3d02bd779 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -3,6 +3,8 @@ package com.intellectualcrafters.plot.util; import java.util.HashMap; import java.util.Map; +import org.bukkit.generator.ChunkGenerator; + import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; @@ -10,9 +12,9 @@ import com.intellectualcrafters.plot.object.SetupObject; public abstract class SetupUtils { public static SetupUtils manager; - + public final static Map setupMap = new HashMap<>(); - public static HashMap generators = new HashMap<>(); + public static HashMap generators = new HashMap<>(); public abstract void updateGenerators(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 727593950..b908b1c81 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -31,12 +31,12 @@ public class BukkitSetupUtils extends SetupUtils { if (generator != null) { PlotSquared.removePlotWorld(testWorld); final String name = plugin.getDescription().getName(); - if (generator instanceof PlotGenerator) { - final PlotGenerator pgen = (PlotGenerator) generator; +// if (generator instanceof PlotGenerator) { +// final PlotGenerator pgen = (PlotGenerator) generator; // if (pgen.getPlotManager() instanceof SquarePlotManager) { - SetupUtils.generators.put(name, pgen); + SetupUtils.generators.put(name, generator); // } - } +// } } } } @@ -52,22 +52,25 @@ public class BukkitSetupUtils extends SetupUtils { if (object.type != 0) { PlotSquared.config.set("worlds." + world + "." + "generator.type", object.type); PlotSquared.config.set("worlds." + world + "." + "generator.terrain", object.terrain); - PlotSquared.config.set("worlds." + world + "." + "generator.plugin", object.generator); + PlotSquared.config.set("worlds." + world + "." + "generator.plugin", object.plotManager); + if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) { + PlotSquared.config.set("worlds." + world + "." + "generator.init", object.setupGenerator); + } } try { PlotSquared.config.save(PlotSquared.configFile); } catch (final IOException e) { e.printStackTrace(); } - if (object.type == 0) { + if (object.setupGenerator != null) { if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.generator); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.setupGenerator); } else { if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.generator); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.setupGenerator); } else { final WorldCreator wc = new WorldCreator(object.world); - wc.generator(object.generator); + wc.generator(object.setupGenerator); wc.environment(Environment.NORMAL); Bukkit.createWorld(wc); } @@ -99,7 +102,7 @@ public class BukkitSetupUtils extends SetupUtils { if (!(generator instanceof PlotGenerator)) { return null; } - for (Entry entry : generators.entrySet()) { + for (Entry entry : generators.entrySet()) { if (entry.getValue().getClass().getName().equals(generator.getClass().getName())) { return entry.getKey(); } diff --git a/PlotSquared/src/main/resources/german.yml b/PlotSquared/src/main/resources/german.yml new file mode 100644 index 000000000..34f1bf5f1 --- /dev/null +++ b/PlotSquared/src/main/resources/german.yml @@ -0,0 +1,233 @@ +### TEMPLATE ### +# Translated by: Krauti2 / EvilOlaf +# +### TEMPLATE ### +FAILED_CONFIRM: "$2Es gibt keine zur Bestätigung ausstehenden Befehle!" +REQUIRES_CONFIRM: "$2Bist du sicher, dass du diesen Befehl ausführen willst: $1%s$2?n$2Die Änderung ist unwiderruflich! Wenn du sicher bist: $1/plot confirm" +MOVE_SUCCESS: "$4Plot erfolgreich verschoben." +REQUIRES_UNOWNED: "$2Der angegebene Ort ist bereits belegt." +COMPASS_TARGET: "$4Plot erfolgreich mit dem Kompass anvisiert." +CLUSTER_AVAILABLE_ARGS: "$1Die folgenden Parameter sind verfügbar: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4helpers$2, $4info$2, $4tp$2, $4sethome" +CLUSTER_LIST_HEADING: "$2Es gibt $1%s$2 Cluster in dieser Welt." +CLUSTER_LIST_ELEMENT: "$2 - $1%sn" +CLUSTER_INTERSECTION: "$2Der vorgeschlagene Bereich überlappt mit $1%s$2 existierendem/n Cluster/n" +CLUSTER_ADDED: "$4Cluster erfolgreich erstellt." +CLUSTER_DELETED: "$4Cluster erfolgreich gelöscht." +CLUSTER_RESIZED: "$4Größe des Clusters wurde erfolgreich geändert." +CLUSTER_ADDED_USER: "$4Spieler erfolgreich zum Cluster hinzugefügt." +CANNOT_KICK_PLAYER: "$2Du kannst diesen Spieler nicht kicken." +CLUSTER_INVITED: "$1Du wurdest in folgenden Cluster eingeladen: $2%s" +CLUSTER_REMOVED: "$1Du wurdest aus folgendem Cluster enfernt: $2%s" +CLUSTER_KICKED_USER: "$4Spieler erfolgreich gekickt." +INVALID_CLUSTER: "$1Clustername ungültig: $2%s" +CLUSTER_NOT_ADDED: "$2Dieser Spieler war nicht zum Cluster hinzugefügt." +CLUSTER_CANNOT_LEAVE: "$1Du musst deinen Besitz löschen oder transferieren bevor du gehen kannst." +CLUSTER_ADDED_HELPER: "$4Helfer erfolgreich hinzugefügt." +CLUSTER_REMOVED_HELPER: "$4Helfer erfolgreich vom Cluster entfernt." +CLUSTER_REGENERATED: "$4Clusterregeneration erfolgreich gestartet" +CLUSTER_TELEPORTING: "$4Teleportiere..." +CLUSTER_INFO: "$1Aktueller Cluster: $2%id%n$1Name: $2%name%n$1Besitzer: $2%owner%n$1Größe: $2%size%n$1Rechte: $2%rights%" +CLUSTER_CURRENT_PLOTID: "$1Aktueller Plot: $2%s" +BORDER: "$2Du befindest dich ausserhalb der aktuellen Weltengrenze" +UNCLAIM_SUCCESS: "$4Dieser Plot gehört dir jetzt nicht mehr." +REQUIRE_SELECTION_IN_MASK: "$2%s deiner Selektion befindet sich nicht innerhalb deines Plots. Du kannst Änderungen nur innerhalb deines Plots vornehmen." +RECORD_PLAY: "$2%player $2startete Spielaufzeichnung $1%name" +NOTIFY_ENTER: "$2%player $2betritt deinen Plot ($1%plot$2)" +NOTIFY_LEAVE: "$2%player $2verlies deinen Plot ($1%plot$2)" +SWAP_SYNTAX: "$2/plots swap " +SWAP_SUCCESS: "$4Plots erfolgreich getauscht" +COMMENT_SYNTAX: "$2Syntax: /plots comment " +INVALID_INBOX: "$2Dieses Postfach ist ungültig.n$1Akzeptierte Werte: %s" +COMMENT_REMOVED: "$4Erfolgreich gelöscht: %s." +COMMENT_ADDED: "$4Ein Kommentar wurde hinterlassen." +NOT_CONSOLE: "$2Aus Sicherheitsgründen kann dieser Befehl nur von der Konsole ausgeführt werden." +IS_CONSOLE: "$2Dieser Befehl kann nur von einem Spieler ausgeführt werden." +CLIPBOARD_SET: "$2Der aktuelle Plot wird in die Zwischenablage kopiert. Benutze $1/plot paste$2 um ihn einzufügen." +PASTED: "$4Die Plotauswahl wurde erfolgreich eingefügt. Die Zwischenablage wurde geleert." +PASTE_FAILED: "$2Einfügen fehlgeschlagen: $2%s" +NO_CLIPBOARD: "$2Deine Zwischenablage ist leer." +CLIPBOARD_INFO: "$2Aktuelle Auswahl - Plot ID: $1%id$2, Breite: $1%width$2, Anzahl Blöcke: $1%total$2" +RATING_NOT_VALID: "$2Wähle eine Zahl zwischen 1 und 10" +RATING_ALREADY_EXISTS: "$2Du hast diesen Plot bereits bewertet: $2%s" +RATING_APPLIED: "$4Du hast diesen Plot erfolgreich bewertet: $2%s" +RATING_NOT_YOUR_OWN: "$2Du kannst deinen eigenen Plot nicht selbst bewerten." +RATING_NOT_OWNED: "$2Plots ohne Besitzer können nicht bewertet werden." +ECON_DISABLED: "$2Ökonomie ist nicht aktiviert." +CANNOT_AFFORD_PLOT: "$2Du kannst dir diesen Plot nicht leisten. Er kostet $1%s" +NOT_FOR_SALE: "$2Dieser Plot steht nicht zum Verkauf." +CANNOT_BUY_OWN: "$2Du kannst deinen eigenen Plot nicht kaufen." +PLOT_SOLD: "$4Dein Plot $1%s$4, wurde an $1%s$4 für $1$%s$4 verkauft." +CANNOT_AFFORD_MERGE: "$2Du kannst dir das Zusammenfügen der Plots nicht leisten. Es kostet $1%s" +ADDED_BALANCE: "$1%s $2wurden deinem Guthaben hinzugefügt." +REMOVED_BALANCE: "$1%s $2wurden von deinem Guthaben abgezogen." +SETUP_INIT: "$1Verwendung: $2/plot setup " +SETUP_STEP: "$3[$1Schritt %s$3] $1%s $2- $1Erwarte: $2%s $1Standard: $2%s" +SETUP_INVALID_ARG: "$2%s ist kein gültiger Wer für Schritt %s. Um Setup abzubrechen verwende: $1/plot setup cancel" +SETUP_VALID_ARG: "$2Wert $1%s $2gesetzt auf %s" +SETUP_FINISHED: "$3Falls du MULTIVERSE oder MULTIWORLD verwendest sollte die Welt generiert worden sein. Andernfalls musst du die Welt manuell über bukkit.yml hinzufügen." +SETUP_WORLD_TAKEN: "$2%s ist bereits eine bekannte Plotwelt" +SETUP_MISSING_WORLD: "$2Du musst einen Namen für die Welt vergeben ($1/plot setup &l$1 $2)n$1Zusätzliche Befehle:n$2 - $1/plot setup n$2 - $1/plot setup backn$2 - $1/plot setup cancel" +SETUP_MISSING_GENERATOR: "$2Du musst einen Generator angeben ($1/plot setup &l&r$2)n$1Zusätzliche Befehle:n$2 - $1/plot setup n$2 - $1/plot setup backn$2 - $1/plot setup cancel" +SETUP_INVALID_GENERATOR: "$2Ungültiger Generarator. Mögliche Optionen: %s" +SCHEMATIC_MISSING_ARG: "$2Du musst einen Wert angeben. Gültige Werte: $1test $2 , $1save$2 , $1paste $2, $1exportall" +SCHEMATIC_INVALID: "$2Diese Schematic ist ungültig: $2%s" +SCHEMATIC_VALID: "$2Diese Schematic ist gültig." +SCHEMATIC_PASTE_FAILED: "$2Einfügen der Schematic fehlgeschlagen" +SCHEMATIC_PASTE_SUCCESS: "$4Einfügen der Schematic erfolgreich." +TITLE_ENTERED_PLOT: "Du betrittst Plot %world%;%x%;%z%" +TITLE_ENTERED_PLOT_COLOR: "GOLD" +TITLE_ENTERED_PLOT_SUB: "Besitzer: %s" +TITLE_ENTERED_PLOT_SUB_COLOR: "RED" +TITLE_LEFT_PLOT: "Du verlässt Plot %s" +TITLE_LEFT_PLOT_COLOR: "GOLD" +TITLE_LEFT_PLOT_SUB: "Besitzer: %s" +TITLE_LEFT_PLOT_SUB_COLOR: "RED" +PREFIX_GREETING: "$1%id%$2> " +PREFIX_FAREWELL: "$1%id%$2> " +PREFIX: "$3[$1P²$3] " +ENABLED: "$1PlotSquared wurde aktiviert" +EXAMPLE_MESSAGE: "$2Das ist eine Beispielnachricht &k!!!" +RELOADED_CONFIGS: "$1Übersetzungen und Welteneinstellungen wurden neu geladen" +RELOAD_FAILED: "$2Erneutes Laden der Konfiguration fehlgeschlagen" +BOSSBAR_CLEARING: "$2Leere Plot: $1%id%" +ALIAS_SET_TO: "$2Plot Alias geseztt auf $1%alias%" +MISSING_ALIAS: "$2Du musst ein Alias angeben" +ALIAS_TOO_LONG: "$2Der Alias darf nicht länger als 50 Zeichen sein" +ALIAS_IS_TAKEN: "$2Dieser Alias wird bereits verwendet" +MISSING_POSITION: "$2Du musst eine Position angeben. Mögliche Werte: $1none" +POSITION_SET: "$1Die Position wurde auf deinen aktuellen Standort gesetzt" +HOME_ARGUMENT: "$2Verwende /plot set home [none]" +INVALID_POSITION: "$2That is not a valid position value" +TIME_FORMAT: "$1%hours%, %min%, %sec%" +NO_SCHEMATIC_PERMISSION: "$2Du hast keine Berechtigung Schmatics zu verwenden: $1%s" +NO_PERMISSION: "$2Dir fehlt folgende Berechtigung: $1%s" +NO_PLOT_PERMS: "$2Diese Aktion kann nur der Besitzer des Plots" +CANT_CLAIM_MORE_PLOTS: "$2Du kannst keine weiteren Plots besitzen." +CANT_CLAIM_MORE_PLOTS_NUM: "$2Du kannst nicht mehr als $1%s $2Plots auf einmal einnehmen." +YOU_BE_DENIED: "$2Es ist dir nicht gestattet diesen Plot zu betreten." +NO_PERM_MERGE: "$2Du bist nicht Besitzer des Plots $1%plot%" +UNLINK_REQUIRED: "$2Die Plots müssen vorher getrennt (unlink) werden." +UNLINK_IMPOSSIBLE: "$2Die Trennung (unlink) funktioniert nur auf Megaplots." +UNLINK_SUCCESS: "$2Trennung erfolgreich." +NO_MERGE_TO_MEGA: "$2Füge einzelne Plots deinem Megaplot hinzu, nicht anders herum." +NOT_VALID_SUBCOMMAND: "$2Das ist kein gültiger Parameter." +DID_YOU_MEAN: "$2Meinst du: $1%s" +NAME_LITTLE: "$2%s Name ist zu kurz, $1%s$2<$1%s" +NO_COMMANDS: "$2Du hast für keinen Befehl eine Berechtigung." +SUBCOMMAND_SET_OPTIONS_HEADER: "$2Mögliche Werte: " +COMMAND_SYNTAX: "$1Verwendung: $2%s" +INVALID_PLAYER: "$2Spieler nicht gefunden: $1%s." +COMMAND_WENT_WRONG: "$2Beim ausführen des Befehls ging etwas schief..." +PURGE_SYNTAX: "Verwende /plot purge " +PURGE_SUCCESS: "$4%s Plots erfolgreich gelöscht." +TRIM_SYNTAX: "Verwende /plot trim " +TRIM_START: "Starte Weltenbeschneidung..." +TRIM_IN_PROGRESS: "Die Weltenbeschneidung ist bereits gestartet!" +NOT_VALID_HYBRID_PLOT_WORLD: "Hybrid Plot Manager wird für diese Aktion benötigt." +NO_FREE_PLOTS: "$2Es sind keine freien Plots verfügbar." +NOT_IN_PLOT: "$2Du befindest dich nicht auf einem Plot." +NOT_IN_CLUSTER: "$2Du musst dich innerhalb eines Plot Clusters befinden um das zu tun." +NOT_IN_PLOT_WORLD: "$2Du befindest dich nicht in einer Plotwelt." +NOT_VALID_WORLD: "$2Das ist keine gültige Welt (Groß- / Kleinschreibung beachten)" +NOT_VALID_PLOT_WORLD: "$2Das ist keine gültige Plotwelt (Groß- / Kleinschreibung beachten)" +NO_PLOTS: "$2Du hast keine Plots" +NOT_VALID_BLOCK_LIST_HEADER: "$2Das ist kein gültiger Block. Gültige Blöcke sind:\n" +BLOCK_LIST_ITEM: " $1%mat%$2," +BLOCK_LIST_SEPARATER: "$1,$2 " +NEED_BIOME: "$2Du musst ein Biom angeben." +BIOME_SET_TO: "$2Plot biome gesetzt: $2" +TELEPORTED_TO_PLOT: "$1Du wurdest teleportiert." +TELEPORTED_TO_ROAD: "$2Du wurdest auf die Straße teleportiert." +TELEPORT_IN_SECONDS: "$1Teleportiere in %s Sekunden. Bewege dich nicht..." +TELEPORT_FAILED: "$2Teleportation wurde wegen einer Bewegen or Schaden abgebrochen." +SET_BLOCK_ACTION_FINISHED: "$1The last setblock action is now finished." +DEUBG_HEADER: "$1Debug Information\n" +DEBUG_SECTION: "$2>> $1&l%val%" +DEBUG_LINE: "$2>> $1%var%$2:$1 %val%\n" +NOT_VALID_DATA: "$2Das ist kein gültiger Datenwert." +NOT_VALID_BLOCK: "$2Das ist kein gültiger Block." +NOT_VALID_NUMBER: "$2Das ist keine gültige Zahl." +NOT_VALID_PLOT_ID: "$2Das ist keine gültige Plot-ID." +PLOT_ID_FORM: "$2Die Plot-ID muss wie folgt angegeben werden: $1X;Y $2z.B. $1-5;7" +NOT_YOUR_PLOT: "$2Das ist nicht dein Plot." +NO_SUCH_PLOT: "$2Ein solcher Plot existiert nicht." +PLAYER_HAS_NOT_BEEN_ON: "$2Dieser Spieler war nicht in der Plotwelt." +FOUND_NO_PLOTS: "$2Dein Suchmuster ergab keine Treffer." +CAMERA_STARTED: "$2Du verwendest den Kameramodus für Plot $1%s" +CAMERA_STOPPED: "$2Der Kameramodus wurde abeschaltet." +NEED_PLOT_NUMBER: "$2Du musst eine Plotnummer oder einen Alias angeben." +NEED_BLOCK: "$2Du musst einen Block angeben." +NEED_PLOT_ID: "$2Du musst eine Plot-ID angeben." +NEED_PLOT_WORLD: "$2Du musst eine Plotwelt angeben." +NEED_USER: "$2Du musst einen Spielernamen angeben." +PLOT_UNOWNED: "$2Für diese Aktion muss dieser Plot einen Besitzer aufweisen." +PLOT_INFO_UNCLAIMED: "$2Plot $1%s$2 hat bisher keinen Besitzer." +PLOT_INFO_HEADER: "$3====== $1INFO $3======" +PLOT_INFO: "$1ID: $2%id%$1n$1Alias: $2%alias%$1n$1Besitzer: $2%owner%$1n$1Biom: $2%biome%$1n$1Baurechte: $2%build%$1n$1Wertung: $2%rating%$1/$210$1n$1Helfer: $2%helpers%$1n$1Vertraut: $2%trusted%$1n$1Verboten: $2%denied%$1n$1Flags: $2%flags%" +PLOT_INFO_HELPERS: "$1Helfer:$2 %helpers%" +PLOT_INFO_TRUSTED: "$1Vertraute:$2 %trusted%" +PLOT_INFO_DENIED: "$1Verboten:$2 %denied%" +PLOT_INFO_FLAGS: "$1Flags:$2 %flags%" +PLOT_INFO_BIOME: "$1Biom:$2 %biome%" +PLOT_INFO_RATING: "$1Wertung:$2 %rating%" +PLOT_INFO_OWNER: "$1Besitzer:$2 %owner%" +PLOT_INFO_ID: "$1ID:$2 %id%" +PLOT_INFO_ALIAS: "$1Alias:$2 %alias%" +PLOT_INFO_SIZE: "$1Größe:$2 %size%" +PLOT_USER_LIST: " $1%user%$2," +INFO_SYNTAX_CONSOLE: "$2/plot info X;Y" +GENERATING_COMPONENT: "$1Die Generierung wurde gemäß deiner Einstellungen gestartet." +CLEARING_PLOT: "$2Plot wird asyncron geleert." +CLEARING_DONE: "$4Erfolgreich geleert. Dauerte %sms." +PLOT_NOT_CLAIMED: "$2Dieser Plot hat keinen Besitzer" +PLOT_IS_CLAIMED: "$2Dieser Plot hat bereits einen Besitzer." +CLAIMED: "$4Plot erfolgreich in Besitz genommen." +PLOT_LIST_HEADER_PAGED: "$2(Seite $1%von$2/$1%max$2) $1Liste Plots nach %word%" +PLOT_LIST_HEADER: "$1Liste aller %word% Plots" +PLOT_LIST_ITEM: "$2>> $1%id$2:$1%Welt $2- $1%owner" +PLOT_LIST_ITEM_ORDERED: "$2[$1%in$2] >> $1%id$2:$1%Welt $2- $1%owner" +PLOT_LIST_FOOTER: "$2>> $1%word% umfasst insgesamt $2%num% $1Plots %plot%." +LEFT_PLOT: "$2Du hast einen Plot verlassen." +NOT_USING_PLOTME: "$2Dieser Server verwendet das $1PlotSquared $2Plotmanagement System. Verwende stattdessen $1/plots" +WAIT_FOR_TIMER: "$2Ein zeitgeber wurde an den Plot oder an dich gebunden. Bitte warte bis die Zeit abgelaufen." +PLOT_CHAT_FORMAT: "$2[$1Plot Chat$2][$1%plot_id%$2] $1%sender%$2: $1%msg%" +DENIED_REMOVED: "$4Der Spieler darf diesen Plot wieder betreten." +DENIED_ADDED: "$4Der Spieler darf diesen Plot nicht mehr betreten." +DENIED_NEED_ARGUMENT: "$2Argumente fehlen. $1/plot denied add $2oder $1/plot helpers remove " +WAS_NOT_DENIED: "$2Der Spieler durfte diesen Plot bereits betreten." +NEED_ON_OFF: "$2Du musst einen Wert angeben. Mögliche Werte: $1on$2, $1off" +SETTING_UPDATED: "$4Einstellungen erfolgreich aktualisiert." +FLAG_KEY: "$2Schlüssel: %s" +FLAG_TYPE: "$2Typ: %s" +FLAG_DESC: "$2Beschreibung: %s" +NEED_KEY: "$2Mögliche Werte: $1%values%" +NOT_VALID_FLAG: "$2Ungültige Flag" +NOT_VALID_VALUE: "$2Wert der Flag muss alphanumerisch angegeben werden." +FLAG_NOT_IN_PLOT: "$2Diese Flag wurde in diesem Plot nicht gesetzt." +FLAG_NOT_REMOVED: "$2Die Flag konnte nicht entfernt werden." +FLAG_NOT_ADDED: "$2Flag konnte nicht gesetzt werden." +FLAG_REMOVED: "$4Flag erfolgreich entfernt." +FLAG_ADDED: "$4Successfully added flag" +HELPER_ADDED: "$4Helfer erfolgreich zu diesem Plot hinzugefügt." +HELPER_REMOVED: "$4Helfer erfolgreich von diesem Plot enfernt." +HELPER_NEED_ARGUMENT: "$2Argumente fehlen. $1/plot helpers add $2oder $1/plot helpers remove " +WAS_NOT_ADDED: "$2Dieser Spieler war bisher kein Helfer auf diesem Plot." +PLOT_REMOVED_HELPER: "$1Plot %s auf dem du Helfer warst wurde wegen Inaktivität des Besitzers gelöscht." +ALREADY_OWNER: "$2Dieser Spieler ist bereits Besitzer des Plots." +ALREADY_ADDED: "$2Dieser Spieler ist bereits in dieser Kategorie." +TRUSTED_ADDED: "$4Spieler erfolgreich in diesem Plot vertraut." +TRUSTED_REMOVED: "$1Diesem Spieler wird auf diesem Plot nicht mehr vertraut." +TRUSTED_NEED_ARGUMENT: "$2Argumente fehlen. $1/plot trusted add $2oder $1/plot trusted remove " +T_WAS_NOT_ADDED: "$2Diesem Spieler wurde bisher nicht vertraut." +SET_OWNER: "$4lotbesitzer erfolgreich gesetzt." +OWNER_SIGN_LINE_1: "$1ID: $1%id%" +OWNER_SIGN_LINE_2: "$1Besitzer:" +OWNER_SIGN_LINE_3: "$2%plr%" +OWNER_SIGN_LINE_4: "$3in Besitz" +HELP_HEADER: "$3====== $1Plot² Hilfe $3======" +HELP_CATEGORY: "$1Kategorie: $2%category%$2,$1 Seite: $2%currentt%$3/$2%max%$2,$1 Zeige: $2%dis%$3/$2%total%" +HELP_INFO: "$3====== $1Wähle eine Kategorie $3======" +HELP_INFO_ITEM: "$1/plots help %category% $3- $2%category_desc%" +HELP_ITEM: "$1%usage% [%alias%]n $3- $2%desc%n" +DIRECTION: "$1Aktuelle Himmelsrichtung: %dir%" +CUSTOM_STRING: "-" \ No newline at end of file diff --git a/PlotSquared/src/main/resources/s_chinese.yml b/PlotSquared/src/main/resources/s_chinese.yml new file mode 100644 index 000000000..aaa691123 --- /dev/null +++ b/PlotSquared/src/main/resources/s_chinese.yml @@ -0,0 +1,257 @@ +### TEMPLATE ### +# Translated by: Liouftgoo/Mayomi9 +# UTF-8 ESCAPE USING: http://www.rapidmonkey.com/unicodeconverter/ +### TEMPLATE ### +camera_started: "$2\u4F60\u8FDB\u5165\u4E86\u5730\u76AE $1%s \u7684\u6444\u50CF\u673A\u6A21\u5F0F" +command_syntax: "$1\u7528\u6CD5: $2%s" +not_valid_flag: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u6807\u8BC6" +setup_world_taken: "$2%s \u5DF2\u7ECF\u662F\u5730\u76AE\u4E16\u754C\u4E86" +plot_list_item: "$2>> $1%id$2:$1%world $2- $1%owner" +schematic_invalid: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u5EFA\u7B51\u6587\u4EF6. \u539F\u56E0: $2%s" +not_valid_inbox_index: "$2\u9875\u6570 %s \u6CA1\u6709\u7559\u8A00" +setup_invalid_generator: "$2\u65E0\u6548\u7684\u751F\u6210\u53C2\u6570. \u53EF\u9009: %s" +teleported_to_road: "$2\u4F60\u4F20\u9001\u5230\u4E86\u8DEF\u4E2D" +debug_section: "$2>> $1&l%val%" +plot_id_form: "$2\u5730\u76AEID\u7684\u683C\u5F0F\u5FC5\u987B\u4E3A: $1X;Y $2\u4F8B\u5982: $1-5;7" +invalid_position: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u4F4D\u7F6E" +worldedit_unsafe: "$2\u8BE5\u6307\u4EE4\u5DF2\u7ECF\u88AB\u7981\u6B62\u4F7F\u7528" +not_in_plot_world: "$2\u4F60\u4E0D\u5728\u5730\u76AE\u4E16\u754C\u4E2D" +cannot_buy_own: "$2\u4F60\u4E0D\u80FD\u4E70\u4F60\u81EA\u5DF1\u7684\u5730\u76AE" +help_item: "$1%usage% [%alias%]&- $3- $2sc%&-" +not_valid_world: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u4E16\u754C (\u6CE8\u610F\u5927\u5C0F\u5199)" +home_argument: "$2\u7528\u6CD5 /plot set home [\u53EF\u4E0D\u586B]" +title_left_plot_color: "GOLD" +merge_not_valid: "$2\u5408\u5E76\u8BF7\u6C42\u5DF2\u5931\u6548." +debug_line: "$2>> $1%var%$2:$1 %val% " +comment_added: "$4\u6DFB\u52A0\u4E86\u4E00\u6761\u65B0\u7684\u7559\u8A00" +alias_is_taken: "$2\u8FD9\u4E2A\u522B\u540D\u5DF2\u88AB\u522B\u4EBA\u4F7F\u7528" +setup_missing_generator: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u751F\u6210\u53C2\u6570 ($1/plot setup <\u4E16\u754C\u540D\u79F0> &l<\u751F\u6210\u53C2\u6570>&r$2)&-$1\u9644\u52A0\u6307\u4EE4:&-$2 - $1/plot setup <\u53C2\u6570>&-$2 - $1/plot setup back&-$2 - $1/plot setup cancel" +block_list_separater: "$1,$2 " +alias_set_to: "$2\u5730\u76AE\u7684\u522B\u540D\u8BBE\u7F6E\u4E3A $1%alias%" +did_you_mean: "$2\u4F60\u7684\u610F\u601D\u662F $1%s $2\u5417?" +cluster_not_added: "$2\u8FD9\u4E2A\u73A9\u5BB6\u672A\u88AB\u52A0\u5165\u5730\u76AE\u7EC4\u7FA4\u4E2D" +success_merge: "$2\u5730\u76AE\u6210\u529F\u88AB\u5408\u5E76!" +position_set: "$1\u5728\u4F60\u5F53\u524D\u7684\u4F4D\u7F6E\u8BBE\u7F6E\u5BB6" +cluster_regenerated: "$4\u6210\u529F\u5F00\u59CB\u7FA4\u7EC4\u91CD\u5EFA" +not_valid_data: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u53C2\u6570\u503C." +not_for_sale: "$2\u8FD9\u5757\u5730\u76AE\u5E76\u4E0D\u51FA\u552E" +not_in_cluster: "$2\u4F60\u5FC5\u987B\u5728\u4E00\u4E2A\u5730\u76AE\u7EC4\u7FA4\u4E2D\u624D\u80FD\u8FDB\u884C\u6B64\u64CD\u4F5C" +schematic_paste_success: "$4\u5EFA\u7B51\u6587\u4EF6\u7C98\u8D34\u6210\u529F" +set_block_action_finished: "$1\u6700\u540E\u4E00\u4E2A\u65B9\u5757\u8BBE\u7F6E\u5DF2\u5B8C\u6210." +missing_alias: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u522B\u540D" +paste_failed: "$2\u7C98\u8D34\u65F6\u53D1\u751F\u9519\u8BEF. \u539F\u56E0: $2%s" +invalid_player: "$2\u672A\u627E\u5230\u73A9\u5BB6 $1%s." +plot_info_helpers: "$1\u5E2E\u624B:$2 %helpers%" +cluster_added: "$4\u6210\u529F\u521B\u5EFA\u7EC4\u7FA4." +setup_init: "$1\u7528\u6CD5: $2/plot setup <\u53C2\u6570>" +bossbar_clearing: "$2\u6B63\u5728\u6E05\u7406\u5730\u76AE $1%id%" +title_entered_plot_sub_color: "RED" +prefix_greeting: "$1%id%$2> " +not_your_plot: "$2\u8FD9\u4E0D\u662F\u4F60\u7684\u5730\u76AE." +worldedit_volume: "$2\u4F60\u65E0\u6CD5\u9009\u62E9 %current% \u7684\u7A7A\u95F4. \u6700\u5927\u7A7A\u95F4\u53EF\u4EE5\u8BBE\u7F6E\u4E3A %max%." +not_valid_plot_id: "$2\u8FD9\u4E0D\u662F\u6709\u6548\u7684\u5730\u76AEID." +unclaim_success: "$4\u4F60\u653E\u5F03\u4E86\u8FD9\u5757\u5730\u76AE." +teleport_failed: "$2\u56E0\u4E3A\u53D7\u5230\u4F24\u5BB3\u800C\u88AB\u53D6\u6D88\u4F20\u9001" +need_plot_world: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u5730\u76AE\u4E16\u754C." +plot_not_claimed: "$2\u5730\u76AE\u672A\u88AB\u9886\u53D6" +title_entered_plot_color: "GOLD" +denied_removed: "$4\u4F60\u89E3\u9664\u4E86\u8FD9\u4E2A\u5730\u76AE\u5BF9\u73A9\u5BB6\u7684\u9ED1\u540D\u5355" +plot_removed_helper: "$1\u4F60\u52A0\u5165\u7684\u5730\u76AE %s \u56E0\u4E3A\u62E5\u6709\u8005\u4E0D\u6D3B\u8DC3\u800C\u88AB\u5220\u9664\u4E86" +plotworld_incompatible: "$2\u4E24\u4E2A\u4E16\u754C\u5FC5\u987B\u76F8\u4E92\u517C\u5BB9" +generating_component: "$1\u5F00\u59CB\u6839\u636E\u4F60\u7684\u8BBE\u5B9A\u751F\u6210" +not_valid_block_list_header: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u65B9\u5757. \u6709\u6548\u7684\u65B9\u5757: " +alias_too_long: "$2\u522B\u540D\u7684\u957F\u5EA6\u5FC5\u987B\u5C0F\u4E8E50\u4E2A\u5B57\u7B26" +move_success: "$4\u6210\u529F\u79FB\u9664\u5730\u76AE." +no_plot_perms: "$2\u4F60\u5FC5\u987B\u662F\u5730\u76AE\u62E5\u6709\u8005\u624D\u80FD\u6267\u884C\u8FD9\u4E2A\u64CD\u4F5C" +command_went_wrong: "$2\u6267\u884C\u547D\u4EE4\u65F6\u53D1\u751F\u4E86\u9519\u8BEF..." +helper_added: "$4\u4F60\u6210\u529F\u4E3A\u5730\u76AE\u52A0\u5165\u4E86\u5E2E\u624B" +schematic_paste_failed: "$2\u7C98\u8D34\u5EFA\u7B51\u6587\u4EF6\u5931\u8D25" +removed_balance: "$2\u4ECE\u4F60\u7684\u8D26\u6237\u4E2D\u6263\u9664\u4E86 $1%s" +setup_step: "$3[$1\u6B65\u9AA4 - %s$3] $1%s $2- $1\u7C7B\u578B: $2%s $1\u9ED8\u8BA4\u503C: $2%s" +schematic_valid: "$2\u8FD9\u662F\u4E00\u4E2A\u6709\u6548\u7684\u5EFA\u7B51\u6587\u4EF6" +owner_sign_line_4: "$3\u5DF2\u9886\u53D6" +cluster_added_helper: "$4\u6210\u529F\u4E3A\u7EC4\u7FA4\u52A0\u5165\u5E2E\u624B" +owner_sign_line_3: "$2%plr%" +already_owner: "$2\u8FD9\u4E2A\u73A9\u5BB6\u5DF2\u7ECF\u62E5\u6709\u5730\u76AE\u4E86." +owner_sign_line_2: "$1\u62E5\u6709\u8005:" +owner_sign_line_1: "$1ID: $1%id%" +not_valid_subcommand: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u5B50\u547D\u4EE4" +subcommand_set_options_header: "$2\u53EF\u7528\u7684\u53C2\u6570: " +requires_unowned: "$2\u8BE5\u4F4D\u7F6E\u5DF2\u88AB\u5360\u7528." +plot_unowned: "$2\u4F60\u5FC5\u987B\u662F\u5730\u76AE\u62E5\u6709\u8005\u624D\u80FD\u6267\u884C\u8FD9\u4E2A\u64CD\u4F5C" +inbox_item: "$2 - $4%s" +cannot_kick_player: "$2\u4F60\u4E0D\u80FD\u8E22\u51FA\u8BE5\u73A9\u5BB6" +clearing_done: "$4\u6E05\u7406\u5B8C\u6210! \u8017\u65F6 %s\u6BEB\u79D2." +setup_valid_arg: "$2\u53C2\u6570 $1%s $2\u8BBE\u7F6E\u4E3A %s" +camera_stopped: "$2\u4F60\u53D6\u6D88\u4E86\u6444\u50CF\u673A\u6A21\u5F0F" +flag_type: "$2\u7C7B\u578B: %s" +pasted: "$4\u88AB\u9009\u62E9\u7684\u5730\u76AE\u6210\u529F\u7C98\u8D34." +cluster_info: "$1\u5F53\u524D\u7EC4\u7FA4: $2%id%&-$1\u540D\u79F0: $2%name%&-$1\u62E5\u6709\u8005: $2%owner%&-$1\u5927\u5C0F: $2%size%&-$1\u6743\u9650: $2%rights%" +cluster_cannot_leave: "$1\u5728\u9000\u51FA\u4E4B\u524D\u5148\u8F6C\u79FB\u6240\u6709\u6743" +help_header: "$3====== $1\u5730\u76AE\u5E2E\u52A9\u83DC\u5355 $3======" +cannot_afford_merge: "$2\u4F60\u6CA1\u6709\u8DB3\u591F\u7684\u91D1\u94B1\u5408\u5E76\u5730\u76AE. \u9700\u8981\u82B1\u8D39 $1%s" +setting_updated: "$4\u4F60\u66F4\u65B0\u4E86\u4F60\u7684\u8BBE\u5B9A" +need_key: "$2\u53EF\u7528\u53C2\u6570: $1%values%" +merge_requested: "$2\u6210\u529F\u53D1\u9001\u5408\u5E76\u8BF7\u6C42" +compass_target: "$4S\u6210\u529F\u4F20\u9001\u5230\u76EE\u6807\u5730\u76AE" +flag_not_added: "$2\u8BE5\u6807\u8BC6\u65E0\u6CD5\u88AB\u6DFB\u52A0" +no_plots: "$2\u4F60\u6CA1\u6709\u989D\u5916\u7684\u5730\u76AE\u4E86" +need_plot_id: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u5730\u76AEID." +flag_not_removed: "$2\u8BE5\u6807\u8BC6\u65E0\u6CD5\u88AB\u79FB\u9664" +trusted_removed: "$1\u4F60\u4ECE\u5730\u76AE\u4E2D\u79FB\u9664\u4E86\u4E00\u540D\u53EF\u4FE1\u73A9\u5BB6" +comment_header: "$2====== \u7559\u8A00\u677F ======" +flag_removed: "$4\u6210\u529F\u79FB\u9664\u6807\u8BC6" +rating_applied: "$4\u4F60\u4E3A\u5730\u76AE $2%s $4\u6253\u5206\u4E86" +requires_confirm: "$2\u4F60\u662F\u5426\u6267\u884C: $1%s$2?&-$2\u8BE5\u64CD\u4F5C\u4E0D\u53EF\u9006! \u5982\u679C\u786E\u5B9A\u8BF7\u8F93\u5165: $1/plot confirm" +flag_added: "$4\u6210\u529F\u6DFB\u52A0\u6807\u8BC6" +econ_disabled: "$2\u7ECF\u6D4E\u529F\u80FD\u672A\u542F\u7528" +not_valid_hybrid_plot_world: "The hybrid plot manager is required to perform this action" +no_commands: "$2\u4F60\u6CA1\u6709\u6743\u9650\u4F7F\u7528\u4EFB\u4F55\u6307\u4EE4." +missing_position: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u4F4D\u7F6E. \u53EF\u7528\u7684\u53C2\u6570: $1none" +record_play: "$2%player $2\u5F00\u59CB\u64AD\u653ECD $1%name" +no_perm_inbox_modify: "$2\u4F60\u6CA1\u6709\u6743\u9650\u4FEE\u6539" +unlink_required: "$2\u5982\u679C\u9700\u8981\u53D6\u6D88\u5408\u5E76\u5730\u76AE." +denied_need_argument: "$2\u7F3A\u5C11\u53C2\u6570. $1/plot denied add <\u73A9\u5BB6\u540D\u79F0> $2\u6216 $1/plot denied remove <\u73A9\u5BB6\u540D\u79F0>" +added_balance: "$2\u5411\u4F60\u7684\u8D26\u6237\u4E2D\u52A0\u5165\u4E86 $1%s" +not_using_plotme: "$2\u8FD9\u4E2A\u670D\u52A1\u5668\u4F7F\u7528\u4E86 $1PlotSquared $2\u5730\u76AE\u7BA1\u7406\u7CFB\u7EDF. \u8BF7\u8F93\u5165 $1/ps $2\u6216 $1/p2 $2\u6216 $1/plots $2\u6765\u4EE3\u66FF" +player_has_not_been_on: "$2\u8FD9\u4E2A\u73A9\u5BB6\u8FD8\u6CA1\u62E5\u6709\u5730\u76AE" +plot_list_footer: "$2>> $1%word% \u6709 $2%num% $1\u88AB\u9886\u53D6\u7684 %plot%." +trim_in_progress: "\u5730\u76AE\u6E05\u7406\u4EFB\u52A1\u6B63\u5728\u8FDB\u884C!" +cluster_deleted: "$4\u6210\u529F\u5220\u9664\u7EC4\u7FA4." +cant_claim_more_plots: "$2\u4F60\u4E0D\u80FD\u9886\u53D6\u66F4\u591A\u7684\u5730\u76AE\u4E86." +unlink_success: "$2\u6210\u529F\u53D6\u6D88\u5730\u76AE\u5408\u5E76." +no_perm_inbox: "$2\u4F60\u6CA1\u6709\u6743\u9650\u8FD9\u6837\u505A" +worldedit_bypass: "$2&o\u8DF3\u8FC7\u6743\u9650\u8BF7\u8F93\u5165 $3/plot wea" +prefix: "$3[$1\u5730\u76AE$3] " +claimed: "$4\u4F60\u6210\u529F\u9886\u53D6\u4E86\u5730\u76AE" +failed_confirm: "$2\u4E0B\u4E00\u6B65\u65F6\u53D1\u751F\u4E86\u9519\u8BEF!" +copy_success: "$4\u4F60\u6210\u529F\u590D\u5236\u4E86\u5730\u76AE." +cluster_available_args: "$1\u53EF\u7528\u7684\u7EC4\u7FA4\u6307\u4EE4: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4helpers$2, $4info$2, $4tp$2, $4sethome" +cluster_list_heading: "$2\u8BE5\u4E16\u754C\u4E2D\u6709 $1%s$2 \u4E2A\u7EC4\u7FA4" +cluster_list_element: "$2 - $1%s&-" +cluster_intersection: "$2\u8BE5\u5730\u533A\u6709\u91CD\u53E0\u7684 $1%s$2 \u4E2A\u7EC4\u7FA4" +cluster_resized: "$4\u6210\u529F\u8C03\u6574\u4E86\u7EC4\u7FA4\u7684\u5927\u5C0F." +cluster_added_user: "$4\u6210\u529F\u52A0\u5165\u73A9\u5BB6\u5230\u7EC4\u7FA4\u4E2D." +cluster_invited: "$1\u4F60\u88AB\u9080\u8BF7\u5230\u7EC4\u7FA4: $2%s" +cluster_removed: "$1\u4F60\u88AB\u7EC4\u7FA4 $2%s \u8E22\u51FA\u4E86" +cluster_kicked_user: "$4\u6210\u529F\u8E22\u51FA\u73A9\u5BB6" +invalid_cluster: "$1\u65E0\u6548\u7684\u7EC4\u7FA4\u540D\u79F0: $2%s" +cluster_removed_helper: "$4\u6210\u529F\u79FB\u9664\u4E86\u7EC4\u7FA4\u7684\u5E2E\u624B" +cluster_teleporting: "$4\u4F20\u9001\u4E2D..." +cluster_current_plotid: "$1\u5F53\u524D\u5730\u76AE: $2%s" +border: "$2\u4F60\u8D70\u5230\u4E86\u5730\u56FE\u8FB9\u5883" +require_selection_in_mask: "$2\u4F60\u9009\u62E9\u7684\u5730\u76AE %s \u4E0D\u662F\u4F60\u7684. \u4F60\u53EA\u80FD\u5728\u4F60\u7684\u5730\u76AE\u4E2D\u5EFA\u7B51." +worldedit_iterations: "$2\u4F60\u4E0D\u80FD\u91CD\u590D %current% \u6B21. \u6700\u5927\u91CD\u590D\u6B21\u6570\u4E3A %max%." +worldedit_unmasked: "$1\u4F60\u7684WE\u529F\u80FD\u6CA1\u6709\u9650\u5236." +worldedit_restricted: "$1\u4F60\u7684WE\u529F\u80FD\u88AB\u9650\u5236." +notify_enter: "$2%player $2\u8FDB\u5165\u4E86\u4F60\u7684\u5730\u76AE ($1%plot$2)" +notify_leave: "$2%player $2\u79BB\u5F00\u4E86\u4F60\u7684\u5730\u76AE ($1%plot$2)" +swap_overlap: "$2\u8BE5\u533A\u57DF\u4E0D\u5141\u8BB8\u8986\u76D6" +swap_dimensions: "$2\u8BE5\u533A\u57DF\u9700\u8981\u540C\u6837\u5927\u5C0F\u7684\u5C3A\u5BF8" +swap_syntax: "$2/plots swap <\u5730\u76AEID>" +swap_success: "$4\u6210\u529F\u4EA4\u6362\u5730\u76AE" +started_swap: "$2\u5F00\u59CB\u5730\u76AE\u4EA4\u6362. \u4EA4\u6362\u5C31\u7EEA\u540E\u4F1A\u901A\u77E5\u4F60" +comment_syntax: "$2\u7528\u6CD5 /plots comment [X;Z] <%s> <\u7559\u8A00>" +invalid_inbox: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u9875\u6570.&-$1\u53EF\u7528\u7684\u53C2\u6570: %s" +no_plot_inbox: "$2\u8FD9\u4E0D\u662F\u6709\u6548\u7684\u5730\u76AE\u9875\u6570" +comment_removed: "$4\u6210\u529F\u5220\u9664\u5730\u76AE\u7559\u8A00/s:n$2 - \'$3%s$2\'" +not_console: "$\u8BE5\u6307\u4EE4\u4EC5\u9650\u63A7\u5236\u53F0\u8F93\u5165." +is_console: "$2\u8BE5\u6307\u4EE4\u4EC5\u9650\u73A9\u5BB6\u8F93\u5165." +clipboard_set: "$2\u5F53\u524D\u5730\u76AE\u5DF2\u7ECF\u88AB\u590D\u5236\u5230\u4E86\u526A\u5207\u677F, \u4F7F\u7528 $1/plot paste$2 \u6765\u7C98\u8D34\u5B83" +no_clipboard: "$2\u4F60\u6CA1\u6709\u9009\u62E9\u526A\u5207\u677F" +clipboard_info: "$2\u5F53\u524D\u9009\u62E9 - \u5730\u76AE ID: $1%id$2, \u5BBD\u5EA6: $1%width$2, \u65B9\u5757\u6570\u91CF: $1%total$2" +rating_not_valid: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A1~10\u4E4B\u95F4\u7684\u6570" +rating_already_exists: "$2\u4F60\u5DF2\u7ECF\u4E3A\u5730\u76AE $2%s \u8BC4\u8FC7\u5206\u4E86" +rating_not_your_own: "$2\u4F60\u4E0D\u80FD\u4E3A\u81EA\u5DF1\u5730\u76AE\u8BC4\u5206" +rating_not_owned: "$2\u4F60\u4E0D\u80FD\u4E3A\u95F2\u7F6E\u5730\u76AE\u8BC4\u5206" +cannot_afford_plot: "$2\u4F60\u6CA1\u6709\u8DB3\u591F\u7684\u91D1\u94B1\u8D2D\u4E70\u5730\u76AE. \u9700\u8981\u82B1\u8D39 $1%s" +plot_sold: "$4\u4F60\u7684\u5730\u76AE; $1%s$4, \u5DF2\u5356\u7ED9\u4E86 $1%s$4 \u4EF7\u683C\u4E3A $1$%s" +setup_invalid_arg: "$2%s\u4E0D\u662F\u6B65\u9AA4 %s \u7684\u6709\u6548\u53C2\u6570. \u53D6\u6D88\u6784\u5EFA\u8F93\u5165: $1/plot setup cancel" +setup_finished: "$3\u5982\u679C\u4F7F\u7528\u4E86 MULTIVERSE \u6216 MULTIWORLD \u63D2\u4EF6\u4E16\u754C\u7684\u914D\u7F6E\u4F1A\u81EA\u52A8\u5199\u5165. \u5426\u5219\u4F60\u9700\u8981\u624B\u52A8\u5199\u5165\u6587\u4EF6 bukkit.yml" +setup_missing_world: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u4E16\u754C\u540D\u79F0 ($1/plot setup &l<\u4E16\u754C\u540D\u79F0>$1 <\u751F\u6210\u53C2\u6570>$2)&-$1\u9644\u52A0\u6307\u4EE4:&-$2 - $1/plot setup <\u53C2\u6570>&-$2 - $1/plot setup back&-$2 - $1/plot setup cancel" +schematic_missing_arg: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u53C2\u6570. \u53EF\u7528\u7684\u53C2\u6570: $1test <\u540D\u79F0>$2 , $1save$2 , $1paste $2, $1exportall" +title_entered_plot: "\u5730\u76AE\u4F4D\u7F6E: %world%;%x%;%z%" +title_entered_plot_sub: "\u62E5\u6709\u8005 %s" +title_left_plot: "\u4F60\u79BB\u5F00\u4E86 %s" +title_left_plot_sub: "\u62E5\u6709\u8005 %s" +title_left_plot_sub_color: "RED" +prefix_farewell: "$1%id%$2> " +enabled: "$1PlotSquared \u5DF2\u542F\u7528" +example_message: "$2\u8FD9\u662F\u4E00\u6761\u6F14\u793A\u6D88\u606F &k!!!" +reloaded_configs: "$1\u6587\u4EF6\u4E0E\u8BBE\u5B9A\u88AB\u91CD\u65B0\u8BFB\u53D6" +reload_failed: "$2\u91CD\u65B0\u8BFB\u53D6\u5931\u8D25\u4E86" +time_format: "$1%hours%, %min%, %sec%" +no_schematic_permission: "$2\u4F60\u6CA1\u6709\u6743\u9650\u4F7F\u7528\u5EFA\u7B51\u6587\u4EF6 $1%s" +no_permission: "$2\u4F60\u7F3A\u5C11\u4E86\u6743\u9650: $1%s" +cant_transfer_more_plots: "$2\u4F60\u4E0D\u80FD\u53D1\u51FA\u66F4\u591A\u7684\u5730\u76AE\u9080\u8BF7\u4E86" +cant_claim_more_plots_num: "$2\u4F60\u4E0D\u80FD\u4E00\u6B21\u9886\u53D6 $1%s $2\u5757\u5730\u76AE" +you_be_denied: "$2\u4F60\u4E0D\u80FD\u8FDB\u5165\u8FD9\u5757\u5730\u76AE" +no_perm_merge: "$2\u4F60\u4E0D\u662F\u8FD9\u5757\u5730\u76AE $1%plot% $2\u7684\u62E5\u6709\u8005" +unlink_impossible: "$2\u4F60\u53EA\u80FD\u53D6\u6D88\u5408\u5E76\u8D85\u7EA7\u5730\u76AE" +no_merge_to_mega: "$2\u8D85\u7EA7\u5730\u76AE\u65E0\u6CD5\u88AB\u5408\u5E76." +merge_accepted: "$2\u5408\u5E76\u8BF7\u6C42\u5DF2\u88AB\u63A5\u53D7" +merge_request_confirm: "\u6536\u5230\u4E86 %s \u7684\u5408\u5E76\u8BF7\u6C42" +name_little: "$2%s \u540D\u5B57\u592A\u77ED\u4E86, $1%s$2<$1%s" +purge_syntax: "\u7528\u6CD5 /plot purge <\u4E16\u754C\u540D\u79F0>" +purge_success: "$4\u6210\u529F\u6E05\u7406\u4E86 %s \u5757\u5730\u76AE" +trim_syntax: "\u7528\u6CD5 /plot trim <\u4E16\u754C\u540D\u79F0>" +trim_start: "\u5F00\u59CB\u5730\u76AE\u6574\u7406..." +no_free_plots: "$2\u6CA1\u6709\u514D\u8D39\u7684\u5730\u76AE\u53EF\u7528" +not_in_plot: "$2\u4F60\u4E0D\u5728\u5730\u76AE\u4E0A" +not_valid_plot_world: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u4E16\u754C (\u6CE8\u610F\u5927\u5C0F\u5199)" +block_list_item: " $1%mat%$2," +need_biome: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u751F\u7269\u7FA4\u843D" +biome_set_to: "$2\u5730\u76AE\u7684\u751F\u7269\u7FA4\u843D\u8BBE\u7F6E\u4E3A $2" +teleported_to_plot: "$2\u4F60\u4F20\u9001\u5230\u4E86\u5730\u76AE\u4E2D" +teleport_in_seconds: "$1\u5C06\u5728 %s \u79D2\u5185\u4F20\u9001. \u8BF7\u52FF\u79FB\u52A8..." +deubg_header: "$1\u8C03\u8BD5\u4FE1\u606F" +not_valid_block: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u65B9\u5757." +not_valid_number: "$2\u8FD9\u4E0D\u662F\u4E00\u4E2A\u6709\u6548\u7684\u6570\u5B57" +no_such_plot: "$2\u6CA1\u6709\u8BE5\u7C7B\u578B\u7684\u5730\u76AE" +found_no_plots: "$2\u65E0\u6CD5\u6839\u636E\u8BE5\u8981\u6C42\u67E5\u627E\u5730\u76AE" +need_plot_number: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u5730\u76AEID\u6216\u522B\u540D" +need_block: "$\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u79CD\u65B9\u5757" +need_user: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u73A9\u5BB6" +plot_info_unclaimed: "$2\u5730\u76AE $1%s$2 \u8FD8\u672A\u88AB\u9886\u53D6" +plot_info_header: "$3====== $1INFO $3======" +plot_info: "$1ID: $2%id%$1&-$1\u522B\u540D: $2%alias%$1&-$1\u62E5\u6709\u8005: $2%owner%$1&-$1\u751F\u7269\u7FA4\u843D: $2%biome%$1&-$1\u53EF\u5426\u5EFA\u7B51: $2%build%$1&-$1\u8BC4\u5206: $2%rating%$1/$210$1&-$1\u5E2E\u624B: $2%helpers%$1&-$1\u53EF\u4FE1\u73A9\u5BB6: $2%trusted%$1&-$1\u9ED1\u540D\u5355: $2nied%$1&-$1\u6807\u8BC6: $2%flags%" +plot_info_trusted: "$1\u53EF\u4FE1\u73A9\u5BB6:$2 %trusted%" +plot_info_denied: "$1\u9ED1\u540D\u5355\u73A9\u5BB6:$2 nied%" +plot_info_flags: "$1\u6807\u8BC6:$2 %flags%" +plot_info_biome: "$1\u751F\u7269\u7FA4\u843D:$2 %biome%" +plot_info_rating: "$1\u8BC4\u5206:$2 %rating%" +plot_info_owner: "$1\u62E5\u6709\u8005:$2 %owner%" +plot_info_id: "$1ID:$2 %id%" +plot_info_alias: "$1\u522B\u540D:$2 %alias%" +plot_info_size: "$1\u5927\u5C0F:$2 %size%" +plot_user_list: " $1%user%$2," +info_syntax_console: "$2/plot info <\u4E16\u754C\u540D\u79F0> X;Y" +clearing_plot: "$2\u6E05\u7406\u5730\u76AE\u4E2D." +plot_is_claimed: "$2\u8FD9\u5757\u5730\u76AE\u5DF2\u88AB\u9886\u53D6" +plot_list_header_paged: "$2(\u9875\u6570 $1%cur$2/$1%max$2) $1\u5217\u51FA\u4E86 %word% \u5757\u5730\u76AE" +plot_list_header: "$11\u5217\u51FA\u4E86 %word% \u5757\u5730\u76AE" +plot_list_item_ordered: "$2[$1%in$2] >> $1%id$2:$1%world $2- $1%owner" +left_plot: "$2\u4F60\u79BB\u5F00\u4E86\u5730\u76AE" +wait_for_timer: "$2\u8BBE\u7F6E\u65B9\u5757\u8BA1\u65F6\u5668\u5DF2\u542F\u7528. \u8BF7\u7A0D\u540E..." +plot_chat_format: "$2[$1\u5730\u76AE\u804A\u5929$2][$1%plot_id%$2] $1%sender%$2: $1%msg%" +denied_added: "$4\u4F60\u6210\u529F\u4E3A\u5730\u76AE\u52A0\u5165\u4E86\u9ED1\u540D\u5355\u73A9\u5BB6" +was_not_denied: "$2\u4F60\u8FD9\u73A9\u5BB6\u4E0D\u5728\u9ED1\u540D\u5355\u4E2D" +need_on_off: "$2\u4F60\u9700\u8981\u6307\u5B9A\u4E00\u4E2A\u53C2\u6570. \u53EF\u7528\u7684\u53C2\u6570: $1on$2, $1off" +flag_key: "$2\u5173\u952E\u5B57: %s" +flag_desc: "$2\u63CF\u8FF0: %s" +not_valid_value: "$2\u6807\u8BC6\u7684\u53C2\u6570\u5FC5\u987B\u4E3A\u6570\u5B57" +flag_not_in_plot: "$2\u8FD9\u5757\u5730\u76AE\u8FD8\u6CA1\u6709\u8BBE\u7F6E\u6807\u8BC6 26" +helper_removed: "$4\u4F60\u6210\u529F\u4E3A\u5730\u76AE\u79FB\u9664\u4E86\u5E2E\u624B" +helper_need_argument: "$2\u7F3A\u5C11\u53C2\u6570. $1/plot helpers add <\u73A9\u5BB6\u540D\u79F0> $2\u6216 $1/plot helpers remove <\u73A9\u5BB6\u540D\u79F0>" +was_not_added: "$2\u8FD9\u4E2A\u73A9\u5BB6\u8FD8\u6CA1\u6709\u6210\u4E3A\u8BE5\u5730\u76AE\u7684\u5E2E\u624B" +already_added: "$2\u8FD9\u4E2A\u73A9\u5BB6\u5DF2\u7ECF\u52A0\u5165\u4E86\u8BE5\u5206\u7EC4." +trusted_added: "$4\u4F60\u6210\u529F\u4E3A\u5730\u76AE\u52A0\u5165\u4E86\u53EF\u4FE1\u73A9\u5BB6" +trusted_need_argument: "$2\u7F3A\u5C11\u53C2\u6570. $1/plot trusted add <\u73A9\u5BB6\u540D\u79F0> $2\u6216 $1/plot trusted remove <\u73A9\u5BB6\u540D\u79F0>" +t_was_not_added: "$2\u8FD9\u4E2A\u73A9\u5BB6\u8FD8\u6CA1\u6709\u6210\u4E3A\u8BE5\u5730\u76AE\u7684\u53EF\u4FE1\u73A9\u5BB6" +set_owner: "$4\u4F60\u6210\u529F\u4E3A\u5730\u76AE\u8BBE\u7F6E\u4E86\u62E5\u6709\u8005" +now_owner: "$4\u4F60\u73B0\u5728\u6210\u4E3A\u5730\u76AE %s \u7684\u62E5\u6709\u8005\u4E86" +help_category: "$1\u5206\u7C7B: $2tegory%$2,$1 \u9875\u6570: $2%current%$3/$2%max%$2,$1 \u5DF2\u663E\u793A: $2%dis%$3/$2%total%" +help_info: "$3====== $1\u9009\u62E9\u4E00\u4E2A\u5206\u7C7B $3======" +help_info_item: "$1/plots help tegory% $3- $2tegory_desc%" +direction: "$1\u5F53\u524D\u65B9\u5411: %dir%" +custom_string: "-" \ No newline at end of file diff --git a/PlotSquared/src/main/resources/s_chinese_unescaped.yml b/PlotSquared/src/main/resources/s_chinese_unescaped.yml new file mode 100644 index 000000000..52c2c25ea --- /dev/null +++ b/PlotSquared/src/main/resources/s_chinese_unescaped.yml @@ -0,0 +1,257 @@ +### UNESCAPED TEMPLATE ### +# Translated by: Liouftgoo/Mayomi9 +# UTF-8 ESCAPE USING: http://www.rapidmonkey.com/unicodeconverter/ +### UNESCAPED TEMPLATE ### +camera_started: "$2Äã½øÈëÁ˵ØƤ $1%s µÄÉãÏñ»úģʽ" +command_syntax: "$1Ó÷¨: $2%s" +not_valid_flag: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄ±êʶ" +setup_world_taken: "$2%s ÒѾ­ÊǵØƤÊÀ½çÁË" +plot_list_item: "$2>> $1%id$2:$1%world $2- $1%owner" +schematic_invalid: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄ½¨ÖþÎļþ. Ô­Òò: $2%s" +not_valid_inbox_index: "$2Ò³Êý %s ûÓÐÁôÑÔ" +setup_invalid_generator: "$2ÎÞЧµÄÉú³É²ÎÊý. ¿ÉÑ¡: %s" +teleported_to_road: "$2Äã´«Ë͵½ÁË·ÖÐ" +debug_section: "$2>> $1&l%val%" +plot_id_form: "$2µØƤIDµÄ¸ñʽ±ØÐëΪ: $1X;Y $2ÀýÈç: $1-5;7" +invalid_position: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄλÖÃ" +worldedit_unsafe: "$2¸ÃÖ¸ÁîÒѾ­±»½ûֹʹÓÃ" +not_in_plot_world: "$2Äã²»ÔÚµØƤÊÀ½çÖÐ" +cannot_buy_own: "$2Äã²»ÄÜÂòÄã×Ô¼ºµÄµØƤ" +help_item: "$1%usage% [%alias%]&- $3- $2%desc%&-" +not_valid_world: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄÊÀ½ç (×¢Òâ´óСд)" +home_argument: "$2Ó÷¨ /plot set home [¿É²»Ìî]" +title_left_plot_color: "GOLD" +merge_not_valid: "$2ºÏ²¢ÇëÇóÒÑʧЧ." +debug_line: "$2>> $1%var%$2:$1 %val% " +comment_added: "$4Ìí¼ÓÁËÒ»ÌõеÄÁôÑÔ" +alias_is_taken: "$2Õâ¸ö±ðÃûÒѱ»±ðÈËʹÓÃ" +setup_missing_generator: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öÉú³É²ÎÊý ($1/plot setup <ÊÀ½çÃû³Æ> &l<Éú³É²ÎÊý>&r$2)&-$1¸½¼ÓÖ¸Áî:&-$2 - $1/plot setup <²ÎÊý>&-$2 - $1/plot setup back&-$2 - $1/plot setup cancel" +block_list_separater: "$1,$2 " +alias_set_to: "$2µØƤµÄ±ðÃûÉèÖÃΪ $1%alias%" +did_you_mean: "$2ÄãµÄÒâ˼ÊÇ $1%s $2Âð?" +cluster_not_added: "$2Õâ¸öÍæ¼Òδ±»¼ÓÈëµØƤ×éȺÖÐ" +success_merge: "$2µØƤ³É¹¦±»ºÏ²¢!" +position_set: "$1ÔÚÄ㵱ǰµÄλÖÃÉèÖüÒ" +cluster_regenerated: "$4³É¹¦¿ªÊ¼Èº×éÖؽ¨" +not_valid_data: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄ²ÎÊýÖµ." +not_for_sale: "$2Õâ¿éµØƤ²¢²»³öÊÛ" +not_in_cluster: "$2Äã±ØÐëÔÚÒ»¸öµØƤ×éȺÖвÅÄܽøÐд˲Ù×÷" +schematic_paste_success: "$4½¨ÖþÎļþÕ³Ìù³É¹¦" +set_block_action_finished: "$1×îºóÒ»¸ö·½¿éÉèÖÃÒÑÍê³É." +missing_alias: "$2ÄãÐèÒªÖ¸¶¨Ò»¸ö±ðÃû" +paste_failed: "$2Õ³Ìùʱ·¢Éú´íÎó. Ô­Òò: $2%s" +invalid_player: "$2δÕÒµ½Íæ¼Ò $1%s." +plot_info_helpers: "$1°ïÊÖ:$2 %helpers%" +cluster_added: "$4³É¹¦´´½¨×éȺ." +setup_init: "$1Ó÷¨: $2/plot setup <²ÎÊý>" +bossbar_clearing: "$2ÕýÔÚÇåÀíµØƤ $1%id%" +title_entered_plot_sub_color: "RED" +prefix_greeting: "$1%id%$2> " +not_your_plot: "$2Õâ²»ÊÇÄãµÄµØƤ." +worldedit_volume: "$2ÄãÎÞ·¨Ñ¡Ôñ %current% µÄ¿Õ¼ä. ×î´ó¿Õ¼ä¿ÉÒÔÉèÖÃΪ %max%." +not_valid_plot_id: "$2Õâ²»ÊÇÓÐЧµÄµØƤID." +unclaim_success: "$4Äã·ÅÆúÁËÕâ¿éµØƤ." +teleport_failed: "$2ÒòΪÊܵ½É˺¦¶ø±»È¡Ïû´«ËÍ" +need_plot_world: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öµØƤÊÀ½ç." +plot_not_claimed: "$2µØƤδ±»ÁìÈ¡" +title_entered_plot_color: "GOLD" +denied_removed: "$4Äã½â³ýÁËÕâ¸öµØƤ¶ÔÍæ¼ÒµÄºÚÃûµ¥" +plot_removed_helper: "$1Äã¼ÓÈëµÄµØƤ %s ÒòΪӵÓÐÕß²»»îÔ¾¶ø±»É¾³ýÁË" +plotworld_incompatible: "$2Á½¸öÊÀ½ç±ØÐëÏ໥¼æÈÝ" +generating_component: "$1¿ªÊ¼¸ù¾ÝÄãµÄÉ趨Éú³É" +not_valid_block_list_header: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄ·½¿é. ÓÐЧµÄ·½¿é: " +alias_too_long: "$2±ðÃûµÄ³¤¶È±ØÐëСÓÚ50¸ö×Ö·û" +move_success: "$4³É¹¦ÒƳýµØƤ." +no_plot_perms: "$2Äã±ØÐëÊǵØƤӵÓÐÕß²ÅÄÜÖ´ÐÐÕâ¸ö²Ù×÷" +command_went_wrong: "$2Ö´ÐÐÃüÁîʱ·¢ÉúÁË´íÎó..." +helper_added: "$4Äã³É¹¦ÎªµØƤ¼ÓÈëÁË°ïÊÖ" +schematic_paste_failed: "$2Õ³Ìù½¨ÖþÎļþʧ°Ü" +removed_balance: "$2´ÓÄãµÄÕË»§Öп۳ýÁË $1%s" +setup_step: "$3[$1²½Öè - %s$3] $1%s $2- $1ÀàÐÍ: $2%s $1ĬÈÏÖµ: $2%s" +schematic_valid: "$2ÕâÊÇÒ»¸öÓÐЧµÄ½¨ÖþÎļþ" +owner_sign_line_4: "$3ÒÑÁìÈ¡" +cluster_added_helper: "$4³É¹¦Îª×éȺ¼ÓÈë°ïÊÖ" +owner_sign_line_3: "$2%plr%" +already_owner: "$2Õâ¸öÍæ¼ÒÒѾ­ÓµÓеØƤÁË." +owner_sign_line_2: "$1ÓµÓÐÕß:" +owner_sign_line_1: "$1ID: $1%id%" +not_valid_subcommand: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄ×ÓÃüÁî" +subcommand_set_options_header: "$2¿ÉÓõIJÎÊý: " +requires_unowned: "$2¸ÃλÖÃÒѱ»Õ¼ÓÃ." +plot_unowned: "$2Äã±ØÐëÊǵØƤӵÓÐÕß²ÅÄÜÖ´ÐÐÕâ¸ö²Ù×÷" +inbox_item: "$2 - $4%s" +cannot_kick_player: "$2Äã²»ÄÜÌß³ö¸ÃÍæ¼Ò" +clearing_done: "$4ÇåÀíÍê³É! ºÄʱ %sºÁÃë." +setup_valid_arg: "$2²ÎÊý $1%s $2ÉèÖÃΪ %s" +camera_stopped: "$2ÄãÈ¡ÏûÁËÉãÏñ»úģʽ" +flag_type: "$2ÀàÐÍ: %s" +pasted: "$4±»Ñ¡ÔñµÄµØƤ³É¹¦Õ³Ìù." +cluster_info: "$1µ±Ç°×éȺ: $2%id%&-$1Ãû³Æ: $2%name%&-$1ÓµÓÐÕß: $2%owner%&-$1´óС: $2%size%&-$1ȨÏÞ: $2%rights%" +cluster_cannot_leave: "$1ÔÚÍ˳ö֮ǰÏÈתÒÆËùÓÐȨ" +help_header: "$3====== $1µØƤ°ïÖú²Ëµ¥ $3======" +cannot_afford_merge: "$2ÄãûÓÐ×ã¹»µÄ½ðÇ®ºÏ²¢µØƤ. ÐèÒª»¨·Ñ $1%s" +setting_updated: "$4Äã¸üÐÂÁËÄãµÄÉ趨" +need_key: "$2¿ÉÓòÎÊý: $1%values%" +merge_requested: "$2³É¹¦·¢Ëͺϲ¢ÇëÇó" +compass_target: "$4S³É¹¦´«Ë͵½Ä¿±êµØƤ" +flag_not_added: "$2¸Ã±êʶÎÞ·¨±»Ìí¼Ó" +no_plots: "$2ÄãûÓжîÍâµÄµØƤÁË" +need_plot_id: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öµØƤID." +flag_not_removed: "$2¸Ã±êʶÎÞ·¨±»ÒƳý" +trusted_removed: "$1Äã´ÓµØƤÖÐÒƳýÁËÒ»Ãû¿ÉÐÅÍæ¼Ò" +comment_header: "$2====== ÁôÑÔ°å ======" +flag_removed: "$4³É¹¦ÒƳý±êʶ" +rating_applied: "$4ÄãΪµØƤ $2%s $4´ò·ÖÁË" +requires_confirm: "$2ÄãÊÇ·ñÖ´ÐÐ: $1%s$2?&-$2¸Ã²Ù×÷²»¿ÉÄæ! Èç¹ûÈ·¶¨ÇëÊäÈë: $1/plot confirm" +flag_added: "$4³É¹¦Ìí¼Ó±êʶ" +econ_disabled: "$2¾­¼Ã¹¦ÄÜδÆôÓÃ" +not_valid_hybrid_plot_world: "The hybrid plot manager is required to perform this action" +no_commands: "$2ÄãûÓÐȨÏÞʹÓÃÈκÎÖ¸Áî." +missing_position: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öλÖÃ. ¿ÉÓõIJÎÊý: $1none" +record_play: "$2%player $2¿ªÊ¼²¥·ÅCD $1%name" +no_perm_inbox_modify: "$2ÄãûÓÐȨÏÞÐÞ¸Ä" +unlink_required: "$2Èç¹ûÐèҪȡÏûºÏ²¢µØƤ." +denied_need_argument: "$2ȱÉÙ²ÎÊý. $1/plot denied add <Íæ¼ÒÃû³Æ> $2»ò $1/plot denied remove <Íæ¼ÒÃû³Æ>" +added_balance: "$2ÏòÄãµÄÕË»§ÖмÓÈëÁË $1%s" +not_using_plotme: "$2Õâ¸ö·þÎñÆ÷ʹÓÃÁË $1PlotSquared $2µØƤ¹ÜÀíϵͳ. ÇëÊäÈë $1/ps $2»ò $1/p2 $2»ò $1/plots $2À´´úÌæ" +player_has_not_been_on: "$2Õâ¸öÍæ¼Ò»¹Ã»ÓµÓеØƤ" +plot_list_footer: "$2>> $1%word% ÓÐ $2%num% $1±»ÁìÈ¡µÄ %plot%." +trim_in_progress: "µØƤÇåÀíÈÎÎñÕýÔÚ½øÐÐ!" +cluster_deleted: "$4³É¹¦É¾³ý×éȺ." +cant_claim_more_plots: "$2Äã²»ÄÜÁìÈ¡¸ü¶àµÄµØƤÁË." +unlink_success: "$2³É¹¦È¡ÏûµØƤºÏ²¢." +no_perm_inbox: "$2ÄãûÓÐȨÏÞÕâÑù×ö" +worldedit_bypass: "$2&oÌø¹ýȨÏÞÇëÊäÈë $3/plot wea" +prefix: "$3[$1µØƤ$3] " +claimed: "$4Äã³É¹¦ÁìÈ¡Á˵ØƤ" +failed_confirm: "$2ÏÂÒ»²½Ê±·¢ÉúÁË´íÎó!" +copy_success: "$4Äã³É¹¦¸´ÖÆÁ˵ØƤ." +cluster_available_args: "$1¿ÉÓõÄ×éȺָÁî: $4list$2, $4create$2, $4delete$2, $4resize$2, $4invite$2, $4kick$2, $4leave$2, $4helpers$2, $4info$2, $4tp$2, $4sethome" +cluster_list_heading: "$2¸ÃÊÀ½çÖÐÓÐ $1%s$2 ¸ö×éȺ" +cluster_list_element: "$2 - $1%s&-" +cluster_intersection: "$2¸ÃµØÇøÓÐÖصþµÄ $1%s$2 ¸ö×éȺ" +cluster_resized: "$4³É¹¦µ÷ÕûÁË×éȺµÄ´óС." +cluster_added_user: "$4³É¹¦¼ÓÈëÍæ¼Òµ½×éȺÖÐ." +cluster_invited: "$1Äã±»ÑûÇëµ½×éȺ: $2%s" +cluster_removed: "$1Äã±»×éȺ $2%s Ìß³öÁË" +cluster_kicked_user: "$4³É¹¦Ìß³öÍæ¼Ò" +invalid_cluster: "$1ÎÞЧµÄ×éȺÃû³Æ: $2%s" +cluster_removed_helper: "$4³É¹¦ÒƳýÁË×éȺµÄ°ïÊÖ" +cluster_teleporting: "$4´«ËÍÖÐ..." +cluster_current_plotid: "$1µ±Ç°µØƤ: $2%s" +border: "$2Äã×ßµ½Á˵Øͼ±ß¾³" +require_selection_in_mask: "$2ÄãÑ¡ÔñµÄµØƤ %s ²»ÊÇÄãµÄ. ÄãÖ»ÄÜÔÚÄãµÄµØƤÖн¨Öþ." +worldedit_iterations: "$2Äã²»ÄÜÖظ´ %current% ´Î. ×î´óÖظ´´ÎÊýΪ %max%." +worldedit_unmasked: "$1ÄãµÄWE¹¦ÄÜûÓÐÏÞÖÆ." +worldedit_restricted: "$1ÄãµÄWE¹¦Äܱ»ÏÞÖÆ." +notify_enter: "$2%player $2½øÈëÁËÄãµÄµØƤ ($1%plot$2)" +notify_leave: "$2%player $2À뿪ÁËÄãµÄµØƤ ($1%plot$2)" +swap_overlap: "$2¸ÃÇøÓò²»ÔÊÐí¸²¸Ç" +swap_dimensions: "$2¸ÃÇøÓòÐèҪͬÑù´óСµÄ³ß´ç" +swap_syntax: "$2/plots swap <µØƤID>" +swap_success: "$4³É¹¦½»»»µØƤ" +started_swap: "$2¿ªÊ¼µØƤ½»»». ½»»»¾ÍÐ÷ºó»á֪ͨÄã" +comment_syntax: "$2Ó÷¨ /plots comment [X;Z] <%s> <ÁôÑÔ>" +invalid_inbox: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄÒ³Êý.&-$1¿ÉÓõIJÎÊý: %s" +no_plot_inbox: "$2Õâ²»ÊÇÓÐЧµÄµØƤҳÊý" +comment_removed: "$4³É¹¦É¾³ýµØƤÁôÑÔ/s:n$2 - '$3%s$2'" +not_console: "$¸ÃÖ¸Áî½öÏÞ¿ØÖÆ̨ÊäÈë." +is_console: "$2¸ÃÖ¸Áî½öÏÞÍæ¼ÒÊäÈë." +clipboard_set: "$2µ±Ç°µØƤÒѾ­±»¸´ÖƵ½Á˼ôÇаå, ʹÓà $1/plot paste$2 À´Õ³ÌùËü" +no_clipboard: "$2ÄãûÓÐÑ¡Ôñ¼ôÇаå" +clipboard_info: "$2µ±Ç°Ñ¡Ôñ - µØƤ ID: $1%id$2, ¿í¶È: $1%width$2, ·½¿éÊýÁ¿: $1%total$2" +rating_not_valid: "$2ÄãÐèÒªÖ¸¶¨Ò»¸ö1~10Ö®¼äµÄÊý" +rating_already_exists: "$2ÄãÒѾ­ÎªµØƤ $2%s ÆÀ¹ý·ÖÁË" +rating_not_your_own: "$2Äã²»ÄÜΪ×Ô¼ºµØƤÆÀ·Ö" +rating_not_owned: "$2Äã²»ÄÜΪÏÐÖõØƤÆÀ·Ö" +cannot_afford_plot: "$2ÄãûÓÐ×ã¹»µÄ½ðÇ®¹ºÂòµØƤ. ÐèÒª»¨·Ñ $1%s" +plot_sold: "$4ÄãµÄµØƤ; $1%s$4, ÒÑÂô¸øÁË $1%s$4 ¼Û¸ñΪ $1$%s" +setup_invalid_arg: "$2%s²»ÊDz½Öè %s µÄÓÐЧ²ÎÊý. È¡Ïû¹¹½¨ÊäÈë: $1/plot setup cancel" +setup_finished: "$3Èç¹ûʹÓÃÁË MULTIVERSE »ò MULTIWORLD ²å¼þÊÀ½çµÄÅäÖûá×Ô¶¯Ð´Èë. ·ñÔòÄãÐèÒªÊÖ¶¯Ð´ÈëÎļþ bukkit.yml" +setup_missing_world: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öÊÀ½çÃû³Æ ($1/plot setup &l<ÊÀ½çÃû³Æ>$1 <Éú³É²ÎÊý>$2)&-$1¸½¼ÓÖ¸Áî:&-$2 - $1/plot setup <²ÎÊý>&-$2 - $1/plot setup back&-$2 - $1/plot setup cancel" +schematic_missing_arg: "$2ÄãÐèÒªÖ¸¶¨Ò»¸ö²ÎÊý. ¿ÉÓõIJÎÊý: $1test <Ãû³Æ>$2 , $1save$2 , $1paste $2, $1exportall" +title_entered_plot: "µØƤλÖÃ: %world%;%x%;%z%" +title_entered_plot_sub: "ÓµÓÐÕß %s" +title_left_plot: "ÄãÀ뿪ÁË %s" +title_left_plot_sub: "ÓµÓÐÕß %s" +title_left_plot_sub_color: "RED" +prefix_farewell: "$1%id%$2> " +enabled: "$1PlotSquared ÒÑÆôÓÃ" +example_message: "$2ÕâÊÇÒ»ÌõÑÝʾÏûÏ¢ &k!!!" +reloaded_configs: "$1ÎļþÓëÉ趨±»ÖØжÁÈ¡" +reload_failed: "$2ÖØжÁȡʧ°ÜÁË" +time_format: "$1%hours%, %min%, %sec%" +no_schematic_permission: "$2ÄãûÓÐȨÏÞʹÓý¨ÖþÎļþ $1%s" +no_permission: "$2ÄãȱÉÙÁËȨÏÞ: $1%s" +cant_transfer_more_plots: "$2Äã²»ÄÜ·¢³ö¸ü¶àµÄµØƤÑûÇëÁË" +cant_claim_more_plots_num: "$2Äã²»ÄÜÒ»´ÎÁìÈ¡ $1%s $2¿éµØƤ" +you_be_denied: "$2Äã²»ÄܽøÈëÕâ¿éµØƤ" +no_perm_merge: "$2Äã²»ÊÇÕâ¿éµØƤ $1%plot% $2µÄÓµÓÐÕß" +unlink_impossible: "$2ÄãÖ»ÄÜÈ¡ÏûºÏ²¢³¬¼¶µØƤ" +no_merge_to_mega: "$2³¬¼¶µØƤÎÞ·¨±»ºÏ²¢." +merge_accepted: "$2ºÏ²¢ÇëÇóÒѱ»½ÓÊÜ" +merge_request_confirm: "ÊÕµ½ÁË %s µÄºÏ²¢ÇëÇó" +name_little: "$2%s Ãû×ÖÌ«¶ÌÁË, $1%s$2<$1%s" +purge_syntax: "Ó÷¨ /plot purge <ÊÀ½çÃû³Æ>" +purge_success: "$4³É¹¦ÇåÀíÁË %s ¿éµØƤ" +trim_syntax: "Ó÷¨ /plot trim <ÊÀ½çÃû³Æ>" +trim_start: "¿ªÊ¼µØƤÕûÀí..." +no_free_plots: "$2ûÓÐÃâ·ÑµÄµØƤ¿ÉÓÃ" +not_in_plot: "$2Äã²»ÔÚµØƤÉÏ" +not_valid_plot_world: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄÊÀ½ç (×¢Òâ´óСд)" +block_list_item: " $1%mat%$2," +need_biome: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öÉúÎïȺÂä" +biome_set_to: "$2µØƤµÄÉúÎïȺÂäÉèÖÃΪ $2" +teleported_to_plot: "$2Äã´«Ë͵½Á˵ØƤÖÐ" +teleport_in_seconds: "$1½«ÔÚ %s ÃëÄÚ´«ËÍ. ÇëÎðÒƶ¯..." +deubg_header: "$1µ÷ÊÔÐÅÏ¢" +not_valid_block: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄ·½¿é." +not_valid_number: "$2Õâ²»ÊÇÒ»¸öÓÐЧµÄÊý×Ö" +no_such_plot: "$2ûÓиÃÀàÐ͵ĵØƤ" +found_no_plots: "$2ÎÞ·¨¸ù¾Ý¸ÃÒªÇó²éÕÒµØƤ" +need_plot_number: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öµØƤID»ò±ðÃû" +need_block: "$ÄãÐèÒªÖ¸¶¨Ò»ÖÖ·½¿é" +need_user: "$2ÄãÐèÒªÖ¸¶¨Ò»¸öÍæ¼Ò" +plot_info_unclaimed: "$2µØƤ $1%s$2 »¹Î´±»ÁìÈ¡" +plot_info_header: "$3====== $1INFO $3======" +plot_info: "$1ID: $2%id%$1&-$1±ðÃû: $2%alias%$1&-$1ÓµÓÐÕß: $2%owner%$1&-$1ÉúÎïȺÂä: $2%biome%$1&-$1¿É·ñ½¨Öþ: $2%build%$1&-$1ÆÀ·Ö: $2%rating%$1/$210$1&-$1°ïÊÖ: $2%helpers%$1&-$1¿ÉÐÅÍæ¼Ò: $2%trusted%$1&-$1ºÚÃûµ¥: $2%denied%$1&-$1±êʶ: $2%flags%" +plot_info_trusted: "$1¿ÉÐÅÍæ¼Ò:$2 %trusted%" +plot_info_denied: "$1ºÚÃûµ¥Íæ¼Ò:$2 %denied%" +plot_info_flags: "$1±êʶ:$2 %flags%" +plot_info_biome: "$1ÉúÎïȺÂä:$2 %biome%" +plot_info_rating: "$1ÆÀ·Ö:$2 %rating%" +plot_info_owner: "$1ÓµÓÐÕß:$2 %owner%" +plot_info_id: "$1ID:$2 %id%" +plot_info_alias: "$1±ðÃû:$2 %alias%" +plot_info_size: "$1´óС:$2 %size%" +plot_user_list: " $1%user%$2," +info_syntax_console: "$2/plot info <ÊÀ½çÃû³Æ> X;Y" +clearing_plot: "$2ÇåÀíµØƤÖÐ." +plot_is_claimed: "$2Õâ¿éµØƤÒѱ»ÁìÈ¡" +plot_list_header_paged: "$2(Ò³Êý $1%cur$2/$1%max$2) $1ÁгöÁË %word% ¿éµØƤ" +plot_list_header: "$11ÁгöÁË %word% ¿éµØƤ" +plot_list_item_ordered: "$2[$1%in$2] >> $1%id$2:$1%world $2- $1%owner" +left_plot: "$2ÄãÀ뿪Á˵ØƤ" +wait_for_timer: "$2ÉèÖ÷½¿é¼ÆʱÆ÷ÒÑÆôÓÃ. ÇëÉÔºó..." +plot_chat_format: "$2[$1µØƤÁÄÌì$2][$1%plot_id%$2] $1%sender%$2: $1%msg%" +denied_added: "$4Äã³É¹¦ÎªµØƤ¼ÓÈëÁ˺ÚÃûµ¥Íæ¼Ò" +was_not_denied: "$2ÄãÕâÍæ¼Ò²»ÔÚºÚÃûµ¥ÖÐ" +need_on_off: "$2ÄãÐèÒªÖ¸¶¨Ò»¸ö²ÎÊý. ¿ÉÓõIJÎÊý: $1on$2, $1off" +flag_key: "$2¹Ø¼ü×Ö: %s" +flag_desc: "$2ÃèÊö: %s" +not_valid_value: "$2±êʶµÄ²ÎÊý±ØÐëΪÊý×Ö" +flag_not_in_plot: "$2Õâ¿éµØƤ»¹Ã»ÓÐÉèÖñêʶ 26" +helper_removed: "$4Äã³É¹¦ÎªµØƤÒƳýÁË°ïÊÖ" +helper_need_argument: "$2ȱÉÙ²ÎÊý. $1/plot helpers add <Íæ¼ÒÃû³Æ> $2»ò $1/plot helpers remove <Íæ¼ÒÃû³Æ>" +was_not_added: "$2Õâ¸öÍæ¼Ò»¹Ã»ÓгÉΪ¸ÃµØƤµÄ°ïÊÖ" +already_added: "$2Õâ¸öÍæ¼ÒÒѾ­¼ÓÈëÁ˸÷Ö×é." +trusted_added: "$4Äã³É¹¦ÎªµØƤ¼ÓÈëÁË¿ÉÐÅÍæ¼Ò" +trusted_need_argument: "$2ȱÉÙ²ÎÊý. $1/plot trusted add <Íæ¼ÒÃû³Æ> $2»ò $1/plot trusted remove <Íæ¼ÒÃû³Æ>" +t_was_not_added: "$2Õâ¸öÍæ¼Ò»¹Ã»ÓгÉΪ¸ÃµØƤµÄ¿ÉÐÅÍæ¼Ò" +set_owner: "$4Äã³É¹¦ÎªµØƤÉèÖÃÁËÓµÓÐÕß" +now_owner: "$4ÄãÏÖÔÚ³ÉΪµØƤ %s µÄÓµÓÐÕßÁË" +help_category: "$1·ÖÀà: $2%category%$2,$1 Ò³Êý: $2%current%$3/$2%max%$2,$1 ÒÑÏÔʾ: $2%dis%$3/$2%total%" +help_info: "$3====== $1Ñ¡ÔñÒ»¸ö·ÖÀà $3======" +help_info_item: "$1/plots help %category% $3- $2%category_desc%" +direction: "$1µ±Ç°·½Ïò: %dir%" +custom_string: "-" \ No newline at end of file From f020d9e640ea7bc936e54767d0bac5eb834a152a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 21 Apr 2015 22:49:09 +1000 Subject: [PATCH 180/223] Add new language options --- PlotSquared/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 97e95c67e..43772e4e5 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -28,6 +28,9 @@ skyblock.template town.template + s_chinese.yml + s_chinese_unescaped.yml + german.yml ${basedir}/src/main/resources/ From 80a3c14189c26d8b528876510e94596e4fb8f29c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 22 Apr 2015 00:03:27 +1000 Subject: [PATCH 181/223] Optimized populator --- .../plot/commands/Setup.java | 57 ++++++++------- .../plot/commands/Template.java | 15 ++-- .../plot/generator/AugmentedPopulator.java | 72 +++++++++++++------ .../plot/object/PlotGenerator.java | 2 +- .../plot/util/bukkit/BukkitSetupUtils.java | 3 + 5 files changed, 95 insertions(+), 54 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index f55dc2513..613166fbd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -110,7 +110,8 @@ public class Setup extends SubCommand { break; } case 1: { // choose world type - List allTypes = Arrays.asList(new String[] { "default", "augmented", "partial" }); + List allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"}); + List allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"}); ArrayList types = new ArrayList<>(); if (SetupUtils.generators.get(object.setupGenerator) instanceof PlotGenerator) { types.add("default"); @@ -120,51 +121,55 @@ public class Setup extends SubCommand { types.add("partial"); } if ((args.length != 1) || !types.contains(args[0].toLowerCase())) { - MainUtil.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots"); + MainUtil.sendMessage(plr, "&cYou must choose a world type!"); + for (String type : types) { + int i = allTypes.indexOf(type); + if (type.equals("default")) { + MainUtil.sendMessage(plr, "&8 - &2" + type + " &8-&7 " + allDesc.get(i)); + } + else { + MainUtil.sendMessage(plr, "&8 - &7" + type + " &8-&7 " + allDesc.get(i)); + } + } return false; } object.type = allTypes.indexOf(args[0].toLowerCase()); + ChunkGenerator gen = SetupUtils.generators.get(object.setupGenerator); if (object.type == 0) { object.current++; if (object.step == null) { - ChunkGenerator gen = SetupUtils.generators.get(object.setupGenerator); - if (gen instanceof PlotGenerator) { - object.plotManager = object.setupGenerator; - object.step = ((PlotGenerator) SetupUtils.generators.get(object.setupGenerator)).getNewPlotWorld(null).getSettingNodes(); - ((PlotGenerator) gen).processSetup(object, plr); - } - else { - - - MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as PlotGenerator"); - MainUtil.sendMessage(plr, "&7Searching for a configuration script..."); - - boolean script = false; - // TODO allow external configuration scripts - - MainUtil.sendMessage(plr, "&cNo script has been found:"); - MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin"); - object.step = ((PlotGenerator) SetupUtils.generators.get("PlotSquared")).getNewPlotWorld(null).getSettingNodes(); - } + object.plotManager = object.setupGenerator; + object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); } else { + if (gen instanceof PlotGenerator) { + object.plotManager = object.setupGenerator; + object.setupGenerator = null; + object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); + } + else { + object.plotManager = "PlotSquared"; + MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as PlotGenerator"); + MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin"); + object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); + } MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); } object.current++; break; } case 2: { // Choose terrain - final List terrain = Arrays.asList(new String[] { "none", "ore", "all" }); + final List terrain = Arrays.asList(new String[] { "none", "ore", "road", "all" }); if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) { - MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation&8 - &7ROAD&8 - &7Vanilla except for roads\n" + "&8 - &7ALL&8 - &7Entirely vanilla generation"); return false; } object.terrain = terrain.indexOf(args[0].toLowerCase()); object.current++; if (object.step == null) { - object.step = SetupUtils.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes(); + object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); @@ -211,11 +216,11 @@ public class Setup extends SubCommand { object.world = args[0]; SetupUtils.setupMap.remove(plr.getName()); final String world; - if (object.manager == null) { + if (object.setupManager == null) { world = SetupUtils.manager.setupWorld(object); } else { - + world = object.setupManager.setupWorld(object); } try { plr.teleport(BlockManager.manager.getSpawn(world)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 7bdab70c1..4b40fe96d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -90,14 +90,21 @@ public class Template extends SubCommand { } catch (IOException e) { e.printStackTrace(); } - String generator = worldConfig.getString("generator.plugin"); - if (generator == null) { - generator = "PlotSquared"; + String manager = worldConfig.getString("generator.plugin"); + if (manager == null) { + manager = "PlotSquared"; } + String generator = worldConfig.getString("generator.init"); + if (generator == null) { + generator = manager; + } + int type = worldConfig.getInt("generator.type"); int terrain = worldConfig.getInt("generator.terrain"); + SetupObject setup = new SetupObject(); - setup.generator = generator; + setup.plotManager = manager; + setup.setupGenerator = generator; setup.type = type; setup.terrain = terrain; setup.step = new ConfigurationNode[0]; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index fe284fdcb..844268176 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -51,19 +51,36 @@ public class AugmentedPopulator extends BlockPopulator { } } - public BlockWrapper get(final int X, final int Z, final int i, final int j, final short[][] r, final boolean c) { + public BlockWrapper get(final int x, final int z, final int i, final int j, final short[][] r, final boolean c) { final int y = (i << 4) + (j >> 8); final int a = (j - ((y & 0xF) << 8)); - final int z = (a >> 4); - final int x = a - (z << 4); + final int z1 = (a >> 4); + final int x1 = a - (z1 << 4); if (r[i] == null) { - return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, (short) 0, (byte) 0); + return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, (short) 0, (byte) 0); } else { - return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, r[i][j], (byte) 0); + return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, r[i][j], (byte) 0); } } + + private short[][] x_loc; + private short[][] y_loc; + private short[][] z_loc; public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { + for (int i = 0; i < 16; i++) { + int i4 = i << 4; + for (int j = 0; j < 4096; j++) { + final int y = (i4) + (j >> 8); + final int a = (j - ((y & 0xF) << 8)); + final int z1 = (a >> 4); + final int x1 = a - (z1 << 4); + x_loc[i][j] = (short) x1; + y_loc[i][j] = (short) y; + z_loc[i][j] = (short) z1; + } + } + this.cluster = cluster; this.generator = generator; this.plotworld = PlotSquared.getPlotWorld(world); @@ -95,6 +112,10 @@ public class AugmentedPopulator extends BlockPopulator { @Override public void populate(final World world, final Random rand, final Chunk chunk) { + if (this.plotworld.TERRAIN == 3) { + // FIXME check CURRENT_PLOT_CLEAR && FORCE_PASTE + return; + } final int X = chunk.getX(); final int Z = chunk.getZ(); final int x = X << 4; @@ -116,7 +137,7 @@ public class AugmentedPopulator extends BlockPopulator { } else { check = false; } - if (this.plotworld.TERRAIN == 2) { + if (this.plotworld.TERRAIN > 1) { final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, x, 0, z); final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, x2, 0, z2); if ((plot1 != null) && (plot2 != null) && plot1.equals(plot2)) { @@ -129,7 +150,8 @@ public class AugmentedPopulator extends BlockPopulator { TaskManager.runTaskLater(new Runnable() { @Override public void run() { - populateBiome(world, x, z); + // Don't need to populate biome with this +// populateBiome(world, x, z); MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } }, 20); @@ -161,28 +183,32 @@ public class AugmentedPopulator extends BlockPopulator { } } } - + private void populateBlocks(final World world, final Random rand, final int X, final int Z, final int x, final int z, final boolean check) { final short[][] result = this.generator.generateExtBlockSections(world, rand, X, Z, null); - final int length = result[0].length; for (int i = 0; i < result.length; i++) { - for (int j = 0; j < length; j++) { - final BlockWrapper blockInfo = get(x, z, i, j, result, check); - if (blockInfo == null) { - continue; - } - final int xx = x + blockInfo.x; - final int zz = z + blockInfo.z; - if (this.p) { - if (ChunkManager.CURRENT_PLOT_CLEAR != null) { - if (BukkitChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, xx, zz)) { - continue; - } - } else if (this.manager.getPlotIdAbs(this.plotworld, xx, 0, zz) != null) { + if (result[i] != null) { + for (int j = 0; j < 4096; j++) { + int x1 = x_loc[i][j]; + int y = y_loc[i][j]; + int z1 = z_loc[i][j]; + short id = result[i][j]; + final int xx = x + x1; + final int zz = z + z1; + if (check && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) { continue; } + if (this.p) { + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + if (BukkitChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, xx, zz)) { + continue; + } + } else if (this.manager.getPlotIdAbs(this.plotworld, xx, 0, zz) != null) { + continue; + } + } + BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, id, (byte) 0); } - BukkitSetBlockManager.setBlockManager.set(world, xx, blockInfo.y, zz, blockInfo.id, (byte) 0); } } for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 368e15eee..6d5948b9d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -178,5 +178,5 @@ public abstract class PlotGenerator extends ChunkGenerator { public abstract PlotManager getPlotManager(); - public void processSetup(SetupObject object, PlotPlayer player) {}; + public void processSetup(SetupObject object) {}; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index b908b1c81..5dafb8934 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.object.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; @@ -44,6 +45,8 @@ public class BukkitSetupUtils extends SetupUtils { @Override public String setupWorld(final SetupObject object) { + SetupUtils.manager.updateGenerators(); + ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);; final ConfigurationNode[] steps = object.step; final String world = object.world; for (final ConfigurationNode step : steps) { From 29cf1326f6ee7903ebeafed74deb9bff91f85371 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 22 Apr 2015 00:19:46 +1000 Subject: [PATCH 182/223] Fixes #242 --- .../plot/generator/AugmentedPopulator.java | 32 +++++++++++-------- .../plot/object/PlotPopulator.java | 13 ++++++++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index 844268176..44ef93699 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -63,21 +63,26 @@ public class AugmentedPopulator extends BlockPopulator { } } - private short[][] x_loc; - private short[][] y_loc; - private short[][] z_loc; + private static short[][] x_loc; + private static short[][] y_loc; + private static short[][] z_loc; public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { - for (int i = 0; i < 16; i++) { - int i4 = i << 4; - for (int j = 0; j < 4096; j++) { - final int y = (i4) + (j >> 8); - final int a = (j - ((y & 0xF) << 8)); - final int z1 = (a >> 4); - final int x1 = a - (z1 << 4); - x_loc[i][j] = (short) x1; - y_loc[i][j] = (short) y; - z_loc[i][j] = (short) z1; + if (x_loc == null) { + x_loc = new short[16][4096]; + y_loc = new short[16][4096]; + z_loc = new short[16][4096]; + for (int i = 0; i < 16; i++) { + int i4 = i << 4; + for (int j = 0; j < 4096; j++) { + final int y = (i4) + (j >> 8); + final int a = (j - ((y & 0xF) << 8)); + final int z1 = (a >> 4); + final int x1 = a - (z1 << 4); + x_loc[i][j] = (short) x1; + y_loc[i][j] = (short) y; + z_loc[i][j] = (short) z1; + } } } @@ -113,7 +118,6 @@ public class AugmentedPopulator extends BlockPopulator { @Override public void populate(final World world, final Random rand, final Chunk chunk) { if (this.plotworld.TERRAIN == 3) { - // FIXME check CURRENT_PLOT_CLEAR && FORCE_PASTE return; } final int X = chunk.getX(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index 15852aea6..dfe7f917a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -76,6 +76,19 @@ public abstract class PlotPopulator extends BlockPopulator { * @param data */ public void setBlock(int x, int y, int z, byte data) { + if (data != 0) { + world.getBlockAt(X + x, y, Z + z).setData(data); + } + } + + /** + * Like setblock, but lacks the data != 0 check + * @param x + * @param y + * @param z + * @param data + */ + public void setBlockAbs(int x, int y, int z, byte data) { world.getBlockAt(X + x, y, Z + z).setData(data); } From 5882a9c58f368a74a1b14ab38ea00b5031c3eeb8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 22 Apr 2015 00:46:59 +1000 Subject: [PATCH 183/223] Terrain mode 3 augmented sch pasting + plot clearing. --- .../plot/generator/AugmentedPopulator.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index 44ef93699..2174efbd6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -1,7 +1,9 @@ package com.intellectualcrafters.plot.generator; +import java.util.HashMap; import java.util.Iterator; import java.util.Random; +import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -16,6 +18,7 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; @@ -118,6 +121,53 @@ public class AugmentedPopulator extends BlockPopulator { @Override public void populate(final World world, final Random rand, final Chunk chunk) { if (this.plotworld.TERRAIN == 3) { + int X = chunk.getX() << 4; + int Z = chunk.getZ() << 4; + if (ChunkManager.FORCE_PASTE) { + for (short x = 0; x < 16; x++) { + for (short z = 0; z < 16; z++) { + final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); + final HashMap blocks = ChunkManager.GENERATE_BLOCKS.get(loc); + HashMap datas = ChunkManager.GENERATE_DATA.get(loc); + for (final Entry entry : blocks.entrySet()) { + int y = entry.getKey(); + byte data; + if (datas != null) { + data = datas.get(y); + } + else { + data = 0; + } + BukkitSetBlockManager.setBlockManager.set(world, x, y, z, blocks.get(y), (byte) data); + } + } + } + return; + } + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + PlotLoc loc; + for (Entry> entry : ChunkManager.GENERATE_DATA.entrySet()) { + HashMap datas = ChunkManager.GENERATE_DATA.get(entry.getKey()); + for (Entry entry2 : entry.getValue().entrySet()) { + Short y = entry2.getKey(); + byte data; + if (datas != null) { + data = datas.get(y); + } + else { + data = 0; + } + loc = entry.getKey(); + int xx = loc.x - X; + int zz = loc.z - Z; + if (xx >= 0 && xx < 16) { + if (zz >= 0 && zz < 16) { + BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, entry2.getValue(), (byte) data); + } + } + } + } + } return; } final int X = chunk.getX(); From 0da524bfdef62774635823abbd03856285706d98 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 22 Apr 2015 09:32:01 +1000 Subject: [PATCH 184/223] Fixes #271 --- .../plot/listeners/PlayerEvents.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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 8e168fca0..8d3422ba4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -738,7 +738,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { - if (event.getAction() == Action.LEFT_CLICK_BLOCK) { + Action action = event.getAction(); + if (action == Action.LEFT_CLICK_BLOCK) { return; } final Block block = event.getClickedBlock(); @@ -758,7 +759,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { return; } - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); + if (action != Action.PHYSICAL) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); + } event.setCancelled(true); return; } @@ -771,7 +774,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.interact.other")) { return; } - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); + if (action != Action.PHYSICAL) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); + } event.setCancelled(true); return; } @@ -782,7 +787,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); + if (action != Action.PHYSICAL) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); + } event.setCancelled(true); return; } From 41bb2c028487782d8684f96b95e986dfa3d55b54 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 24 Apr 2015 19:47:31 +1000 Subject: [PATCH 185/223] Fixes #220 --- .../plot/listeners/PlayerEvents.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) 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 8d3422ba4..1a4b4610f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -20,12 +20,14 @@ import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Fireball; +import org.bukkit.entity.FishHook; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LargeFireball; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.SmallFireball; +import org.bukkit.entity.Snowball; import org.bukkit.entity.Tameable; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.Vehicle; @@ -1298,27 +1300,29 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi else if (damager instanceof Projectile) { projectile = (Projectile) damager; //Arrow, Egg, EnderPearl, Fireball, Fish, FishHook, LargeFireball, SmallFireball, Snowball, ThrownExpBottle, ThrownPotion, WitherSkull - if (damager instanceof Arrow || damager instanceof LargeFireball || damager instanceof Fireball || damager instanceof SmallFireball) { - ProjectileSource shooter = projectile.getShooter(); - if (shooter == null || !(shooter instanceof Player)) { - return; - } - p = (Player) shooter; - } - else if (damager instanceof ThrownPotion) { - ThrownPotion potion = (ThrownPotion) damager; - Collection effects = potion.getEffects(); - for (PotionEffect effect : effects) { - PotionEffectType type = effect.getType(); - if (type == PotionEffectType.BLINDNESS || type == PotionEffectType.CONFUSION || type == PotionEffectType.HARM || type == PotionEffectType.INVISIBILITY || type == PotionEffectType.POISON || type == PotionEffectType.SLOW || type == PotionEffectType.SLOW_DIGGING || type == PotionEffectType.WEAKNESS || type == PotionEffectType.WITHER) { - ProjectileSource shooter = ((Projectile) damager).getShooter(); - if (shooter == null || !(shooter instanceof Player)) { - return; + if (damager instanceof Projectile) { + if (damager instanceof ThrownPotion) { + ThrownPotion potion = (ThrownPotion) damager; + Collection effects = potion.getEffects(); + for (PotionEffect effect : effects) { + PotionEffectType type = effect.getType(); + if (type == PotionEffectType.BLINDNESS || type == PotionEffectType.CONFUSION || type == PotionEffectType.HARM || type == PotionEffectType.INVISIBILITY || type == PotionEffectType.POISON || type == PotionEffectType.SLOW || type == PotionEffectType.SLOW_DIGGING || type == PotionEffectType.WEAKNESS || type == PotionEffectType.WITHER) { + ProjectileSource shooter = ((Projectile) damager).getShooter(); + if (shooter == null || !(shooter instanceof Player)) { + return; + } + p = (Player) shooter; + break; } - p = (Player) shooter; - break; } } + else { + ProjectileSource shooter = projectile.getShooter(); + if (shooter == null || !(shooter instanceof Player)) { + return; + } + p = (Player) shooter; + } } else { return; From 5c6bc8b1ba5686be3daa972018bde988aa613766 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 24 Apr 2015 22:07:00 +1000 Subject: [PATCH 186/223] Fixed piston from unowned --- .../plot/listeners/PlayerEvents.java | 63 ++++++++++--------- .../plot/util/MainUtil.java | 10 +++ 2 files changed, 43 insertions(+), 30 deletions(-) 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 1a4b4610f..1e3770399 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -665,36 +665,34 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } Plot plot = MainUtil.getPlot(loc); - if (plot != null) { - BlockFace face = event.getDirection(); - Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); - List blocks = event.getBlocks(); - for (final Block b : blocks) { - Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative)); - Plot newPlot = MainUtil.getPlot(bloc); - if (!plot.equals(newPlot)) { - event.setCancelled(true); - return; - } - } - if (!Settings.PISTON_FALLING_BLOCK_CHECK) { + BlockFace face = event.getDirection(); + Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ()); + List blocks = event.getBlocks(); + for (final Block b : blocks) { + Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative)); + Plot newPlot = MainUtil.getPlot(bloc); + if (MainUtil.equals(plot, newPlot)) { + event.setCancelled(true); return; } - org.bukkit.Location lastLoc; - if (blocks.size() > 0) { - lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative); - } - else { - lastLoc = event.getBlock().getLocation().add(relative); - } - Entity[] ents = lastLoc.getChunk().getEntities(); - for (Entity entity : ents) { - if (entity instanceof FallingBlock) { - org.bukkit.Location eloc = entity.getLocation(); - if (eloc.distanceSquared(lastLoc) < 2) { - event.setCancelled(true); - return; - } + } + if (!Settings.PISTON_FALLING_BLOCK_CHECK) { + return; + } + org.bukkit.Location lastLoc; + if (blocks.size() > 0) { + lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative); + } + else { + lastLoc = event.getBlock().getLocation().add(relative); + } + Entity[] ents = lastLoc.getChunk().getEntities(); + for (Entity entity : ents) { + if (entity instanceof FallingBlock) { + org.bukkit.Location eloc = entity.getLocation(); + if (eloc.distanceSquared(lastLoc) < 2) { + event.setCancelled(true); + return; } } } @@ -729,15 +727,20 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final List blocks = e.getBlocks(); + if (blocks.size() == 0) { + return; + } + Plot origin = MainUtil.getPlot(BukkitUtil.getLocation(blocks.get(0).getLocation())); + BlockState start = blocks.get(0); for (int i = blocks.size() - 1; i >= 0; i--) { final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation()); final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { + if (MainUtil.equals(plot, origin)) { e.getBlocks().remove(i); } } } - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public static void onInteract(final PlayerInteractEvent event) { Action action = event.getAction(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 319b80df4..0105ef80b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -79,6 +79,16 @@ public class MainUtil { } return myplots; } + + public static boolean equals(Object a, Object b) { + if (a == b) { + return true; + } + if (a == null ^ b == null) { + return false; + } + return a.equals(b); + } /** * Get the number of plots for a player From c09c5b048e16b6399fe690ca278b79f528ed027f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 25 Apr 2015 01:43:59 +1000 Subject: [PATCH 187/223] Allow gmask/mask --- .../plot/listeners/worldedit/WEListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index a1182c30d..4e22eb116 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -50,7 +50,7 @@ public class WEListener implements Listener { public final HashSet region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr", "regen", "copy", "cut", "green", "setbiome")); public final HashSet regionExtend = new HashSet<>(Arrays.asList("stack")); public final HashSet unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem")); - public final HashSet unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "gmask", "mask", "restore", "snapshot", "delchunks", "listchunks", "sel poly")); + public final HashSet unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks", "sel poly")); public final HashSet unsafe2 = new HashSet<>(Arrays.asList("sel poly", "worldedit reload")); public final HashSet restricted = new HashSet<>(Arrays.asList("up")); From ec80151cd95c8398da0bd09fa711d2638735ffa0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 16:29:58 +1000 Subject: [PATCH 188/223] Cleanup --- .../intellectualcrafters/plot/BukkitMain.java | 24 +- .../intellectualcrafters/plot/IPlotMain.java | 7 + .../plot/PlotSquared.java | 8 + .../plot/commands/FlagCmd.java | 8 +- .../plot/commands/SchematicCmd.java | 4 - .../plot/commands/Set.java | 8 +- .../plot/commands/WE_Anywhere.java | 2 - .../plot/database/SQLManager.java | 18 +- .../plot/flag/FlagManager.java | 12 + .../plot/generator/AugmentedPopulator.java | 2 +- .../plot/listeners/APlotListener.java | 13 + .../plot/listeners/ChunkListener.java | 3 - .../plot/listeners/ForceFieldListener.java | 2 +- .../plot/listeners/PlayerEvents.java | 430 +++++++++--------- .../plot/listeners/PlayerEvents_1_8.java | 50 +- .../plot/listeners/PlotListener.java | 95 +--- .../plot/listeners/PlotPlusListener.java | 12 +- .../plot/listeners/worldedit/WEListener.java | 14 - .../plot/util/ClusterManager.java | 16 +- .../plot/util/MainUtil.java | 48 ++ .../plot/util/SchematicHandler.java | 1 - .../plot/util/SetBlockQueue.java | 1 - .../plot/util/SetupUtils.java | 1 - .../plot/util/bukkit/BukkitChunkManager.java | 8 +- .../plot/util/bukkit/BukkitSetupUtils.java | 1 - 25 files changed, 417 insertions(+), 371 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/APlotListener.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 94e0171db..f7afb4a5d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -30,11 +30,13 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.listeners.ChunkListener; import com.intellectualcrafters.plot.listeners.ForceFieldListener; import com.intellectualcrafters.plot.listeners.InventoryListener; import com.intellectualcrafters.plot.listeners.PlayerEvents; import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; +import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.TNTListener; import com.intellectualcrafters.plot.listeners.WorldEvents; @@ -107,13 +109,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } else { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } - getServer().getPluginManager().registerEvents(new WorldEvents(), this); - - // Experimental - if (Settings.CHUNK_PROCESSOR) { - getServer().getPluginManager().registerEvents(new ChunkListener(), this); - } - List worlds = Bukkit.getWorlds(); if (worlds.size() > 0) { UUIDHandler.cacheAll(worlds.get(0).getName()); @@ -398,4 +393,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public void unregister(PlotPlayer player) { BukkitUtil.removePlayer(player.getName()); } + + @Override + public APlotListener initPlotListener() { + return new PlotListener(); + } + + @Override + public void registerChunkProcessor() { + getServer().getPluginManager().registerEvents(new ChunkListener(), this); + } + + @Override + public void registerWorldEvents() { + getServer().getPluginManager().registerEvents(new WorldEvents(), this); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 907cb05ec..5f1cb2e68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -7,6 +7,7 @@ import net.milkbowl.vault.economy.Economy; import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; @@ -61,4 +62,10 @@ public interface IPlotMain { public void unregister(PlotPlayer player); public ChunkGenerator getGenerator(String world, String name); + + public APlotListener initPlotListener(); + + public void registerChunkProcessor(); + + public void registerWorldEvents(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 70b848e1c..3427babc1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -48,6 +48,7 @@ import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.SquarePlotManager; import com.intellectualcrafters.plot.generator.SquarePlotWorld; +import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotCluster; @@ -528,6 +529,10 @@ public class PlotSquared { IMP.registerPlotPlusEvents(); IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); + IMP.registerWorldEvents(); + if (Settings.CHUNK_PROCESSOR) { + IMP.registerChunkProcessor(); + } // create UUIDWrapper UUIDHandler.uuidWrapper = IMP.initUUIDHandler(); // create event util class @@ -540,6 +545,9 @@ public class PlotSquared { BlockManager.manager = IMP.initBlockManager(); // Set chunk ChunkManager.manager = IMP.initChunkManager(); + // Plot listener + APlotListener.manager = IMP.initPlotListener(); + // PlotMe if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { TaskManager.runTaskLater(new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index e1fb81ce1..082458fb7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagValue; -import com.intellectualcrafters.plot.listeners.PlotListener; +import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -125,7 +125,7 @@ public class FlagCmd extends SubCommand { return false; } MainUtil.sendMessage(player, C.FLAG_ADDED); - PlotListener.plotEntry(player, plot); + APlotListener.manager.plotEntry(player, plot); return true; } case "remove": { @@ -163,7 +163,7 @@ public class FlagCmd extends SubCommand { } } MainUtil.sendMessage(player, C.FLAG_REMOVED); - PlotListener.plotEntry(player, plot); + APlotListener.manager.plotEntry(player, plot); return true; } case "add": { @@ -203,7 +203,7 @@ public class FlagCmd extends SubCommand { } DBFunc.setFlags(plot.world, plot, plot.settings.flags); MainUtil.sendMessage(player, C.FLAG_ADDED); - PlotListener.plotEntry(player, plot); + APlotListener.manager.plotEntry(player, plot); return true; } case "list": { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index c36ef959f..075f4b5f2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -23,12 +23,9 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; -import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -42,7 +39,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Dimension; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class SchematicCmd extends SubCommand { private int counter = 0; 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 b90d2193f..10e19d329 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.listeners.PlotListener; +import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -90,8 +90,6 @@ public class Set extends SubCommand { break; } } - /* TODO: Implement option */ - // final boolean advanced_permissions = true; if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); return false; @@ -127,7 +125,7 @@ public class Set extends SubCommand { return false; } MainUtil.sendMessage(plr, C.FLAG_REMOVED); - PlotListener.plotEntry(plr, plot); + APlotListener.manager.plotEntry(plr, plot); return true; } try { @@ -144,7 +142,7 @@ public class Set extends SubCommand { return false; } MainUtil.sendMessage(plr, C.FLAG_ADDED); - PlotListener.plotEntry(plr, plot); + APlotListener.manager.plotEntry(plr, plot); return true; } catch (final Exception e) { MainUtil.sendMessage(plr, "&c" + e.getMessage()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 06ba35ccf..333847663 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -22,9 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.listeners.worldedit.WEListener; import com.intellectualcrafters.plot.listeners.worldedit.WEManager; -import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 748a8d5ae..e019c6e25 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -97,13 +97,19 @@ public class SQLManager implements AbstractDB { TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { - try { - SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); - } catch (final Exception e) { - e.printStackTrace(); - } + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + try { + System.out.print("CONNECTIN"); + SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); + } catch (final Exception e) { + e.printStackTrace(); + } + } + }); } - }, 11000); + }, 1); } updateTables(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 4a342eb6b..b654d1032 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -94,6 +94,18 @@ public class FlagManager { } return null; } + + public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) { + final Flag flag = FlagManager.getPlotFlag(plot, key); + if (flag == null) { + return defaultValue; + } + final Object value = flag.getValue(); + if (value instanceof Boolean) { + return (boolean) value; + } + return defaultValue; + } /** * Get the value of a flag for a plot (respects flag defaults) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index 2174efbd6..377eab737 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -2,8 +2,8 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.Iterator; -import java.util.Random; import java.util.Map.Entry; +import java.util.Random; import org.bukkit.Bukkit; import org.bukkit.Chunk; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/APlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/APlotListener.java new file mode 100644 index 000000000..6a50dacf8 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/APlotListener.java @@ -0,0 +1,13 @@ +package com.intellectualcrafters.plot.listeners; + +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; + +public abstract class APlotListener { + + public static APlotListener manager; + + public abstract void plotExit(final PlotPlayer player, final Plot plot); + + public abstract void plotEntry(final PlotPlayer player, final Plot plot); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index e337aa9f5..17e9942ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -3,14 +3,11 @@ package com.intellectualcrafters.plot.listeners; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; -import org.bukkit.World; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Item; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 1c1ca51e0..184269231 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -105,7 +105,7 @@ public class ForceFieldListener implements Listener { return; } if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) { - if (!PlotListener.booleanFlag(plot, "forcefield", false)) { + if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) { final UUID uuid = pp.getUUID(); if (plot.isAdded(uuid)) { final Set players = getNearbyPlayers(player, plot); 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 1e3770399..2a074caa0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -19,15 +19,10 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Fireball; -import org.bukkit.entity.FishHook; import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.LargeFireball; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; -import org.bukkit.entity.SmallFireball; -import org.bukkit.entity.Snowball; import org.bukkit.entity.Tameable; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.Vehicle; @@ -86,7 +81,6 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.listeners.worldedit.WEListener; import com.intellectualcrafters.plot.listeners.worldedit.WEManager; import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; @@ -115,10 +109,10 @@ import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { @EventHandler - public static void onRedstoneEvent(BlockRedstoneEvent event) { + public void onRedstoneEvent(BlockRedstoneEvent event) { Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); - if (!isPlotWorld(loc.getWorld())) { + if (!PlotSquared.isPlotWorld(loc.getWorld())) { return; } Plot plot = MainUtil.getPlot(loc); @@ -129,7 +123,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (redstone == null || (Boolean) redstone.getValue()) { return; } - if (!isPlotArea(loc)) { + if (!MainUtil.isPlotArea(plot)) { return; } switch (block.getType()) { @@ -166,10 +160,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler - public static void onPhysicsEvent(BlockPhysicsEvent event) { + public void onPhysicsEvent(BlockPhysicsEvent event) { Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); - if (!isPlotWorld(loc.getWorld())) { + if (!PlotSquared.isPlotWorld(loc.getWorld())) { return; } switch (block.getType()) { @@ -183,7 +177,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (redstone == null || (Boolean) redstone.getValue()) { return; } - if (!isPlotArea(loc)) { + if (!MainUtil.isPlotArea(plot)) { return; } event.setCancelled(true); @@ -196,11 +190,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi public void onProjectileHit(ProjectileHitEvent event) { Projectile entity = (Projectile) event.getEntity(); Location loc = BukkitUtil.getLocation(entity); - if (!isPlotWorld(loc.getWorld())) { + if (!PlotSquared.isPlotWorld(loc.getWorld())) { return; } Plot plot = MainUtil.getPlot(loc); - if (!isPlotArea(loc)) { + if (!MainUtil.isPlotArea(loc)) { return; } ProjectileSource shooter = entity.getShooter(); @@ -252,7 +246,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void onChunkLoad(final ChunkLoadEvent event) { + public void onChunkLoad(final ChunkLoadEvent event) { final String worldname = event.getWorld().getName(); final Chunk chunk = event.getChunk(); if (MainUtil.worldBorder.containsKey(worldname)) { @@ -266,7 +260,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void onJoin(final PlayerJoinEvent event) { + public void onJoin(final PlayerJoinEvent event) { final Player player = event.getPlayer(); if (!player.hasPlayedBefore()) { player.saveData(); @@ -289,7 +283,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public static void PlayerMove(final PlayerMoveEvent event) { + public void PlayerMove(final PlayerMoveEvent event) { final Location f = BukkitUtil.getLocation(event.getFrom()); final Location t = BukkitUtil.getLocation(event.getTo()); if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) { @@ -298,7 +292,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi TaskManager.TELEPORT_QUEUE.remove(player.getName()); } final String worldname = t.getWorld(); - if (!isPlotWorld(worldname)) { + if (!PlotSquared.isPlotWorld(worldname)) { return; } if (MainUtil.worldBorder.containsKey(worldname)) { @@ -322,7 +316,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } - Plot plot = getCurrentPlot(t); + Plot plot = MainUtil.getPlot(t); if (plot != null) { if (plot.denied.size() > 0) { final PlotPlayer pp = BukkitUtil.getPlayer(player); @@ -334,22 +328,22 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - if (!plot.equals(getCurrentPlot(f))) { + if (!plot.equals(MainUtil.getPlot(f))) { plotEntry(player, plot); } } - else if (leftPlot(f, t)) { - plot = getCurrentPlot(f); - plotExit(player, plot); + else if (MainUtil.leftPlot(f, t)) { + plot = MainUtil.getPlot(f); + plotExit(BukkitUtil.getPlayer(player), plot); } } } @EventHandler(priority = EventPriority.HIGHEST) - public static void onChat(final AsyncPlayerChatEvent event) { + public void onChat(final AsyncPlayerChatEvent event) { final Player player = event.getPlayer(); final String world = player.getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); @@ -357,7 +351,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final Location loc = BukkitUtil.getLocation(player); - final Plot plot = getCurrentPlot(loc); + final Plot plot = MainUtil.getPlot(loc); if (plot == null) { return; } @@ -368,7 +362,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Set recipients = event.getRecipients(); recipients.clear(); for (final Player p : Bukkit.getOnlinePlayers()) { - if (getCurrentPlot(BukkitUtil.getLocation(p)) == plot) { + if (MainUtil.getPlot(BukkitUtil.getLocation(p)) == plot) { recipients.add(p); } } @@ -378,14 +372,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH) - public static void BlockDestroy(final BlockBreakEvent event) { + public void BlockDestroy(final BlockBreakEvent event) { final Player player = event.getPlayer(); final String world = player.getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); - final Plot plot = getCurrentPlot(loc); + final Plot plot = MainUtil.getPlot(loc); if (plot != null) { if (event.getBlock().getY() == 0) { event.setCancelled(true); @@ -420,7 +414,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) { return; } - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); return; @@ -428,32 +422,32 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void onBigBoom(final EntityExplodeEvent event) { + public void onBigBoom(final EntityExplodeEvent event) { Location loc = BukkitUtil.getLocation(event.getLocation()); final String world = loc.getWorld(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } - final Plot plot = getCurrentPlot(loc); + final Plot plot = MainUtil.getPlot(loc); if ((plot != null) && plot.hasOwner()) { if (FlagManager.isPlotFlagTrue(plot, "explosion")) { final Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { final Block b = iter.next(); - if (!plot.equals(getCurrentPlot(BukkitUtil.getLocation(b.getLocation())))) { + if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) { iter.remove(); } } return; } } - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { event.setCancelled(true); } else { final Iterator iter = event.blockList().iterator(); while (iter.hasNext()) { iter.next(); - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { iter.remove(); } } @@ -461,7 +455,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onWorldChanged(final PlayerChangedWorldEvent event) { + public void onWorldChanged(final PlayerChangedWorldEvent event) { final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); if (PlotSquared.worldEdit != null) { WEManager.bypass.remove(player.getName()); @@ -471,9 +465,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { + public void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { final String world = event.getBlock().getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } final Entity e = event.getEntity(); @@ -486,16 +480,18 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Block b = event.getBlock(); final Player p = (Player) e; final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (!isInPlot(loc)) { - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); - event.setCancelled(true); - return; + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + if (MainUtil.isPlotAreaAbs(loc)) { + final PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); + event.setCancelled(true); + return; + } } } else { - final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -506,7 +502,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!plot.isAdded(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; @@ -519,63 +515,57 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onEntityBlockForm(final EntityBlockFormEvent e) { + public void onEntityBlockForm(final EntityBlockFormEvent e) { final String world = e.getBlock().getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } if ((!(e.getEntity() instanceof Player))) { - if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { + if (MainUtil.isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { e.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onBS(final BlockSpreadEvent e) { + public void onBS(final BlockSpreadEvent e) { final Block b = e.getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { - if (!isInPlot(loc)) { - if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { - e.setCancelled(true); - } + if (PlotSquared.isPlotWorld(loc.getWorld())) { + if (MainUtil.isPlotRoad(loc)) { + e.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onBF(final BlockFormEvent e) { + public void onBF(final BlockFormEvent e) { final Block b = e.getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { - if (!isInPlot(loc)) { - if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { - e.setCancelled(true); - } + if (PlotSquared.isPlotWorld(loc.getWorld())) { + if (MainUtil.isPlotRoad(loc)) { + e.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onBD(final BlockDamageEvent event) { + public void onBD(final BlockDamageEvent event) { final Player player = event.getPlayer(); if (player == null) { final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); - if (isPlotWorld(loc)) { - if (!isInPlot(loc)) { - if (isPlotArea(loc)) { - event.setCancelled(true); - } + if (PlotSquared.isPlotWorld(loc.getWorld())) { + if (MainUtil.isPlotRoad(loc)) { + event.setCancelled(true); } } } final String world = player.getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); - final Plot plot = getCurrentPlot(loc); + final Plot plot = MainUtil.getPlot(loc); if (plot != null) { if (event.getBlock().getY() == 0) { event.setCancelled(true); @@ -610,7 +600,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) { return; } - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); return; @@ -618,46 +608,40 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onFade(final BlockFadeEvent e) { + public void onFade(final BlockFadeEvent e) { final Block b = e.getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { - if (!isInPlot(loc)) { - if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { - e.setCancelled(true); - } + if (PlotSquared.isPlotWorld(loc.getWorld())) { + if (MainUtil.isPlotRoad(loc)) { + e.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onChange(final BlockFromToEvent e) { + public void onChange(final BlockFromToEvent e) { final Block b = e.getToBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { - if (!isInPlot(loc)) { - if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { - e.setCancelled(true); - } + if (PlotSquared.isPlotWorld(loc.getWorld())) { + if (MainUtil.isPlotRoad(loc)) { + e.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onGrow(final BlockGrowEvent e) { + public void onGrow(final BlockGrowEvent e) { final Block b = e.getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { - if (!isInPlot(loc)) { - if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { - e.setCancelled(true); - } + if (PlotSquared.isPlotWorld(loc.getWorld())) { + if (MainUtil.isPlotRoad(loc)) { + e.setCancelled(true); } } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public static void onBlockPistonExtend(final BlockPistonExtendEvent event) { + public void onBlockPistonExtend(final BlockPistonExtendEvent event) { final Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); String world = loc.getWorld(); @@ -671,7 +655,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi for (final Block b : blocks) { Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative)); Plot newPlot = MainUtil.getPlot(bloc); - if (MainUtil.equals(plot, newPlot)) { + if (!MainUtil.equals(plot, newPlot)) { event.setCancelled(true); return; } @@ -698,23 +682,41 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } + private boolean pistonBlocks = true; + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public static void onBlockPistonRetract(final BlockPistonRetractEvent event) { + public void onBlockPistonRetract(final BlockPistonRetractEvent event) { final Block block = event.getBlock(); Location loc = BukkitUtil.getLocation(block.getLocation()); String world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { return; } - if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_MOVING_PIECE) { + if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_BASE && block.getType() != Material.PISTON_MOVING_PIECE) { return; } + Plot plot = MainUtil.getPlot(loc); - if (plot != null) { + + if (pistonBlocks) { + try { + for (Block pulled : event.getBlocks()) { + Plot other = MainUtil.getPlot(BukkitUtil.getLocation(pulled.getLocation())); + if (!MainUtil.equals(plot, other)) { + event.setCancelled(true); + return; + } + } + } + catch (Exception e) { + pistonBlocks = false; + } + } + if (!pistonBlocks && block.getType() != Material.PISTON_BASE) { BlockFace dir = event.getDirection(); Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2)); Plot newPlot = MainUtil.getPlot(bloc); - if (!plot.equals(newPlot)) { + if (!MainUtil.equals(plot, newPlot)) { event.setCancelled(true); return; } @@ -722,8 +724,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onStructureGrow(final StructureGrowEvent e) { - if (!isPlotWorld(e.getWorld().getName())) { + public void onStructureGrow(final StructureGrowEvent e) { + if (!PlotSquared.isPlotWorld(e.getWorld().getName())) { return; } final List blocks = e.getBlocks(); @@ -734,15 +736,15 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi BlockState start = blocks.get(0); for (int i = blocks.size() - 1; i >= 0; i--) { final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation()); - final Plot plot = getCurrentPlot(loc); - if (MainUtil.equals(plot, origin)) { + final Plot plot = MainUtil.getPlot(loc); + if (!MainUtil.equals(plot, origin)) { e.getBlocks().remove(i); } } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void onInteract(final PlayerInteractEvent event) { + public void onInteract(final PlayerInteractEvent event) { Action action = event.getAction(); if (action == Action.LEFT_CLICK_BLOCK) { return; @@ -753,12 +755,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final Player player = event.getPlayer(); final String world = player.getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } final Location loc = BukkitUtil.getLocation(event.getClickedBlock().getLocation()); - if (isInPlot(loc)) { - final Plot plot = getCurrentPlot(loc); + + Plot plot = MainUtil.getPlot(loc); + if (plot != null) { if (!plot.hasOwner()) { final PlotPlayer pp = BukkitUtil.getPlayer(player); if (Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { @@ -791,7 +794,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.interact.road")) { return; } - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { if (action != Action.PHYSICAL) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); } @@ -801,17 +804,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void MobSpawn(final CreatureSpawnEvent event) { + public void MobSpawn(final CreatureSpawnEvent event) { Entity entity = event.getEntity(); if (entity instanceof Player) { return; } final Location loc = BukkitUtil.getLocation(event.getLocation()); final String world = loc.getWorld(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } - if (!isPlotArea(loc)) { + if (!MainUtil.isPlotArea(loc)) { return; } final PlotWorld pW = PlotSquared.getPlotWorld(world); @@ -893,7 +896,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onBlockIgnite(final BlockIgniteEvent e) { + public void onBlockIgnite(final BlockIgniteEvent e) { final Player player = e.getPlayer(); final Block b = e.getBlock(); final Location loc; @@ -922,7 +925,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else { return; } - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) { @@ -930,22 +933,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (player == null) { - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { e.setCancelled(true); } return; } final Player p = e.getPlayer(); - if (!isInPlot(loc)) { - final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); - e.setCancelled(true); - return; + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + if (MainUtil.isPlotAreaAbs(loc)) { + final PlotPlayer pp = BukkitUtil.getPlayer(p); + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); + e.setCancelled(true); + return; + } } } else { - final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); @@ -956,7 +961,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!plot.isAdded(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -968,7 +973,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public static void onTeleport(final PlayerTeleportEvent event) { + public void onTeleport(final PlayerTeleportEvent event) { if (event.getTo() == null || event.getFrom() == null) { return; } @@ -976,26 +981,26 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final Location t = BukkitUtil.getLocation(event.getTo()); final Location q = new Location(t.getWorld(), t.getX(), 64, t.getZ()); final Player player = event.getPlayer(); - if (isPlotWorld(q)) { - final Plot plot = getCurrentPlot(q); + if (PlotSquared.isPlotWorld(q.getWorld())) { + final Plot plot = MainUtil.getPlot(q); if (plot != null) { final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.isDenied(pp.getUUID())) { if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) { return; } - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); + MainUtil.sendMessage(pp, C.YOU_BE_DENIED); event.setCancelled(true); return; } else { - if (enteredPlot(f, t)) { + if (MainUtil.enteredPlot(f, t)) { plotEntry(player, plot); } } } else { - if (leftPlot(f, t)) { - final Plot plot2 = getCurrentPlot(f); - plotExit(player, plot2); + if (MainUtil.leftPlot(f, t)) { + final Plot plot2 = MainUtil.getPlot(f); + APlotListener.manager.plotExit(BukkitUtil.getPlayer(player), plot2); } } if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) { @@ -1006,22 +1011,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onBucketEmpty(final PlayerBucketEmptyEvent e) { + public void onBucketEmpty(final PlayerBucketEmptyEvent e) { final BlockFace bf = e.getBlockFace(); final Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { + if (PlotSquared.isPlotWorld(loc.getWorld())) { final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); - if (!isInPlot(loc)) { - if (Permissions.hasPermission(pp, "plots.admin.build.road")) { + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + if (MainUtil.isPlotAreaAbs(loc)) { + if (Permissions.hasPermission(pp, "plots.admin.build.road")) { + return; + } + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); + e.setCancelled(true); return; } - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); - e.setCancelled(true); - return; } else { - final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) { return; } @@ -1036,7 +1043,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.build.other")) { return; } - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -1047,7 +1054,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGHEST) - public static void onInventoryClick(final InventoryClickEvent event) { + public void onInventoryClick(final InventoryClickEvent event) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { event.setCancelled(true); return; @@ -1055,7 +1062,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler - public static void onLeave(final PlayerQuitEvent event) { + public void onLeave(final PlayerQuitEvent event) { PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); EventUtil.unregisterPlayer(pp); if (PlotSquared.worldEdit != null) { @@ -1074,22 +1081,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onBucketFill(final PlayerBucketFillEvent e) { + public void onBucketFill(final PlayerBucketFillEvent e) { final Block b = e.getBlockClicked(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { + if (PlotSquared.isPlotWorld(loc.getWorld())) { final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!isInPlot(loc)) { - if (Permissions.hasPermission(pp, "plots.admin.build.road")) { + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + if (MainUtil.isPlotAreaAbs(loc)) { + if (Permissions.hasPermission(pp, "plots.admin.build.road")) { + return; + } + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); + e.setCancelled(true); return; } - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); - e.setCancelled(true); - return; } else { - final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) { return; } @@ -1105,7 +1114,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Permissions.hasPermission(pp, "plots.admin.build.other")) { return; } - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -1116,21 +1125,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onHangingPlace(final HangingPlaceEvent e) { + public void onHangingPlace(final HangingPlaceEvent e) { final Block b = e.getBlock(); final Location loc = BukkitUtil.getLocation(b.getLocation()); - if (isPlotWorld(loc)) { + if (PlotSquared.isPlotWorld(loc.getWorld())) { final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!isInPlot(loc)) { - if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); - e.setCancelled(true); - return; + Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + if (MainUtil.isPlotAreaAbs(loc)) { + if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); + e.setCancelled(true); + return; + } } } else { - final Plot plot = getCurrentPlot(loc); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.build.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.unowned"); e.setCancelled(true); @@ -1141,7 +1152,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!Permissions.hasPermission(pp, "plots.admin.build.other")) { - if (isPlotArea(loc)) { + if (MainUtil.isPlotArea(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.other"); e.setCancelled(true); return; @@ -1153,22 +1164,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { + public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { final Entity r = e.getRemover(); if (r instanceof Player) { final Player p = (Player) r; final Location l = BukkitUtil.getLocation(e.getEntity()); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (isPlotWorld(l)) { - if (!isInPlot(l)) { - if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); - e.setCancelled(true); - return; + if (PlotSquared.isPlotWorld(l.getWorld())) { + Plot plot = MainUtil.getPlot(l); + if (plot == null) { + if (MainUtil.isPlotAreaAbs(l)) { + if (!Permissions.hasPermission(pp, "plots.admin.destroy.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road"); + e.setCancelled(true); + return; + } } } else { - final Plot plot = getCurrentPlot(l); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned"); e.setCancelled(true); @@ -1179,7 +1192,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!Permissions.hasPermission(pp, "plots.admin.destroy.other")) { - if (isPlotArea(l)) { + if (MainUtil.isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other"); e.setCancelled(true); return; @@ -1192,13 +1205,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { + public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); - if (isPlotWorld(l)) { + if (PlotSquared.isPlotWorld(l.getWorld())) { final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!isInPlot(l)) { - if (!isPlotArea(l)) { + Plot plot = MainUtil.getPlot(l); + if (plot == null) { + if (!MainUtil.isPlotAreaAbs(l)) { return; } if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { @@ -1207,8 +1221,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } else { - final Plot plot = getCurrentPlot(l); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); @@ -1229,7 +1242,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { - if (isPlotArea(l)) { + if (MainUtil.isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); return; @@ -1241,23 +1254,26 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onVehicleDestroy(final VehicleDestroyEvent e) { + public void onVehicleDestroy(final VehicleDestroyEvent e) { final Location l = BukkitUtil.getLocation(e.getVehicle()); - if (isPlotWorld(l)) { + if (PlotSquared.isPlotWorld(l.getWorld())) { final Entity d = e.getAttacker(); if (d instanceof Player) { final Player p = (Player) d; PlotSquared.getPlotWorld(l.getWorld()); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!isInPlot(l)) { + Plot plot = MainUtil.getPlot(l); + if (plot == null) { + if (!MainUtil.isPlotAreaAbs(l)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.road"); e.setCancelled(true); return; } } else { - final Plot plot = getCurrentPlot(l); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned"); e.setCancelled(true); @@ -1270,7 +1286,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) { - if (isPlotArea(l)) { + if (MainUtil.isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.other"); e.setCancelled(true); return; @@ -1283,7 +1299,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { + public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { final Location l = BukkitUtil.getLocation(e.getEntity()); final Entity damager = e.getDamager(); final Entity victim = e.getEntity(); @@ -1294,7 +1310,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi TaskManager.TELEPORT_QUEUE.remove(name); } } - if (isPlotWorld(l)) { + if (PlotSquared.isPlotWorld(l.getWorld())) { Player p = null; Projectile projectile = null; if (damager instanceof Player) { @@ -1339,7 +1355,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } else if (aPlr && pW.PVP) { return; } - if (!isInPlot(l)) { + Plot plot = MainUtil.getPlot(l); + if (plot == null) { + if (!MainUtil.isPlotAreaAbs(l)) { + return; + } final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.pve.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.road"); @@ -1347,8 +1367,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } } else { - final Plot plot = getCurrentPlot(l); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { final PlotPlayer pp = BukkitUtil.getPlayer(p); if (!Permissions.hasPermission(pp, "plots.admin.pve.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.unowned"); @@ -1358,10 +1377,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi e.setCancelled(true); return; } - } else if (aPlr && booleanFlag(plot, "pvp", false)) { + } else if (aPlr && FlagManager.isBooleanFlag(plot, "pvp", false)) { return; } - if (!aPlr && booleanFlag(plot, "pve", false)) { + if (!aPlr && FlagManager.isBooleanFlag(plot, "pve", false)) { return; } assert plot != null; @@ -1377,7 +1396,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!Permissions.hasPermission(pp, "plots.admin.pve.other")) { - if (isPlotArea(l)) { + if (MainUtil.isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.pve.other"); if (projectile != null) { projectile.remove(); @@ -1390,27 +1409,30 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if ((damager instanceof Arrow) && isPlotArea(l) && (!(victim instanceof Creature))) { + if ((damager instanceof Arrow) && MainUtil.isPlotArea(l) && (!(victim instanceof Creature))) { e.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public static void onPlayerEggThrow(final PlayerEggThrowEvent e) { + public void onPlayerEggThrow(final PlayerEggThrowEvent e) { final Location l = BukkitUtil.getLocation(e.getEgg().getLocation()); - if (isPlotWorld(l)) { + if (PlotSquared.isPlotWorld(l.getWorld())) { final Player p = e.getPlayer(); final PlotPlayer pp = BukkitUtil.getPlayer(p); - if (!isInPlot(l)) { + Plot plot = MainUtil.getPlot(l); + if (plot == null) { + if (!MainUtil.isPlotAreaAbs(l)) { + return; + } if (!Permissions.hasPermission(pp, "plots.admin.projectile.road")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.road"); e.setHatching(false); return; } } else { - final Plot plot = getCurrentPlot(l); - if ((plot == null) || !plot.hasOwner()) { + if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.projectile.unowned")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.unowned"); e.setHatching(false); @@ -1418,7 +1440,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } else if (!plot.isAdded(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.projectile.other")) { - if (isPlotArea(l)) { + if (MainUtil.isPlotArea(l)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.projectile.other"); e.setHatching(false); return; @@ -1433,7 +1455,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi public void BlockCreate(final BlockPlaceEvent event) { final Player player = event.getPlayer(); final String world = player.getWorld().getName(); - if (!isPlotWorld(world)) { + if (!PlotSquared.isPlotWorld(world)) { return; } final PlotPlayer pp = BukkitUtil.getPlayer(player); @@ -1441,8 +1463,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation()); - if (isInPlot(loc)) { - final Plot plot = getCurrentPlot(loc); + final Plot plot = MainUtil.getPlot(loc); + if (plot != null) { if (!plot.hasOwner()) { if (Permissions.hasPermission(pp, "plots.admin.build.unowned")) { return; @@ -1465,8 +1487,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } return; } - if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { - if (isPlotArea(loc)) { + else if (!Permissions.hasPermission(pp, "plots.admin.build.road")) { + if (MainUtil.isPlotAreaAbs(loc)) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 634f7ee65..7e15843ad 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -25,34 +26,35 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { return; } final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation()); - if (isPlotWorld(l)) { - e.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); - if (!isInPlot(l)) { - if (!isPlotArea(l)) { - return; - } - if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); + String world = l.getWorld(); + if (!PlotSquared.isPlotWorld(world)) { + return; + } + Plot plot = MainUtil.getPlot(l); + PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); + if (plot == null) { + if (!MainUtil.isPlotArea(l)) { + return; + } + if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road"); + e.setCancelled(true); + } + } + else { + if (!plot.hasOwner()) { + if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); e.setCancelled(true); } - } else { - final Plot plot = MainUtil.getPlot(l); - if ((plot == null) || !plot.hasOwner()) { - if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned"); + } + else { + final UUID uuid = pp.getUUID(); + if (!plot.isAdded(uuid)) { + if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { + MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); e.setCancelled(true); } - } else { - final UUID uuid = pp.getUUID(); - if (!plot.isAdded(uuid)) { - if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { - if (isPlotArea(l)) { - MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other"); - e.setCancelled(true); - } - } - } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 549fed1e5..5235690fa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -37,56 +37,23 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.BukkitPlayer; -import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.titles.AbstractTitle; -import com.intellectualcrafters.plot.util.ClusterManager; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * @author Citymonstret * @author Empire92 */ -public class PlotListener { - public static void textures(final Player p) { - if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) { +public class PlotListener extends APlotListener { + public void textures(final Player p) { + if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PlotSquared.isPlotWorld(p.getWorld().getName())) { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } } - public static boolean booleanFlag(final Plot plot, final String key, final boolean defaultValue) { - final Flag flag = FlagManager.getPlotFlag(plot, key); - if (flag == null) { - return defaultValue; - } - final Object value = flag.getValue(); - if (value instanceof Boolean) { - return (boolean) value; - } - return defaultValue; - } - - public static boolean isInPlot(final String world, final int x, final int y, final int z) { - return (MainUtil.getPlot(new Location(world, x, y, z)) != null); - } - - public static boolean isPlotWorld(final String world) { - return PlotSquared.isPlotWorld(world); - } - - public static boolean isPlotArea(final Location location) { - final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); - if (plotworld.TYPE == 2) { - return ClusterManager.getCluster(location) != null; - } - return true; - } - - private static String getName(final UUID id) { + private String getName(final UUID id) { if (id == null) { return "none"; } @@ -97,39 +64,7 @@ public class PlotListener { return name; } - public static UUID getUUID(final String name) { - return UUIDHandler.getUUID(name); - } - - public static boolean enteredPlot(final Location l1, final Location l2) { - final PlotId p1 = MainUtil.getPlotId(l1); - final PlotId p2 = MainUtil.getPlotId(l2); - return (p2 != null) && ((p1 == null) || !p1.equals(p2)); - } - - public static boolean leftPlot(final Location l1, final Location l2) { - final PlotId p1 = MainUtil.getPlotId(l1); - final PlotId p2 = MainUtil.getPlotId(l2); - return (p1 != null) && ((p2 == null) || !p1.equals(p2)); - } - - public static boolean isPlotWorld(final Location l) { - return PlotSquared.isPlotWorld(l.getWorld()); - } - - public static boolean isInPlot(final Location loc) { - return getCurrentPlot(loc) != null; - } - - public static Plot getCurrentPlot(final Location loc) { - final PlotId id = MainUtil.getPlotId(loc); - if (id == null) { - return null; - } - return MainUtil.getPlot(loc.getWorld(), id); - } - - private static WeatherType getWeatherType(String str) { + private WeatherType getWeatherType(String str) { str = str.toLowerCase(); if (str.equals("rain")) { return WeatherType.DOWNFALL; @@ -138,7 +73,7 @@ public class PlotListener { } } - private static GameMode getGameMode(final String str) { + private GameMode getGameMode(final String str) { switch (str) { case "creative": return GameMode.CREATIVE; @@ -151,11 +86,12 @@ public class PlotListener { } } - public static void plotEntry(final PlotPlayer player, final Plot plot) { + public void plotEntry(final PlotPlayer player, final Plot plot) { plotEntry(((BukkitPlayer) player).player, plot); } - public static void plotEntry(final Player player, final Plot plot) { + public void plotEntry(final Player pp, final Plot plot) { + Player player = ((BukkitPlayer) pp).player; if (plot.hasOwner()) { final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode"); if (gamemodeFlag != null) { @@ -178,7 +114,7 @@ public class PlotListener { if (weatherFlag != null) { player.setPlayerWeather(getWeatherType(weatherFlag.getValueString())); } - if ((booleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { + if ((FlagManager.isBooleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) { final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + ""); final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); if (AbstractTitle.TITLE_CLASS != null) { @@ -192,11 +128,10 @@ public class PlotListener { } } - public static void plotExit(final Player player, final Plot plot) { - { - final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); - Bukkit.getPluginManager().callEvent(callEvent); - } + public void plotExit(final PlotPlayer pp, final Plot plot) { + Player player = ((BukkitPlayer) pp).player; + final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); + Bukkit.getPluginManager().callEvent(callEvent); if (FlagManager.getPlotFlag(plot, "fly") != null) { player.setAllowFlight(Bukkit.getAllowFlight()); } @@ -211,7 +146,7 @@ public class PlotListener { } } - public static boolean getFlagValue(final String value) { + public boolean getFlagValue(final String value) { return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 8bec3842c..20161dcfd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -160,7 +160,7 @@ public class PlotPlusListener extends PlotListener implements Listener { if (plot == null) { return; } - if (booleanFlag(plot, "instabreak", false)) { + if (FlagManager.isBooleanFlag(plot, "instabreak", false)) { event.getBlock().breakNaturally(); } } @@ -175,7 +175,7 @@ public class PlotPlusListener extends PlotListener implements Listener { if (plot == null) { return; } - if (booleanFlag(plot, "invincible", false)) { + if (FlagManager.isBooleanFlag(plot, "invincible", false)) { event.setCancelled(true); } } @@ -189,7 +189,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } final UUID uuid = pp.getUUID(); - if (plot.isAdded(uuid) && booleanFlag(plot, "drop-protection", false)) { + if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) { event.setCancelled(true); } } @@ -203,7 +203,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } final UUID uuid = pp.getUUID(); - if (plot.isAdded(uuid) && booleanFlag(plot, "item-drop", false)) { + if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) { event.setCancelled(true); } } @@ -214,7 +214,7 @@ public class PlotPlusListener extends PlotListener implements Listener { if (FlagManager.getPlotFlag(plot, "greeting") != null) { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString())); } - if (booleanFlag(plot, "notify-enter", false)) { + if (FlagManager.isBooleanFlag(plot, "notify-enter", false)) { final Player trespasser = event.getPlayer(); final PlotPlayer pt = BukkitUtil.getPlayer(trespasser); if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) { @@ -265,7 +265,7 @@ public class PlotPlusListener extends PlotListener implements Listener { if (healRunnable.containsKey(leaver)) { healRunnable.remove(leaver); } - if (booleanFlag(plot, "notify-leave", false)) { + if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) { if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) { return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index 4e22eb116..b63d429a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -3,8 +3,6 @@ package com.intellectualcrafters.plot.listeners.worldedit; import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Set; -import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -16,26 +14,14 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.IncompleteRegionException; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.selections.Selection; -import com.sk89q.worldedit.event.extent.EditSessionEvent; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extent.NullExtent; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.util.eventbus.EventHandler.Priority; -import com.sk89q.worldedit.util.eventbus.Subscribe; public class WEListener implements Listener { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 519d01fa6..9504032ff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -141,9 +141,9 @@ public class ClusterManager { public static PlotCluster getCluster(final Plot plot) { return getCluster(plot.world, plot.id); } - - public static PlotCluster getCluster(final Location loc) { - final String world = loc.getWorld(); + + public static PlotCluster getClusterAbs(final Location loc) { + String world = loc.getWorld(); if ((last != null) && last.world.equals(world)) { if (contains(last, loc)) { return last; @@ -164,6 +164,16 @@ public class ClusterManager { } return null; } + + public static PlotCluster getCluster(final Location loc) { + final String world = loc.getWorld(); + PlotManager manager = PlotSquared.getPlotManager(world); + PlotId id = manager.getPlotIdAbs(PlotSquared.getPlotWorld(world), loc.getX(), loc.getY(), loc.getZ()); + if (id != null) { + return getCluster(world, id); + } + return getClusterAbs(loc); + } public static PlotCluster getCluster(final String world, final PlotId id) { if ((last != null) && last.world.equals(world)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0105ef80b..379833e20 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -58,6 +58,54 @@ public class MainUtil { public static HashMap worldBorder = new HashMap<>(); static PseudoRandom random = new PseudoRandom(); + public static boolean isPlotArea(final Location location) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); + if (plotworld.TYPE == 2) { + return ClusterManager.getCluster(location) != null; + } + return true; + } + + public static boolean isPlotAreaAbs(final Location location) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); + if (plotworld.TYPE == 2) { + return ClusterManager.getClusterAbs(location) != null; + } + return true; + } + + public static boolean isPlotRoad(final Location location) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); + if (plotworld.TYPE == 2) { + PlotCluster cluster = ClusterManager.getCluster(location); + if (cluster == null) { + return false; + } + } + PlotManager manager = PlotSquared.getPlotManager(location.getWorld()); + return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null; + } + + public static boolean isPlotArea(final Plot plot) { + final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world); + if (plotworld.TYPE == 2) { + return ClusterManager.getCluster(plot) != null; + } + return true; + } + + public static boolean enteredPlot(final Location l1, final Location l2) { + final PlotId p1 = MainUtil.getPlotId(l1); + final PlotId p2 = MainUtil.getPlotId(l2); + return (p2 != null) && ((p1 == null) || !p1.equals(p2)); + } + + public static boolean leftPlot(final Location l1, final Location l2) { + final PlotId p1 = MainUtil.getPlotId(l1); + final PlotId p2 = MainUtil.getPlotId(l2); + return (p1 != null) && ((p2 == null) || !p1.equals(p2)); + } + public static ArrayList getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) { final Plot plot1 = PlotSquared.getPlots(world).get(pos1); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 16f2eced5..16d39e517 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -25,7 +25,6 @@ import com.intellectualcrafters.jnbt.NBTOutputStream; import com.intellectualcrafters.jnbt.ShortTag; import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.commands.SchematicCmd; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java index 0a89424dc..6aa25d27f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -7,7 +7,6 @@ import java.util.Map.Entry; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.util.TaskManager; public class SetBlockQueue { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index 3d02bd779..560e8a6c6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -5,7 +5,6 @@ import java.util.Map; import org.bukkit.generator.ChunkGenerator; -import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index bc79915c3..cf8115f78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -46,13 +46,14 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.listeners.PlotListener; +import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotLoc; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.ChunkManager; @@ -771,8 +772,9 @@ public class BukkitChunkManager extends ChunkManager { if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - BukkitUtil.getPlayer(player).teleport(MainUtil.getDefaultHome(plot)); - PlotListener.plotExit(player, plot); + PlotPlayer pp = BukkitUtil.getPlayer(player); + pp.teleport(MainUtil.getDefaultHome(plot)); + APlotListener.manager.plotExit(pp, plot); } else { entity.remove(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index 5dafb8934..fee1b5334 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -13,7 +13,6 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.object.PlotGenerator; -import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; From 8ce33753f3f206c055e2bc087b96947f64e4061a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 16:32:05 +1000 Subject: [PATCH 189/223] Added WorldEdit bypass on join --- .../plot/listeners/PlayerEvents.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 2a074caa0..636e9e072 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -270,6 +270,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final StringWrapper name = new StringWrapper(username); final UUID uuid = pp.getUUID(); UUIDHandler.add(name, uuid); + if (PlotSquared.worldEdit != null) { + if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { + WEManager.bypass.add(pp.getName()); + } + } final Location loc = BukkitUtil.getLocation(player.getLocation()); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { @@ -458,7 +463,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi public void onWorldChanged(final PlayerChangedWorldEvent event) { final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); if (PlotSquared.worldEdit != null) { - WEManager.bypass.remove(player.getName()); + if (!Permissions.hasPermission(player, "plots.worldedit.bypass")) { + WEManager.bypass.remove(player.getName()); + } + else { + WEManager.bypass.add(player.getName()); + } } ((BukkitPlayer) player).hasPerm = new HashSet<>(); ((BukkitPlayer) player).noPerm = new HashSet<>(); From fb277920767c6a609669afde011aa4c45d22e144 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 17:47:45 +1000 Subject: [PATCH 190/223] Fixed bed in nethe --- PlotSquared/pom.xml | 2 +- .../plot/commands/Set.java | 2 +- .../intellectualcrafters/plot/config/C.java | 2 +- .../plot/database/SQLManager.java | 19 ++++----- .../plot/listeners/PlayerEvents.java | 9 +++-- .../plot/listeners/PlayerEvents_1_8.java | 39 +++++++++++++++++++ .../plot/listeners/PlotListener.java | 6 +-- 7 files changed, 55 insertions(+), 24 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 43772e4e5..19b1543f9 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -81,7 +81,7 @@ org.bukkit bukkit - 1.8-R0.1-SNAPSHOT + 1.8.3-R0.1-SNAPSHOT com.sk89q 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 10e19d329..3f1bb0b4a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -293,7 +293,7 @@ public class Set extends SubCommand { private String getBiomeList(final String[] biomes) { final StringBuilder builder = new StringBuilder(); - builder.append(MainUtil.colorise('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); + builder.append(MainUtil.colorise('&', C.NEED_BIOME.s())); for (final String b : biomes) { builder.append(getString(b)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 7458b41d2..3ac10f838 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -286,7 +286,7 @@ public enum C { /* * Biome */ - NEED_BIOME("$2You have got to specify a biome"), + NEED_BIOME("$2You need to specify a valid biome."), BIOME_SET_TO("$2Plot biome set to $2"), /* * Teleport / Entry diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index e019c6e25..dd041ef22 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -97,19 +97,14 @@ public class SQLManager implements AbstractDB { TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { - TaskManager.runTaskAsync(new Runnable() { - @Override - public void run() { - try { - System.out.print("CONNECTIN"); - SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); - } catch (final Exception e) { - e.printStackTrace(); - } - } - }); + try { + SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); + } + catch (Exception e) { + e.printStackTrace(); + } } - }, 1); + }, 11000); } updateTables(); } 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 636e9e072..4e4cae1fb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -49,6 +49,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingPlaceEvent; @@ -284,7 +285,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi MainUtil.teleportPlayer(pp, pp.getLocation(), plot); MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD); } - plotEntry(player, plot); + plotEntry(pp, plot); } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @@ -323,8 +324,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } Plot plot = MainUtil.getPlot(t); if (plot != null) { + final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.denied.size() > 0) { - final PlotPlayer pp = BukkitUtil.getPlayer(player); if (plot.isDenied(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied"); @@ -334,7 +335,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } if (!plot.equals(MainUtil.getPlot(f))) { - plotEntry(player, plot); + plotEntry(pp, plot); } } else if (MainUtil.leftPlot(f, t)) { @@ -1004,7 +1005,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } else { if (MainUtil.enteredPlot(f, t)) { - plotEntry(player, plot); + plotEntry(pp, plot); } } } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 7e15843ad..df491fda0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -1,16 +1,20 @@ package com.intellectualcrafters.plot.listeners; +import java.util.Iterator; import java.util.UUID; +import org.bukkit.block.Block; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -19,6 +23,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class PlayerEvents_1_8 extends PlotListener implements Listener { + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onInteract(final PlayerInteractAtEntityEvent e) { Entity entity = e.getRightClicked(); @@ -59,4 +64,38 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { } } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBigBoom(final BlockExplodeEvent event) { + Block block = event.getBlock(); + Location loc = BukkitUtil.getLocation(block.getLocation()); + final String world = loc.getWorld(); + if (!PlotSquared.isPlotWorld(world)) { + return; + } + final Plot plot = MainUtil.getPlot(loc); + if ((plot != null) && plot.hasOwner()) { + if (FlagManager.isPlotFlagTrue(plot, "explosion")) { + final Iterator iter = event.blockList().iterator(); + while (iter.hasNext()) { + final Block b = iter.next(); + if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(b.getLocation())))) { + iter.remove(); + } + } + return; + } + } + if (MainUtil.isPlotArea(loc)) { + event.setCancelled(true); + } else { + final Iterator iter = event.blockList().iterator(); + while (iter.hasNext()) { + iter.next(); + if (MainUtil.isPlotArea(loc)) { + iter.remove(); + } + } + } + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 5235690fa..5a43683ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -86,11 +86,7 @@ public class PlotListener extends APlotListener { } } - public void plotEntry(final PlotPlayer player, final Plot plot) { - plotEntry(((BukkitPlayer) player).player, plot); - } - - public void plotEntry(final Player pp, final Plot plot) { + public void plotEntry(final PlotPlayer pp, final Plot plot) { Player player = ((BukkitPlayer) pp).player; if (plot.hasOwner()) { final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode"); From 34772527e2e52f8a76f8680e0d2d9c19f9324c0e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 18:51:13 +1000 Subject: [PATCH 191/223] Added creaturespawn to chunk processor --- .../plot/commands/DebugUUID.java | 56 +++++++++++++++++++ .../plot/listeners/ChunkListener.java | 38 ++++++++++--- 2 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java new file mode 100644 index 000000000..af3fd5d8b --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -0,0 +1,56 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map.Entry; +import java.util.UUID; + +import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.OfflinePlotPlayer; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.ExpireManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class DebugUUID extends SubCommand { + public DebugUUID() { + super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false); + } + + @Override + public boolean execute(final PlotPlayer player, final String... args) { + + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java index 17e9942ad..e685631c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java @@ -6,8 +6,11 @@ import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; @@ -30,16 +33,10 @@ public class ChunkListener implements Listener { processChunk(event.getChunk(), false); } - private int count = 0; private Chunk lastChunk = null; @EventHandler public void onItemSpawn(ItemSpawnEvent event) { - count++; - if (count < Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { - lastChunk = null; - return; - } Item entity = event.getEntity(); Chunk chunk = entity.getLocation().getChunk(); if (chunk == lastChunk) { @@ -52,13 +49,34 @@ public class ChunkListener implements Listener { } Entity[] entities = chunk.getEntities(); if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { - PlotSquared.log("[PlotSquared] &cDetected unsafe entity creation (" + (chunk.getX() << 4) + "," + (chunk.getX() << 4) + "). Mitigating threat."); event.getEntity().remove(); event.setCancelled(true); lastChunk = chunk; } else { - count = 0; + lastChunk = null; + } + } + + @EventHandler + public void onEntitySpawn(CreatureSpawnEvent event) { + LivingEntity entity = event.getEntity(); + Chunk chunk = entity.getLocation().getChunk(); + if (chunk == lastChunk) { + event.getEntity().remove(); + event.setCancelled(true); + return; + } + if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) { + return; + } + Entity[] entities = chunk.getEntities(); + if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { + event.getEntity().remove(); + event.setCancelled(true); + lastChunk = chunk; + } + else { lastChunk = null; } } @@ -110,7 +128,9 @@ public class ChunkListener implements Listener { BlockState[] tiles = chunk.getTileEntities(); if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) { for (Entity ent : entities) { - ent.remove(); + if (!(ent instanceof Player)) { + ent.remove(); + } } PlotSquared.log("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); } From e8b5edf50b1fa25191ffb82cc4c3aed072bcbe14 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 21:38:29 +1000 Subject: [PATCH 192/223] Working on UUID mode conversion --- .../intellectualcrafters/plot/BukkitMain.java | 100 ++++++++++++++++++ .../plot/commands/DebugUUID.java | 29 ++--- .../plot/commands/MainCommand.java | 2 +- 3 files changed, 108 insertions(+), 23 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index f7afb4a5d..0a70a3765 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -19,10 +19,60 @@ 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.BukkitCommand; import com.intellectualcrafters.plot.commands.Buy; +import com.intellectualcrafters.plot.commands.Claim; +import com.intellectualcrafters.plot.commands.Clear; +import com.intellectualcrafters.plot.commands.Comment; +import com.intellectualcrafters.plot.commands.Condense; +import com.intellectualcrafters.plot.commands.Confirm; +import com.intellectualcrafters.plot.commands.Copy; +import com.intellectualcrafters.plot.commands.CreateRoadSchematic; +import com.intellectualcrafters.plot.commands.Database; +import com.intellectualcrafters.plot.commands.Debug; +import com.intellectualcrafters.plot.commands.DebugClaimTest; +import com.intellectualcrafters.plot.commands.DebugClear; +import com.intellectualcrafters.plot.commands.DebugExec; +import com.intellectualcrafters.plot.commands.DebugFixFlags; +import com.intellectualcrafters.plot.commands.DebugLoadTest; +import com.intellectualcrafters.plot.commands.DebugRoadRegen; +import com.intellectualcrafters.plot.commands.DebugSaveTest; +import com.intellectualcrafters.plot.commands.DebugUUID; +import com.intellectualcrafters.plot.commands.Delete; +import com.intellectualcrafters.plot.commands.Denied; +import com.intellectualcrafters.plot.commands.FlagCmd; +import com.intellectualcrafters.plot.commands.Help; +import com.intellectualcrafters.plot.commands.Helpers; +import com.intellectualcrafters.plot.commands.Home; +import com.intellectualcrafters.plot.commands.Inbox; +import com.intellectualcrafters.plot.commands.Info; +import com.intellectualcrafters.plot.commands.Inventory; +import com.intellectualcrafters.plot.commands.Kick; import com.intellectualcrafters.plot.commands.MainCommand; +import com.intellectualcrafters.plot.commands.Merge; +import com.intellectualcrafters.plot.commands.Move; +import com.intellectualcrafters.plot.commands.MusicSubcommand; +import com.intellectualcrafters.plot.commands.Purge; +import com.intellectualcrafters.plot.commands.Rate; +import com.intellectualcrafters.plot.commands.RegenAllRoads; +import com.intellectualcrafters.plot.commands.Reload; +import com.intellectualcrafters.plot.commands.SchematicCmd; +import com.intellectualcrafters.plot.commands.Set; +import com.intellectualcrafters.plot.commands.SetOwner; +import com.intellectualcrafters.plot.commands.Setup; +import com.intellectualcrafters.plot.commands.Swap; +import com.intellectualcrafters.plot.commands.TP; +import com.intellectualcrafters.plot.commands.Target; +import com.intellectualcrafters.plot.commands.Template; +import com.intellectualcrafters.plot.commands.Trim; +import com.intellectualcrafters.plot.commands.Trusted; +import com.intellectualcrafters.plot.commands.Unclaim; +import com.intellectualcrafters.plot.commands.Unlink; +import com.intellectualcrafters.plot.commands.Visit; import com.intellectualcrafters.plot.commands.WE_Anywhere; +import com.intellectualcrafters.plot.commands.list; +import com.intellectualcrafters.plot.commands.plugin; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.PlotMeConverter; @@ -156,6 +206,56 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void registerCommands() { new MainCommand(); + MainCommand.subCommands.add(new Template()); + MainCommand.subCommands.add(new Setup()); + MainCommand.subCommands.add(new DebugUUID()); + MainCommand.subCommands.add(new DebugSaveTest()); + MainCommand.subCommands.add(new DebugLoadTest()); + MainCommand.subCommands.add(new CreateRoadSchematic()); + MainCommand.subCommands.add(new RegenAllRoads()); + MainCommand.subCommands.add(new DebugClear()); + MainCommand.subCommands.add(new Claim()); + MainCommand.subCommands.add(new Auto()); + MainCommand.subCommands.add(new Home()); + MainCommand.subCommands.add(new Visit()); + MainCommand.subCommands.add(new TP()); + MainCommand.subCommands.add(new Set()); + MainCommand.subCommands.add(new Clear()); + MainCommand.subCommands.add(new Delete()); + MainCommand.subCommands.add(new SetOwner()); + MainCommand.subCommands.add(new Denied()); + MainCommand.subCommands.add(new Helpers()); + MainCommand.subCommands.add(new Trusted()); + MainCommand.subCommands.add(new Info()); + MainCommand.subCommands.add(new list()); + MainCommand.subCommands.add(new Help()); + MainCommand.subCommands.add(new Debug()); + MainCommand.subCommands.add(new SchematicCmd()); + MainCommand.subCommands.add(new plugin()); + MainCommand.subCommands.add(new Inventory()); + MainCommand.subCommands.add(new Purge()); + MainCommand.subCommands.add(new Reload()); + MainCommand.subCommands.add(new Merge()); + MainCommand.subCommands.add(new Unlink()); + MainCommand.subCommands.add(new Kick()); + MainCommand.subCommands.add(new Rate()); + MainCommand.subCommands.add(new DebugClaimTest()); + MainCommand.subCommands.add(new Inbox()); + MainCommand.subCommands.add(new Comment()); + MainCommand.subCommands.add(new Database()); + MainCommand.subCommands.add(new Unclaim()); + MainCommand.subCommands.add(new Swap()); + MainCommand.subCommands.add(new MusicSubcommand()); + MainCommand.subCommands.add(new DebugRoadRegen()); + MainCommand.subCommands.add(new Trim()); + MainCommand.subCommands.add(new DebugExec()); + MainCommand.subCommands.add(new FlagCmd()); + MainCommand.subCommands.add(new Target()); + MainCommand.subCommands.add(new DebugFixFlags()); + MainCommand.subCommands.add(new Move()); + MainCommand.subCommands.add(new Condense()); + MainCommand.subCommands.add(new Confirm()); + MainCommand.subCommands.add(new Copy()); final BukkitCommand bcmd = new BukkitCommand(); final PluginCommand plotCommand = getCommand("plots"); plotCommand.setExecutor(bcmd); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index af3fd5d8b..f147502ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -20,37 +20,22 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map.Entry; -import java.util.UUID; - -import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; - -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.object.ChunkLoc; -import com.intellectualcrafters.plot.object.OfflinePlotPlayer; -import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugUUID extends SubCommand { public DebugUUID() { - super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false); + super("debuguuid", "plots.admin", "Debug uuid conversion", "debuguuid", "uuidconvert", CommandCategory.DEBUG, false); } @Override public boolean execute(final PlotPlayer player, final String... args) { + if (player != null) { + MainUtil.sendMessage(player, C.NOT_CONSOLE); + return false; + } + return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index a35372d32..fcc39c0db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -40,7 +40,7 @@ public class MainCommand { /** * Main Permission Node */ - private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm(), new Copy(), new WE_Anywhere() }; + private final static SubCommand[] _subCommands = new SubCommand[] { }; public final static ArrayList subCommands = new ArrayList() { { addAll(Arrays.asList(_subCommands)); From 6c68f88df9f80fef8baaa6df067f4c4ca3331838 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 22:11:18 +1000 Subject: [PATCH 193/223] Optimized fastmode clearing --- .../plot/util/bukkit/BukkitChunkManager.java | 101 +++++++++--------- .../plot/util/bukkit/BukkitUtil.java | 6 +- 2 files changed, 57 insertions(+), 50 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index cf8115f78..e1ba34a41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -289,64 +289,67 @@ public class BukkitChunkManager extends ChunkManager { final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { - if (chunks.size() == 0) { - TaskManager.runTaskLater(whenDone, 1); - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); - TaskManager.tasks.remove(currentIndex); - return; - } - CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - final Chunk chunk = chunks.get(0); - chunks.remove(0); - final int x = chunk.getX(); - final int z = chunk.getZ(); - boolean loaded = true; - if (!chunk.isLoaded()) { - final boolean result = chunk.load(false); - if (!result) { - loaded = false; - ; + long start = System.currentTimeMillis(); + while (System.currentTimeMillis() - start < 20) { + if (chunks.size() == 0) { + TaskManager.runTaskLater(whenDone, 1); + Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); + TaskManager.tasks.remove(currentIndex); + return; } + CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); + final Chunk chunk = chunks.get(0); + chunks.remove(0); + final int x = chunk.getX(); + final int z = chunk.getZ(); + boolean loaded = true; if (!chunk.isLoaded()) { - loaded = false; - } - } - if (loaded) { - initMaps(); - final int absX = x << 4; - final int absZ = z << 4; - boolean save = false; - if ((x == c1x) || (z == c1z)) { - save = true; - for (int X = 0; X < 16; X++) { - for (int Z = 0; Z < 16; Z++) { - if ((((X + absX) < sx) || ((Z + absZ) < sz)) || (((X + absX) > ex) || ((Z + absZ) > ez))) { - saveBlocks(world, maxY, X + absX, Z + absZ); - } - } + final boolean result = chunk.load(false); + if (!result) { + loaded = false; + ; } - } else if ((x == c2x) || (z == c2z)) { - for (int X = 0; X < 16; X++) { + if (!chunk.isLoaded()) { + loaded = false; + } + } + if (loaded) { + initMaps(); + final int absX = x << 4; + final int absZ = z << 4; + boolean save = false; + if ((x == c1x) || (z == c1z)) { save = true; - for (int Z = 0; Z < 16; Z++) { - if ((((X + absX) > ex) || ((Z + absZ) > ez)) || (((X + absX) < sx) || ((Z + absZ) < sz))) { - saveBlocks(world, maxY, X + absX, Z + absZ); + for (int X = 0; X < 16; X++) { + for (int Z = 0; Z < 16; Z++) { + if ((((X + absX) < sx) || ((Z + absZ) < sz)) || (((X + absX) > ex) || ((Z + absZ) > ez))) { + saveBlocks(world, maxY, X + absX, Z + absZ); + } + } + } + } else if ((x == c2x) || (z == c2z)) { + for (int X = 0; X < 16; X++) { + save = true; + for (int Z = 0; Z < 16; Z++) { + if ((((X + absX) > ex) || ((Z + absZ) > ez)) || (((X + absX) < sx) || ((Z + absZ) < sz))) { + saveBlocks(world, maxY, X + absX, Z + absZ); + } } } } + if (save) { + saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR); + } + world.regenerateChunk(x, z); + if (save) { + restoreBlocks(world, 0, 0); + restoreEntities(world, 0, 0); + } + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); + BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } - if (save) { - saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR); - } - world.regenerateChunk(x, z); - if (save) { - restoreBlocks(world, 0, 0); - restoreEntities(world, 0, 0); - } - MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); - BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); + CURRENT_PLOT_CLEAR = null; } - CURRENT_PLOT_CLEAR = null; } }, 1, 1); TaskManager.tasks.put(currentIndex, task); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 9312ebbee..efe1a7f64 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -151,7 +151,11 @@ public class BukkitUtil extends BlockManager { } public static void regenerateChunk(final String world, final int x, final int z) { - getWorld(world).regenerateChunk(x, z); + World worldObj = getWorld(world); + Chunk chunk = worldObj.getChunkAt(x, z); + if (chunk.isLoaded() || chunk.load(false)) { + worldObj.regenerateChunk(x, z); + } } public static PlotBlock getBlock(final Location loc) { From 2c76c0608c418faf8a74b5bcfe96292ec406e0c7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 26 Apr 2015 23:38:02 +1000 Subject: [PATCH 194/223] Added debugfill command --- .../intellectualcrafters/plot/BukkitMain.java | 2 + .../plot/commands/DebugFill.java | 120 ++++++++++++++++++ .../plot/commands/DebugUUID.java | 48 ++++++- 3 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 0a70a3765..e2a3cbd76 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -34,6 +34,7 @@ import com.intellectualcrafters.plot.commands.Debug; import com.intellectualcrafters.plot.commands.DebugClaimTest; import com.intellectualcrafters.plot.commands.DebugClear; import com.intellectualcrafters.plot.commands.DebugExec; +import com.intellectualcrafters.plot.commands.DebugFill; import com.intellectualcrafters.plot.commands.DebugFixFlags; import com.intellectualcrafters.plot.commands.DebugLoadTest; import com.intellectualcrafters.plot.commands.DebugRoadRegen; @@ -209,6 +210,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { MainCommand.subCommands.add(new Template()); MainCommand.subCommands.add(new Setup()); MainCommand.subCommands.add(new DebugUUID()); + MainCommand.subCommands.add(new DebugFill()); MainCommand.subCommands.add(new DebugSaveTest()); MainCommand.subCommands.add(new DebugLoadTest()); MainCommand.subCommands.add(new CreateRoadSchematic()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java new file mode 100644 index 000000000..fc676c07c --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java @@ -0,0 +1,120 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.SetBlockQueue; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; + +public class DebugFill extends SubCommand { + public DebugFill() { + super("fill", "plots.fill", "Fill or surround a plot in bedrock", "fill", "debugfill", CommandCategory.DEBUG, true); + } + + @Override + public boolean execute(final PlotPlayer player, final String... args) { + if (args.length != 1 || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill "); + return true; + } + final Location loc = player.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(player, C.NOT_IN_PLOT); + } + if ((plot == null) || !plot.hasOwner()) { + MainUtil.sendMessage(player, C.PLOT_UNOWNED); + return false; + } + if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.fill")) { + MainUtil.sendMessage(player, C.NO_PLOT_PERMS); + return true; + } + final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id); + MainUtil.sendMessage(player, "&cPreparing task"); + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(player, "&7 - Starting"); + if (args[0].equalsIgnoreCase("all")) { + for (int x = bottom.getX(); x <= top.getX(); x++) { + for (int y = 0; y <= 255; y++) { + for (int z = bottom.getZ(); z <= top.getZ(); z++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + } + } + else if (args[0].equals("outline")) { + int x, z; + z = bottom.getZ(); + for (x = bottom.getX(); x <= (top.getX() - 1); x++) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + x = top.getX(); + for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + z = top.getZ(); + for (x = top.getX(); x >= (bottom.getX() + 1); x--) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + x = bottom.getX(); + for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) { + for (int y = 1; y <= 255; y++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + int y = 255; + for (x = bottom.getX(); x <= top.getX(); x++) { + for (z = bottom.getZ(); z <= top.getZ(); z++) { + SetBlockQueue.setBlock(plot.world, x, y, z, 7); + } + } + } + SetBlockQueue.addNotify(new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(player, "&aFill task complete!"); + } + }); + } + }); + return true; + } +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index f147502ee..1e072abac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -21,12 +21,21 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetBlockQueue; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; public class DebugUUID extends SubCommand { public DebugUUID() { - super("debuguuid", "plots.admin", "Debug uuid conversion", "debuguuid", "uuidconvert", CommandCategory.DEBUG, false); + super("uuidconvert", "plots.admin", "Debug uuid conversion", "debuguuid", "debuguuid", CommandCategory.DEBUG, false); } @Override @@ -35,6 +44,43 @@ public class DebugUUID extends SubCommand { MainUtil.sendMessage(player, C.NOT_CONSOLE); return false; } + if (args.length == 0) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert "); + return false; + } + + UUIDWrapper currentUUIDWrapper = UUIDHandler.uuidWrapper; + UUIDWrapper newWrapper = null; + + switch (args[0].toLowerCase()) { + case "lower": { + newWrapper = new LowerOfflineUUIDWrapper(); + break; + } + case "offline": { + newWrapper = new OfflineUUIDWrapper(); + break; + } + case "online": { + newWrapper = new DefaultUUIDWrapper(); + break; + } + default: { + try { + Class clazz = Class.forName(args[0]); + newWrapper = (UUIDWrapper) clazz.newInstance(); + } + catch (Exception e) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert "); + return false; + } + } + } + + if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) { + MainUtil.sendMessage(player, "&cUUID mode already in use!"); + return false; + } return true; } From 27c2b08c2f7fae3985f98aab98d3cf88b75e8c58 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 27 Apr 2015 00:56:10 +1000 Subject: [PATCH 195/223] Added experimental block setting method. --- .../plot/commands/DebugUUID.java | 4 - .../plot/generator/AugmentedPopulator.java | 13 +- .../plot/util/ChunkManager.java | 4 + .../plot/util/SetBlockQueue.java | 22 ++- .../plot/util/bukkit/BukkitChunkManager.java | 54 ++++++ .../plot/util/bukkit/DebugSetBlockQueue.java | 166 ------------------ 6 files changed, 79 insertions(+), 184 deletions(-) delete mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 1e072abac..ecb69eeee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -21,12 +21,8 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.SetBlockQueue; -import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index 377eab737..dba2d9553 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -66,11 +66,11 @@ public class AugmentedPopulator extends BlockPopulator { } } - private static short[][] x_loc; - private static short[][] y_loc; - private static short[][] z_loc; + public static short[][] x_loc; + public static short[][] y_loc; + public static short[][] z_loc; - public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { + public static void initCache() { if (x_loc == null) { x_loc = new short[16][4096]; y_loc = new short[16][4096]; @@ -88,7 +88,10 @@ public class AugmentedPopulator extends BlockPopulator { } } } - + } + + public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { + initCache(); this.cluster = cluster; this.generator = generator; this.plotworld = PlotSquared.getPlotWorld(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java index 6a3910552..1ccaf416e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java @@ -6,9 +6,11 @@ import java.util.List; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper; public abstract class ChunkManager { @@ -25,6 +27,8 @@ public abstract class ChunkManager { return new ChunkLoc(x, z); } + public abstract void setChunk(ChunkWrapper loc, PlotBlock[][] result); + public abstract int[] countEntities(Plot plot); public abstract boolean loadChunk(String world, ChunkLoc loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java index 6aa25d27f..46df665cc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -6,12 +6,13 @@ import java.util.Iterator; import java.util.Map.Entry; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.PlotBlock; public class SetBlockQueue { private volatile static HashMap blocks; - private volatile static int allocate = 50; + private volatile static int allocate = 20; private volatile static boolean running = false; private volatile static boolean locked = false; private volatile static HashSet runnables; @@ -31,6 +32,9 @@ public class SetBlockQueue { public synchronized static void init() { if (blocks == null) { + if (AugmentedPopulator.x_loc == null) { + AugmentedPopulator.initCache(); + } blocks = new HashMap<>(); runnables = new HashSet<>(); } @@ -66,16 +70,16 @@ public class SetBlockQueue { int Z = chunk.z << 4; PlotBlock[][] blocks = n.getValue(); String world = chunk.world; +// ChunkManager.manager.setChunk(chunk, blocks); for (int j = 0; j < blocks.length; j++) { PlotBlock[] blocksj = blocks[j]; if (blocksj != null) { for (int k = 0; k < blocksj.length; k++) { PlotBlock block = blocksj[k]; if (block != null) { - final int y = (j << 4) + (k >> 8); - final int a = (k - ((y & 0xF) << 8)); - final int z = (a >> 4); - final int x = a - (z << 4); + int x = AugmentedPopulator.x_loc[j][k]; + int y = AugmentedPopulator.y_loc[j][k]; + int z = AugmentedPopulator.z_loc[j][k]; BlockManager.manager.functionSetBlock(world, X + x, y, Z + z, block.id, block.data); } } @@ -83,7 +87,7 @@ public class SetBlockQueue { } } } - }, 5); + }, 2); TaskManager.tasks.put(current, task); running = true; } @@ -146,9 +150,9 @@ public class SetBlockQueue { } public static class ChunkWrapper { - final int x; - final int z; - final String world; + public final int x; + public final int z; + public final String world; public ChunkWrapper(String world, int x, int z) { this.world = world; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index e1ba34a41..c3fbc59ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -44,13 +44,16 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; +import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.listeners.APlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -974,5 +977,56 @@ public class BukkitChunkManager extends ChunkManager { count[4]++; } } + + @Override + public void setChunk(ChunkWrapper loc, PlotBlock[][] blocks) { + CURRENT_PLOT_CLEAR = new RegionWrapper(0,0,0,0); + World world = Bukkit.getWorld(loc.world); + Chunk chunk = world.getChunkAt(loc.x, loc.z); + final int cx = chunk.getX(); + final int cz = chunk.getZ(); + if (!chunk.isLoaded()) { + chunk.load(true); + } + initMaps(); + final int absX = cx << 4; + final int absZ = cz << 4; + boolean save = false; + + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + saveBlocks(world, 255, absX + x, absZ + z); + PlotLoc pl = new PlotLoc(absX + x, absZ + z); + HashMap ids = GENERATE_BLOCKS.get(pl); + HashMap datas = GENERATE_BLOCKS.get(pl); + for (int i = 0; i < blocks.length; i++) { + if (blocks[i] != null) { + short y0 = (short) (i << 4); + for (short y = y0; y < y0 + 16; y++) { + int j = ((y & 0xF) << 8) | (z << 4) | x; + PlotBlock block = blocks[i][j]; + if (block != null) { + ids.put(y, block.id); + if (block.data != 0) { + datas.put(y, block.id); + } + } + } + } + } + } + } + if (save) { + saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR); + } + world.regenerateChunk(cx, cz); + if (save) { + restoreBlocks(world, 0, 0); + restoreEntities(world, 0, 0); + } + MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); + BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); + CURRENT_PLOT_CLEAR = null; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java deleted file mode 100644 index 8cc2317e7..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/DebugSetBlockQueue.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.intellectualcrafters.plot.util.bukkit; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; - -import org.bukkit.Bukkit; -import org.bukkit.World; - -import com.intellectualcrafters.plot.util.TaskManager; - -public class DebugSetBlockQueue { - - private volatile static HashMap blocks; - private volatile static int allocate = 50; - private volatile static boolean running = false; - private volatile static boolean locked = false; - private volatile static HashSet runnables; - - public synchronized static void allocate(int t) { - allocate = t; - } - - public synchronized static void addNotify(Runnable whenDone) { - if (runnables == null) { - TaskManager.runTask(whenDone); - } - else { - runnables.add(whenDone); - } - } - - public synchronized static void init() { - if (blocks == null) { - blocks = new HashMap<>(); - runnables = new HashSet<>(); - } - if (!running) { - TaskManager.index.increment(); - final int current = TaskManager.index.intValue(); - int task = TaskManager.runTaskRepeat(new Runnable() { - @Override - public void run() { - if (locked) { - return; - } - if (blocks.size() == 0) { - Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(current)); - for (Runnable runnable : runnables) { - TaskManager.runTask(runnable); - } - runnables = null; - blocks = null; - running = false; - return; - } - long start = System.currentTimeMillis() + allocate; - Iterator> i = blocks.entrySet().iterator(); - while (System.currentTimeMillis() < start && i.hasNext()) { - if (locked) { - return; - } - Entry n = i.next(); - i.remove(); - ChunkWrapper chunk = n.getKey(); - int X = chunk.x << 4; - int Z = chunk.z << 4; - short[][] blocks = n.getValue(); - World world = chunk.world; - for (int j = 0; j < blocks.length; j++) { - short[] blocksj = blocks[j]; - if (blocksj != null) { - for (int k = 0; k < blocksj.length; k++) { - short id = blocksj[k]; - if (id != 0) { - final int y = (j << 4) + (k >> 8); - final int a = (k - ((y & 0xF) << 8)); - final int z = (a >> 4); - final int x = a - (z << 4); - BukkitSetBlockManager.setBlockManager.set(world, X + x, y, Z + z, id, (byte) 0); - } - } - } - } - } - } - }, 5); - TaskManager.tasks.put(current, task); - running = true; - } - } - - public static void setBlock(final World world, int x, final int y, int z, final short blkid) { - locked = true; - if (!running) { - init(); - } - int X = x >> 4; - int Z = z >> 4; - x -= X << 4; - z -= Z << 4; - - ChunkWrapper wrap = new ChunkWrapper(world, X, Z); - short[][] result = blocks.get(wrap); - if (!blocks.containsKey(wrap)) { - result = new short[16][]; - blocks.put(wrap, result); - } - if (result[y >> 4] == null) { - result[y >> 4] = new short[4096]; - } - result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid; - locked = false; - } - - public static class ChunkWrapper { - final int x; - final int z; - final World world; - - public ChunkWrapper(World world, int x, int z) { - this.world = world; - this.x = x; - this.z = z; - } - - @Override - public int hashCode() { - int result; - if (this.x >= 0) { - if (this.z >= 0) { - result = (this.x * this.x) + (3 * this.x) + (2 * this.x * this.z) + this.z + (this.z * this.z); - } else { - final int y1 = -this.z; - result = (this.x * this.x) + (3 * this.x) + (2 * this.x * y1) + y1 + (y1 * y1) + 1; - } - } else { - final int x1 = -this.x; - if (this.z >= 0) { - result = -((x1 * x1) + (3 * x1) + (2 * x1 * this.z) + this.z + (this.z * this.z)); - } else { - final int y1 = -this.z; - result = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1); - } - } - result = result * 31 + world.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ChunkWrapper other = (ChunkWrapper) obj; - return ((this.x == other.x) && (this.z == other.z) && (this.world.equals(other.world))); - } - } -} From 42a34fc44a54392fffe7d03034f6a1fd1a429ead Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 27 Apr 2015 19:07:42 +1000 Subject: [PATCH 196/223] UUID mode conversion (untested) --- .../intellectualcrafters/plot/BukkitMain.java | 7 + .../intellectualcrafters/plot/IPlotMain.java | 3 + .../plot/PlotSquared.java | 3 + .../plot/commands/DebugUUID.java | 192 ++++++++++++++++++ .../plot/database/AbstractDB.java | 7 + .../plot/database/SQLManager.java | 29 +++ .../plot/object/Plot.java | 20 +- .../plot/object/PlotId.java | 31 +-- .../plot/util/PlayerManager.java | 9 + .../plot/util/bukkit/BukkitPlayerManager.java | 14 ++ 10 files changed, 284 insertions(+), 31 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerManager.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerManager.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index e2a3cbd76..71f0d8c20 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -102,10 +102,12 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlayerManager; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitEventUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerManager; import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager; import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; @@ -510,4 +512,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public void registerWorldEvents() { getServer().getPluginManager().registerEvents(new WorldEvents(), this); } + + @Override + public PlayerManager initPlayerManager() { + return new BukkitPlayerManager(); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 5f1cb2e68..20401bbc6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.PlayerManager; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.uuid.UUIDWrapper; @@ -68,4 +69,6 @@ public interface IPlotMain { public void registerChunkProcessor(); public void registerWorldEvents(); + + public PlayerManager initPlayerManager(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 3427babc1..75b10fa7c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -67,6 +67,7 @@ import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.Logger; import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlayerManager; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -547,6 +548,8 @@ public class PlotSquared { ChunkManager.manager = IMP.initChunkManager(); // Plot listener APlotListener.manager = IMP.initPlotListener(); + // Player manager + PlayerManager.manager = IMP.initPlayerManager(); // PlotMe if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index ecb69eeee..56653ff0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -20,9 +20,28 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.UUID; + +import org.bukkit.Bukkit; + +import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.database.AbstractDB; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.database.SQLManager; +import com.intellectualcrafters.plot.object.OfflinePlotPlayer; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlayerManager; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper; @@ -73,11 +92,184 @@ public class DebugUUID extends SubCommand { } } + if (args.length != 2 || !args[1].equals("-o")) { + MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o"); + MainUtil.sendMessage(player, "&cBe aware of the following!"); + MainUtil.sendMessage(player, "&8 - &cIf the process is interrupted, all plots could be deleted"); + MainUtil.sendMessage(player, "&8 - &cIf an error occurs, all plots could be deleted"); + MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion"); + MainUtil.sendMessage(player, "&cBACK UP YOUR DATABASE BEFORE USING THIS!!!"); + MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready"); + return false; + } + if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) { MainUtil.sendMessage(player, "&cUUID mode already in use!"); return false; } + MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion"); + MainUtil.sendConsoleMessage("&7 - Disconnecting players"); + for (PlotPlayer user : UUIDHandler.players.values()) { + PlayerManager.manager.kickPlayer(user, "PlotSquared UUID conversion has been initiated. You may reconnect when finished."); + } + MainUtil.sendConsoleMessage("&7 - Initializing map"); + + HashMap uCMap = new HashMap(); + HashMap uCReverse = new HashMap(); + + MainUtil.sendConsoleMessage("&7 - Collecting playerdata"); + + final HashSet worlds = new HashSet<>(); + worlds.add(Bukkit.getWorlds().get(0).getName()); + worlds.add("world"); + final HashSet uuids = new HashSet<>(); + final HashSet names = new HashSet<>(); + for (final String worldname : worlds) { + final File playerdataFolder = new File(worldname + File.separator + "playerdata"); + String[] dat = playerdataFolder.list(new FilenameFilter() { + @Override + public boolean accept(final File f, final String s) { + return s.endsWith(".dat"); + } + }); + if (dat != null) { + for (final String current : dat) { + final String s = current.replaceAll(".dat$", ""); + try { + final UUID uuid = UUID.fromString(s); + uuids.add(uuid); + } catch (final Exception e) { + PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: " + current); + } + } + } + final File playersFolder = new File(worldname + File.separator + "players"); + dat = playersFolder.list(new FilenameFilter() { + @Override + public boolean accept(final File f, final String s) { + return s.endsWith(".dat"); + } + }); + if (dat != null) { + for (final String current : dat) { + names.add(current.replaceAll(".dat$", "")); + } + } + } + + MainUtil.sendConsoleMessage("&7 - Populating map"); + UUID uuid2; + final UUIDWrapper wrapper = new DefaultUUIDWrapper(); + for (UUID uuid : uuids) { + try { + final OfflinePlotPlayer op = wrapper.getOfflinePlayer(uuid); + uuid = currentUUIDWrapper.getUUID(op); + uuid2 = newWrapper.getUUID(op); + if (!uuid.equals(uuid2)) { + uCMap.put(uuid, uuid2); + uCReverse.put(uuid2, uuid); + } + } catch (final Throwable e) { + PlotSquared.log(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat"); + } + } + for (final String name : names) { + final UUID uuid = currentUUIDWrapper.getUUID(name); + uuid2 = newWrapper.getUUID(name); + if (!uuid.equals(uuid2)) { + uCMap.put(uuid, uuid2); + uCReverse.put(uuid2, uuid); + } + } + if (uCMap.size() == 0) { + MainUtil.sendConsoleMessage("&c - Error! Attempting to repopulate"); + for (OfflinePlotPlayer op : currentUUIDWrapper.getOfflinePlayers()) { + if (op.getLastPlayed() != 0) { + String name = op.getName(); + StringWrapper wrap = new StringWrapper(name); + UUID uuid = currentUUIDWrapper.getUUID(op); + uuid2 = newWrapper.getUUID(op); + if (!uuid.equals(uuid2)) { + uCMap.put(uuid, uuid2); + uCReverse.put(uuid2, uuid); + } + } + } + if (uCMap.size() == 0) { + MainUtil.sendConsoleMessage("&cError. Failed to collect UUIDs!"); + return false; + } + else { + MainUtil.sendConsoleMessage("&a - Successfully repopulated"); + } + } + + MainUtil.sendConsoleMessage("&7 - Replacing cache"); + for (Entry entry : uCMap.entrySet()) { + String name = UUIDHandler.getName(entry.getKey()); + UUIDHandler.add(new StringWrapper(name), entry.getValue()); + } + + MainUtil.sendConsoleMessage("&7 - Replacing wrapper"); + UUIDHandler.uuidWrapper = newWrapper; + + MainUtil.sendConsoleMessage("&7 - Updating plot objects"); + + for (Plot plot : PlotSquared.getPlots()) { + UUID value = uCMap.get(plot.owner); + if (value != null) { + plot.owner = value; + } + plot.helpers = new ArrayList<>(); + plot.trusted = new ArrayList<>(); + plot.denied = new ArrayList<>(); + } + + MainUtil.sendConsoleMessage("&7 - Deleting database"); + final AbstractDB database = DBFunc.dbManager; + boolean result = database.deleteTables(); + + MainUtil.sendConsoleMessage("&7 - Creating tables"); + + try { + database.createTables(PlotSquared.getMySQL() != null ? "mysql" : "sqlite", true); + if (!result) { + MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery"); + for (Plot plot : PlotSquared.getPlots()) { + UUID value = uCReverse.get(plot.owner); + if (value != null) { + plot.owner = value; + } + } + database.createPlots(new ArrayList<>(PlotSquared.getPlots())); + return false; + } + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + + MainUtil.sendConsoleMessage("&7 - Populating tables"); + + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + ArrayList plots = new ArrayList<>(PlotSquared.getPlots()); + database.createPlots(plots); + int size = plots.size(); + ArrayList ids = new ArrayList(); + for (int i = 1; i <= size; i++) { + ids.add(i); + } + database.createSettings(ids); + MainUtil.sendConsoleMessage("&aConversion complete!"); + } + }); + + MainUtil.sendConsoleMessage("&aIt is now safe for players to join"); + MainUtil.sendConsoleMessage("&cConversion is still in progress, you will be notified when it is complete"); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 55d22898f..32b590264 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -337,4 +337,11 @@ public interface AbstractDB { public void resizeCluster(PlotCluster current, PlotClusterId resize); public void movePlot(Plot originalPlot, Plot newPlot); + + public void createSettings(final ArrayList mylist); + + /** + * Don't fuck with this one, unless you enjoy it rough + */ + public boolean deleteTables(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index dd041ef22..d4c598ccf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1888,4 +1888,33 @@ public class SQLManager implements AbstractDB { } }); } + + @Override + public boolean deleteTables() { + try { + SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); + final Statement stmt = this.connection.createStatement(); + stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`"); + stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`"); + stmt.addBatch("DROP TABLE `" + prefix + "cluster`"); + stmt.addBatch("DROP TABLE `" + prefix + "plot_ratings`"); + stmt.addBatch("DROP TABLE `" + prefix + "plot_settings`"); + stmt.addBatch("DROP TABLE `" + prefix + "plot_comments`"); + stmt.addBatch("DROP TABLE `" + prefix + "plot_trusted`"); + stmt.addBatch("DROP TABLE `" + prefix + "plot_helpers`"); + stmt.addBatch("DROP TABLE `" + prefix + "plot_denied`"); + stmt.executeBatch(); + stmt.clearBatch(); + stmt.close(); + + PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`"); + statement.executeUpdate(); + statement.close(); + return true; + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index dc465c000..ec372d6f1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -275,6 +275,7 @@ public class Plot implements Cloneable { return ((this.id.x.equals(other.id.x)) && (this.id.y.equals(other.id.y)) && (this.world.equals(other.world))); } + /** * Get the plot hashcode * @@ -283,23 +284,6 @@ public class Plot implements Cloneable { */ @Override public int hashCode() { - final int x = this.id.x; - final int y = this.id.y; - if (x >= 0) { - if (y >= 0) { - return (x * x) + (3 * x) + (2 * x * y) + y + (y * y); - } else { - final int y1 = -y; - return (x * x) + (3 * x) + (2 * x * y1) + y1 + (y1 * y1) + 1; - } - } else { - final int x1 = -x; - if (y >= 0) { - return -((x1 * x1) + (3 * x1) + (2 * x1 * y) + y + (y * y)); - } else { - final int y1 = -y; - return -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1); - } - } + return this.id.hashCode(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index 5ff26a5ba..d769154a1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -124,23 +124,28 @@ public class PlotId { } } + private int hash; + @Override public int hashCode() { - if (this.x >= 0) { - if (this.y >= 0) { - return (this.x * this.x) + (3 * this.x) + (2 * this.x * this.y) + this.y + (this.y * this.y); + if (hash == 0) { + if (x >= 0) { + if (y >= 0) { + hash = (x * x) + (3 * x) + (2 * x * y) + y + (y * y); + } else { + final int y1 = -y; + hash = (x * x) + (3 * x) + (2 * x * y1) + y1 + (y1 * y1) + 1; + } } else { - final int y1 = -this.y; - return (this.x * this.x) + (3 * this.x) + (2 * this.x * y1) + y1 + (y1 * y1) + 1; - } - } else { - final int x1 = -this.x; - if (this.y >= 0) { - return -((x1 * x1) + (3 * x1) + (2 * x1 * this.y) + this.y + (this.y * this.y)); - } else { - final int y1 = -this.y; - return -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1); + final int x1 = -x; + if (y >= 0) { + hash = -((x1 * x1) + (3 * x1) + (2 * x1 * y) + y + (y * y)); + } else { + final int y1 = -y; + hash = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1); + } } } + return hash; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerManager.java new file mode 100644 index 000000000..cfcdcb137 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerManager.java @@ -0,0 +1,9 @@ +package com.intellectualcrafters.plot.util; + +import com.intellectualcrafters.plot.object.PlotPlayer; + +public abstract class PlayerManager { + public static PlayerManager manager; + + public abstract void kickPlayer(PlotPlayer player, String reason); +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerManager.java new file mode 100644 index 000000000..b654f22dc --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerManager.java @@ -0,0 +1,14 @@ +package com.intellectualcrafters.plot.util.bukkit; + +import com.intellectualcrafters.plot.object.BukkitPlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.PlayerManager; + +public class BukkitPlayerManager extends PlayerManager { + + @Override + public void kickPlayer(PlotPlayer player, String reason) { + ((BukkitPlayer) player).player.kickPlayer(reason); + } + +} From dda2636250c3c577d0ef31e228e083ab7722211c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 28 Apr 2015 00:53:07 +1000 Subject: [PATCH 197/223] Fixed setup command --- .../plot/PlotSquared.java | 5 +++++ .../plot/commands/Info.java | 4 +++- .../plot/commands/Setup.java | 2 ++ .../plot/object/PlotGenerator.java | 22 ++++++++++++++++++- .../plot/util/bukkit/BukkitSetupUtils.java | 1 - 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 75b10fa7c..7602010cc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -27,6 +27,7 @@ import java.util.zip.ZipInputStream; import net.milkbowl.vault.economy.Economy; +import org.apache.commons.lang.StringUtils; import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.commands.Cluster; @@ -361,18 +362,22 @@ public class PlotSquared { final PlotGenerator gen_class = generator; plotWorld = gen_class.getNewPlotWorld(world); plotManager = gen_class.getPlotManager(); + if (!config.contains(path)) { config.createSection(path); } + plotWorld.TYPE = 2; plotWorld.TERRAIN = 0; plotWorld.saveConfiguration(config.getConfigurationSection(path)); plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); + try { config.save(configFile); } catch (final IOException e) { e.printStackTrace(); } + if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) { log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!"); return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 91a1fbd49..7b357d131 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -163,7 +163,9 @@ public class Info extends SubCommand { final PlotId id2 = MainUtil.getTopPlot(plot).id; final int num = MainUtil.getPlotSelectionIds(id, id2).size(); final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; - final String biome = BlockManager.manager.getBiome(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1)); + Location top = MainUtil.getPlotTopLoc(world, plot.id); + Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1,0,1); + final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2)); final String helpers = getPlayerList(plot.helpers); final String trusted = getPlayerList(plot.trusted); final String denied = getPlayerList(plot.denied); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 613166fbd..a6da94f11 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -140,6 +140,7 @@ public class Setup extends SubCommand { if (object.step == null) { object.plotManager = object.setupGenerator; object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); + ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object); } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); @@ -148,6 +149,7 @@ public class Setup extends SubCommand { object.plotManager = object.setupGenerator; object.setupGenerator = null; object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); + ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object); } else { object.plotManager = "PlotSquared"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 6d5948b9d..1e5603760 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -150,7 +150,7 @@ public abstract class PlotGenerator extends ChunkGenerator { } /** - * random is a optimized random number generator.
      + * random is an optimized random number generator.
      * - Change the state to have the same chunk random each time it generates
      * requiredRegion If a plot is being regenerated, you are only required to generate content in this area
      * - use the contains(RegionWrapper, x, z) method to check if the region contains a location
      @@ -172,11 +172,31 @@ public abstract class PlotGenerator extends ChunkGenerator { public abstract List getPopulators(String world); + /** + * This is called when the generator is initialized. + * You don't need to do anything with it necessarily. + * @param plotworld + */ public abstract void init(PlotWorld plotworld); + /** + * Return a new instance of the PlotWorld for a world + * @param world + * @return + */ public abstract PlotWorld getNewPlotWorld(final String world); + /** + * Get the PlotManager class for this generator + * @return + */ public abstract PlotManager getPlotManager(); + /** + * If you need to do anything fancy for /plot setup
      + * - Otherwise it will just use the PlotWorld configuration
      + * Feel free to extend BukkitSetupUtils and customize world creation + * @param object + */ public void processSetup(SetupObject object) {}; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index fee1b5334..2dfeabb86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -45,7 +45,6 @@ public class BukkitSetupUtils extends SetupUtils { @Override public String setupWorld(final SetupObject object) { SetupUtils.manager.updateGenerators(); - ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);; final ConfigurationNode[] steps = object.step; final String world = object.world; for (final ConfigurationNode step : steps) { From a1a0969e63a1cf6813149f0ad920f708d2d9de44 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 28 Apr 2015 21:13:19 +1000 Subject: [PATCH 198/223] Fixed piston event for older versions --- .../com/intellectualcrafters/plot/listeners/PlayerEvents.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4e4cae1fb..815e914c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -719,7 +719,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } } - catch (Exception e) { + catch (Throwable e) { pistonBlocks = false; } } From 75e45de7807447ee4eb1f1f0a7470b4fd23f86b2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Apr 2015 09:36:38 +1000 Subject: [PATCH 199/223] Fixed TNT listener not being enabled --- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 7602010cc..2bd1aad21 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -536,6 +536,9 @@ public class PlotSquared { IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); IMP.registerWorldEvents(); + if (Settings.TNT_LISTENER) { + IMP.registerTNTListener(); + } if (Settings.CHUNK_PROCESSOR) { IMP.registerChunkProcessor(); } From 0bd716bb63b7b415abc8ddeba13a8a400e7bdbde Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Apr 2015 10:27:21 +1000 Subject: [PATCH 200/223] Fixes #287 --- .../java/com/intellectualcrafters/plot/util/MainUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 379833e20..ec1fbf07a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -260,13 +260,13 @@ public class MainUtil { public static void update(final Plot plot) { Location bot = getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); - Location top = getPlotBottomLoc(plot.world, plot.id); + Location top = getPlotTopLoc(plot.world, plot.id); int bx = bot.getX() >> 4; int bz = bot.getZ() >> 4; - int tx = 1 + (top.getX() >> 4); - int tz = 1 + (top.getZ() >> 4); + int tx = (top.getX() >> 4); + int tz = (top.getZ() >> 4); ArrayList chunks = new ArrayList<>(); From 0da9db00d0688d8371f45eb47a6b21ab07322ed6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Apr 2015 18:09:29 +1000 Subject: [PATCH 201/223] Workin on UUID conversion (still) --- .../plot/database/SQLManager.java | 100 +++++++++++++++++- .../plot/database/StmtMod.java | 34 ++++++ 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index d4c598ccf..d158b08b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -238,7 +238,105 @@ public class SQLManager implements AbstractDB { } } + public void setBulk(ArrayList objList, StmtMod mod) { + final int size = objList.size(); + int packet; + if (PlotSquared.getMySQL() != null) { + packet = Math.min(size, 50000); + } else { + packet = Math.min(size, 50); + } + final int amount = size / packet; + for (int j = 0; j <= amount; j++) { + final List subList = objList.subList(j * packet, Math.min(size, (j + 1) * packet)); + if (subList.size() == 0) { + return; + } + String statement = mod.getCreateMySQL(packet); + PreparedStatement stmt = null; + try { + stmt = this.connection.prepareStatement(statement.toString()); + for (int i = 0; i < subList.size(); i++) { + final T obj = subList.get(i); + mod.setMySQL(stmt,i , obj); + } + stmt.executeUpdate(); + stmt.close(); + } catch (final Exception e) { + try { + String unionstmt = mod.getCreateSQLite(packet); + stmt = this.connection.prepareStatement(unionstmt.toString()); + for (int i = 0; i < subList.size(); i++) { + mod.setSQLite(stmt, i, subList.get(i)); + } + stmt.executeUpdate(); + stmt.close(); + } + catch (Exception e2) { + e2.printStackTrace(); + PlotSquared.log("&6[WARN] " + "Could not bulk save!"); + try { + for (final T obj : subList) { + try { + stmt = connection.prepareStatement(mod.getCreateSQL()); + mod.setSQL(stmt, obj); + stmt.executeUpdate(); + stmt.close(); + } catch (final Exception e3) { + PlotSquared.log("&c[ERROR] " + "Failed to save " + obj + "!"); + } + } + } catch (final Exception e4) { + e4.printStackTrace(); + PlotSquared.log("&c[ERROR] " + "Failed to save all!"); + } + } + } + } + } + public void createSettings(final ArrayList mylist) { + StmtMod mod = new StmtMod() { + + @Override + public String getCreateMySQL(int size) { + return getCreateMySQL(size, CREATE_SETTINGS, 1); + } + + @Override + public String getCreateSQLite(int size) { + String query = "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` "; + int params = 10; + for (int i = 0; i < (ids.size() - 2); i++) { + unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); + } + unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); + } + + @Override + public String getCreateSQL() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMySQL(PreparedStatement stmt, int i, Integer obj) { + // TODO Auto-generated method stub + } + + @Override + public void setSQLite(PreparedStatement stmt, int i, Integer obj) { + // TODO Auto-generated method stub + } + + @Override + public void setSQL(PreparedStatement stmt, Integer obj) { + // TODO Auto-generated method stub + } + }; + + String create1 = CREATE_SETTINGS; + final int size = mylist.size(); int packet; if (PlotSquared.getMySQL() != null) { @@ -252,7 +350,7 @@ public class SQLManager implements AbstractDB { if (ids.size() == 0) { return; } - final StringBuilder statement = new StringBuilder(this.CREATE_SETTINGS); + final StringBuilder statement = new StringBuilder(create1); for (int i = 0; i < (ids.size() - 1); i++) { statement.append("(?),"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java new file mode 100644 index 000000000..429750375 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java @@ -0,0 +1,34 @@ +package com.intellectualcrafters.plot.database; + +import java.sql.PreparedStatement; + +import org.apache.commons.lang.StringUtils; + +public abstract class StmtMod { + public abstract String getCreateMySQL(int size); + + public String getCreateMySQL(int size, String query, int params) { + final StringBuilder statement = new StringBuilder(query); + for (int i = 0; i < size - 1; i++) { + statement.append(StringUtils.repeat("(?),", params)); + } + statement.append(StringUtils.repeat(",(?)", params).substring(1)); + return statement.toString(); + } + + public String getCreateSQLite(int size, String query, int params) { + StringBuilder statement = new StringBuilder(query); + String modParams = StringUtils.repeat(",?", params).substring(1); + for (int i = 0; i < (size - 1); i++) { + statement.append("UNION SELECT " + modParams + " "); + } + return statement.toString(); + } + + public abstract String getCreateSQLite(int size); + public abstract String getCreateSQL(); + + public abstract void setMySQL(PreparedStatement stmt, int i, T obj); + public abstract void setSQLite(PreparedStatement stmt, int i, T obj); + public abstract void setSQL(PreparedStatement stmt, T obj); +} From 8c57bc74458048bfaecb770794b9ea597b130525 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Apr 2015 18:42:40 +1000 Subject: [PATCH 202/223] More work --- .../plot/database/SQLManager.java | 242 ++++++------------ .../plot/database/StmtMod.java | 7 +- 2 files changed, 82 insertions(+), 167 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index d158b08b7..f6c29562c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -295,9 +295,9 @@ public class SQLManager implements AbstractDB { } } - public void createSettings(final ArrayList mylist) { - StmtMod mod = new StmtMod() { - + @Override + public void createSettings(final ArrayList myList) { + final StmtMod mod = new StmtMod() { @Override public String getCreateMySQL(int size) { return getCreateMySQL(size, CREATE_SETTINGS, 1); @@ -305,195 +305,109 @@ public class SQLManager implements AbstractDB { @Override public String getCreateSQLite(int size) { - String query = "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` "; - int params = 10; - for (int i = 0; i < (ids.size() - 2); i++) { - unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); - } - unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); + return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ", 10); } @Override public String getCreateSQL() { - // TODO Auto-generated method stub - return null; + return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"; } @Override - public void setMySQL(PreparedStatement stmt, int i, Integer obj) { - // TODO Auto-generated method stub + public void setMySQL(PreparedStatement stmt, int i, Integer id) throws SQLException { + stmt.setInt((i * 1) + 1, id); } @Override - public void setSQLite(PreparedStatement stmt, int i, Integer obj) { - // TODO Auto-generated method stub + public void setSQLite(PreparedStatement stmt, int i, Integer id) throws SQLException { + stmt.setInt((i * 10) + 1, id); + stmt.setNull((i * 10) + 2, 4); + stmt.setNull((i * 10) + 3, 4); + stmt.setNull((i * 10) + 4, 4); + stmt.setNull((i * 10) + 5, 4); + stmt.setNull((i * 10) + 6, 4); + stmt.setNull((i * 10) + 7, 4); + stmt.setNull((i * 10) + 8, 4); + stmt.setNull((i * 10) + 9, 4); + stmt.setString((i * 10) + 10, "DEFAULT"); } @Override - public void setSQL(PreparedStatement stmt, Integer obj) { - // TODO Auto-generated method stub + public void setSQL(PreparedStatement stmt, Integer id) throws SQLException { + stmt.setInt(1, id); } }; - - String create1 = CREATE_SETTINGS; - - final int size = mylist.size(); - int packet; - if (PlotSquared.getMySQL() != null) { - packet = Math.min(size, 50000); - } else { - packet = Math.min(size, 50); - } - final int amount = size / packet; - for (int j = 0; j <= amount; j++) { - final List ids = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); - if (ids.size() == 0) { - return; + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + setBulk(myList, mod); } - final StringBuilder statement = new StringBuilder(create1); - for (int i = 0; i < (ids.size() - 1); i++) { - statement.append("(?),"); - } - statement.append("(?)"); - PreparedStatement stmt = null; - try { - stmt = this.connection.prepareStatement(statement.toString()); - for (int i = 0; i < ids.size(); i++) { - final Integer id = ids.get(i); - stmt.setInt((i * 1) + 1, id); - } - stmt.executeUpdate(); - stmt.close(); - } catch (final Exception e) { - try { - StringBuilder unionstmt = new StringBuilder("INSERT INTO `" + this.prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` "); - for (int i = 0; i < (ids.size() - 2); i++) { - unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); - } - unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "); - stmt = this.connection.prepareStatement(unionstmt.toString()); - for (int i = 0; i < ids.size(); i++) { - Integer id = ids.get(i); - stmt.setInt((i * 10) + 1, id); - stmt.setNull((i * 10) + 2, 4); - stmt.setNull((i * 10) + 3, 4); - stmt.setNull((i * 10) + 4, 4); - stmt.setNull((i * 10) + 5, 4); - stmt.setNull((i * 10) + 6, 4); - stmt.setNull((i * 10) + 7, 4); - stmt.setNull((i * 10) + 8, 4); - stmt.setNull((i * 10) + 9, 4); - stmt.setString((i * 10) + 10, "DEFAULT"); - } - stmt.executeUpdate(); - stmt.close(); - } - catch (Exception e2) { - e2.printStackTrace(); - PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower..."); - try { - for (final Integer id : ids) { - try { - stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"); - stmt.setInt(1, id); - stmt.executeUpdate(); - stmt.close(); - } catch (final Exception e3) { - PlotSquared.log("&c[ERROR] " + "Failed to save plot setting: " + id); - } - } - } catch (final Exception e4) { - e4.printStackTrace(); - PlotSquared.log("&c[ERROR] " + "Failed to save plot settings!"); - } - } - } - } + }); } /** * Create a plot * - * @param mylist list of plots to be created + * @param myList list of plots to be created */ @Override - public void createPlots(final ArrayList mylist) { - final int size = mylist.size(); - int packet; - if (PlotSquared.getMySQL() != null) { - packet = Math.min(size, 50000); - } else { - packet = Math.min(size, 100); - } - final int amount = size / packet; - for (int j = 0; j <= amount; j++) { - final List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); - if (plots.size() == 0) { - return; + public void createPlots(final ArrayList myList) { + final StmtMod mod = new StmtMod() { + @Override + public String getCreateMySQL(int size) { + return getCreateMySQL(size, CREATE_PLOTS, 4); } - final StringBuilder statement = new StringBuilder(this.CREATE_PLOTS); - for (int i = 0; i < (plots.size() - 1); i++) { - statement.append("(?,?,?,?),"); + + @Override + public String getCreateSQLite(int size) { + return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` ", 6); } - statement.append("(?,?,?,?)"); - PreparedStatement stmt = null; - try { - stmt = this.connection.prepareStatement(statement.toString()); - for (int i = 0; i < plots.size(); i++) { - final Plot plot = plots.get(i); - stmt.setInt((i * 4) + 1, plot.id.x); - stmt.setInt((i * 4) + 2, plot.id.y); - try { - stmt.setString((i * 4) + 3, plot.owner.toString()); - } catch (final Exception e) { - stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); - } - stmt.setString((i * 4) + 4, plot.world); - } - stmt.executeUpdate(); - stmt.close(); - } catch (final Exception e) { + + @Override + public String getCreateSQL() { + return CREATE_PLOT; + } + + @Override + public void setMySQL(PreparedStatement stmt, int i, Plot plot) throws SQLException { + stmt.setInt((i * 4) + 1, plot.id.x); + stmt.setInt((i * 4) + 2, plot.id.y); try { - StringBuilder unionstmt = new StringBuilder("INSERT INTO `" + this.prefix + "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` "); - for (int i = 0; i < (plots.size() - 2); i++) { - unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ? "); - } - unionstmt.append("UNION SELECT ?, ?, ?, ?, ?, ? "); - stmt = this.connection.prepareStatement(unionstmt.toString()); - for (int i = 0; i < plots.size(); i++) { - final Plot plot = plots.get(i); - stmt.setNull((i * 6) + 1, 4); - stmt.setInt((i * 6) + 2, plot.id.x); - stmt.setInt((i * 6) + 3, plot.id.y); - try { - stmt.setString((i * 6) + 4, plot.owner.toString()); - } catch (final Exception e1) { - stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); - } - stmt.setString((i * 6) + 5, plot.world); - stmt.setTimestamp((i * 6) + 6, new Timestamp(System.currentTimeMillis())); - } - stmt.executeUpdate(); - stmt.close(); - } - catch (Exception e2) { - e2.printStackTrace(); - PlotSquared.log("&6[WARN] " + "Could not bulk save. Conversion may be slower..."); - try { - for (final Plot plot : plots) { - try { - createPlot(plot); - } catch (final Exception e3) { - PlotSquared.log("&c[ERROR] " + "Failed to save plot: " + plot.id); - } - } - } catch (final Exception e4) { - e4.printStackTrace(); - PlotSquared.log("&c[ERROR] " + "Failed to save plots!"); - } + stmt.setString((i * 4) + 3, plot.owner.toString()); + } catch (final Exception e) { + stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); } + stmt.setString((i * 4) + 4, plot.world); } - } + + @Override + public void setSQLite(PreparedStatement stmt, int i, Plot plot) throws SQLException { + stmt.setNull((i * 6) + 1, 4); + stmt.setInt((i * 6) + 2, plot.id.x); + stmt.setInt((i * 6) + 3, plot.id.y); + try { + stmt.setString((i * 6) + 4, plot.owner.toString()); + } catch (final Exception e1) { + stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); + } + stmt.setString((i * 6) + 5, plot.world); + stmt.setTimestamp((i * 6) + 6, new Timestamp(System.currentTimeMillis())); + } + + @Override + public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException { + stmt.setInt(1, plot.id.x); + stmt.setInt(2, plot.id.y); + stmt.setString(3, plot.owner.toString()); + stmt.setString(4, plot.world); + } + }; + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + setBulk(myList, mod); + } + }); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java index 429750375..dc204ac60 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/StmtMod.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.database; import java.sql.PreparedStatement; +import java.sql.SQLException; import org.apache.commons.lang.StringUtils; @@ -28,7 +29,7 @@ public abstract class StmtMod { public abstract String getCreateSQLite(int size); public abstract String getCreateSQL(); - public abstract void setMySQL(PreparedStatement stmt, int i, T obj); - public abstract void setSQLite(PreparedStatement stmt, int i, T obj); - public abstract void setSQL(PreparedStatement stmt, T obj); + public abstract void setMySQL(PreparedStatement stmt, int i, T obj) throws SQLException; + public abstract void setSQLite(PreparedStatement stmt, int i, T obj) throws SQLException; + public abstract void setSQL(PreparedStatement stmt, T obj) throws SQLException; } From ffb47100804d9603ec3dade3d870aeed50250daa Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Apr 2015 22:04:25 +1000 Subject: [PATCH 203/223] Conversion functions --- .../plot/commands/Database.java | 10 +- .../plot/commands/DebugClaimTest.java | 8 +- .../plot/commands/DebugSaveTest.java | 9 +- .../plot/commands/DebugUUID.java | 21 +- .../plot/database/AbstractDB.java | 13 +- .../plot/database/DBFunc.java | 13 +- .../plot/database/PlotMeConverter.java | 11 +- .../plot/database/SQLManager.java | 393 ++++++++++-------- .../plot/util/TaskManager.java | 5 + 9 files changed, 278 insertions(+), 205 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 42a671435..8db789af1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -53,9 +53,13 @@ public class Database extends SubCommand { for (final Plot p : plots) { ps.add(p); } - manager.createPlots(ps); - manager.createAllSettingsAndHelpers(ps); - sendMessageU(requester, "&6Database conversion finished"); + sendMessageU(requester, "&6Starting..."); + manager.createPlotsAndData(ps, new Runnable() { + @Override + public void run() { + sendMessageU(requester, "&6Database conversion finished!"); + } + }); } catch (final Exception e) { sendMessageU(requester, "Failed to insert plot objects, see stacktrace for info"); e.printStackTrace(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 76b92e195..f007b537a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -134,8 +134,12 @@ public class DebugClaimTest extends SubCommand { } if (plots.size() > 0) { MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!"); - DBFunc.createPlots(plots); - DBFunc.createAllSettingsAndHelpers(plots); + DBFunc.createPlotsAndData(plots, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(null, "&6Database update finished!"); + } + }); for (final Plot plot : plots) { PlotSquared.updatePlot(plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java index 9a2af9c5b..6b3166742 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -41,8 +41,13 @@ public class DebugSaveTest extends SubCommand { if (plr == null) { final ArrayList plots = new ArrayList(); plots.addAll(PlotSquared.getPlots()); - DBFunc.createPlots(plots); - DBFunc.createAllSettingsAndHelpers(plots); + MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`"); + DBFunc.createPlotsAndData(plots, new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(null, "&6Database sync finished!"); + } + }); } else { MainUtil.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 56653ff0c..6000e56b5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -242,7 +242,12 @@ public class DebugUUID extends SubCommand { plot.owner = value; } } - database.createPlots(new ArrayList<>(PlotSquared.getPlots())); + database.createPlotsAndData(new ArrayList<>(PlotSquared.getPlots()), new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(null, "&6Recovery was successful!"); + } + }); return false; } } @@ -257,14 +262,12 @@ public class DebugUUID extends SubCommand { @Override public void run() { ArrayList plots = new ArrayList<>(PlotSquared.getPlots()); - database.createPlots(plots); - int size = plots.size(); - ArrayList ids = new ArrayList(); - for (int i = 1; i <= size; i++) { - ids.add(i); - } - database.createSettings(ids); - MainUtil.sendConsoleMessage("&aConversion complete!"); + database.createPlotsAndData(plots, new Runnable() { + @Override + public void run() { + MainUtil.sendConsoleMessage("&aConversion complete!"); + } + }); } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 32b590264..a90f2396c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -60,14 +60,7 @@ public interface AbstractDB { * * @param plots Plots for which the default table entries should be created */ - public void createAllSettingsAndHelpers(final ArrayList plots); - - /** - * Create a plot - * - * @param plots Plots that should be created - */ - public void createPlots(final ArrayList plots); + public void createPlotsAndData(final ArrayList plots, Runnable whenDone); /** * Create a plot @@ -312,7 +305,7 @@ public interface AbstractDB { /** * Set a plot comment - * + * * @param world World in which the plot is located * @param plot Plot Object * @param comment Comment to add @@ -338,8 +331,6 @@ public interface AbstractDB { public void movePlot(Plot originalPlot, Plot newPlot); - public void createSettings(final ArrayList mylist); - /** * Don't fuck with this one, unless you enjoy it rough */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index c15e4be08..a0c67f3f3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -94,17 +94,8 @@ public class DBFunc { * * @param plots List containing all plot objects */ - public static void createAllSettingsAndHelpers(final ArrayList plots) { - dbManager.createAllSettingsAndHelpers(plots); - } - - /** - * Create all plots - * - * @param plots A list containing plot objects - */ - public static void createPlots(final ArrayList plots) { - dbManager.createPlots(plots); + public static void createPlotsAndData(final ArrayList plots, Runnable whenDone) { + dbManager.createPlotsAndData(plots, whenDone); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index c7c9c927a..70e7c4c68 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -321,9 +321,12 @@ public class PlotMeConverter { } sendMessage("Creating plot DB"); Thread.sleep(1000); - DBFunc.createPlots(createdPlots); - sendMessage("Creating settings/helpers DB"); - DBFunc.createAllSettingsAndHelpers(createdPlots); + DBFunc.createPlotsAndData(createdPlots, new Runnable() { + @Override + public void run() { + sendMessage("&aDatabase conversion is now complete!"); + } + }); sendMessage("Saving configuration..."); try { PlotSquared.config.save(PlotSquared.configFile); @@ -378,7 +381,7 @@ public class PlotMeConverter { } catch (final Exception e) { e.printStackTrace(); } - sendMessage("Conversion has finished"); + sendMessage("&cPlease wait until database conversion is complete. You will be notified when this happens"); PlotSquared.log("&c - Stop the server"); PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml"); PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index f6c29562c..fab845c31 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -47,6 +47,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotClusterId; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.ClusterManager; @@ -61,7 +62,7 @@ public class SQLManager implements AbstractDB { public final String GET_ALL_PLOTS; public final String CREATE_PLOTS; public final String CREATE_SETTINGS; - public final String CREATE_HELPERS; + public final String CREATE_TIERS; public final String CREATE_PLOT; public final String CREATE_CLUSTER; private final String prefix; @@ -89,7 +90,7 @@ public class SQLManager implements AbstractDB { this.GET_ALL_PLOTS = "SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `" + this.prefix + "plot`"; this.CREATE_PLOTS = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values "; this.CREATE_SETTINGS = "INSERT INTO `" + this.prefix + "plot_settings` (`plot_plot_id`) values "; - this.CREATE_HELPERS = "INSERT INTO `" + this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) values "; + this.CREATE_TIERS = "INSERT INTO `" + this.prefix + "plot_%tier%` (`plot_plot_id`, `user_uuid`) values "; this.CREATE_PLOT = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"; this.CREATE_CLUSTER = "INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)"; // schedule reconnect @@ -136,110 +137,193 @@ public class SQLManager implements AbstractDB { }); } - @Override - public void createAllSettingsAndHelpers(final ArrayList mylist) { - final int size = mylist.size(); - int packet; - if (PlotSquared.getMySQL() != null) { - packet = Math.min(size, 50000); - } else { - packet = Math.min(size, 5000); + private class UUIDPair { + public final int id; + public final UUID uuid; + + public UUIDPair(int id, UUID uuid) { + this.id = id; + this.uuid = uuid; } - final int amount = size / packet; - for (int j = 0; j <= amount; j++) { - final List plots = mylist.subList(j * packet, Math.min(size, (j + 1) * packet)); - final HashMap> stored = new HashMap<>(); - final HashMap> helpers = new HashMap<>(); - try { - final PreparedStatement stmt = this.connection.prepareStatement(this.GET_ALL_PLOTS); - final ResultSet result = stmt.executeQuery(); - while (result.next()) { - final int id = result.getInt("id"); - final int idx = result.getInt("plot_id_x"); - final int idz = result.getInt("plot_id_z"); - final String world = result.getString("world"); - if (!stored.containsKey(world)) { - stored.put(world, new HashMap()); - } - stored.get(world).put(new PlotId(idx, idz), id); - } - result.close(); - stmt.close(); - } catch (final SQLException e) { - e.printStackTrace(); - } - for (final Plot plot : plots) { - final String world = plot.world; - if (stored.containsKey(world)) { - final Integer id = stored.get(world).get(plot.id); - if (id != null) { - helpers.put(id, plot.helpers); - } - } - } - if (helpers.size() == 0) { - return; - } - // add plot settings - final Integer[] ids = helpers.keySet().toArray(new Integer[helpers.keySet().size()]); - StringBuilder statement = new StringBuilder(this.CREATE_SETTINGS); - for (int i = 0; i < (ids.length - 1); i++) { - statement.append("(?),"); - } - statement.append("(?)"); - PreparedStatement stmt = null; - try { - stmt = this.connection.prepareStatement(statement.toString()); - for (int i = 0; i < ids.length; i++) { - stmt.setInt(i + 1, ids[i]); - } - stmt.executeUpdate(); - stmt.close(); - } catch (final SQLException e) { - for (final Integer id : ids) { - createPlotSettings(id, null); - } - } - // add plot helpers - String prefix = ""; - statement = new StringBuilder(this.CREATE_HELPERS); - for (final Integer id : helpers.keySet()) { - for (final UUID helper : helpers.get(id)) { - statement.append(prefix + "(?, ?)"); - prefix = ","; - } - } - if (prefix.equals("")) { - return; - } - try { - stmt = this.connection.prepareStatement(statement.toString()); - int counter = 0; - for (final Integer id : helpers.keySet()) { - for (final UUID helper : helpers.get(id)) { - stmt.setInt((counter * 2) + 1, id); - stmt.setString((counter * 2) + 2, helper.toString()); - counter++; - } - } - stmt.executeUpdate(); - stmt.close(); - } catch (final SQLException e) { + } + + private class SettingsPair { + public final int id; + public final PlotSettings settings; + + public SettingsPair(int id, PlotSettings settings) { + this.id = id; + this.settings = settings; + } + } + + @Override + public void createPlotsAndData(final ArrayList myList, final Runnable whenDone) { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { try { - for (final Integer id : helpers.keySet()) { - for (final UUID helper : helpers.get(id)) { - setHelper(id, helper); + // Create the plots + createPlots(myList); + + // Creating datastructures + HashMap plotMap = new HashMap<>(); + for (Plot plot : myList) { + plotMap.put(plot.id, plot); + } + ArrayList settings = new ArrayList<>(); + ArrayList helpers = new ArrayList<>(); + ArrayList trusted = new ArrayList<>(); + ArrayList denied = new ArrayList<>(); + + // Populating structures + final PreparedStatement stmt = connection.prepareStatement(GET_ALL_PLOTS); + final ResultSet result = stmt.executeQuery(); + while (result.next()) { + final int id = result.getInt("id"); + Plot plot = plotMap.get(id); + if (plot != null) { + settings.add(new SettingsPair(id, plot.settings)); + if (plot.denied != null) { + for (UUID uuid : plot.denied) { + denied.add(new UUIDPair(id, uuid)); + } + } + if (plot.trusted != null) { + for (UUID uuid : plot.trusted) { + trusted.add(new UUIDPair(id, uuid)); + } + } + if (plot.helpers != null) { + for (UUID uuid : plot.helpers) { + helpers.add(new UUIDPair(id, uuid)); + } + } } } - } catch (final Exception e2) { + createSettings(settings); + createTiers(helpers, "helpers"); + createTiers(trusted, "trusted"); + createTiers(denied, "denied"); + + TaskManager.runTaskLater(whenDone, 20); + } + catch (SQLException e) { + e.printStackTrace(); + PlotSquared.log("&7[WARN] " + "Failed to set all helpers for plots"); } - PlotSquared.log("&7[WARN] " + "Failed to set all helpers for plots"); } - } + }); + } + + /** + * Create a plot + * + * @param myList list of plots to be created + */ + public void createTiers(final ArrayList myList, final String tier) { + final StmtMod mod = new StmtMod() { + @Override + public String getCreateMySQL(int size) { + return getCreateMySQL(size, CREATE_TIERS.replaceAll("%tier%", tier), 2); + } + + @Override + public String getCreateSQLite(int size) { + return getCreateSQLite(size, + "INSERT INTO `" + prefix + "plot_" + tier + "` SELECT ? AS `plot_plot_id`, ? AS `user_uuid`", 2); + } + + @Override + public String getCreateSQL() { + return "INSERT INTO `" + SQLManager.this.prefix + "plot_" + tier + "` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"; + } + + @Override + public void setMySQL(PreparedStatement stmt, int i, UUIDPair pair) throws SQLException { + stmt.setInt((i * 2) + 1, pair.id); + stmt.setString((i * 2) + 2, pair.uuid.toString()); + } + + @Override + public void setSQLite(PreparedStatement stmt, int i, UUIDPair pair) throws SQLException { + stmt.setInt((i * 2) + 1, pair.id); + stmt.setString((i * 2) + 2, pair.uuid.toString()); + } + + @Override + public void setSQL(PreparedStatement stmt, UUIDPair pair) throws SQLException { + stmt.setInt(1, pair.id); + stmt.setString(2, pair.uuid.toString()); + } + }; + setBulk(myList, mod); + } + + /** + * Create a plot + * + * @param myList list of plots to be created + */ + public void createPlots(final ArrayList myList) { + final StmtMod mod = new StmtMod() { + @Override + public String getCreateMySQL(int size) { + return getCreateMySQL(size, CREATE_PLOTS, 4); + } + + @Override + public String getCreateSQLite(int size) { + return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` ", 6); + } + + @Override + public String getCreateSQL() { + return CREATE_PLOT; + } + + @Override + public void setMySQL(PreparedStatement stmt, int i, Plot plot) throws SQLException { + stmt.setInt((i * 4) + 1, plot.id.x); + stmt.setInt((i * 4) + 2, plot.id.y); + try { + stmt.setString((i * 4) + 3, plot.owner.toString()); + } catch (final Exception e) { + stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); + } + stmt.setString((i * 4) + 4, plot.world); + } + + @Override + public void setSQLite(PreparedStatement stmt, int i, Plot plot) throws SQLException { + stmt.setNull((i * 6) + 1, 4); + stmt.setInt((i * 6) + 2, plot.id.x); + stmt.setInt((i * 6) + 3, plot.id.y); + try { + stmt.setString((i * 6) + 4, plot.owner.toString()); + } catch (final Exception e1) { + stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); + } + stmt.setString((i * 6) + 5, plot.world); + stmt.setTimestamp((i * 6) + 6, new Timestamp(System.currentTimeMillis())); + } + + @Override + public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException { + stmt.setInt(1, plot.id.x); + stmt.setInt(2, plot.id.y); + stmt.setString(3, plot.owner.toString()); + stmt.setString(4, plot.world); + } + }; + setBulk(myList, mod); } public void setBulk(ArrayList objList, StmtMod mod) { final int size = objList.size(); + if (size == 0) { + return; + } int packet; if (PlotSquared.getMySQL() != null) { packet = Math.min(size, 50000); @@ -295,32 +379,31 @@ public class SQLManager implements AbstractDB { } } - @Override - public void createSettings(final ArrayList myList) { - final StmtMod mod = new StmtMod() { - @Override - public String getCreateMySQL(int size) { - return getCreateMySQL(size, CREATE_SETTINGS, 1); - } + public void createSettings(final ArrayList myList) { + final StmtMod mod = new StmtMod() { + @Override + public String getCreateMySQL(int size) { + return getCreateMySQL(size, CREATE_SETTINGS, 1); + } - @Override - public String getCreateSQLite(int size) { - return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ", 10); - } + @Override + public String getCreateSQLite(int size) { + return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ", 10); + } - @Override - public String getCreateSQL() { - return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"; - } + @Override + public String getCreateSQL() { + return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"; + } - @Override - public void setMySQL(PreparedStatement stmt, int i, Integer id) throws SQLException { - stmt.setInt((i * 1) + 1, id); - } + @Override + public void setMySQL(PreparedStatement stmt, int i, SettingsPair id) throws SQLException { + stmt.setInt((i * 1) + 1, id.id); + } - @Override - public void setSQLite(PreparedStatement stmt, int i, Integer id) throws SQLException { - stmt.setInt((i * 10) + 1, id); + @Override + public void setSQLite(PreparedStatement stmt, int i, SettingsPair id) throws SQLException { + stmt.setInt((i * 10) + 1, id.id ); stmt.setNull((i * 10) + 2, 4); stmt.setNull((i * 10) + 3, 4); stmt.setNull((i * 10) + 4, 4); @@ -330,76 +413,60 @@ public class SQLManager implements AbstractDB { stmt.setNull((i * 10) + 8, 4); stmt.setNull((i * 10) + 9, 4); stmt.setString((i * 10) + 10, "DEFAULT"); - } + } - @Override - public void setSQL(PreparedStatement stmt, Integer id) throws SQLException { - stmt.setInt(1, id); - } - }; - TaskManager.runTaskAsync(new Runnable() { + @Override + public void setSQL(PreparedStatement stmt, SettingsPair id) throws SQLException { + stmt.setInt(1, id.id); + } + }; + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { setBulk(myList, mod); } }); } - - /** - * Create a plot - * - * @param myList list of plots to be created - */ - @Override - public void createPlots(final ArrayList myList) { - final StmtMod mod = new StmtMod() { + + public void createEmptySettings(final ArrayList myList) { + final StmtMod mod = new StmtMod() { @Override public String getCreateMySQL(int size) { - return getCreateMySQL(size, CREATE_PLOTS, 4); + return getCreateMySQL(size, CREATE_SETTINGS, 1); } @Override public String getCreateSQLite(int size) { - return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot` SELECT ? AS `id`, ? AS `plot_id_x`, ? AS `plot_id_z`, ? AS `owner`, ? AS `world`, ? AS `timestamp` ", 6); + return getCreateSQLite(size, "INSERT INTO `" + prefix + "plot_settings` SELECT ? AS `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` ", 10); } @Override public String getCreateSQL() { - return CREATE_PLOT; + return "INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(?)"; } @Override - public void setMySQL(PreparedStatement stmt, int i, Plot plot) throws SQLException { - stmt.setInt((i * 4) + 1, plot.id.x); - stmt.setInt((i * 4) + 2, plot.id.y); - try { - stmt.setString((i * 4) + 3, plot.owner.toString()); - } catch (final Exception e) { - stmt.setString((i * 4) + 3, DBFunc.everyone.toString()); - } - stmt.setString((i * 4) + 4, plot.world); + public void setMySQL(PreparedStatement stmt, int i, Integer id) throws SQLException { + stmt.setInt((i * 1) + 1, id); } @Override - public void setSQLite(PreparedStatement stmt, int i, Plot plot) throws SQLException { - stmt.setNull((i * 6) + 1, 4); - stmt.setInt((i * 6) + 2, plot.id.x); - stmt.setInt((i * 6) + 3, plot.id.y); - try { - stmt.setString((i * 6) + 4, plot.owner.toString()); - } catch (final Exception e1) { - stmt.setString((i * 6) + 4, DBFunc.everyone.toString()); - } - stmt.setString((i * 6) + 5, plot.world); - stmt.setTimestamp((i * 6) + 6, new Timestamp(System.currentTimeMillis())); + public void setSQLite(PreparedStatement stmt, int i, Integer id) throws SQLException { + stmt.setInt((i * 10) + 1, id ); + stmt.setNull((i * 10) + 2, 4); + stmt.setNull((i * 10) + 3, 4); + stmt.setNull((i * 10) + 4, 4); + stmt.setNull((i * 10) + 5, 4); + stmt.setNull((i * 10) + 6, 4); + stmt.setNull((i * 10) + 7, 4); + stmt.setNull((i * 10) + 8, 4); + stmt.setNull((i * 10) + 9, 4); + stmt.setString((i * 10) + 10, "DEFAULT"); } @Override - public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException { - stmt.setInt(1, plot.id.x); - stmt.setInt(2, plot.id.y); - stmt.setString(3, plot.owner.toString()); - stmt.setString(4, plot.world); + public void setSQL(PreparedStatement stmt, Integer id) throws SQLException { + stmt.setInt(1, id); } }; TaskManager.runTaskAsync(new Runnable() { @@ -821,7 +888,7 @@ public class SQLManager implements AbstractDB { stmt.close(); r.close(); if (plots.keySet().size() > 0) { - createSettings(new ArrayList(plots.keySet())); + createEmptySettings(new ArrayList(plots.keySet())); } boolean invalidPlot = false; for (final String worldname : noExist.keySet()) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java index 526eec67c..ec1a6898c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -44,6 +44,11 @@ public abstract class TaskManager { } } + /** + * Run task later (delay in ticks) + * @param r + * @param delay + */ public static void runTaskLater(final Runnable r, final int delay) { if (r != null) { PlotSquared.TASK.taskLater(r, delay); From d790d5b7c8152c54bd2a8e2c119821b98c972a92 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 29 Apr 2015 23:07:12 +1000 Subject: [PATCH 204/223] Fixed basic UUID conversion --- .../plot/PlotSquared.java | 21 +++++++++--------- .../plot/commands/DebugUUID.java | 22 ++++++++++++++++++- .../plot/database/Database.java | 2 ++ .../plot/database/SQLManager.java | 12 +++++----- .../plot/database/SQLite.java | 7 ++++++ 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 2bd1aad21..8b0bba94d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -36,6 +36,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.database.Database; import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.database.SQLite; @@ -94,11 +95,11 @@ public class PlotSquared { private final static HashMap plotworlds = new HashMap<>(); private final static HashMap plotmanagers = new HashMap<>(); private static LinkedHashMap> plots; - private static MySQL mySQL; + private static Database database; public static Connection connection; - public static MySQL getMySQL() { - return mySQL; + public static Database getDatabase() { + return database; } public static void updatePlot(final Plot plot) { @@ -631,12 +632,9 @@ public class PlotSquared { public void disable() { try { - connection.close(); - mySQL.closeConnection(); + database.closeConnection(); } catch (NullPointerException | SQLException e) { - if (mySQL != null) { - log("&cCould not close mysql connection!"); - } + log("&cCould not close database connection!"); } } @@ -654,8 +652,8 @@ public class PlotSquared { } if (Settings.DB.USE_MYSQL) { try { - mySQL = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); - connection = mySQL.openConnection(); + database = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); + connection = database.openConnection(); { if (DBFunc.dbManager == null) { DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); @@ -693,7 +691,8 @@ public class PlotSquared { log(C.PREFIX.s() + "MongoDB is not yet implemented"); } else if (Settings.DB.USE_SQLITE) { try { - connection = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection(); + this.database = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db"); + connection = this.database.openConnection(); { DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX); final DatabaseMetaData meta = connection.getMetaData(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 6000e56b5..0280dd40a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -32,6 +32,7 @@ import org.bukkit.Bukkit; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.AbstractDB; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.SQLManager; @@ -233,7 +234,7 @@ public class DebugUUID extends SubCommand { MainUtil.sendConsoleMessage("&7 - Creating tables"); try { - database.createTables(PlotSquared.getMySQL() != null ? "mysql" : "sqlite", true); + database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite", true); if (!result) { MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery"); for (Plot plot : PlotSquared.getPlots()) { @@ -256,6 +257,25 @@ public class DebugUUID extends SubCommand { return false; } + if (newWrapper instanceof OfflineUUIDWrapper) { + PlotSquared.config.set("UUID.force-lowercase", false); + PlotSquared.config.set("UUID.offline", true); + } + else if (newWrapper instanceof LowerOfflineUUIDWrapper) { + PlotSquared.config.set("UUID.force-lowercase", true); + PlotSquared.config.set("UUID.offline", true); + } + else if (newWrapper instanceof DefaultUUIDWrapper) { + PlotSquared.config.set("UUID.force-lowercase", false); + PlotSquared.config.set("UUID.offline", false); + } + try { + PlotSquared.config.save(PlotSquared.configFile); + } + catch (Exception e) { + MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!"); + } + MainUtil.sendConsoleMessage("&7 - Populating tables"); TaskManager.runTaskAsync(new Runnable() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java index f473aa5d0..e785db7e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -46,6 +46,8 @@ public abstract class Database { protected Database(final PlotSquared plotsquared) { this.plotsquared = plotsquared; } + + public abstract Connection forceConnection() throws SQLException, ClassNotFoundException ; /** * Opens a connection with the database diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index fab845c31..db19b460a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -40,6 +40,7 @@ import org.apache.commons.lang.StringUtils; import org.bukkit.block.Biome; import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.BlockLoc; @@ -94,12 +95,12 @@ public class SQLManager implements AbstractDB { this.CREATE_PLOT = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"; this.CREATE_CLUSTER = "INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)"; // schedule reconnect - if (PlotSquared.getMySQL() != null) { + if (Settings.DB.USE_MYSQL) { TaskManager.runTaskRepeat(new Runnable() { @Override public void run() { try { - SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); + SQLManager.this.connection = PlotSquared.getDatabase().forceConnection(); } catch (Exception e) { e.printStackTrace(); @@ -325,7 +326,7 @@ public class SQLManager implements AbstractDB { return; } int packet; - if (PlotSquared.getMySQL() != null) { + if (Settings.DB.USE_MYSQL) { packet = Math.min(size, 50000); } else { packet = Math.min(size, 50); @@ -673,7 +674,7 @@ public class SQLManager implements AbstractDB { try { final Statement statement = this.connection.createStatement(); statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); - if (PlotSquared.getMySQL() != null) { + if (Settings.DB.USE_MYSQL) { statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); } else { @@ -1971,7 +1972,8 @@ public class SQLManager implements AbstractDB { @Override public boolean deleteTables() { try { - SQLManager.this.connection = PlotSquared.getMySQL().forceConnection(); + SQLManager.this.connection.close(); + SQLManager.this.connection = PlotSquared.getDatabase().forceConnection(); final Statement stmt = this.connection.createStatement(); stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index 3810ab34c..5e16ad5f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -107,4 +107,11 @@ public class SQLite extends Database { final Statement statement = this.connection.createStatement(); return statement.executeUpdate(query); } + + @Override + public Connection forceConnection() throws SQLException, ClassNotFoundException { + Class.forName("org.sqlite.JDBC"); + this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation); + return this.connection; + } } From 4090cfb306d0c33532ef4b80b8aee44048b97b7c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 30 Apr 2015 00:22:06 +1000 Subject: [PATCH 205/223] Some settings --- .../plot/database/SQLManager.java | 63 ++++++++++++++++--- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index db19b460a..ca167a8ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -182,7 +182,10 @@ public class SQLManager implements AbstractDB { final ResultSet result = stmt.executeQuery(); while (result.next()) { final int id = result.getInt("id"); - Plot plot = plotMap.get(id); + int x = result.getInt("plot_id_x"); + int y = result.getInt("plot_id_z"); + PlotId plotId = new PlotId(x, y); + Plot plot = plotMap.get(plotId); if (plot != null) { settings.add(new SettingsPair(id, plot.settings)); if (plot.denied != null) { @@ -384,7 +387,7 @@ public class SQLManager implements AbstractDB { final StmtMod mod = new StmtMod() { @Override public String getCreateMySQL(int size) { - return getCreateMySQL(size, CREATE_SETTINGS, 1); + return getCreateMySQL(size, CREATE_SETTINGS, 10); } @Override @@ -398,13 +401,57 @@ public class SQLManager implements AbstractDB { } @Override - public void setMySQL(PreparedStatement stmt, int i, SettingsPair id) throws SQLException { - stmt.setInt((i * 1) + 1, id.id); + public void setMySQL(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException { +// stmt.setInt((i * 1) + 1, id.id); + // `plot_plot_id`, ? AS `biome`, ? AS `rain`, ? AS `custom_time`, ? AS `time`, ? AS `deny_entry`, ? AS `alias`, ? AS `flags`, ? AS `merged`, ? AS `position` + + stmt.setInt((i * 10) + 1, pair.id ); // id + stmt.setNull((i * 10) + 2, 4); // biome + stmt.setNull((i * 10) + 3, 4); // rain + stmt.setNull((i * 10) + 4, 4); // custom_time + stmt.setNull((i * 10) + 5, 4); // time + stmt.setNull((i * 10) + 6, 4); // deny_entry + if (pair.settings.getAlias().equals("")) { + stmt.setNull((i * 10) + 7, 4); + } + else { + stmt.setString((i * 10) + 7, pair.settings.getAlias()); + } + if (pair.settings.flags == null) { + stmt.setNull((i * 10) + 8, 4); + } + else { + final StringBuilder flag_string = new StringBuilder(); + int k = 0; + for (final Flag flag : pair.settings.flags) { + if (k != 0) { + flag_string.append(","); + } + flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4")); + k++; + } + stmt.setString((i * 10) + 8, flag_string.toString()); + } + boolean[] merged = pair.settings.getMerged(); + int n = 0; + for (int j = 0; j < 4; ++j) { + n = (n << 1) + (merged[j] ? 1 : 0); + } + stmt.setInt((i * 10) + 9, n); + BlockLoc loc = pair.settings.getPosition(); + String position; + if (loc.y == 0) { + position = "DEFAULT"; + } + else { + position = loc.x + "," + loc.y + "," + loc.z; + } + stmt.setString((i * 10) + 10, position); } @Override - public void setSQLite(PreparedStatement stmt, int i, SettingsPair id) throws SQLException { - stmt.setInt((i * 10) + 1, id.id ); + public void setSQLite(PreparedStatement stmt, int i, SettingsPair pair) throws SQLException { + stmt.setInt((i * 10) + 1, pair.id ); stmt.setNull((i * 10) + 2, 4); stmt.setNull((i * 10) + 3, 4); stmt.setNull((i * 10) + 4, 4); @@ -417,8 +464,8 @@ public class SQLManager implements AbstractDB { } @Override - public void setSQL(PreparedStatement stmt, SettingsPair id) throws SQLException { - stmt.setInt(1, id.id); + public void setSQL(PreparedStatement stmt, SettingsPair pair) throws SQLException { + stmt.setInt(1, pair.id); } }; TaskManager.runTaskAsync(new Runnable() { From 304decbcefbd5a15b230337928849170735f0f3b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 30 Apr 2015 14:33:57 +1000 Subject: [PATCH 206/223] New experimental async plot clearing --- .../plot/generator/HybridPlotManager.java | 445 +++++------------- .../plot/util/MainUtil.java | 32 ++ .../plot/util/bukkit/BukkitChunkManager.java | 4 + 3 files changed, 165 insertions(+), 316 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 4a05adbd4..83c958490 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -34,39 +34,40 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetBlockQueue; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class HybridPlotManager extends ClassicPlotManager { - + @Override - public void exportTemplate(PlotWorld plotworld) throws IOException { - HashSet files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld)))); - String psRoot = PlotSquared.IMP.getDirectory() + File.separator; - String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator; - String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator; + public void exportTemplate(final PlotWorld plotworld) throws IOException { + final HashSet files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld)))); + final String psRoot = PlotSquared.IMP.getDirectory() + File.separator; + final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator; + final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator; try { - File sideroad = new File(psRoot + dir + "sideroad.schematic"); - if (sideroad.exists()) { - files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath()))); + final File sideroad = new File(psRoot + dir + "sideroad.schematic"); + if (sideroad.exists()) { + files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath()))); + } + final File intersection = new File(psRoot + dir + "intersection.schematic"); + if (intersection.exists()) { + files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath()))); + } + final File plot = new File(psRoot + dir + "plot.schematic"); + if (plot.exists()) { + files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath()))); + } } - File intersection = new File(psRoot + dir + "intersection.schematic"); - if (intersection.exists()) { - files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath()))); - } - File plot = new File(psRoot + dir + "plot.schematic"); - if (plot.exists()) { - files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath()))); - } - } - catch (Exception e) { + catch (final Exception e) { e.printStackTrace(); } Template.zipAll(plotworld.worldname, files); } - + /** - * Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid + * Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync * function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster * than block updates This code is very messy, but you don't need to do something quite as complex unless you happen * to have 512x512 sized plots @@ -74,19 +75,11 @@ public class HybridPlotManager extends ClassicPlotManager { @Override public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { final String world = plotworld.worldname; - MainUtil.runners.put(plot, 1); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.runners.remove(plot); - } - }, 90); final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld); final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1); final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id); final PlotBlock[] plotfloor = dpw.TOP_BLOCK; final PlotBlock[] filling = dpw.MAIN_BLOCK; - // PlotBlock wall = dpw.WALL_BLOCK; final PlotBlock wall; if (isDelete) { wall = dpw.WALL_BLOCK; @@ -96,296 +89,116 @@ public class HybridPlotManager extends ClassicPlotManager { final PlotBlock wall_filling = dpw.WALL_FILLING; setWallFilling(dpw, plot.id, new PlotBlock[] { wall_filling }); final int maxy = BukkitUtil.getMaxHeight(world); - TaskManager.runTaskLater(new Runnable() { + final short bedrock = (short) (dpw.PLOT_BEDROCK ? 7 : 0); + final int startX = (pos1.getX() / 16) * 16; + final int startZ = (pos1.getZ() / 16) * 16; + final int chunkX = 16 + pos2.getX(); + final int chunkZ = 16 + pos2.getZ(); + final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id); + final Location l2 = MainUtil.getPlotTopLoc(world, plot.id); + final int plotMinX = l1.getX() + 1; + final int plotMinZ = l1.getZ() + 1; + final int plotMaxX = l2.getX(); + final int plotMaxZ = l2.getZ(); + Location mn = null; + Location mx = null; + for (int i = startX; i < chunkX; i += 16) { + for (int j = startZ; j < chunkZ; j += 16) { + final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j)); + if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) { + break; + } + final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j)); + if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) { + break; + } + final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15)); + if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) { + break; + } + final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15)); + if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) { + break; + } + final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15)); + if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) { + break; + } + if (mn == null) { + mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ)); + mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); + } else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) { + mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); + } + final int I = i; + final int J = j; + BukkitUtil.regenerateChunk(world, I / 16, J / 16); + if (!MainUtil.canSendChunk) { + BukkitUtil.refreshChunk(world, I / 16, J / 16); + } + } + } + setWall(dpw, plot.id, new PlotBlock[] { wall }); + final Location max = mx; + final Location min = mn; + TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - final short bedrock = (short) (dpw.PLOT_BEDROCK ? 7 : 0); - final int startX = (pos1.getX() / 16) * 16; - final int startZ = (pos1.getZ() / 16) * 16; - final int chunkX = 16 + pos2.getX(); - final int chunkZ = 16 + pos2.getZ(); - final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id); - final Location l2 = MainUtil.getPlotTopLoc(world, plot.id); - final int plotMinX = l1.getX() + 1; - final int plotMinZ = l1.getZ() + 1; - final int plotMaxX = l2.getX(); - final int plotMaxZ = l2.getZ(); - Location mn = null; - Location mx = null; - for (int i = startX; i < chunkX; i += 16) { - for (int j = startZ; j < chunkZ; j += 16) { - final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j)); - if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) { - break; - } - final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j)); - if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) { - break; - } - final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15)); - if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) { - break; - } - final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15)); - if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) { - break; - } - final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15)); - if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) { - break; - } - if (mn == null) { - mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ)); - mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); - } else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) { - mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); - } - final int I = i; - final int J = j; - BukkitUtil.regenerateChunk(world, I / 16, J / 16); - if (!MainUtil.canSendChunk) { - BukkitUtil.refreshChunk(world, I / 16, J / 16); - } - } - } - setWall(dpw, plot.id, new PlotBlock[] { wall }); - final Location max = mx; - final Location min = mn; - if (min == null) { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); - } - }, 5); - } - }, 5); - } - }, 5); - return; - } else { - if (min.getX() < plotMinX) { - min.setX(plotMinX); - } - if (min.getZ() < plotMinZ) { - min.setZ(plotMinZ); - } - if (max.getX() > plotMaxX) { - max.setX(plotMaxX); - } - if (max.getZ() > plotMaxZ) { - max.setZ(plotMaxZ); - } - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 21); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 25); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 29); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 33); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 37); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 41); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 45); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - TaskManager.runTask(whenDone); - } - }, 1); - } - }, 1); - } - }, 1); - } - }, 49); - } - } - }, 20); + if (min == null) { + MainUtil.setSimpleCuboidAsync(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); + SetBlockQueue.addNotify(whenDone); + return; + } + if (min.getX() < plotMinX) { + min.setX(plotMinX); + } + if (min.getZ() < plotMinZ) { + min.setZ(plotMinZ); + } + if (max.getX() > plotMaxX) { + max.setX(plotMaxX); + } + if (max.getZ() > plotMaxZ) { + max.setZ(plotMaxZ); + } + MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor); + MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0)); + MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + SetBlockQueue.addNotify(whenDone); } - }, 20); + }); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index ec1fbf07a..9e872598e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -601,6 +601,7 @@ public class MainUtil { */ public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { if (runners.containsKey(plot)) { + System.out.print("RUNNABLE ALREADY"); return false; } ChunkManager.manager.clearAllEntities(plot); @@ -610,6 +611,7 @@ public class MainUtil { } public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { + System.out.print(1); final PlotManager manager = PlotSquared.getPlotManager(world); final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final int prime = 31; @@ -620,20 +622,24 @@ public class MainUtil { System.currentTimeMillis(); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); runners.put(plot, 1); + System.out.print(2); if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { + System.out.print(3); runners.remove(plot); TaskManager.runTask(whenDone); } }); return; } + System.out.print(2.1); final Runnable run = new Runnable() { @Override public void run() { + System.out.print(3.1); MainUtil.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); @@ -670,6 +676,22 @@ public class MainUtil { } BlockManager.setBlocks(world, xl, yl, zl, ids, data); } + + public static void setCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { + if (blocks.length == 1) { + setSimpleCuboidAsync(world, pos1, pos2, blocks[0]); + return; + } + for (int y = pos1.getY(); y < pos2.getY(); y++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { + final int i = random.random(blocks.length); + final PlotBlock block = blocks[i]; + SetBlockQueue.setBlock(world, x, y, z, block); + } + } + } + } public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); @@ -693,6 +715,16 @@ public class MainUtil { } BlockManager.setBlocks(world, xl, yl, zl, ids, data); } + + public static void setSimpleCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { + for (int y = pos1.getY(); y < pos2.getY(); y++) { + for (int x = pos1.getX(); x < pos2.getX(); x++) { + for (int z = pos1.getZ(); z < pos2.getZ(); z++) { + SetBlockQueue.setBlock(world, x, y, z, newblock); + } + } + } + } public static void setBiome(final String world, final Plot plot, final String biome) { final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index c3fbc59ee..a4fee398e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -279,6 +279,8 @@ public class BukkitChunkManager extends ChunkManager { final int c2x = c2.getX(); final int c2z = c2.getZ(); + System.out.print(4); + final ArrayList chunks = new ArrayList(); for (int x = c1x; x <= c2x; x++) { for (int z = c1z; z <= c2z; z++) { @@ -295,11 +297,13 @@ public class BukkitChunkManager extends ChunkManager { long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < 20) { if (chunks.size() == 0) { + System.out.print(5); TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); return; } + System.out.print(6); CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); final Chunk chunk = chunks.get(0); chunks.remove(0); From 5968b9e22e1dd2c26ec21caf1eacb5bb12cd8364 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 30 Apr 2015 14:46:24 +1000 Subject: [PATCH 207/223] Fixed setup + new plot clearing --- .../intellectualcrafters/plot/commands/Setup.java | 12 +++++++----- .../com/intellectualcrafters/plot/util/MainUtil.java | 10 ++-------- .../plot/util/bukkit/BukkitChunkManager.java | 5 ----- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index a6da94f11..4131daaf6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -45,22 +45,24 @@ public class Setup extends SubCommand { } public void displayGenerators(PlotPlayer plr) { - MainUtil.sendMessage(plr, "&6What generator do you want?"); + StringBuffer message = new StringBuffer(); + message.append("&6What generator do you want?"); for (Entry entry : SetupUtils.generators.entrySet()) { // + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared") if (entry.getKey().equals("PlotSquared")) { - MainUtil.sendMessage(plr, "\n&8 - &2" + entry.getKey() + "(Hybrid Generator)"); + message.append("\n&8 - &2" + entry.getKey() + "(Hybrid Generator)"); } else if (entry.getValue() instanceof HybridGen) { - MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Hybrid Generator)"); + message.append("\n&8 - &7" + entry.getKey() + "(Hybrid Generator)"); } else if (entry.getValue() instanceof PlotGenerator) { - MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Plot Generator)"); + message.append("\n&8 - &7" + entry.getKey() + "(Plot Generator)"); } else { - MainUtil.sendMessage(plr, "\n&8 - &7" + entry.getKey() + "(Unknown structure)"); + message.append("\n&8 - &7" + entry.getKey() + "(Unknown structure)"); } } + MainUtil.sendMessage(plr, message.toString()); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 9e872598e..c7264c4a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -601,7 +601,6 @@ public class MainUtil { */ public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) { if (runners.containsKey(plot)) { - System.out.print("RUNNABLE ALREADY"); return false; } ChunkManager.manager.clearAllEntities(plot); @@ -611,7 +610,6 @@ public class MainUtil { } public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { - System.out.print(1); final PlotManager manager = PlotSquared.getPlotManager(world); final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final int prime = 31; @@ -622,24 +620,20 @@ public class MainUtil { System.currentTimeMillis(); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); runners.put(plot, 1); - System.out.print(2); if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { - System.out.print(3); runners.remove(plot); TaskManager.runTask(whenDone); } }); return; } - System.out.print(2.1); final Runnable run = new Runnable() { @Override public void run() { - System.out.print(3.1); MainUtil.setBiome(world, plot, "FOREST"); runners.remove(plot); TaskManager.runTask(whenDone); @@ -682,7 +676,7 @@ public class MainUtil { setSimpleCuboidAsync(world, pos1, pos2, blocks[0]); return; } - for (int y = pos1.getY(); y < pos2.getY(); y++) { + for (int y = pos1.getY(); y < Math.min(256, pos2.getY()); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { final int i = random.random(blocks.length); @@ -717,7 +711,7 @@ public class MainUtil { } public static void setSimpleCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { - for (int y = pos1.getY(); y < pos2.getY(); y++) { + for (int y = pos1.getY(); y < Math.min(256, pos2.getY()); y++) { for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) { SetBlockQueue.setBlock(world, x, y, z, newblock); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index a4fee398e..4884b567c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -278,9 +278,6 @@ public class BukkitChunkManager extends ChunkManager { final int c1z = c1.getZ(); final int c2x = c2.getX(); final int c2z = c2.getZ(); - - System.out.print(4); - final ArrayList chunks = new ArrayList(); for (int x = c1x; x <= c2x; x++) { for (int z = c1z; z <= c2z; z++) { @@ -297,13 +294,11 @@ public class BukkitChunkManager extends ChunkManager { long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < 20) { if (chunks.size() == 0) { - System.out.print(5); TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); return; } - System.out.print(6); CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); final Chunk chunk = chunks.get(0); chunks.remove(0); From 3540e1f6cad15d5bccb4490cfb37ed7003461715 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 30 Apr 2015 23:57:44 +1000 Subject: [PATCH 208/223] Yay! version 2.10 is coming soon. --- PlotSquared/pom.xml | 2 +- .../plot/commands/Unlink.java | 59 +------------------ .../plot/generator/HybridPlotManager.java | 21 +++++++ .../plot/generator/HybridPlotWorld.java | 1 - .../plot/util/ExpireManager.java | 2 +- .../plot/util/MainUtil.java | 59 +++++++++++++++++++ .../plot/util/SetBlockQueue.java | 6 +- .../plot/util/bukkit/BukkitChunkManager.java | 6 +- 8 files changed, 93 insertions(+), 63 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 19b1543f9..fbba2eb39 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.9.17 + 2.10 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index 00b8f64c9..1bd856359 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -66,7 +66,7 @@ public class Unlink extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - if (!unlinkPlot(plot)) { + if (!MainUtil.unlinkPlot(plot)) { MainUtil.sendMessage(plr, "&cUnlink has been cancelled"); return; } @@ -81,61 +81,4 @@ public class Unlink extends SubCommand { } return true; } - - public static boolean unlinkPlot(final Plot plot) { - final String world = plot.world; - final PlotId pos1 = MainUtil.getBottomPlot(plot).id; - final PlotId pos2 = MainUtil.getTopPlot(plot).id; - final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); - final boolean result = EventUtil.manager.callUnlink(world, ids); - if (!result) { - return false; - } - final PlotManager manager = PlotSquared.getPlotManager(world); - final PlotWorld plotworld = PlotSquared.getPlotWorld(world); - manager.startPlotUnlink(plotworld, ids); - for (final PlotId id : ids) { - final Plot myplot = PlotSquared.getPlots(world).get(id); - if (plot == null) { - continue; - } - if (plot.helpers != null) { - myplot.helpers = plot.helpers; - } - if (plot.denied != null) { - myplot.denied = plot.denied; - } - myplot.deny_entry = plot.deny_entry; - myplot.settings.setMerged(new boolean[] { false, false, false, false }); - DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); - } - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - final boolean lx = x < pos2.x; - final boolean ly = y < pos2.y; - final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); - if (lx) { - manager.createRoadEast(plotworld, p); - if (ly) { - manager.createRoadSouthEast(plotworld, p); - } - } - if (ly) { - manager.createRoadSouth(plotworld, p); - } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); - } - } - manager.finishPlotUnlink(plotworld, ids); - for (final PlotId id : ids) { - final Plot myPlot = MainUtil.getPlot(world, id); - if (plot.hasOwner()) { - final String name = UUIDHandler.getName(myPlot.owner); - if (name != null) { - MainUtil.setSign(name, myPlot); - } - } - } - return true; - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 83c958490..890306d4e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -66,6 +66,27 @@ public class HybridPlotManager extends ClassicPlotManager { Template.zipAll(plotworld.worldname, files); } + @Override + public boolean createRoadEast(PlotWorld plotworld, Plot plot) { + super.createRoadEast(plotworld, plot); + // TODO schematic + return true; + } + + @Override + public boolean createRoadSouth(PlotWorld plotworld, Plot plot) { + super.createRoadSouth(plotworld, plot); + // TODO schematic + return true; + } + + @Override + public boolean createRoadSouthEast(PlotWorld plotworld, Plot plot) { + super.createRoadSouthEast(plotworld, plot); + // TODO schematic + return true; + } + /** * Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync * function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index f73e2ced3..40b67badd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -88,7 +88,6 @@ public class HybridPlotWorld extends ClassicPlotWorld { setupSchematics(); } catch (final Exception e) { PlotSquared.log("&c - road schematics are disabled for this world."); - this.ROAD_SCHEMATIC_ENABLED = false; } } 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 ab83c26b2..806ada38c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -107,7 +107,7 @@ public class ExpireManager { return; } if (plot.settings.isMerged()) { - Unlink.unlinkPlot(plot); + MainUtil.unlinkPlot(plot); } final PlotWorld plotworld = PlotSquared.getPlotWorld(world); manager.clearPlot(plotworld, plot, false, null); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c7264c4a6..a6e7c267b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -42,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** * plot functions @@ -66,6 +67,64 @@ public class MainUtil { return true; } + public static boolean unlinkPlot(final Plot plot) { + final String world = plot.world; + final PlotId pos1 = MainUtil.getBottomPlot(plot).id; + final PlotId pos2 = MainUtil.getTopPlot(plot).id; + final ArrayList ids = MainUtil.getPlotSelectionIds(pos1, pos2); + final boolean result = EventUtil.manager.callUnlink(world, ids); + if (!result) { + return false; + } + final PlotManager manager = PlotSquared.getPlotManager(world); + final PlotWorld plotworld = PlotSquared.getPlotWorld(world); + manager.startPlotUnlink(plotworld, ids); + for (final PlotId id : ids) { + final Plot myplot = PlotSquared.getPlots(world).get(id); + if (plot == null) { + continue; + } + if (plot.helpers != null) { + myplot.helpers = plot.helpers; + } + if (plot.denied != null) { + myplot.denied = plot.denied; + } + myplot.deny_entry = plot.deny_entry; + myplot.settings.setMerged(new boolean[] { false, false, false, false }); + DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); + } + // FIXME unlink augmented + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final boolean lx = x < pos2.x; + final boolean ly = y < pos2.y; + final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); + if (lx) { + manager.createRoadEast(plotworld, p); + if (ly) { + manager.createRoadSouthEast(plotworld, p); + } + } + if (ly) { + manager.createRoadSouth(plotworld, p); + } + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + } + } + manager.finishPlotUnlink(plotworld, ids); + for (final PlotId id : ids) { + final Plot myPlot = MainUtil.getPlot(world, id); + if (plot.hasOwner()) { + final String name = UUIDHandler.getName(myPlot.owner); + if (name != null) { + MainUtil.setSign(name, myPlot); + } + } + } + return true; + } + public static boolean isPlotAreaAbs(final Location location) { final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld()); if (plotworld.TYPE == 2) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java index 46df665cc..082b27a56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; public class SetBlockQueue { private volatile static HashMap blocks; - private volatile static int allocate = 20; + private volatile static int allocate = 25; private volatile static boolean running = false; private volatile static boolean locked = false; private volatile static HashSet runnables; @@ -21,6 +21,10 @@ public class SetBlockQueue { allocate = t; } + public static int getAllocate() { + return allocate; + } + public synchronized static void addNotify(Runnable whenDone) { if (runnables == null) { TaskManager.runTask(whenDone); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index 4884b567c..e78651549 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -61,6 +61,7 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.entity.EntityWrapper; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.SetBlockQueue; import com.intellectualcrafters.plot.util.TaskManager; public class BukkitChunkManager extends ChunkManager { @@ -292,8 +293,11 @@ public class BukkitChunkManager extends ChunkManager { @Override public void run() { long start = System.currentTimeMillis(); - while (System.currentTimeMillis() - start < 20) { + int allocated = SetBlockQueue.getAllocate(); + SetBlockQueue.allocate(0); + while (System.currentTimeMillis() - start < allocated) { if (chunks.size() == 0) { + SetBlockQueue.allocate(SetBlockQueue.getAllocate() + allocated); TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); From 454772fd27fb9e89ef179affbcc1e2232d7c249f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 14:12:31 +1000 Subject: [PATCH 209/223] Abstract PlotMe connector --- .../intellectualcrafters/plot/BukkitMain.java | 2 +- .../database/plotme/APlotMeConnector.java | 16 ++ .../plotme/ClassicPlotMeConnector.java | 141 ++++++++++++++++++ .../{ => plotme}/PlotMeConverter.java | 124 ++------------- .../plot/util/MainUtil.java | 32 ++-- 5 files changed, 187 insertions(+), 128 deletions(-) create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/APlotMeConnector.java create mode 100644 PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java rename PlotSquared/src/main/java/com/intellectualcrafters/plot/database/{ => plotme}/PlotMeConverter.java (76%) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 71f0d8c20..6f95a95c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -76,7 +76,7 @@ import com.intellectualcrafters.plot.commands.list; import com.intellectualcrafters.plot.commands.plugin; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.PlotMeConverter; +import com.intellectualcrafters.plot.database.plotme.PlotMeConverter; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridGen; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/APlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/APlotMeConnector.java new file mode 100644 index 000000000..6341e47a2 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/APlotMeConnector.java @@ -0,0 +1,16 @@ +package com.intellectualcrafters.plot.database.plotme; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.HashMap; + +import org.bukkit.configuration.file.FileConfiguration; + +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; + +public abstract class APlotMeConnector { + public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder); + + public abstract HashMap> getPlotMePlots(Connection connection) throws SQLException; +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java new file mode 100644 index 000000000..ea2add089 --- /dev/null +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java @@ -0,0 +1,141 @@ +package com.intellectualcrafters.plot.database.plotme; + +import java.io.File; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; + +import org.bukkit.configuration.file.FileConfiguration; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.database.SQLite; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.StringWrapper; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; + +public class ClassicPlotMeConnector extends APlotMeConnector { + + @Override + public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) { + try { + if (plotConfig.getBoolean("usemySQL")) { + final String user = plotConfig.getString("mySQLuname"); + final String password = plotConfig.getString("mySQLpass"); + final String con = plotConfig.getString("mySQLconn"); + return DriverManager.getConnection(con, user, password); + } else { + return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection(); + } + } + catch (SQLException | ClassNotFoundException e) {} + return null; + } + + @Override + public HashMap> getPlotMePlots(Connection connection) throws SQLException { + ResultSet r; + Statement stmt; + final HashMap plotSize = new HashMap<>(); + final HashMap> plots = new HashMap<>(); + stmt = connection.createStatement(); + r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); + + boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); + + while (r.next()) { + final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); + final String name = r.getString("owner"); + final String world = PlotMeConverter.getWorld(r.getString("world")); + if (!plotSize.containsKey(world)) { + final int size = r.getInt("topZ") - r.getInt("bottomZ"); + plotSize.put(world, size); + plots.put(world, new HashMap()); + } + UUID owner = UUIDHandler.getUUID(name); + if (owner == null) { + if (name.equals("*")) { + owner = DBFunc.everyone; + } + else { + if (checkUUID){ + try { + byte[] bytes = r.getBytes("ownerid"); + if (bytes != null) { + owner = UUID.nameUUIDFromBytes(bytes); + if (owner != null) { + UUIDHandler.add(new StringWrapper(name), owner); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + if (owner == null) { + MainUtil.sendConsoleMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + continue; + } + } + } + else { + UUIDHandler.add(new StringWrapper(name), owner); + } + final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); + plots.get(world).put(id, plot); + } + r.close(); + stmt.close(); + + stmt = connection.createStatement(); + r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`"); + while (r.next()) { + final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); + final String name = r.getString("player"); + final String world = PlotMeConverter.getWorld(r.getString("world")); + UUID helper = UUIDHandler.getUUID(name); + if (helper == null) { + if (name.equals("*")) { + helper = DBFunc.everyone; + } else { + MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id); + continue; + } + } + if (plots.get(world).containsKey(id)) { + plots.get(world).get(id).helpers.add(helper); + } + } + + MainUtil.sendConsoleMessage(" - plotmeDenied"); + r = stmt.executeQuery("SELECT * FROM `plotmeDenied`"); + + while (r.next()) { + final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); + final String name = r.getString("player"); + final String world = PlotMeConverter.getWorld(r.getString("world")); + UUID denied = UUIDHandler.getUUID(name); + if (denied == null) { + if (name.equals("*")) { + denied = DBFunc.everyone; + } else { + MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id); + continue; + } + } + if (plots.get(world).containsKey(id)) { + plots.get(world).get(id).denied.add(denied); + } + } + + return plots; + } + +} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java similarity index 76% rename from PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java rename to PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java index 70e7c4c68..99ebe7f96 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java @@ -18,7 +18,7 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.database; +package com.intellectualcrafters.plot.database.plotme; import java.io.File; import java.io.IOException; @@ -42,6 +42,8 @@ import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -77,80 +79,11 @@ public class PlotMeConverter { return YamlConfiguration.loadConfiguration(plotMeFile); } - public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) { - try { - if (plotConfig.getBoolean("usemySQL")) { - final String user = plotConfig.getString("mySQLuname"); - final String password = plotConfig.getString("mySQLpass"); - final String con = plotConfig.getString("mySQLconn"); - return DriverManager.getConnection(con, user, password); - } else { - return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection(); - } - } - catch (SQLException | ClassNotFoundException e) {} - return null; - } - public Set getPlotMeWorlds(FileConfiguration plotConfig) { return plotConfig.getConfigurationSection("worlds").getKeys(false); } - public HashMap> getPlotMePlots(Connection connection) throws SQLException { - ResultSet r; - Statement stmt; - final HashMap plotSize = new HashMap<>(); - final HashMap> plots = new HashMap<>(); - stmt = connection.createStatement(); - r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); - - boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); - - while (r.next()) { - final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); - final String name = r.getString("owner"); - final String world = getWorld(r.getString("world")); - if (!plotSize.containsKey(world)) { - final int size = r.getInt("topZ") - r.getInt("bottomZ"); - plotSize.put(world, size); - plots.put(world, new HashMap()); - } - UUID owner = UUIDHandler.getUUID(name); - if (owner == null) { - if (name.equals("*")) { - owner = DBFunc.everyone; - } - else { - if (checkUUID){ - try { - byte[] bytes = r.getBytes("ownerid"); - if (bytes != null) { - owner = UUID.nameUUIDFromBytes(bytes); - if (owner != null) { - UUIDHandler.add(new StringWrapper(name), owner); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - if (owner == null) { - sendMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); - continue; - } - } - } - else { - UUIDHandler.add(new StringWrapper(name), owner); - } - final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); - plots.get(world).put(id, plot); - } - return plots; - } - - public void runAsync() throws Exception { + public void runAsync(final APlotMeConnector connector) throws Exception { // We have to make it wait a couple of seconds TaskManager.runTaskLaterAsync(new Runnable() { @Override @@ -163,7 +96,7 @@ public class PlotMeConverter { return; } - Connection connection = getPlotMeConnection(plotConfig, dataFolder); + Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder); if (connection == null) { sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue"); @@ -179,7 +112,7 @@ public class PlotMeConverter { sendMessage(" - plotmePlots"); final Set worlds = getPlotMeWorlds(plotConfig); - HashMap> plots = getPlotMePlots(connection); + HashMap> plots = connector.getPlotMePlots(connection); for (Entry> entry : plots.entrySet()) { plotCount += entry.getValue().size(); } @@ -189,45 +122,7 @@ public class PlotMeConverter { } sendMessage(" - plotmeAllowed"); - ResultSet r; - Statement stmt = connection.createStatement(); - r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`"); - while (r.next()) { - final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); - final String name = r.getString("player"); - final String world = getWorld(r.getString("world")); - UUID helper = UUIDHandler.getUUID(name); - if (helper == null) { - if (name.equals("*")) { - helper = DBFunc.everyone; - } else { - sendMessage("&6Could not identify helper for plot: " + id); - continue; - } - } - if (plots.get(world).containsKey(id)) { - plots.get(world).get(id).helpers.add(helper); - } - } - sendMessage(" - plotmeDenied"); - r = stmt.executeQuery("SELECT * FROM `plotmeDenied`"); - while (r.next()) { - final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); - final String name = r.getString("player"); - final String world = getWorld(r.getString("world")); - UUID denied = UUIDHandler.getUUID(name); - if (denied == null) { - if (name.equals("*")) { - denied = DBFunc.everyone; - } else { - sendMessage("&6Could not identify denied for plot: " + id); - continue; - } - } - if (plots.get(world).containsKey(id)) { - plots.get(world).get(id).denied.add(denied); - } - } + sendMessage("Collected " + plotCount + " plots from PlotMe"); for (final String world : plots.keySet()) { sendMessage("Copying config for: " + world); @@ -346,6 +241,9 @@ public class PlotMeConverter { } for (final String worldname : worlds) { final World world = Bukkit.getWorld(getWorld(worldname)); + if (world == null) { + sendMessage("&cInvalid world in PlotMe configuration: " + worldname); + } final String actualWorldName = world.getName(); sendMessage("Reloading generator for world: '" + actualWorldName + "'..."); PlotSquared.removePlotWorld(actualWorldName); @@ -394,7 +292,7 @@ public class PlotMeConverter { }, 20); } - public String getWorld(final String world) { + public static String getWorld(final String world) { for (final World newworld : Bukkit.getWorlds()) { if (newworld.getName().equalsIgnoreCase(world)) { return newworld.getName(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index a6e7c267b..5ec80bad2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -94,22 +94,26 @@ public class MainUtil { myplot.settings.setMerged(new boolean[] { false, false, false, false }); DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); } - // FIXME unlink augmented - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - final boolean lx = x < pos2.x; - final boolean ly = y < pos2.y; - final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); - if (lx) { - manager.createRoadEast(plotworld, p); - if (ly) { - manager.createRoadSouthEast(plotworld, p); + if (plotworld.TYPE != 0 && plotworld.TERRAIN < 2) { + // FIXME unlink augmented + } + else { + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final boolean lx = x < pos2.x; + final boolean ly = y < pos2.y; + final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); + if (lx) { + manager.createRoadEast(plotworld, p); + if (ly) { + manager.createRoadSouthEast(plotworld, p); + } } + if (ly) { + manager.createRoadSouth(plotworld, p); + } + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } - if (ly) { - manager.createRoadSouth(plotworld, p); - } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } } manager.finishPlotUnlink(plotworld, ids); From ea7926b0da8814c120bb0bf4be29ff28c8600868 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 14:13:12 +1000 Subject: [PATCH 210/223] * --- .../main/java/com/intellectualcrafters/plot/BukkitMain.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 6f95a95c7..3021f76db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -76,6 +76,7 @@ import com.intellectualcrafters.plot.commands.list; import com.intellectualcrafters.plot.commands.plugin; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector; import com.intellectualcrafters.plot.database.plotme.PlotMeConverter; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; @@ -410,7 +411,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public boolean initPlotMeConverter() { try { - new PlotMeConverter().runAsync(); + new PlotMeConverter().runAsync(new ClassicPlotMeConnector()); } catch (final Exception e) { e.printStackTrace(); } From e792a85c00194f91b28e07e99730899c333de840 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 17:52:32 +1000 Subject: [PATCH 211/223] Better UUID conversion --- .../plot/commands/DebugUUID.java | 2 +- .../plot/util/MainUtil.java | 75 ++++++++++++++----- 2 files changed, 58 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 0280dd40a..374419b7b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -217,7 +217,7 @@ public class DebugUUID extends SubCommand { MainUtil.sendConsoleMessage("&7 - Updating plot objects"); - for (Plot plot : PlotSquared.getPlots()) { + for (Plot plot : PlotSquared.getPlotsRaw()) { UUID value = uCMap.get(plot.owner); if (value != null) { plot.owner = value; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 5ec80bad2..0325ea75c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -94,26 +94,21 @@ public class MainUtil { myplot.settings.setMerged(new boolean[] { false, false, false, false }); DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); } - if (plotworld.TYPE != 0 && plotworld.TERRAIN < 2) { - // FIXME unlink augmented - } - else { - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - final boolean lx = x < pos2.x; - final boolean ly = y < pos2.y; - final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); - if (lx) { - manager.createRoadEast(plotworld, p); - if (ly) { - manager.createRoadSouthEast(plotworld, p); - } - } + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final boolean lx = x < pos2.x; + final boolean ly = y < pos2.y; + final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); + if (lx) { + manager.createRoadEast(plotworld, p); if (ly) { - manager.createRoadSouth(plotworld, p); + manager.createRoadSouthEast(plotworld, p); } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } + if (ly) { + manager.createRoadSouth(plotworld, p); + } + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } } manager.finishPlotUnlink(plotworld, ids); @@ -424,7 +419,7 @@ public class MainUtil { if (lx) { if (ly) { if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { - if (removeRoads) { + if (removeRoads) { manager.removeRoadSouthEast(plotworld, plot); } } @@ -456,7 +451,51 @@ public class MainUtil { manager.finishPlotMerge(plotworld, plotIds); return true; } + + public static void removeRoadSouthEast(PlotWorld plotworld, Plot plot) { + if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x + 1, id.y + 1); + Location pos1 = getPlotTopLoc(plot.world, id).add(1, 0, 1); + Location pos2 = getPlotBottomLoc(plot.world, id2); + ChunkManager.manager.regenerateRegion(pos1, pos2, null); + } + else { + PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + } + } + + public static void removeRoadEast(PlotWorld plotworld, Plot plot) { + if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x + 1, id.y); + Location bot = getPlotBottomLocAbs(plot.world, id2); + Location top = getPlotTopLocAbs(plot.world, id); + Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() + 1); + Location pos2 = new Location(plot.world, bot.getX(), 0, top.getZ()); + ChunkManager.manager.regenerateRegion(pos1, pos2, null); + } + else { + PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + } + } + + public static void removeRoadSouth(PlotWorld plotworld, Plot plot) { + if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x, id.y + 1); + Location bot = getPlotBottomLocAbs(plot.world, id2); + Location top = getPlotTopLocAbs(plot.world, id); + Location pos1 = new Location(plot.world, bot.getX() + 1, 0, top.getZ() + 1); + Location pos2 = new Location(plot.world, top.getX(), 0, bot.getZ()); + ChunkManager.manager.regenerateRegion(pos1, pos2, null); + } + else { + PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + } + } + /** * Merges 2 plots Removes the road inbetween
      - Assumes the first plot parameter is lower
      - Assumes neither * are a Mega-plot
      - Assumes plots are directly next to each other
      - Saves to DB From 435e33d07963af1ec534f74f2376ee7c7b8b26e3 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 21:00:17 +1000 Subject: [PATCH 212/223] More work on unlinking --- .../intellectualcrafters/plot/BukkitMain.java | 11 +- .../plot/PlotSquared.java | 2 +- .../plotme/ClassicPlotMeConnector.java | 93 +++-- .../plot/database/plotme/PlotMeConverter.java | 386 +++++++++--------- .../plot/util/MainUtil.java | 6 +- 5 files changed, 254 insertions(+), 244 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 3021f76db..a76bd8301 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -410,11 +410,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public boolean initPlotMeConverter() { - try { - new PlotMeConverter().runAsync(new ClassicPlotMeConnector()); - } catch (final Exception e) { - e.printStackTrace(); - } + TaskManager.runTaskLaterAsync(new Runnable() { + @Override + public void run() { + new PlotMeConverter().run(new ClassicPlotMeConnector()); + } + }, 20); if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) { return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 8b0bba94d..b7a6bb37e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -570,7 +570,7 @@ public class PlotSquared { log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); - log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'"); + log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'"); } } }, 200); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java index ea2add089..768f3d839 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.database.plotme; import java.io.File; import java.sql.Connection; import java.sql.DriverManager; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -14,6 +15,7 @@ import org.bukkit.configuration.file.FileConfiguration; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; @@ -31,6 +33,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { final String password = plotConfig.getString("mySQLpass"); final String con = plotConfig.getString("mySQLconn"); return DriverManager.getConnection(con, user, password); +// return new MySQL(plotsquared, hostname, port, database, username, password) } else { return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection(); } @@ -42,12 +45,11 @@ public class ClassicPlotMeConnector extends APlotMeConnector { @Override public HashMap> getPlotMePlots(Connection connection) throws SQLException { ResultSet r; - Statement stmt; + PreparedStatement stmt; final HashMap plotSize = new HashMap<>(); final HashMap> plots = new HashMap<>(); - stmt = connection.createStatement(); - r = stmt.executeQuery("SELECT * FROM `plotmePlots`"); - + stmt = connection.prepareStatement("SELECT * FROM `plotmePlots`"); + r = stmt.executeQuery(); boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); while (r.next()) { @@ -91,48 +93,61 @@ public class ClassicPlotMeConnector extends APlotMeConnector { final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); plots.get(world).put(id, plot); } + r.close(); stmt.close(); - stmt = connection.createStatement(); - r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`"); - while (r.next()) { - final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); - final String name = r.getString("player"); - final String world = PlotMeConverter.getWorld(r.getString("world")); - UUID helper = UUIDHandler.getUUID(name); - if (helper == null) { - if (name.equals("*")) { - helper = DBFunc.everyone; - } else { - MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id); - continue; + try { + + MainUtil.sendConsoleMessage(" - plotmeDenied"); + stmt = connection.prepareStatement("SELECT * FROM `plotmeDenied`"); + r = stmt.executeQuery(); + + while (r.next()) { + final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); + final String name = r.getString("player"); + final String world = PlotMeConverter.getWorld(r.getString("world")); + UUID denied = UUIDHandler.getUUID(name); + if (denied == null) { + if (name.equals("*")) { + denied = DBFunc.everyone; + } else { + MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id); + continue; + } + } + if (plots.get(world).containsKey(id)) { + plots.get(world).get(id).denied.add(denied); } } - if (plots.get(world).containsKey(id)) { - plots.get(world).get(id).helpers.add(helper); + + stmt = connection.prepareStatement("SELECT * FROM `plotmeAllowed`"); + r = stmt.executeQuery(); + + while (r.next()) { + final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); + final String name = r.getString("player"); + final String world = PlotMeConverter.getWorld(r.getString("world")); + UUID helper = UUIDHandler.getUUID(name); + if (helper == null) { + if (name.equals("*")) { + helper = DBFunc.everyone; + } else { + MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id); + continue; + } + } + if (plots.get(world).containsKey(id)) { + plots.get(world).get(id).helpers.add(helper); + } } + + r.close(); + stmt.close(); + } - - MainUtil.sendConsoleMessage(" - plotmeDenied"); - r = stmt.executeQuery("SELECT * FROM `plotmeDenied`"); - - while (r.next()) { - final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); - final String name = r.getString("player"); - final String world = PlotMeConverter.getWorld(r.getString("world")); - UUID denied = UUIDHandler.getUUID(name); - if (denied == null) { - if (name.equals("*")) { - denied = DBFunc.everyone; - } else { - MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id); - continue; - } - } - if (plots.get(world).containsKey(id)) { - plots.get(world).get(id).denied.add(denied); - } + catch (Exception e) { + } return plots; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java index 99ebe7f96..b768e79e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java @@ -83,213 +83,207 @@ public class PlotMeConverter { return plotConfig.getConfigurationSection("worlds").getKeys(false); } - public void runAsync(final APlotMeConnector connector) throws Exception { - // We have to make it wait a couple of seconds - TaskManager.runTaskLaterAsync(new Runnable() { - @Override - public void run() { + public void run(final APlotMeConnector connector) { + try { + String dataFolder = getPlotMePath(); + FileConfiguration plotConfig = getPlotMeConfig(dataFolder); + + if (plotConfig == null) { + return; + } + + Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder); + + if (connection == null) { + sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue"); + return; + } + + sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'"); + sendMessage("Connecting to PlotMe DB"); + + int plotCount = 0; + final ArrayList createdPlots = new ArrayList<>(); + + sendMessage("Collecting plot data"); + sendMessage(" - plotmePlots"); + final Set worlds = getPlotMeWorlds(plotConfig); + HashMap> plots = connector.getPlotMePlots(connection); + for (Entry> entry : plots.entrySet()) { + plotCount += entry.getValue().size(); + } + if (!Settings.CONVERT_PLOTME) { + return; + } + + sendMessage(" - plotmeAllowed"); + + sendMessage("Collected " + plotCount + " plots from PlotMe"); + for (final String world : plots.keySet()) { + sendMessage("Copying config for: " + world); try { - String dataFolder = getPlotMePath(); - FileConfiguration plotConfig = getPlotMeConfig(dataFolder); - - if (plotConfig == null) { - return; + final String plotMeWorldName = world.toLowerCase(); + final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); // + PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); + final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); // + PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); + final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); // + PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); + final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); // + PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); + final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); // + PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); + final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId"); + PlotSquared.config.set("worlds." + world + ".road.block", road); + Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // + if (height == null) { + height = 64; } - - Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder); - - if (connection == null) { - sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue"); - } - - sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'"); - sendMessage("Connecting to PlotMe DB"); - - int plotCount = 0; - final ArrayList createdPlots = new ArrayList<>(); - - sendMessage("Collecting plot data"); - sendMessage(" - plotmePlots"); - - final Set worlds = getPlotMeWorlds(plotConfig); - HashMap> plots = connector.getPlotMePlots(connection); - for (Entry> entry : plots.entrySet()) { - plotCount += entry.getValue().size(); - } - - if (!Settings.CONVERT_PLOTME) { - return; - } - - sendMessage(" - plotmeAllowed"); - - sendMessage("Collected " + plotCount + " plots from PlotMe"); + PlotSquared.config.set("worlds." + world + ".road.height", height); + PlotSquared.config.save(PlotSquared.configFile); + } catch (final Exception e) { + sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); + } + } + final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml"); + if (PLOTME_DG_FILE.exists()) { + final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE); + try { for (final String world : plots.keySet()) { - sendMessage("Copying config for: " + world); - try { - final String plotMeWorldName = world.toLowerCase(); - final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); // - PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); - final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); // - PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); - final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); // - PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); - final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); // - PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); - final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); // - PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); - final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId"); - PlotSquared.config.set("worlds." + world + ".road.block", road); - Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // - if (height == null) { + final String plotMeWorldName = world.toLowerCase(); + Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); // + if (pathwidth == null) { + pathwidth = 7; + } + PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); + Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // + if (plotsize == null) { + plotsize = 32; + } + PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); + String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // + if (wallblock == null) { + wallblock = "44"; + } + PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); + String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // + if (floor == null) { + floor = "2"; + } + PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); + String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // + if (filling == null) { + filling = "3"; + } + PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); + String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); + if (road == null) { + road = "5"; + } + PlotSquared.config.set("worlds." + world + ".road.block", road); + Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // + if ((height == null) || (height == 0)) { + height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); // + if ((height == null) || (height == 0)) { height = 64; } - PlotSquared.config.set("worlds." + world + ".road.height", height); - PlotSquared.config.save(PlotSquared.configFile); - } catch (final Exception e) { - sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } - } - final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml"); - if (PLOTME_DG_FILE.exists()) { - final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE); - try { - for (final String world : plots.keySet()) { - final String plotMeWorldName = world.toLowerCase(); - Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); // - if (pathwidth == null) { - pathwidth = 7; - } - PlotSquared.config.set("worlds." + world + ".road.width", pathwidth); - Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // - if (plotsize == null) { - plotsize = 32; - } - PlotSquared.config.set("worlds." + world + ".plot.size", plotsize); - String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // - if (wallblock == null) { - wallblock = "44"; - } - PlotSquared.config.set("worlds." + world + ".wall.block", wallblock); - String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // - if (floor == null) { - floor = "2"; - } - PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); - String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // - if (filling == null) { - filling = "3"; - } - PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); - String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); - if (road == null) { - road = "5"; - } - PlotSquared.config.set("worlds." + world + ".road.block", road); - Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // - if ((height == null) || (height == 0)) { - height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); // - if ((height == null) || (height == 0)) { - height = 64; - } - } - PlotSquared.config.set("worlds." + world + ".road.height", height); - PlotSquared.config.set("worlds." + world + ".plot.height", height); - PlotSquared.config.set("worlds." + world + ".wall.height", height); - PlotSquared.config.save(PlotSquared.configFile); - } - } catch (final Exception e) { - } - } - for (final String world : plots.keySet()) { - int duplicate = 0; - for (final Plot plot : plots.get(world).values()) { - if (!PlotSquared.getPlots(world).containsKey(plot.id)) { - createdPlots.add(plot); - } else { - duplicate++; - } - } - if (duplicate > 0) { - PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?"); - } - } - sendMessage("Creating plot DB"); - Thread.sleep(1000); - DBFunc.createPlotsAndData(createdPlots, new Runnable() { - @Override - public void run() { - sendMessage("&aDatabase conversion is now complete!"); - } - }); - sendMessage("Saving configuration..."); - try { + PlotSquared.config.set("worlds." + world + ".road.height", height); + PlotSquared.config.set("worlds." + world + ".plot.height", height); + PlotSquared.config.set("worlds." + world + ".wall.height", height); PlotSquared.config.save(PlotSquared.configFile); - } catch (final IOException e) { - sendMessage(" - &cFailed to save configuration."); } - TaskManager.runTask(new Runnable() { - @Override - public void run() { - try { - boolean MV = false; - boolean MW = false; - if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { - MV = true; - } else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { - MW = true; - } - for (final String worldname : worlds) { - final World world = Bukkit.getWorld(getWorld(worldname)); - if (world == null) { - sendMessage("&cInvalid world in PlotMe configuration: " + worldname); - } - final String actualWorldName = world.getName(); - sendMessage("Reloading generator for world: '" + actualWorldName + "'..."); - PlotSquared.removePlotWorld(actualWorldName); - if (MV) { - // unload world with MV - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName); - try { - Thread.sleep(1000); - } catch (final InterruptedException ex) { - Thread.currentThread().interrupt(); - } - // load world with MV - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared"); - } else if (MW) { - // unload world with MW - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName); - try { - Thread.sleep(1000); - } catch (final InterruptedException ex) { - Thread.currentThread().interrupt(); - } - // load world with MW - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared"); - } else { - // Load using Bukkit API - // - User must set generator manually - Bukkit.getServer().unloadWorld(world, true); - final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld(); - myworld.save(); - } - } - PlotSquared.setAllPlotsRaw(DBFunc.getPlots()); - } catch (final Exception e) { - e.printStackTrace(); - } - sendMessage("&cPlease wait until database conversion is complete. You will be notified when this happens"); - PlotSquared.log("&c - Stop the server"); - PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml"); - PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly"); - PlotSquared.log("&c - Start the server"); - } - }); } catch (final Exception e) { } } - }, 20); + for (final String world : plots.keySet()) { + int duplicate = 0; + for (final Plot plot : plots.get(world).values()) { + if (!PlotSquared.getPlots(world).containsKey(plot.id)) { + createdPlots.add(plot); + } else { + duplicate++; + } + } + if (duplicate > 0) { + PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?"); + } + } + sendMessage("Creating plot DB"); + Thread.sleep(1000); + DBFunc.createPlotsAndData(createdPlots, new Runnable() { + @Override + public void run() { + sendMessage("&aDatabase conversion is now complete!"); + } + }); + sendMessage("Saving configuration..."); + try { + PlotSquared.config.save(PlotSquared.configFile); + } catch (final IOException e) { + sendMessage(" - &cFailed to save configuration."); + } + TaskManager.runTask(new Runnable() { + @Override + public void run() { + try { + boolean MV = false; + boolean MW = false; + if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) { + MV = true; + } else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) { + MW = true; + } + for (final String worldname : worlds) { + final World world = Bukkit.getWorld(getWorld(worldname)); + if (world == null) { + sendMessage("&cInvalid world in PlotMe configuration: " + worldname); + } + final String actualWorldName = world.getName(); + sendMessage("Reloading generator for world: '" + actualWorldName + "'..."); + PlotSquared.removePlotWorld(actualWorldName); + if (MV) { + // unload world with MV + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName); + try { + Thread.sleep(1000); + } catch (final InterruptedException ex) { + Thread.currentThread().interrupt(); + } + // load world with MV + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared"); + } else if (MW) { + // unload world with MW + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName); + try { + Thread.sleep(1000); + } catch (final InterruptedException ex) { + Thread.currentThread().interrupt(); + } + // load world with MW + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared"); + } else { + // Load using Bukkit API + // - User must set generator manually + Bukkit.getServer().unloadWorld(world, true); + final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld(); + myworld.save(); + } + } + PlotSquared.setAllPlotsRaw(DBFunc.getPlots()); + } catch (final Exception e) { + e.printStackTrace(); + } + sendMessage("&cPlease wait until database conversion is complete. You will be notified when this happens"); + PlotSquared.log("&c - Stop the server"); + PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml"); + PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly"); + PlotSquared.log("&c - Start the server"); + } + }); + } catch (final Exception e) { + PlotSquared.log("&/end/"); + } } public static String getWorld(final String world) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0325ea75c..da4530973 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -420,7 +420,7 @@ public class MainUtil { if (ly) { if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { if (removeRoads) { - manager.removeRoadSouthEast(plotworld, plot); + MainUtil.removeRoadSouthEast(plotworld, plot); } } } @@ -512,7 +512,7 @@ public class MainUtil { lesserPlot.settings.setMerged(2, true); greaterPlot.settings.setMerged(0, true); if (removeRoads) { - manager.removeRoadSouth(plotworld, lesserPlot); + MainUtil.removeRoadSouth(plotworld, lesserPlot); } } } else { @@ -520,7 +520,7 @@ public class MainUtil { lesserPlot.settings.setMerged(1, true); greaterPlot.settings.setMerged(3, true); if (removeRoads) { - manager.removeRoadEast(plotworld, lesserPlot); + MainUtil.removeRoadEast(plotworld, lesserPlot); } } } From 1e6db07e3a50bbe98c8c0836d1aecea57545eb25 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 22:42:10 +1000 Subject: [PATCH 213/223] Finished linking augmented --- .../intellectualcrafters/plot/commands/Setup.java | 12 ++++++------ .../plot/database/SQLManager.java | 6 +++--- .../intellectualcrafters/plot/util/MainUtil.java | 13 ++++++++++--- .../plot/util/bukkit/BukkitChunkManager.java | 6 +----- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 4131daaf6..30aff6d6d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -50,16 +50,16 @@ public class Setup extends SubCommand { for (Entry entry : SetupUtils.generators.entrySet()) { // + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared") if (entry.getKey().equals("PlotSquared")) { - message.append("\n&8 - &2" + entry.getKey() + "(Hybrid Generator)"); + message.append("\n&8 - &2" + entry.getKey() + " (Hybrid Generator)"); } else if (entry.getValue() instanceof HybridGen) { - message.append("\n&8 - &7" + entry.getKey() + "(Hybrid Generator)"); + message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)"); } else if (entry.getValue() instanceof PlotGenerator) { - message.append("\n&8 - &7" + entry.getKey() + "(Plot Generator)"); + message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)"); } else { - message.append("\n&8 - &7" + entry.getKey() + "(Unknown structure)"); + message.append("\n&8 - &7" + entry.getKey() + " (Unknown structure)"); } } MainUtil.sendMessage(plr, message.toString()); @@ -159,7 +159,7 @@ public class Setup extends SubCommand { MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin"); object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); } - MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); + MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); } object.current++; break; @@ -167,7 +167,7 @@ public class Setup extends SubCommand { case 2: { // Choose terrain final List terrain = Arrays.asList(new String[] { "none", "ore", "road", "all" }); if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) { - MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation&8 - &7ROAD&8 - &7Vanilla except for roads\n" + "&8 - &7ALL&8 - &7Entirely vanilla generation"); + MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation"); return false; } object.terrain = terrain.indexOf(args[0].toLowerCase()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index ca167a8ef..37e4ae648 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -285,7 +285,7 @@ public class SQLManager implements AbstractDB { public String getCreateSQL() { return CREATE_PLOT; } - + @Override public void setMySQL(PreparedStatement stmt, int i, Plot plot) throws SQLException { stmt.setInt((i * 4) + 1, plot.id.x); @@ -340,7 +340,7 @@ public class SQLManager implements AbstractDB { if (subList.size() == 0) { return; } - String statement = mod.getCreateMySQL(packet); + String statement = mod.getCreateMySQL(subList.size()); PreparedStatement stmt = null; try { stmt = this.connection.prepareStatement(statement.toString()); @@ -352,7 +352,7 @@ public class SQLManager implements AbstractDB { stmt.close(); } catch (final Exception e) { try { - String unionstmt = mod.getCreateSQLite(packet); + String unionstmt = mod.getCreateSQLite(subList.size()); stmt = this.connection.prepareStatement(unionstmt.toString()); for (int i = 0; i < subList.size(); i++) { mod.setSQLite(stmt, i, subList.get(i)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index da4530973..f3eaad301 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -458,6 +458,10 @@ public class MainUtil { PlotId id2 = new PlotId(id.x + 1, id.y + 1); Location pos1 = getPlotTopLoc(plot.world, id).add(1, 0, 1); Location pos2 = getPlotBottomLoc(plot.world, id2); + pos1.setY(0); + pos2.setY(256); + System.out.print(pos1); + System.out.print(pos2); ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { @@ -472,7 +476,9 @@ public class MainUtil { Location bot = getPlotBottomLocAbs(plot.world, id2); Location top = getPlotTopLocAbs(plot.world, id); Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() + 1); - Location pos2 = new Location(plot.world, bot.getX(), 0, top.getZ()); + Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ()); + System.out.print(pos1); + System.out.print(pos2); ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { @@ -487,7 +493,9 @@ public class MainUtil { Location bot = getPlotBottomLocAbs(plot.world, id2); Location top = getPlotTopLocAbs(plot.world, id); Location pos1 = new Location(plot.world, bot.getX() + 1, 0, top.getZ() + 1); - Location pos2 = new Location(plot.world, top.getX(), 0, bot.getZ()); + Location pos2 = new Location(plot.world, top.getX(), 256, bot.getZ()); + System.out.print(pos1); + System.out.print(pos2); ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { @@ -505,7 +513,6 @@ public class MainUtil { * @param greaterPlot */ public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) { - final PlotManager manager = PlotSquared.getPlotManager(world); final PlotWorld plotworld = PlotSquared.getPlotWorld(world); if (lesserPlot.id.x.equals(greaterPlot.id.x)) { if (!lesserPlot.settings.getMerged(2)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index e78651549..f625e0a44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -293,11 +293,8 @@ public class BukkitChunkManager extends ChunkManager { @Override public void run() { long start = System.currentTimeMillis(); - int allocated = SetBlockQueue.getAllocate(); - SetBlockQueue.allocate(0); - while (System.currentTimeMillis() - start < allocated) { + while (System.currentTimeMillis() - start < 20) { if (chunks.size() == 0) { - SetBlockQueue.allocate(SetBlockQueue.getAllocate() + allocated); TaskManager.runTaskLater(whenDone, 1); Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); @@ -313,7 +310,6 @@ public class BukkitChunkManager extends ChunkManager { final boolean result = chunk.load(false); if (!result) { loaded = false; - ; } if (!chunk.isLoaded()) { loaded = false; From d53c2de4194209a9f7dbc321ae5ca64b6b074aa7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 1 May 2015 22:44:33 +1000 Subject: [PATCH 214/223] Finished unlink augmented --- .../plot/util/MainUtil.java | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index f3eaad301..c5cb17f94 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -94,21 +94,23 @@ public class MainUtil { myplot.settings.setMerged(new boolean[] { false, false, false, false }); DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); } - for (int x = pos1.x; x <= pos2.x; x++) { - for (int y = pos1.y; y <= pos2.y; y++) { - final boolean lx = x < pos2.x; - final boolean ly = y < pos2.y; - final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); - if (lx) { - manager.createRoadEast(plotworld, p); - if (ly) { - manager.createRoadSouthEast(plotworld, p); + if (plotworld.TERRAIN != 3) { + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final boolean lx = x < pos2.x; + final boolean ly = y < pos2.y; + final Plot p = MainUtil.getPlot(world, new PlotId(x, y)); + if (lx) { + manager.createRoadEast(plotworld, p); + if (ly) { + manager.createRoadSouthEast(plotworld, p); + } } + if (ly) { + manager.createRoadSouth(plotworld, p); + } + MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } - if (ly) { - manager.createRoadSouth(plotworld, p); - } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); } } manager.finishPlotUnlink(plotworld, ids); @@ -454,14 +456,15 @@ public class MainUtil { public static void removeRoadSouthEast(PlotWorld plotworld, Plot plot) { if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + if (plotworld.TERRAIN == 3) { + return; + } PlotId id = plot.id; PlotId id2 = new PlotId(id.x + 1, id.y + 1); Location pos1 = getPlotTopLoc(plot.world, id).add(1, 0, 1); Location pos2 = getPlotBottomLoc(plot.world, id2); pos1.setY(0); pos2.setY(256); - System.out.print(pos1); - System.out.print(pos2); ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { @@ -471,14 +474,15 @@ public class MainUtil { public static void removeRoadEast(PlotWorld plotworld, Plot plot) { if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + if (plotworld.TERRAIN == 3) { + return; + } PlotId id = plot.id; PlotId id2 = new PlotId(id.x + 1, id.y); Location bot = getPlotBottomLocAbs(plot.world, id2); Location top = getPlotTopLocAbs(plot.world, id); Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() + 1); Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ()); - System.out.print(pos1); - System.out.print(pos2); ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { @@ -488,14 +492,15 @@ public class MainUtil { public static void removeRoadSouth(PlotWorld plotworld, Plot plot) { if (plotworld.TYPE != 0 && plotworld.TERRAIN > 1) { + if (plotworld.TERRAIN == 3) { + return; + } PlotId id = plot.id; PlotId id2 = new PlotId(id.x, id.y + 1); Location bot = getPlotBottomLocAbs(plot.world, id2); Location top = getPlotTopLocAbs(plot.world, id); Location pos1 = new Location(plot.world, bot.getX() + 1, 0, top.getZ() + 1); Location pos2 = new Location(plot.world, top.getX(), 256, bot.getZ()); - System.out.print(pos1); - System.out.print(pos2); ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { From aa74a0faddc9bf3447488647a4a01df96777da1d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 2 May 2015 00:12:27 +1000 Subject: [PATCH 215/223] Fixes #214 --- .../plot/generator/HybridPlotManager.java | 78 ++++++++++++++++++- .../plot/util/MainUtil.java | 8 +- 2 files changed, 79 insertions(+), 7 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 890306d4e..6bb6d07d7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import com.intellectualcrafters.plot.PlotSquared; @@ -32,7 +33,10 @@ import com.intellectualcrafters.plot.object.FileBytes; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SetBlockQueue; import com.intellectualcrafters.plot.util.TaskManager; @@ -69,21 +73,89 @@ public class HybridPlotManager extends ClassicPlotManager { @Override public boolean createRoadEast(PlotWorld plotworld, Plot plot) { super.createRoadEast(plotworld, plot); - // TODO schematic + HybridPlotWorld hpw = (HybridPlotWorld) plotworld; + if (!hpw.ROAD_SCHEMATIC_ENABLED) { + return true; + } + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x + 1, id.y); + Location bot = getPlotBottomLocAbs(hpw, id2); + Location top = getPlotTopLocAbs(hpw, id); + Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() + 1); + Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ()); + createRoadAbs(hpw, pos1, pos2); return true; } + public static void createRoadAbs(HybridPlotWorld hpw, Location pos1, Location pos2) { + final int sy = hpw.ROAD_HEIGHT; + final int size = hpw.SIZE; + for (int x = pos1.getX(); x <= pos2.getX(); x++) { + for (int z = pos1.getZ(); z <= pos2.getZ(); z++) { + short absX = (short) (x % size); + short absZ = (short) (z % size); + if (absX < 0) { + absX += size; + } + if (absZ < 0) { + absZ += size; + } + final PlotLoc loc = new PlotLoc(absX, absZ); + final HashMap blocks = hpw.G_SCH.get(loc); + for (short y = (short) (hpw.ROAD_HEIGHT); y <= (hpw.ROAD_HEIGHT + hpw.SCHEMATIC_HEIGHT); y++) { + SetBlockQueue.setBlock(hpw.worldname, x, y + y, z, 0); + } + if (blocks != null) { + final HashMap datas = hpw.G_SCH_DATA.get(loc); + if (datas == null) { + for (final Short y : blocks.keySet()) { + SetBlockQueue.setBlock(hpw.worldname, x, sy + y, z, blocks.get(y)); + } + } else { + for (final Short y : blocks.keySet()) { + Byte data = datas.get(y); + if (data == null) { + data = 0; + } + SetBlockQueue.setBlock(hpw.worldname, x, sy + y, z, new PlotBlock(blocks.get(y), data)); + } + } + } + } + } + } + @Override public boolean createRoadSouth(PlotWorld plotworld, Plot plot) { super.createRoadSouth(plotworld, plot); - // TODO schematic + HybridPlotWorld hpw = (HybridPlotWorld) plotworld; + if (!hpw.ROAD_SCHEMATIC_ENABLED) { + return true; + } + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x, id.y + 1); + Location bot = getPlotBottomLocAbs(hpw, id2); + Location top = getPlotTopLocAbs(hpw, id); + Location pos1 = new Location(plot.world, bot.getX() + 1, 0, top.getZ() + 1); + Location pos2 = new Location(plot.world, top.getX(), 256, bot.getZ()); + createRoadAbs(hpw, pos1, pos2); return true; } @Override public boolean createRoadSouthEast(PlotWorld plotworld, Plot plot) { super.createRoadSouthEast(plotworld, plot); - // TODO schematic + HybridPlotWorld hpw = (HybridPlotWorld) plotworld; + if (!hpw.ROAD_SCHEMATIC_ENABLED) { + return true; + } + PlotId id = plot.id; + PlotId id2 = new PlotId(id.x + 1, id.y + 1); + Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1); + Location pos2 = getPlotBottomLocAbs(hpw, id2); + pos1.setY(0); + pos2.setY(256); + createRoadAbs(hpw, pos1, pos2); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index c5cb17f94..fc7343f15 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -461,8 +461,8 @@ public class MainUtil { } PlotId id = plot.id; PlotId id2 = new PlotId(id.x + 1, id.y + 1); - Location pos1 = getPlotTopLoc(plot.world, id).add(1, 0, 1); - Location pos2 = getPlotBottomLoc(plot.world, id2); + Location pos1 = getPlotTopLocAbs(plot.world, id).add(1, 0, 1); + Location pos2 = getPlotBottomLocAbs(plot.world, id2); pos1.setY(0); pos2.setY(256); ChunkManager.manager.regenerateRegion(pos1, pos2, null); @@ -486,7 +486,7 @@ public class MainUtil { ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { - PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + PlotSquared.getPlotManager(plot.world).removeRoadEast(plotworld, plot); } } @@ -504,7 +504,7 @@ public class MainUtil { ChunkManager.manager.regenerateRegion(pos1, pos2, null); } else { - PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot); + PlotSquared.getPlotManager(plot.world).removeRoadSouth(plotworld, plot); } } From 62073fa488348964c351cc2a905976f4203fe210 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 2 May 2015 01:21:21 +1000 Subject: [PATCH 216/223] file save --- .../intellectualsites/translation/YamlTranslationFile.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java index 82021070e..9111c8d72 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java @@ -137,6 +137,10 @@ public class YamlTranslationFile extends TranslationFile { @Override public void saveFile() { try { + if (!this.file.exists()) { + this.file.getParentFile().mkdirs(); + this.file.createNewFile(); + } final FileWriter writer = new FileWriter(this.file); // String s = getYaml().dump(map); if ((this.header != null) && !this.fancyHead) { From 333128b20354369891652bb75bece9422f1c92a4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 2 May 2015 16:18:34 +1000 Subject: [PATCH 217/223] Fixes #290 --- .../plot/generator/HybridPlotWorld.java | 206 +++++++++--------- .../plot/generator/HybridPop.java | 6 +- .../plot/listeners/PlayerEvents.java | 2 + 3 files changed, 102 insertions(+), 112 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java index 40b67badd..71c781df4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotWorld.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.HashSet; import org.apache.commons.lang.StringUtils; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import com.intellectualcrafters.plot.PlotSquared; @@ -194,123 +195,110 @@ public class HybridPlotWorld extends ClassicPlotWorld { } this.ROAD_SCHEMATIC_ENABLED = true; } + + public static byte wrap(byte data, int start) { + if (data >= start && data < start + 4) { + data = (byte) ((((data - start) + 2) % 4) + start); + } + return data; + } + + public static byte wrap2(byte data, int start) { + if (data >= start && data < start + 2) { + data = (byte) ((((data - start) + 1) % 2) + start); + } + return data; + } - public static boolean isRotate(final short id) { + public static byte rotate(final short id, byte data) { switch (id) { - case 23: - return true; - case 26: - return true; - case 27: - return true; - case 28: - return true; - case 29: - return true; - case 33: - return true; - case 53: - return true; - case 54: - return true; - case 55: - return true; - case 61: - return true; - case 62: - return true; - case 64: - return true; - case 65: - return true; - case 67: - return true; - case 68: - return true; - case 71: - return true; - case 77: - return true; - case 86: - return true; - case 84: - return true; - case 93: - return true; - case 94: - return true; - case 96: - return true; - case 107: - return true; - case 108: - return true; - case 109: - return true; - case 111: - return true; - case 119: - return true; - case 128: - return true; - case 130: - return true; - case 131: - return true; - case 134: - return true; - case 135: - return true; - case 136: - return true; - case 143: - return true; - case 144: - return true; - case 145: - return true; - case 146: - return true; - case 149: - return true; - case 150: - return true; - case 156: - return true; - case 157: - return true; - case 158: - return true; - case 163: - return true; - case 164: - return true; - case 167: - return true; - case 180: - return true; case 183: - return true; case 184: - return true; case 185: - return true; case 186: - return true; case 187: - return true; + case 107: + case 53: + case 67: + case 108: + case 109: + case 114: + case 128: + case 134: + case 135: + case 136: + case 156: + case 163: + case 164: + case 180: { + data = wrap(data, 0); + data = wrap(data, 4); + return data; + } + + case 26: + case 86: { + data = wrap(data, 0); + return data; + } + case 64: + case 71: case 193: - return true; case 194: - return true; case 195: - return true; case 196: - return true; case 197: - return true; + case 93: + case 94: + case 131: + case 145: + case 149: + case 150: + case 96: + case 167: { + data = wrap(data, 0); + data = wrap(data, 4); + data = wrap(data, 8); + data = wrap(data, 12); + return data; + } + case 28: + case 66: + case 157: + case 27: { + data = wrap2(data, 0); + data = wrap2(data, 3); + if (data == 2) { + data = 5; + } + else if (data == 5) { + data = 2; + } + return data; + } + + case 23: + case 29: + case 33: + case 158: + case 54: + case 130: + case 146: + case 61: + case 62: + case 65: + case 68: + case 144: { + data = wrap(data, 2); + return data; + } + case 143: + case 77: { + data = wrap(data, 1); + return data; + } default: - return false; + return data; } } @@ -326,12 +314,12 @@ public class HybridPlotWorld extends ClassicPlotWorld { this.G_SCH.put(loc, new HashMap()); } this.G_SCH.get(loc).put(y, id); - if (isRotate(id)) { - if (rotate) { - data = (byte) ((data + 2) % 4); + if (rotate) { + byte newdata = rotate(id, data); + if (data == 0 && newdata == 0) { + return; } - } else if (data == 0) { - return; + data = newdata; } if (!this.G_SCH_DATA.containsKey(loc)) { this.G_SCH_DATA.put(loc, new HashMap()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 2f5a2282c..29aece37d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -138,7 +138,7 @@ public class HybridPop extends PlotPopulator { final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { - setBlock(x, (short) (this.plotheight + y), z, blocks.get(y)); + setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y)); } } if (this.plotworld.G_SCH_STATE != null) { @@ -183,7 +183,7 @@ public class HybridPop extends PlotPopulator { final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { - setBlock(x, (short) (this.plotheight + y), z, blocks.get(y)); + setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y)); } } if (this.plotworld.G_SCH_STATE != null) { @@ -218,7 +218,7 @@ public class HybridPop extends PlotPopulator { final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); if (blocks != null) { for (final short y : blocks.keySet()) { - setBlock(x, (short) (this.roadheight + y), z, blocks.get(y)); + setBlockAbs(x, (short) (this.roadheight + y), z, blocks.get(y)); } } } 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 815e914c5..1669057c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -830,10 +830,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final PlotWorld pW = PlotSquared.getPlotWorld(world); final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); + System.out.print("REASON: " + reason); if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG || reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) && !pW.SPAWN_EGGS) { event.setCancelled(true); return; } else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !pW.SPAWN_BREEDING) { + System.out.print("CANCELLED: " + pW.SPAWN_BREEDING); event.setCancelled(true); return; } else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && !pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) { From 0243f423f69d00280510c6d44eaea6fac5a880b2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 2 May 2015 20:08:30 +1000 Subject: [PATCH 218/223] Optimized UUID caching --- .../intellectualcrafters/plot/BukkitMain.java | 21 ++++--- .../plot/config/Settings.java | 1 + .../plot/util/bukkit/UUIDHandler.java | 56 ++++++++++++++++++- 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index a76bd8301..779511ed9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -445,13 +445,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public UUIDWrapper initUUIDHandler() { final boolean checkVersion = checkVersion(1, 7, 6); - if (!checkVersion) { - log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature."); - Settings.TITLES = false; - FlagManager.removeFlag(FlagManager.getFlag("titles")); - } else { - AbstractTitle.TITLE_CLASS = new DefaultTitle(); - } if (Settings.OFFLINE_MODE) { if (Settings.UUID_LOWERCASE) { UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper(); @@ -472,6 +465,20 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } Settings.OFFLINE_MODE = true; } + if (!checkVersion) { + log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature."); + Settings.TITLES = false; + FlagManager.removeFlag(FlagManager.getFlag("titles")); + } else { + AbstractTitle.TITLE_CLASS = new DefaultTitle(); + + if (UUIDHandler.uuidWrapper instanceof DefaultUUIDWrapper) { + Settings.TWIN_MODE_UUID = true; + } + else if (UUIDHandler.uuidWrapper instanceof OfflineUUIDWrapper && !Bukkit.getOnlineMode()) { + Settings.TWIN_MODE_UUID = true; + } + } if (Settings.OFFLINE_MODE) { log(C.PREFIX.s() + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit"); } else { 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 e12d5a8e4..079ff51ea 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -149,6 +149,7 @@ public class Settings { /** * Use offline mode storage */ + public static boolean TWIN_MODE_UUID = false; public static boolean OFFLINE_MODE = false; public static boolean UUID_LOWERCASE = false; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index 3c8872251..47496872f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -6,6 +6,9 @@ import java.util.HashMap; import java.util.HashSet; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; + import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.intellectualcrafters.plot.PlotSquared; @@ -14,6 +17,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; +import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; @@ -82,15 +86,63 @@ public class UUIDHandler { public static boolean nameExists(final StringWrapper name) { return uuidMap.containsKey(name); } + + public static HashSet getAllUUIDS() { + HashSet uuids = new HashSet(); + for (Plot plot : PlotSquared.getPlotsRaw()) { + for (UUID uuid : plot.helpers) { + uuids.add(uuid); + } + for (UUID uuid : plot.trusted) { + uuids.add(uuid); + } + for (UUID uuid : plot.denied) { + uuids.add(uuid); + } + if (plot.owner != null) { + uuids.add(plot.owner); + } + } + return uuids; + } public static void cacheAll(final String world) { if (CACHED) { return; } PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); + long start = System.currentTimeMillis(); UUIDHandler.CACHED = true; - // OLD UUID CACHING SYSTEM + if (Settings.TWIN_MODE_UUID) { + HashSet all = getAllUUIDS(); + final File playerdataFolder = new File(world + File.separator + "playerdata"); + String[] dat = playerdataFolder.list(new FilenameFilter() { + @Override + public boolean accept(final File f, final String s) { + return s.endsWith(".dat"); + } + }); + if (dat != null) { + for (final String current : dat) { + final String s = current.replaceAll(".dat$", ""); + try { + final UUID uuid = UUID.fromString(s); + if (all.contains(uuid)) { + OfflinePlayer op = Bukkit.getOfflinePlayer(uuid); + add(new StringWrapper(op.getName()), uuid); + } + } catch (final Exception e) { + PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: " + current); + } + } + } + PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); + System.out.print(System.currentTimeMillis() - start); + System.out.print(Settings.TWIN_MODE_UUID); + return; + } + final HashSet worlds = new HashSet<>(); worlds.add(world); worlds.add("world"); @@ -161,6 +213,8 @@ public class UUIDHandler { // add the Everyone '*' UUID add(new StringWrapper("*"), DBFunc.everyone); PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); + System.out.print(System.currentTimeMillis() - start); + System.out.print(Settings.TWIN_MODE_UUID); } public static UUID getUUID(final PlotPlayer player) { From d61e23d04ff6bf9cb93f6bdf328a6061db240ac1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 2 May 2015 21:11:15 +1000 Subject: [PATCH 219/223] Fixed road schem unlink --- .../plot/generator/HybridPlotManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 6bb6d07d7..bbdcf904b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -81,8 +81,8 @@ public class HybridPlotManager extends ClassicPlotManager { PlotId id2 = new PlotId(id.x + 1, id.y); Location bot = getPlotBottomLocAbs(hpw, id2); Location top = getPlotTopLocAbs(hpw, id); - Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ() + 1); - Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ()); + Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ()); + Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ() + 1); createRoadAbs(hpw, pos1, pos2); return true; } @@ -136,8 +136,8 @@ public class HybridPlotManager extends ClassicPlotManager { PlotId id2 = new PlotId(id.x, id.y + 1); Location bot = getPlotBottomLocAbs(hpw, id2); Location top = getPlotTopLocAbs(hpw, id); - Location pos1 = new Location(plot.world, bot.getX() + 1, 0, top.getZ() + 1); - Location pos2 = new Location(plot.world, top.getX(), 256, bot.getZ()); + Location pos1 = new Location(plot.world, bot.getX(), 0, top.getZ() + 1); + Location pos2 = new Location(plot.world, top.getX() + 1, 256, bot.getZ()); createRoadAbs(hpw, pos1, pos2); return true; } From b45eaf1c90beaf36aa36c6340c4f049e098ea487 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 2 May 2015 23:58:52 +1000 Subject: [PATCH 220/223] 2.10, WE blacklist, plot border, string comparison - --- PlotSquared/pom.xml | 2 +- .../plot/PlotSquared.java | 2 ++ .../plot/config/Settings.java | 4 +++ .../plot/generator/ClassicPlotManager.java | 6 ++-- .../plot/listeners/worldedit/WEListener.java | 15 ++------- .../plot/util/StringComparison.java | 31 +++++++++---------- 6 files changed, 26 insertions(+), 34 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index fbba2eb39..ff14f40fa 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.10 + 2.10.1 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index b7a6bb37e..31bd88321 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -866,6 +866,7 @@ public class PlotSquared { options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); options.put("worldedit.max-volume", Settings.WE_MAX_VOLUME); options.put("worldedit.max-iterations", Settings.WE_MAX_ITERATIONS); + options.put("worldedit.blacklist", Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks")); // Chunk processor options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR); @@ -941,6 +942,7 @@ public class PlotSquared { Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask"); Settings.WE_MAX_VOLUME = config.getLong("worldedit.max-volume"); Settings.WE_MAX_ITERATIONS = config.getLong("worldedit.max-iterations"); + Settings.WE_BLACKLIST = config.getStringList("worldedit.blacklist"); // Chunk processor Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled"); 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 079ff51ea..ca5ac5ec6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -20,6 +20,9 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.config; +import java.util.ArrayList; +import java.util.List; + /** * Updater and DB settings * @@ -68,6 +71,7 @@ public class Settings { public static boolean REQUIRE_SELECTION = true; public static long WE_MAX_VOLUME = 500000; public static long WE_MAX_ITERATIONS = 1000; + public static List WE_BLACKLIST = new ArrayList<>(); /** * Default kill road mobs: true */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index 4b09eb12b..d7def6823 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -277,7 +277,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; for (final PlotId id : plotIds) { - if (!block.equals(unclaim)) { + if (block.id != 0 || !block.equals(unclaim)) { setWall(plotworld, id, new PlotBlock[] { block }); } } @@ -298,7 +298,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public boolean claimPlot(final PlotWorld plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; - if (!claim.equals(unclaim)) { + if (claim.id != 0 || !claim.equals(unclaim)) { setWall(plotworld, plot.id, new PlotBlock[] { claim }); } return true; @@ -308,7 +308,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager { public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) { final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK; final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK; - if (!claim.equals(unclaim)) { + if (unclaim.id != 0 || !claim.equals(unclaim)) { setWall(plotworld, plot.id, new PlotBlock[] { unclaim }); } MainUtil.removeSign(plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java index b63d429a1..8a9d94661 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/worldedit/WEListener.java @@ -36,12 +36,9 @@ public class WEListener implements Listener { public final HashSet region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr", "regen", "copy", "cut", "green", "setbiome")); public final HashSet regionExtend = new HashSet<>(Arrays.asList("stack")); public final HashSet unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem")); - public final HashSet unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks", "sel poly")); - public final HashSet unsafe2 = new HashSet<>(Arrays.asList("sel poly", "worldedit reload")); + public final HashSet unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks")); public final HashSet restricted = new HashSet<>(Arrays.asList("up")); -// public final HashSet allowSingleSlash = new HashSet<>(Arrays.asList("sel", ".s", "cs", "restore", "brush", "fixwater", "fixlava", "up", "worldedit", "mask", "gmask", "snapshot", "schem", "schematic", "remove", "fill", "pumpkins", "forestgen", "removenear", "ex", "butcher", "size", "snow")); - public boolean checkCommand(List list, String cmd) { for (String identifier : list) { if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) { @@ -226,20 +223,12 @@ public class WEListener implements Listener { } return true; } - if (unsafe2.contains(reduced)) { - MainUtil.sendMessage(pp, C.WORLDEDIT_UNSAFE); - e.setCancelled(true); - if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { - MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS); - } - return true; - } if (regionExtend.contains(reduced)) { return checkSelection(p, pp, getInt(split[1]), maxVolume, e); } } String reduced = reduceCmd(split[0], single); - if (unsafe1.contains(reduced)) { + if (Settings.WE_BLACKLIST.contains(reduced)) { MainUtil.sendMessage(pp, C.WORLDEDIT_UNSAFE); e.setCancelled(true); if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index 19c68820f..7c4f71842 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -23,6 +23,9 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; import java.util.Collections; +import org.apache.commons.lang.StringUtils; +import org.bukkit.util.StringUtil; + /** * String comparison library * @@ -39,7 +42,7 @@ public class StringComparison { * * Can be checked for low match (< .25 or something) */ - private double match = 0; + private double match = Integer.MAX_VALUE; /** * The actual object */ @@ -51,12 +54,13 @@ public class StringComparison { * @param input Input Base Value * @param objects Objects to compare */ - public StringComparison(final String input, final Object[] objects) { - double c; + public StringComparison(String input, final Object[] objects) { + int c; this.bestMatch = objects[0].toString(); this.bestMatchObject = objects[0]; + input = input.toLowerCase(); for (final Object o : objects) { - if ((c = compare(input, o.toString())) > this.match) { + if ((c = compare(input, o.toString().toLowerCase())) < this.match) { this.match = c; this.bestMatch = o.toString(); this.bestMatchObject = o; @@ -72,20 +76,13 @@ public class StringComparison { * * @return match */ - public static double compare(final String s1, final String s2) { - final ArrayList p1 = wLetterPair(s1.toUpperCase()), p2 = wLetterPair(s2.toUpperCase()); - int intersection = 0; - final int union = p1.size() + p2.size(); - for (final Object aP1 : p1) { - for (final Object aP2 : p2) { - if (aP1.equals(aP2)) { - intersection++; - p2.remove(aP2); - break; - } - } + public static int compare(final String s1, final String s2) { + int distance = StringUtils.getLevenshteinDistance(s1, s2); + if (s2.contains(s1) || s2.contains(s1)) { + distance -= 4; } - return (2.0 * intersection) / union; +// distance += Math.abs(s1.length() - s2.length()); + return distance; } /** From e24d0c53560f865fe97d0f72ad9f42be2fa276a2 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 3 May 2015 00:20:04 +1000 Subject: [PATCH 221/223] Tab completion --- .../plot/commands/BukkitCommand.java | 20 ++++++++++++++----- .../plot/util/StringComparison.java | 6 ++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java index f9e375390..4aea2ba5b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -11,6 +11,7 @@ import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; /** @@ -46,13 +47,22 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { return null; } final List tabOptions = new ArrayList<>(); + final String[] commands = new String[MainCommand.subCommands.size()]; + for (int x = 0; x < MainCommand.subCommands.size(); x++) { + commands[x] = MainCommand.subCommands.get(x).cmd; + } + String best = new StringComparison(strings[0], commands).getBestMatch(); + tabOptions.add(best); + System.out.print("TAB OPTIONS"); final String arg = strings[0].toLowerCase(); for (final SubCommand cmd : MainCommand.subCommands) { - if (cmd.permission.hasPermission(player)) { - if (cmd.cmd.startsWith(arg)) { - tabOptions.add(cmd.cmd); - } else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) { - tabOptions.add(cmd.alias.get(0)); + if (!cmd.cmd.equalsIgnoreCase(best)) { + if (cmd.permission.hasPermission(player)) { + if (cmd.cmd.startsWith(arg)) { + tabOptions.add(cmd.cmd); + } else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) { + tabOptions.add(cmd.alias.get(0)); + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java index 7c4f71842..07dd3b116 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/StringComparison.java @@ -78,10 +78,12 @@ public class StringComparison { */ public static int compare(final String s1, final String s2) { int distance = StringUtils.getLevenshteinDistance(s1, s2); - if (s2.contains(s1) || s2.contains(s1)) { + if (s2.contains(s1)) { + distance -= (Math.min(s1.length(), s2.length())); + } + if (s2.startsWith(s1)) { distance -= 4; } -// distance += Math.abs(s1.length() - s2.length()); return distance; } From f1a7e0d73f741374f0b75c87a613a66357e7c558 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 3 May 2015 13:51:48 +1000 Subject: [PATCH 222/223] Fixes #293 --- PlotSquared/pom.xml | 2 +- .../plot/commands/BukkitCommand.java | 1 - .../plot/generator/AugmentedPopulator.java | 36 +++++++++++++------ .../plot/listeners/PlayerEvents.java | 2 -- .../plot/util/bukkit/UUIDHandler.java | 4 --- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index ff14f40fa..b5d2ed70b 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.10.1 + 2.10.2 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java index 4aea2ba5b..b391de92c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/BukkitCommand.java @@ -53,7 +53,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { } String best = new StringComparison(strings[0], commands).getBestMatch(); tabOptions.add(best); - System.out.print("TAB OPTIONS"); final String arg = strings[0].toLowerCase(); for (final SubCommand cmd : MainCommand.subCommands) { if (!cmd.cmd.equalsIgnoreCase(best)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index dba2d9553..72b4fdc06 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -202,16 +202,7 @@ public class AugmentedPopulator extends BlockPopulator { } } if (this.o) { - chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - // Don't need to populate biome with this -// populateBiome(world, x, z); - MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); - } - }, 20); } else { TaskManager.runTaskLater(new Runnable() { @Override @@ -224,7 +215,6 @@ public class AugmentedPopulator extends BlockPopulator { public void run() { chunk.load(true); populateBlocks(world, rand, X, Z, x, z, check); - MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ())); } }, 40 + rand.nextInt(40)); } @@ -252,7 +242,7 @@ public class AugmentedPopulator extends BlockPopulator { short id = result[i][j]; final int xx = x + x1; final int zz = z + z1; - if (check && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) { + if (check && (((zz) < this.bz) || ((zz) > this.tz) || ((xx) < this.bx) || ((xx) > this.tx))) { continue; } if (this.p) { @@ -267,6 +257,30 @@ public class AugmentedPopulator extends BlockPopulator { BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, id, (byte) 0); } } + else { + short y_min = y_loc[i][0]; + if (y_min < 128) { + for (int x1 = x; x1 < x + 16; x1++) { + for (int z1 = z; z1 < z + 16; z1++) { + if (check && (((z1) < this.bz) || ((z1) > this.tz) || ((x1) < this.bx) || ((x1) > this.tx))) { + continue; + } + if (this.p) { + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + if (BukkitChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, x1, z1)) { + continue; + } + } else if (this.manager.getPlotIdAbs(this.plotworld, x1, 0, z1) != null) { + continue; + } + } + for (int y = y_min; y < y_min + 16; y++) { + BukkitSetBlockManager.setBlockManager.set(world, x1, y, z1, 0, (byte) 0); + } + } + } + } + } } for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) { Chunk chunk = world.getChunkAt(X, Z); 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 1669057c7..815e914c5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -830,12 +830,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } final PlotWorld pW = PlotSquared.getPlotWorld(world); final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason(); - System.out.print("REASON: " + reason); if ((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG || reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG) && !pW.SPAWN_EGGS) { event.setCancelled(true); return; } else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !pW.SPAWN_BREEDING) { - System.out.print("CANCELLED: " + pW.SPAWN_BREEDING); event.setCancelled(true); return; } else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && !pW.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index 47496872f..a07bb44f4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -138,8 +138,6 @@ public class UUIDHandler { } } PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); - System.out.print(System.currentTimeMillis() - start); - System.out.print(Settings.TWIN_MODE_UUID); return; } @@ -213,8 +211,6 @@ public class UUIDHandler { // add the Everyone '*' UUID add(new StringWrapper("*"), DBFunc.everyone); PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); - System.out.print(System.currentTimeMillis() - start); - System.out.print(Settings.TWIN_MODE_UUID); } public static UUID getUUID(final PlotPlayer player) { From 1ad65122b77ff9bef781dac8f439662c697963e4 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 4 May 2015 19:52:37 +1000 Subject: [PATCH 223/223] flags + meta --- .../plot/commands/Info.java | 5 ++-- .../intellectualcrafters/plot/config/C.java | 2 +- .../plot/database/SQLManager.java | 10 +++++-- .../intellectualcrafters/plot/flag/Flag.java | 9 ++---- .../plot/listeners/PlayerEvents.java | 1 + .../plot/object/BukkitPlayer.java | 30 +++++++++++++++++-- .../plot/object/PlotPlayer.java | 4 +++ .../plot/util/bukkit/UUIDHandler.java | 8 ++--- 8 files changed, 50 insertions(+), 19 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 7b357d131..732a1a682 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.Collection; import java.util.UUID; +import java.util.regex.Matcher; import org.apache.commons.lang.StringUtils; @@ -94,7 +95,7 @@ public class Info extends SubCommand { } } if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) { - new InfoInventory(plot, player).build().display(); + new InfoInventory(plot, player).build().display(); return true; } final boolean hasOwner = plot.hasOwner(); @@ -189,7 +190,7 @@ public class Info extends SubCommand { info = info.replaceAll("%trusted%", trusted); info = info.replaceAll("%denied%", denied); info = info.replaceAll("%rating%", rating); - info = info.replaceAll("%flags%", flags); + info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags)); info = info.replaceAll("%build%", build + ""); info = info.replaceAll("%desc%", "No description set."); return info; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 3ac10f838..4bb2abe49 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -187,7 +187,7 @@ public enum C { /* * Core Stuff */ - PREFIX("$3[$1P2$3] "), + PREFIX("$3[$1P2$3] $2"), ENABLED("$1PlotSquared is now enabled"), EXAMPLE_MESSAGE("$2This is an example message &k!!!"), /* diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 37e4ae648..0c7aa2447 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -909,7 +909,7 @@ public class SQLManager implements AbstractDB { } final Set flags = new HashSet(); boolean exception = false; - for (final String element : flags_string) { + for (String element : flags_string) { if (element.contains(":")) { final String[] split = element.split(":"); try { @@ -921,7 +921,13 @@ public class SQLManager implements AbstractDB { exception = true; } } else { - flags.add(new Flag(FlagManager.getFlag(element, true), "")); + element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ","); + if (StringUtils.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) { + flags.add(new Flag(FlagManager.getFlag(element, true), "")); + } + else { + System.out.print("INVALID FLAG: " + element); + } } } if (exception) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index bee4a7270..b8504cbce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -36,13 +36,8 @@ public class Flag { * @throws IllegalArgumentException if you provide inadequate inputs */ public Flag(final AbstractFlag key, final String value) { - final char[] allowedCharacters = new char[] { '[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', ':', '\u00A7' }; - String tempValue = value; - for (final char c : allowedCharacters) { - tempValue = tempValue.replace(c, 'c'); - } - if (!StringUtils.isAlphanumericSpace(tempValue)) { - throw new IllegalArgumentException("Flag must be alphanumerical (colours and some special characters are allowed)"); + if (!StringUtils.isAsciiPrintable(value)) { + throw new IllegalArgumentException("Flag must be ascii"); } if (value.length() > 128) { throw new IllegalArgumentException("Value must be <= 128 characters"); 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 815e914c5..2c76f6318 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -329,6 +329,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (plot.isDenied(pp.getUUID())) { if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) { MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied"); + player.teleport(event.getFrom()); event.setCancelled(true); return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 5fa4db1f9..3832ed22e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.plot.object; +import java.util.HashMap; import java.util.HashSet; import java.util.UUID; @@ -14,10 +15,12 @@ public class BukkitPlayer implements PlotPlayer { public final Player player; UUID uuid; String name; - public HashSet hasPerm = new HashSet<>(); - public HashSet noPerm = new HashSet<>(); private int op = 0; private long last = 0; + public HashSet hasPerm = new HashSet<>(); + public HashSet noPerm = new HashSet<>(); + + private HashMap meta; /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. @@ -118,4 +121,27 @@ public class BukkitPlayer implements PlotPlayer { public Location getLocationFull() { return BukkitUtil.getLocationFull(this.player); } + + @Override + public void setMeta(String key, Object value) { + if (this.meta == null) { + this.meta = new HashMap(); + } + this.meta.put(key, value); + } + + @Override + public Object getMeta(String key) { + if (this.meta != null) { + return this.meta.get(key); + } + return null; + } + + @Override + public void deleteMeta(String key) { + if (this.meta != null) { + this.meta.remove(key); + } + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index cb75aa726..d33f972da 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -30,4 +30,8 @@ public interface PlotPlayer { public String getName(); public void setCompassTarget(Location loc); + + public void setMeta(String key, Object value); + public Object getMeta(String key); + public void deleteMeta(String key); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index a07bb44f4..2d8125751 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -110,10 +110,8 @@ public class UUIDHandler { if (CACHED) { return; } - PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching"); - long start = System.currentTimeMillis(); + PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching: " + world); UUIDHandler.CACHED = true; - if (Settings.TWIN_MODE_UUID) { HashSet all = getAllUUIDS(); final File playerdataFolder = new File(world + File.separator + "playerdata"); @@ -123,12 +121,13 @@ public class UUIDHandler { return s.endsWith(".dat"); } }); + boolean check = all.size() == 0; if (dat != null) { for (final String current : dat) { final String s = current.replaceAll(".dat$", ""); try { final UUID uuid = UUID.fromString(s); - if (all.contains(uuid)) { + if (check || all.contains(uuid)) { OfflinePlayer op = Bukkit.getOfflinePlayer(uuid); add(new StringWrapper(op.getName()), uuid); } @@ -140,7 +139,6 @@ public class UUIDHandler { PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs"); return; } - final HashSet worlds = new HashSet<>(); worlds.add(world); worlds.add("world");