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); + } } } 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: 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"); 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/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, 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 ca28e3f36..5996c768a 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 { 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/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 aa8154feb..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(); } @@ -317,6 +322,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)); } - } - }); + }); + } } } 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; 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) { 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); } }