From 279084b0431fc71d5df7aa814bb4084cb06d5173 Mon Sep 17 00:00:00 2001 From: manuelgu Date: Sat, 9 Jul 2016 09:18:55 +0200 Subject: [PATCH 01/11] Add additional alias for /p middle http://grammarist.com/spelling/center-centre/ --- .../java/com/intellectualcrafters/plot/commands/Middle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java index 4ab8a0b39..4e06c734b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java @@ -11,7 +11,7 @@ import com.plotsquared.general.commands.CommandDeclaration; */ @CommandDeclaration( command = "middle", - aliases = {"center"}, + aliases = {"center", "centre"}, description = "Teleports you to the center of the plot", usage = "/plot middle", category = CommandCategory.TELEPORT, From e859a7f56c148ce6b889cf20d082590b607b2431 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 11 Jul 2016 20:27:15 +1000 Subject: [PATCH 02/11] Change to interact perm, not build --- .../main/java/com/intellectualcrafters/plot/util/EventUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index 0f06b49fe..60105e290 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -238,7 +238,7 @@ public abstract class EventUtil { value = null; } if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) { - if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) { + if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) { return true; } return false; From ca776b29128ef79a18211bc09b4fe38bd3bd25fb Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 12 Jul 2016 22:12:14 +1000 Subject: [PATCH 03/11] Fixes #1226 --- .../plot/database/SQLManager.java | 15 +++------- .../plot/flag/FlagManager.java | 13 ++++++++ .../intellectualcrafters/plot/flag/Flags.java | 30 +++++++------------ 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 0d91604ba..64bdaafef 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1816,14 +1816,7 @@ public class SQLManager implements AbstractDB { String[] split = element.split(":"); try { String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ","); - Flag flag = FlagManager.getFlag(split[0],true); - if (flag == null) { - flag = new StringFlag(split[0]) { - @Override public String getValueDescription() { - return "Generic Filler Flag"; - } - }; - } + Flag flag = FlagManager.getOrCreateFlag(split[0]); flags.put(flag, flag.parseValue(flag_str)); } catch (Exception e) { e.printStackTrace(); @@ -1832,7 +1825,7 @@ public class SQLManager implements AbstractDB { } else { element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ","); if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) { - Flag flag = FlagManager.getFlag(element,true); + Flag flag = FlagManager.getOrCreateFlag(element); if (flag == null) { flag = new StringFlag(element) { @Override public String getValueDescription() { @@ -2634,7 +2627,7 @@ public class SQLManager implements AbstractDB { if (element.contains(":")) { String[] split = element.split(":"); String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("�", ","); - Flag flag = FlagManager.getFlag(split[0],true); + Flag flag = FlagManager.getOrCreateFlag(split[0]); if (flag == null) { flag = new StringFlag(split[0]) { @Override public String getValueDescription() { @@ -2644,7 +2637,7 @@ public class SQLManager implements AbstractDB { } flags.put(flag, flag.parseValue(flag_str)); } else { - Flag flag = FlagManager.getFlag(element,true); + Flag flag = FlagManager.getOrCreateFlag(element); if (flag == null) { flag = new StringFlag(element) { @Override public String getValueDescription() { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index aa8154feb..bd7c1bb97 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -317,6 +317,19 @@ public class FlagManager { return flag; } + public static Flag getOrCreateFlag(String string) { + Flag flag = Flags.getFlag(string); + if (flag == null) { + flag = new StringFlag(string) { + @Override public String getValueDescription() { + return "Generic Filler Flag"; + } + }; + flag.register(); + } + return flag; + } + public static Map, Object> parseFlags(List flagStrings) { HashMap, Object> map = new HashMap<>(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java index fc991ea21..7b8247d25 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java @@ -152,35 +152,25 @@ public final class Flags { public static void registerFlag(final Flag flag) { final Flag duplicate = flags.put(flag.getName(), flag); - PS.get().foreachPlotArea(new RunnableVal() { - @Override public void run(PlotArea value) { - if (duplicate != null) { + if (duplicate != null) { + PS.get().foreachPlotArea(new RunnableVal() { + @Override public void run(PlotArea value) { Object remove; if (value.DEFAULT_FLAGS.containsKey(duplicate)) { remove = value.DEFAULT_FLAGS.remove(duplicate); - if (!(remove instanceof String)) { - //error message? maybe? - return; - } - value.DEFAULT_FLAGS.put(flag,flag.parseValue((String) remove)); + value.DEFAULT_FLAGS.put(flag,flag.parseValue("" + remove)); } } - } - }); - PS.get().foreachPlotRaw(new RunnableVal() { - @Override public void run(Plot value) { - if (duplicate != null) { + }); + PS.get().foreachPlotRaw(new RunnableVal() { + @Override public void run(Plot value) { Object remove = null; if (value.getFlags().containsKey(duplicate)) { remove = value.getFlags().remove(duplicate); } - if (!(remove instanceof String)) { - //error message? maybe? - return; - } - value.getFlags().put(flag,flag.parseValue((String) remove)); + value.getFlags().put(flag,flag.parseValue("" + remove)); } - } - }); + }); + } } } From e2c57cea52378508997512bfe44f70407f126b9a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 12 Jul 2016 23:56:59 +1000 Subject: [PATCH 04/11] . --- .../java/com/plotsquared/bukkit/util/BukkitChunkManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index d20b0174a..a73bb63c3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -534,6 +534,7 @@ public class BukkitChunkManager extends ChunkManager { case PAINTING: case ARMOR_STAND: count[5]++; + break; // misc case MINECART: case MINECART_CHEST: From a43430b722126b97ea0d00064be10760e0fc513f Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 13 Jul 2016 00:14:26 +1000 Subject: [PATCH 05/11] Fix NPE for null arg --- Core/src/main/java/com/intellectualcrafters/plot/config/C.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java index 978950114..2b5546809 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -670,7 +670,7 @@ public enum C { Map map = new LinkedHashMap<>(); if (args.length > 0) { for (int i = args.length - 1; i >= 0; i--) { - String arg = args[i].toString(); + String arg = "" + args[i]; if (arg == null || arg.isEmpty()) { map.put("%s" + i, ""); } else { From ba568a3f60ac7a082bbde5b583d6f1e8148dbab9 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 14 Jul 2016 00:28:46 +1000 Subject: [PATCH 06/11] Recover from invalid flag value --- .../plot/flag/BooleanFlag.java | 6 +----- .../plot/flag/FlagManager.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java index 0158e6175..23e3780fe 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java @@ -9,11 +9,7 @@ public class BooleanFlag extends Flag { } @Override public String valueToString(Object value) { - if (((boolean) value)) { - return "true"; - } else { - return "false"; - } + return value + ""; } @Override public Boolean parseValue(String value) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index bd7c1bb97..76d848749 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -112,12 +112,17 @@ public class FlagManager { StringBuilder flag_string = new StringBuilder(); int i = 0; for (Map.Entry, Object> entry : flags.entrySet()) { - Flag flag = entry.getKey(); - if (i != 0) { - flag_string.append(','); + try { + Flag flag = entry.getKey(); + if (i != 0) { + flag_string.append(','); + } + flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); + i++; + } catch (Exception e) { + PS.debug("Failed to parse flag: " + entry.getKey() + "->" + entry.getValue()); + e.printStackTrace(); } - flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); - i++; } return flag_string.toString(); } From 76bce7c0efb720153b00ab7675f31d23d2b64315 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 14 Jul 2016 20:29:11 +1000 Subject: [PATCH 07/11] Catch CommandException --- .../main/java/com/plotsquared/general/commands/Command.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/general/commands/Command.java b/Core/src/main/java/com/plotsquared/general/commands/Command.java index de19e75a1..5152b0e10 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -333,7 +333,11 @@ public abstract class Command { if (!cmd.checkArgs(player, newArgs) || !cmd.canExecute(player, true)) { return; } - cmd.execute(player, newArgs, confirm, whenDone); + try { + cmd.execute(player, newArgs, confirm, whenDone); + } catch (CommandException e) { + e.perform(player); + } } public boolean checkArgs(PlotPlayer player, String[] args) { From 269e409e3e23778e52eb59da259139c41fdca913 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sun, 17 Jul 2016 23:19:37 -0400 Subject: [PATCH 08/11] Version Bump --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f8e70859e..c547fa0da 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { git = Grgit.open() revision = "-${git.head().abbreviatedId}" } -version = "3.4.4-SNAPSHOT${revision}" +version = "3.4.5-SNAPSHOT${revision}" description = """PlotSquared""" subprojects { From c1d4c481fb1136441c6e3d9fdbe3c70163532ad1 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sun, 17 Jul 2016 23:20:31 -0400 Subject: [PATCH 09/11] Fix #1244 --- .../bukkit/listeners/EntitySpawnListener.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java index 5c871eaf5..3c1ea45e1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java @@ -1,5 +1,7 @@ package com.plotsquared.bukkit.listeners; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotArea; @@ -14,14 +16,14 @@ public class EntitySpawnListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void creatureSpawnEvent(EntitySpawnEvent event) { Entity entity = event.getEntity(); + Location location = BukkitUtil.getLocation(entity.getLocation()); + PlotArea area = location.getPlotArea(); + if (area == null) { + return; + } + Plot plot = area.getOwnedPlotAbs(location); switch (entity.getType()) { case ENDER_CRYSTAL: - Location location = BukkitUtil.getLocation(entity.getLocation()); - PlotArea area = location.getPlotArea(); - if (area == null) { - return; - } - Plot plot = area.getOwnedPlotAbs(location); if (plot == null) { if (!area.MOB_SPAWNING) { event.setCancelled(true); @@ -32,5 +34,8 @@ public class EntitySpawnListener implements Listener { event.setCancelled(true); } } + if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) { + event.setCancelled(true); + } } } From 8b084839fd67bfbf610a92b899ad65e14f78ab09 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Tue, 19 Jul 2016 10:22:50 -0400 Subject: [PATCH 10/11] Fix #1261 --- .../java/com/intellectualcrafters/plot/commands/FlagCmd.java | 3 +++ Core/src/main/java/com/plotsquared/listener/PlotListener.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index a75cbff63..a2f127a71 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -166,6 +166,9 @@ public class FlagCmd extends SubCommand { return false; } } + if(flag == Flags.TIME) { + player.setTime(Long.MAX_VALUE); + } MainUtil.sendMessage(player, C.FLAG_REMOVED); return true; } diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index 5889d8a8d..25197fc5f 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -209,7 +209,7 @@ public class PlotListener { PlotGameMode gameMode = player.getGameMode(); if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) { player.setFlight(false); - } else if (player.getFlight() != true) { + } else if (!player.getFlight()) { player.setFlight(true); } } From 98e865cdf06cb7a1756a2f5d84ecd5c0d4caf249 Mon Sep 17 00:00:00 2001 From: manuelgu Date: Sat, 23 Jul 2016 12:50:39 +0200 Subject: [PATCH 11/11] Make debug output useful --- .../main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index 07973e585..16c89a9c1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -164,7 +164,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { ByteSource is = com.google.common.io.Files.asByteSource(file); NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION); if (!compound.containsKey("bukkit")) { - PS.debug("ERROR: Player data does not contain the the key \"bukkit\""); + PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\""); } else { NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); String name = (String) bukkit.get("lastKnownName");