From ca8b82dcbe5c104947d6192dae882ce916ac735d Mon Sep 17 00:00:00 2001 From: MattBDev Date: Tue, 5 Jul 2016 23:39:38 -0400 Subject: [PATCH 01/27] Version Bump --- .../src/main/java/com/plotsquared/sponge/SpongeMain.java | 2 +- build.gradle | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 0ceef43dc..44848bd05 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -76,7 +76,7 @@ import java.util.UUID; import java.util.stream.Collectors; @Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", - url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3") + url = "https://github.com/IntellectualSites/PlotSquared", version = "3.5.0-SNAPSHOT") public class SpongeMain implements IPlotMain { public static SpongeMain THIS; diff --git a/build.gradle b/build.gradle index f8e70859e..882f3effa 100644 --- a/build.gradle +++ b/build.gradle @@ -6,19 +6,20 @@ buildscript { maven { url = "https://oss.sonatype.org/content/repositories/snapshots/"} jcenter() } - dependencies { + dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' classpath 'org.ajoberstar:grgit:1.7.0' } } group = 'com.intellectualcrafters' -def revision = "" + ext { git = Grgit.open() - revision = "-${git.head().abbreviatedId}" + revision = "${git.head().abbreviatedId}" } -version = "3.4.4-SNAPSHOT${revision}" + +version = "3.5.0-SNAPSHOT-${revision}" description = """PlotSquared""" subprojects { From 8b0e59209c735c3168eb76dd01b638d26957c349 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Tue, 5 Jul 2016 23:43:08 -0400 Subject: [PATCH 02/27] Remove getServerName() --- .../main/java/com/plotsquared/bukkit/BukkitMain.java | 5 ----- .../java/com/intellectualcrafters/plot/IPlotMain.java | 6 ------ .../com/intellectualcrafters/plot/commands/Load.java | 10 ++-------- .../com/intellectualcrafters/plot/commands/Save.java | 3 +-- .../main/java/com/plotsquared/sponge/SpongeMain.java | 5 ----- 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 7fb9c2fde..fcb6354d1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -570,11 +570,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain return new BukkitInventoryUtil(); } - @Override - public String getServerName() { - return Bukkit.getServerName(); - } - @Override public void startMetrics() { Metrics metrics = new Metrics(this); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 205677391..6c644b38b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -236,12 +236,6 @@ public interface IPlotMain extends ILogger { */ void registerWorldEvents(); - /** - * Get the name of the server. - * @return the server name - */ - String getServerName(); - /** * Get the class that will manage player titles. * @return diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java index b8073f9cd..301f0d87f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Load.java @@ -148,13 +148,7 @@ public class Load extends SubCommand { String world = split[1]; PlotId id = PlotId.fromString(split[2] + ';' + split[3]); String size = split[4]; - String server = split[5].replaceAll(".schematic", ""); - String color; - if (PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "").equals(server)) { - color = "$4"; - } else { - color = "$1"; - } + String color = "$4"; MainUtil.sendMessage(player, "$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id + "$3 | " + color + size + 'x' + size); } catch (Exception e) { @@ -191,7 +185,7 @@ public class Load extends SubCommand { time -= minutes * 60; toreturn.append(minutes + "m "); } - if (toreturn.equals("") || (time > 0)) { + if (toreturn.length() == 0 || (time > 0)) { toreturn.append(time + "s "); } return toreturn.toString().trim(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java index c2c99f258..90fb76050 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java @@ -63,12 +63,11 @@ public class Save extends SubCommand { @Override public void run() { String time = (System.currentTimeMillis() / 1000) + ""; - String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", ""); Location[] corners = plot.getCorners(); int size = (corners[1].getX() - corners[0].getX()) + 1; PlotId id = plot.getId(); String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", ""); - final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size + '_' + name; + final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size; UUID uuid = player.getUUID(); SchematicHandler.manager.upload(value, uuid, file, new RunnableVal() { @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 44848bd05..6d5671ebc 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -293,11 +293,6 @@ public class SpongeMain implements IPlotMain { Sponge.getEventManager().registerListeners(this, new WorldEvents()); } - @Override - public String getServerName() { - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); - } - @Override public void startMetrics() { SpongeMetrics metrics = new SpongeMetrics(this.game, this.plugin); From 8538170cbafc40eb16e4e3b7e88b9c2a285264da Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sat, 16 Jul 2016 22:51:49 -0400 Subject: [PATCH 03/27] Metrics --- .../com/plotsquared/bukkit/BukkitMain.java | 10 +- .../plotsquared/bukkit/chat/FancyMessage.java | 96 ++--- .../plotsquared/bukkit/chat/MessagePart.java | 240 ++++++------- .../plotsquared/bukkit/chat/Reflection.java | 55 ++- .../bukkit/listeners/PlayerEvents.java | 22 +- .../com/plotsquared/bukkit/util/Metrics.java | 330 +----------------- .../intellectualcrafters/plot/Platform.java | 9 + .../plot/commands/Auto.java | 2 +- .../plot/commands/Claim.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/MainCommand.java | 4 +- .../plot/commands/Merge.java | 2 +- .../intellectualcrafters/plot/config/C.java | 4 +- .../plot/config/Settings.java | 2 +- .../plot/object/Expression.java | 14 +- Sponge/build.gradle | 10 +- .../com/plotsquared/sponge/SpongeMain.java | 18 +- 17 files changed, 268 insertions(+), 554 deletions(-) create mode 100644 Core/src/main/java/com/intellectualcrafters/plot/Platform.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index fcb6354d1..9dc0691f0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -123,7 +123,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public void onEnable() { + getServer().getName(); new PS(this, "Bukkit"); + if (Settings.Enabled_Components.METRICS) { + new Metrics(this).start(); + PS.log(C.PREFIX + "&6Metrics enabled."); + } else { + PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS); + } } @Override @@ -572,8 +579,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public void startMetrics() { - Metrics metrics = new Metrics(this); - metrics.start(); + new Metrics(this).start(); PS.log(C.PREFIX + "&6Metrics enabled."); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java index ba61fe261..97d112f99 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java @@ -1,10 +1,25 @@ package com.plotsquared.bukkit.chat; +import static com.plotsquared.bukkit.chat.TextualComponent.rawText; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.stream.JsonWriter; +import org.bukkit.Achievement; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Statistic; +import org.bukkit.Statistic.Type; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.serialization.ConfigurationSerializable; +import org.bukkit.configuration.serialization.ConfigurationSerialization; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.Constructor; @@ -19,21 +34,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Level; -import org.bukkit.Achievement; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Statistic; -import org.bukkit.Statistic.Type; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.serialization.ConfigurationSerializable; -import org.bukkit.configuration.serialization.ConfigurationSerialization; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - - -import static com.plotsquared.bukkit.chat.TextualComponent.rawText; /** * Represents a formattable message. Such messages can use elements such as colors, formatting codes, hover and click data, and other features provided by the vanilla Minecraft JSON message formatter. @@ -60,7 +60,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< @Override public FancyMessage clone() throws CloneNotSupportedException { FancyMessage instance = (FancyMessage) super.clone(); - instance.messageParts = new ArrayList(messageParts.size()); + instance.messageParts = new ArrayList<>(messageParts.size()); for (int i = 0; i < messageParts.size(); i++) { instance.messageParts.add(i, messageParts.get(i).clone()); } @@ -78,15 +78,15 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< this(rawText(firstPartText)); } - public FancyMessage(final com.plotsquared.bukkit.chat.TextualComponent firstPartText) { - messageParts = new ArrayList(); + public FancyMessage(final TextualComponent firstPartText) { + messageParts = new ArrayList<>(); messageParts.add(new MessagePart(firstPartText)); jsonString = null; dirty = false; if (nmsPacketPlayOutChatConstructor == null) { try { - nmsPacketPlayOutChatConstructor = com.plotsquared.bukkit.chat.Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent")); + nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent")); nmsPacketPlayOutChatConstructor.setAccessible(true); } catch (NoSuchMethodException e) { Bukkit.getLogger().log(Level.SEVERE, "Could not find Minecraft method or constructor.", e); @@ -100,7 +100,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< * Creates a JSON message without text. */ public FancyMessage() { - this((com.plotsquared.bukkit.chat.TextualComponent) null); + this((TextualComponent) null); } /** @@ -122,7 +122,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< * @param text The new text of the current editing component. * @return This builder instance. */ - public FancyMessage text(com.plotsquared.bukkit.chat.TextualComponent text) { + public FancyMessage text(TextualComponent text) { MessagePart latest = latest(); latest.text = text; dirty = true; @@ -243,8 +243,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< */ public FancyMessage achievementTooltip(final Achievement which) { try { - Object achievement = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which); - return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Achievement"), "name").get(achievement)); + Object achievement = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which); + return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name").get(achievement)); } catch (IllegalAccessException e) { Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); return this; @@ -252,7 +252,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); return this; } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e); + Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); return this; } } @@ -271,8 +271,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!"); } try { - Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which); - return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Statistic"), "name").get(statistic)); + Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which); + return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); } catch (IllegalAccessException e) { Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); return this; @@ -280,7 +280,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); return this; } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e); + Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); return this; } } @@ -303,8 +303,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); } try { - Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item); - return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Statistic"), "name").get(statistic)); + Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item); + return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); } catch (IllegalAccessException e) { Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); return this; @@ -312,7 +312,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); return this; } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e); + Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); return this; } } @@ -335,8 +335,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!"); } try { - Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity); - return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Statistic"), "name").get(statistic)); + Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity); + return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic)); } catch (IllegalAccessException e) { Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e); return this; @@ -344,7 +344,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); return this; } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e); + Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); return this; } } @@ -370,8 +370,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< */ public FancyMessage itemTooltip(final ItemStack itemStack) { try { - Object nmsItem = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack); - return itemTooltip(com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getNMSClass("ItemStack"), "save", com.plotsquared.bukkit.chat.Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, com.plotsquared.bukkit.chat.Reflection.getNMSClass("NBTTagCompound").newInstance()).toString()); + Object nmsItem = Reflection.getMethod(Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack); + return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save", Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance()).toString()); } catch (Exception e) { e.printStackTrace(); return this; @@ -565,7 +565,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< * @param text The text which will populate the new message component. * @return This builder instance. */ - public FancyMessage then(final com.plotsquared.bukkit.chat.TextualComponent text) { + public FancyMessage then(final TextualComponent text) { if (!latest().hasText()) { throw new IllegalStateException("previous message part has no text"); } @@ -641,9 +641,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } Player player = (Player) sender; try { - Object handle = com.plotsquared.bukkit.chat.Reflection.getHandle(player); - Object connection = com.plotsquared.bukkit.chat.Reflection.getField(handle.getClass(), "playerConnection").get(handle); - com.plotsquared.bukkit.chat.Reflection.getMethod(connection.getClass(), "sendPacket", com.plotsquared.bukkit.chat.Reflection.getNMSClass("Packet")).invoke(connection, createChatPacket(jsonString)); + Object handle = Reflection.getHandle(player); + Object connection = Reflection.getField(handle.getClass(), "playerConnection").get(handle); + Reflection.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet")).invoke(connection, createChatPacket(jsonString)); } catch (IllegalArgumentException e) { Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); } catch (IllegalAccessException e) { @@ -651,7 +651,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } catch (InstantiationException e) { Bukkit.getLogger().log(Level.WARNING, "Underlying class is abstract.", e); } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e); + Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e); } catch (NoSuchMethodException e) { Bukkit.getLogger().log(Level.WARNING, "Could not find method.", e); } catch (ClassNotFoundException e) { @@ -673,16 +673,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< // X = major // Y = minor // Z = revision - final String version = com.plotsquared.bukkit.chat.Reflection.getVersion(); + final String version = Reflection.getVersion(); String[] split = version.substring(1, version.length() - 1).split("_"); // Remove trailing dot //int majorVersion = Integer.parseInt(split[0]); int minorVersion = Integer.parseInt(split[1]); int revisionVersion = Integer.parseInt(split[2].substring(1)); // Substring to ignore R if (minorVersion < 8 || (minorVersion == 8 && revisionVersion == 1)) { - chatSerializerClazz = com.plotsquared.bukkit.chat.Reflection.getNMSClass("ChatSerializer"); + chatSerializerClazz = Reflection.getNMSClass("ChatSerializer"); } else { - chatSerializerClazz = com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent$ChatSerializer"); + chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer"); } if (chatSerializerClazz == null) { @@ -702,7 +702,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< // Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)' than to reflectively call it // Of course, the implementation may change, but fuzzy matches might break with signature changes - Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent")); + Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Reflection.getNMSClass("IChatBaseComponent")); return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent); } @@ -781,7 +781,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< // Doc copied from interface public Map serialize() { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); map.put("messageParts", messageParts); // map.put("JSON", toJSONString()); return map; @@ -829,9 +829,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< JsonObject messagePart = mPrt.getAsJsonObject(); for (Map.Entry entry : messagePart.entrySet()) { // Deserialize text - if (com.plotsquared.bukkit.chat.TextualComponent.isTextKey(entry.getKey())) { + if (TextualComponent.isTextKey(entry.getKey())) { // The map mimics the YAML serialization, which has a "key" field and one or more "value" fields - Map serializedMapForm = new HashMap(); // Must be object due to Bukkit serializer API compliance + Map serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance serializedMapForm.put("key", entry.getKey()); if (entry.getValue().isJsonPrimitive()) { // Assume string @@ -842,7 +842,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString()); } } - component.text = com.plotsquared.bukkit.chat.TextualComponent.deserialize(serializedMapForm); + component.text = TextualComponent.deserialize(serializedMapForm); } else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) { if (entry.getValue().getAsBoolean()) { component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey())); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java index dcdc71ee3..a3ed7fa2b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java @@ -19,137 +19,139 @@ import java.util.logging.Level; */ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable { - ChatColor color = ChatColor.WHITE; - ArrayList styles = new ArrayList(); - String clickActionName = null, clickActionData = null, hoverActionName = null; - JsonRepresentedObject hoverActionData = null; - TextualComponent text = null; - String insertionData = null; - ArrayList translationReplacements = new ArrayList(); + ChatColor color = ChatColor.WHITE; + ArrayList styles = new ArrayList<>(); + String clickActionName = null; + String clickActionData = null; + String hoverActionName = null; + JsonRepresentedObject hoverActionData = null; + TextualComponent text = null; + String insertionData = null; + ArrayList translationReplacements = new ArrayList<>(); - MessagePart(final TextualComponent text) { - this.text = text; - } + MessagePart(final TextualComponent text) { + this.text = text; + } - MessagePart() { - this.text = null; - } + MessagePart() { + this.text = null; + } - boolean hasText() { - return text != null; - } + boolean hasText() { + return text != null; + } - @Override - @SuppressWarnings("unchecked") - public MessagePart clone() throws CloneNotSupportedException { - MessagePart obj = (MessagePart) super.clone(); - obj.styles = (ArrayList) styles.clone(); - if (hoverActionData instanceof JsonString) { - obj.hoverActionData = new JsonString(((JsonString) hoverActionData).getValue()); - } else if (hoverActionData instanceof FancyMessage) { - obj.hoverActionData = ((FancyMessage) hoverActionData).clone(); - } - obj.translationReplacements = (ArrayList) translationReplacements.clone(); - return obj; + @Override + @SuppressWarnings("unchecked") + public MessagePart clone() throws CloneNotSupportedException { + MessagePart obj = (MessagePart) super.clone(); + obj.styles = (ArrayList) styles.clone(); + if (hoverActionData instanceof JsonString) { + obj.hoverActionData = new JsonString(((JsonString) hoverActionData).getValue()); + } else if (hoverActionData instanceof FancyMessage) { + obj.hoverActionData = ((FancyMessage) hoverActionData).clone(); + } + obj.translationReplacements = (ArrayList) translationReplacements.clone(); + return obj; - } + } - static final BiMap stylesToNames; + static final BiMap stylesToNames; - static { - ImmutableBiMap.Builder builder = ImmutableBiMap.builder(); - for (final ChatColor style : ChatColor.values()) { - if (!style.isFormat()) { - continue; - } + static { + ImmutableBiMap.Builder builder = ImmutableBiMap.builder(); + for (final ChatColor style : ChatColor.values()) { + if (!style.isFormat()) { + continue; + } - String styleName; - switch (style) { - case MAGIC: - styleName = "obfuscated"; - break; - case UNDERLINE: - styleName = "underlined"; - break; - default: - styleName = style.name().toLowerCase(); - break; - } + String styleName; + switch (style) { + case MAGIC: + styleName = "obfuscated"; + break; + case UNDERLINE: + styleName = "underlined"; + break; + default: + styleName = style.name().toLowerCase(); + break; + } - builder.put(style, styleName); - } - stylesToNames = builder.build(); - } + builder.put(style, styleName); + } + stylesToNames = builder.build(); + } - public void writeJson(JsonWriter json) { - try { - json.beginObject(); - text.writeJson(json); - json.name("color").value(color.name().toLowerCase()); - for (final ChatColor style : styles) { - json.name(stylesToNames.get(style)).value(true); - } - if (clickActionName != null && clickActionData != null) { - json.name("clickEvent") - .beginObject() - .name("action").value(clickActionName) - .name("value").value(clickActionData) - .endObject(); - } - if (hoverActionName != null && hoverActionData != null) { - json.name("hoverEvent") - .beginObject() - .name("action").value(hoverActionName) - .name("value"); - hoverActionData.writeJson(json); - json.endObject(); - } - if (insertionData != null) { - json.name("insertion").value(insertionData); - } - if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) { - json.name("with").beginArray(); - for (JsonRepresentedObject obj : translationReplacements) { - obj.writeJson(json); - } - json.endArray(); - } - json.endObject(); - } catch (IOException e) { - Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e); - } - } + public void writeJson(JsonWriter json) { + try { + json.beginObject(); + text.writeJson(json); + json.name("color").value(color.name().toLowerCase()); + for (final ChatColor style : styles) { + json.name(stylesToNames.get(style)).value(true); + } + if (clickActionName != null && clickActionData != null) { + json.name("clickEvent") + .beginObject() + .name("action").value(clickActionName) + .name("value").value(clickActionData) + .endObject(); + } + if (hoverActionName != null && hoverActionData != null) { + json.name("hoverEvent") + .beginObject() + .name("action").value(hoverActionName) + .name("value"); + hoverActionData.writeJson(json); + json.endObject(); + } + if (insertionData != null) { + json.name("insertion").value(insertionData); + } + if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) { + json.name("with").beginArray(); + for (JsonRepresentedObject obj : translationReplacements) { + obj.writeJson(json); + } + json.endArray(); + } + json.endObject(); + } catch (IOException e) { + Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e); + } + } - public Map serialize() { - HashMap map = new HashMap(); - map.put("text", text); - map.put("styles", styles); - map.put("color", color.getChar()); - map.put("hoverActionName", hoverActionName); - map.put("hoverActionData", hoverActionData); - map.put("clickActionName", clickActionName); - map.put("clickActionData", clickActionData); - map.put("insertion", insertionData); - map.put("translationReplacements", translationReplacements); - return map; - } + public Map serialize() { + HashMap map = new HashMap<>(); + map.put("text", text); + map.put("styles", styles); + map.put("color", color.getChar()); + map.put("hoverActionName", hoverActionName); + map.put("hoverActionData", hoverActionData); + map.put("clickActionName", clickActionName); + map.put("clickActionData", clickActionData); + map.put("insertion", insertionData); + map.put("translationReplacements", translationReplacements); + return map; + } - @SuppressWarnings("unchecked") - public static MessagePart deserialize(Map serialized) { - MessagePart part = new MessagePart((TextualComponent) serialized.get("text")); - part.styles = (ArrayList) serialized.get("styles"); - part.color = ChatColor.getByChar(serialized.get("color").toString()); - part.hoverActionName = (String) serialized.get("hoverActionName"); - part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData"); - part.clickActionName = (String) serialized.get("clickActionName"); - part.clickActionData = (String) serialized.get("clickActionData"); - part.insertionData = (String) serialized.get("insertion"); - part.translationReplacements = (ArrayList) serialized.get("translationReplacements"); - return part; - } + @SuppressWarnings("unchecked") + public static MessagePart deserialize(Map serialized) { + MessagePart part = new MessagePart((TextualComponent) serialized.get("text")); + part.styles = (ArrayList) serialized.get("styles"); + part.color = ChatColor.getByChar(serialized.get("color").toString()); + part.hoverActionName = (String) serialized.get("hoverActionName"); + part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData"); + part.clickActionName = (String) serialized.get("clickActionName"); + part.clickActionData = (String) serialized.get("clickActionData"); + part.insertionData = (String) serialized.get("insertion"); + part.translationReplacements = (ArrayList) serialized.get("translationReplacements"); + return part; + } - static { - ConfigurationSerialization.registerClass(MessagePart.class); - } + static { + ConfigurationSerialization.registerClass(MessagePart.class); + } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java index 33a3c0602..c5a9fe36c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java @@ -3,6 +3,7 @@ package com.plotsquared.bukkit.chat; import org.bukkit.Bukkit; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; @@ -17,17 +18,17 @@ public final class Reflection { /** * Stores loaded classes from the {@code net.minecraft.server} package. */ - private static final Map> _loadedNMSClasses = new HashMap>(); + private static final Map> _loadedNMSClasses = new HashMap<>(); /** * Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages). */ - private static final Map> _loadedOBCClasses = new HashMap>(); - private static final Map, Map> _loadedFields = new HashMap, Map>(); + private static final Map> _loadedOBCClasses = new HashMap<>(); + private static final Map, Map> _loadedFields = new HashMap<>(); /** * Contains loaded methods in a cache. * The map maps [types to maps of [method names to maps of [parameter types to method instances]]]. */ - private static final Map, Map>, Method>>> _loadedMethods = new HashMap, Map>, Method>>>(); + private static final Map, Map>, Method>>> _loadedMethods = new HashMap<>(); private static String _versionString; private Reflection() { } @@ -64,10 +65,10 @@ public final class Reflection { } String fullName = "net.minecraft.server." + getVersion() + className; - Class clazz = null; + Class clazz; try { clazz = Class.forName(fullName); - } catch (Exception e) { + } catch (ClassNotFoundException e) { _loadedNMSClasses.put(className, null); throw new RuntimeException(e); } @@ -88,10 +89,10 @@ public final class Reflection { } String fullName = "org.bukkit.craftbukkit." + getVersion() + className; - Class clazz = null; + Class clazz; try { clazz = Class.forName(fullName); - } catch (Exception e) { + } catch (ClassNotFoundException e) { _loadedOBCClasses.put(className, null); throw new RuntimeException(e); } @@ -108,12 +109,8 @@ public final class Reflection { * @param obj The object for which to retrieve an NMS handle. * @return The NMS handle of the specified object, or {@code null} if it could not be retrieved using {@code getHandle()}. */ - public synchronized static Object getHandle(Object obj) { - try { + public synchronized static Object getHandle(Object obj) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException { return getMethod(obj.getClass(), "getHandle").invoke(obj); - } catch (Exception e) { - throw new RuntimeException(e); - } } /** @@ -137,7 +134,7 @@ public final class Reflection { public synchronized static Field getField(Class clazz, String name) { Map loaded; if (!_loadedFields.containsKey(clazz)) { - loaded = new HashMap(); + loaded = new HashMap<>(); _loadedFields.put(clazz, loaded); } else { loaded = _loadedFields.get(clazz); @@ -146,19 +143,19 @@ public final class Reflection { // If the field is loaded (or cached as not existing), return the relevant value, which might be null return loaded.get(name); } - try { - Field field = clazz.getDeclaredField(name); - field.setAccessible(true); - loaded.put(name, field); - return field; - } catch (Exception e) { - // Error loading - e.printStackTrace(); - // Cache field as not existing - loaded.put(name, null); - return null; - } - } + try { + Field field = clazz.getDeclaredField(name); + field.setAccessible(true); + loaded.put(name, field); + return field; + } catch (NoSuchFieldException | SecurityException e) { + // Error loading + e.printStackTrace(); + // Cache field as not existing + loaded.put(name, null); + return null; + } + } /** * Retrieves a {@link Method} instance declared by the specified class with the specified name and argument types. @@ -167,11 +164,9 @@ public final class Reflection { *

* A global caching mechanism within this class is used to store method. Combined with synchronization, this guarantees that * no method will be reflectively looked up twice. - *

*

* If a method is deemed suitable for return, {@link Method#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned. * This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance. - *

*

* This method does not search superclasses of the specified type for methods with the specified signature. * Callers wishing this behavior should use {@link Class#getDeclaredMethod(String, Class...)}. @@ -192,7 +187,7 @@ public final class Reflection { } Map>, Method> loadedSignatures = loadedMethodNames.get(name); - ArrayWrapper> wrappedArg = new ArrayWrapper>(args); + ArrayWrapper> wrappedArg = new ArrayWrapper<>(args); if (loadedSignatures.containsKey(wrappedArg)) { return loadedSignatures.get(wrappedArg); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 3cecf4b40..47a6ca301 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -28,16 +28,6 @@ import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.listener.PlayerBlockEventType; import com.plotsquared.listener.PlotListener; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -121,6 +111,17 @@ import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.regex.Pattern; + /** * Player Events involving plots. * @@ -1467,6 +1468,7 @@ public class PlayerEvents extends PlotListener implements Listener { case MINECART_TNT: case BOAT: return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP); + case POLAR_BEAR: case RABBIT: case SHEEP: case MUSHROOM_COW: diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java index aee5807e7..d1b30c50c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java @@ -1,6 +1,5 @@ package com.plotsquared.bukkit.util; -import com.intellectualcrafters.plot.PS; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -9,71 +8,38 @@ import org.bukkit.scheduler.BukkitTask; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; -import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Set; import java.util.UUID; -import java.util.logging.Level; import java.util.zip.GZIPOutputStream; public class Metrics { - /** - * The current revision number. - */ + /** The current revision number. */ private static final int REVISION = 7; - /** - * The base url of the metrics domain. - */ + /** The base url of the metrics domain.*/ private static final String BASE_URL = "http://report.mcstats.org"; - /** - * The url used to report a server's status. - */ + /** The url used to report a server's status. */ private static final String REPORT_URL = "/plugin/%s"; - /** - * Interval of time to ping (in minutes). - */ + /** Interval of time to ping (in minutes). */ private static final int PING_INTERVAL = 15; - /** - * The plugin this metrics submits for. - */ + /** The plugin this metrics submits for. */ private final Plugin plugin; - /** - * All of the custom graphs to submit to metrics. - */ - private final Set graphs = Collections.synchronizedSet(new HashSet()); - /** - * Unique server id. - */ + /** Unique server id. */ private final String guid; - /** - * Debug mode. - */ - private final boolean debug; - /** - * The scheduled task. - */ + /** The scheduled task. */ private volatile BukkitTask task = null; public Metrics(Plugin plugin) { - if (plugin == null) { - throw new IllegalArgumentException("Plugin cannot be null"); - } this.plugin = plugin; this.guid = UUID.randomUUID().toString(); - this.debug = false; } /** @@ -186,38 +152,6 @@ public class Metrics { return URLEncoder.encode(text, "UTF-8"); } - /** - * Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics - * website. Plotters can be added to the graph object returned. - * - * @param name The name of the graph - * - * @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given - */ - public Graph createGraph(String name) { - if (name == null) { - throw new IllegalArgumentException("Graph name cannot be null"); - } - // Construct the graph object - Graph graph = new Graph(name); - // Now we can add our graph - this.graphs.add(graph); - // and return back - return graph; - } - - /** - * Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend - * - * @param graph The name of the graph - */ - public void addGraph(Graph graph) { - if (graph == null) { - throw new IllegalArgumentException("Graph cannot be null"); - } - this.graphs.add(graph); - } - /** * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 @@ -244,54 +178,12 @@ public class Metrics { this.firstPost = false; } catch (IOException e) { e.printStackTrace(); - if (Metrics.this.debug) { - Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); - } } } }, 0, PING_INTERVAL * 1200); return true; } - /** - * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. - */ - public void enable() { - // Enable Task, if it is not running - if (this.task == null) { - start(); - } - } - - /** - * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. - */ - public void disable() { - // Disable Task, if it is running - if (this.task != null) { - this.task.cancel(); - this.task = null; - } - } - - /** - * Gets the File object of the config file that should be used to store - * data such as the GUID and opt-out status. - * - * @return the File object for the config file - */ - public File getConfigFile() { - // I believe the easiest way to get the base folder (e.g craftbukkit set - // via -P) for plugins to use - // is to abuse the plugin object we already have - // plugin.getDataFolder() => base/plugins/PluginA/ - // pluginsFolder => base/plugins/ - // The base is not necessarily relative to the startup directory. - File pluginsFolder = this.plugin.getDataFolder().getParentFile(); - // return => base/plugins/PluginMetrics/config.yml - return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml"); - } - /** * Generic method that posts a plugin to the metrics website. */ @@ -342,46 +234,12 @@ public class Metrics { if (isPing) { appendJSONPair(json, "ping", "1"); } - if (!this.graphs.isEmpty()) { - synchronized (this.graphs) { - json.append(','); - json.append('"'); - json.append("graphs"); - json.append('"'); - json.append(':'); - json.append('{'); - boolean firstGraph = true; - for (Graph graph : this.graphs) { - StringBuilder graphJson = new StringBuilder(); - graphJson.append('{'); - for (Plotter plotter : graph.getPlotters()) { - appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue())); - } - graphJson.append('}'); - if (!firstGraph) { - json.append(','); - } - json.append(escapeJSON(graph.getName())); - json.append(':'); - json.append(graphJson); - firstGraph = false; - } - json.append('}'); - } - } // close json json.append('}'); // Create the url URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName))); // Connect to the website - URLConnection connection; - // Mineshafter creates a socks proxy, so we can safely bypass it - // It does not reroute POST requests so we need to go around it - if (isMineshafterPresent()) { - connection = url.openConnection(Proxy.NO_PROXY); - } else { - connection = url.openConnection(); - } + URLConnection connection = url.openConnection(); byte[] uncompressed = json.toString().getBytes(); byte[] compressed = gzip(json.toString()); // Headers @@ -392,9 +250,6 @@ public class Metrics { connection.addRequestProperty("Accept", "application/json"); connection.addRequestProperty("Connection", "close"); connection.setDoOutput(true); - if (this.debug) { - PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); - } try { try (OutputStream os = connection.getOutputStream()) { os.write(compressed); @@ -403,9 +258,6 @@ public class Metrics { String response; try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { response = reader.readLine(); - if (this.debug) { - PS.debug("[Metrics] Response for " + pluginName + ": " + response); - } } if (response == null || response.startsWith("ERR") || response.startsWith("7")) { if (response == null) { @@ -414,171 +266,7 @@ public class Metrics { response = response.substring(response.startsWith("7,") ? 2 : 1); } throw new IOException(response); - } else { - // Is this the first update this hour? - if ("1".equals(response) || response.contains("This is your first update this hour")) { - synchronized (this.graphs) { - for (Graph graph : this.graphs) { - for (Plotter plotter : graph.getPlotters()) { - plotter.reset(); - } - } - } - } } - } catch (Exception e) { - if (this.debug) { - e.printStackTrace(); - } - } - } - - /** - * Check if mineshafter is present. If it is, we need to bypass it to send POST requests - * - * @return true if mineshafter is installed on the server - */ - private boolean isMineshafterPresent() { - try { - Class.forName("mineshafter.MineServer"); - return true; - } catch (ClassNotFoundException ignored) { - return false; - } - } - - /** - * Represents a custom graph on the website - */ - public static class Graph { - - /** - * The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is - * rejected - */ - private final String name; - /** - * The set of plotters that are contained within this graph - */ - private final Set plotters = new LinkedHashSet<>(); - - private Graph(String name) { - this.name = name; - } - - /** - * Gets the graph's name - * - * @return the Graph's name - */ - public String getName() { - return this.name; - } - - /** - * Add a plotter to the graph, which will be used to plot entries - * - * @param plotter the plotter to add to the graph - */ - public void addPlotter(Plotter plotter) { - this.plotters.add(plotter); - } - - /** - * Remove a plotter from the graph - * - * @param plotter the plotter to remove from the graph - */ - public void removePlotter(Plotter plotter) { - this.plotters.remove(plotter); - } - - /** - * Gets an unmodifiable set of the plotter objects in the graph - * - * @return an unmodifiable {@link Set} of the plotter objects - */ - public Set getPlotters() { - return Collections.unmodifiableSet(this.plotters); - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - - @Override - public boolean equals(Object object) { - if (!(object instanceof Graph)) { - return false; - } - Graph graph = (Graph) object; - return graph.name.equals(this.name); - } - - } - - /** - * Interface used to collect custom data for a plugin - */ - public abstract static class Plotter { - - /** - * The plot's name - */ - private final String name; - - /** - * Construct a plotter with the default plot name - */ - public Plotter() { - this("Default"); - } - - /** - * Construct a plotter with a specific plot name - * - * @param name the name of the plotter to use, which will show up on the website - */ - public Plotter(String name) { - this.name = name; - } - - /** - * Get the current value for the plotted point. Since this function defers to an external function it may or may - * not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called - * from any thread so care should be taken when accessing resources that need to be synchronized. - * - * @return the current value for the point to be plotted. - */ - public abstract int getValue(); - - /** - * Get the column name for the plotted point - * - * @return the plotted point's column name - */ - public String getColumnName() { - return this.name; - } - - /** - * Called after the website graphs have been updated - */ - public void reset() {} - - @Override - public int hashCode() { - return getColumnName().hashCode(); - } - - @Override - public boolean equals(Object object) { - if (!(object instanceof Plotter)) { - return false; - } - Plotter plotter = (Plotter) object; - return plotter.name.equals(this.name) && plotter.getValue() == getValue(); - } + } catch (IOException ignored) {} } } \ No newline at end of file diff --git a/Core/src/main/java/com/intellectualcrafters/plot/Platform.java b/Core/src/main/java/com/intellectualcrafters/plot/Platform.java new file mode 100644 index 000000000..d9b461377 --- /dev/null +++ b/Core/src/main/java/com/intellectualcrafters/plot/Platform.java @@ -0,0 +1,9 @@ +package com.intellectualcrafters.plot; + +public enum Platform { + Bukkit, + Sponge, + Spigot, + Cauldron + +} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 2c8fc8cc1..5a9d19d05 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -118,7 +118,7 @@ public class Auto extends SubCommand { } if (EconHandler.manager != null && plotarea.USE_ECONOMY) { Expression costExp = plotarea.PRICES.get("claim"); - double cost = costExp.evalute((double) currentPlots); + double cost = costExp.evaluate((double) currentPlots); cost = (size_x * size_z) * cost; if (cost > 0d) { if (EconHandler.manager.getMoney(player) < cost) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 39cafeca1..52d072cd6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -50,7 +50,7 @@ public class Claim extends SubCommand { PlotArea world = plot.getArea(); if ((EconHandler.manager != null) && world.USE_ECONOMY) { Expression costExr = world.PRICES.get("claim"); - double cost = costExr.evalute((double) currentPlots); + double cost = costExr.evaluate((double) currentPlots); if (cost > 0d) { if (EconHandler.manager.getMoney(player) < cost) { return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 78697bfd0..b26897149 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -56,7 +56,7 @@ public class Delete extends SubCommand { plot.removeRunning(); if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) { Expression valueExr = plotArea.PRICES.get("sell"); - double value = plots.size() * valueExr.evalute((double) currentPlots); + double value = plots.size() * valueExr.evaluate((double) currentPlots); if (value > 0d) { EconHandler.manager.depositMoney(player, value); sendMessage(player, C.ADDED_BALANCE, String.valueOf(value)); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 0ce752e57..a23ef546b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -141,7 +141,7 @@ public class MainCommand extends Command { PlotArea area = player.getApplicablePlotArea(); if (area != null) { Expression priceEval = area.PRICES.get(cmd.getFullId()); - Double price = priceEval != null ? priceEval.evalute(0d) : 0d; + Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; if (price != null && EconHandler.manager.getMoney(player) < price) { if (failure != null) { failure.run(); @@ -161,7 +161,7 @@ public class MainCommand extends Command { PlotArea area = player.getApplicablePlotArea(); if (area != null) { Expression priceEval = area.PRICES.get(cmd.getFullId()); - Double price = priceEval != null ? priceEval.evalute(0d) : 0d; + Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; if (price != 0d && EconHandler.manager.getMoney(player) < price) { if (failure != null) { failure.run(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index bf0f2cb67..55d1161a9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -74,7 +74,7 @@ public class Merge extends SubCommand { final PlotArea plotArea = plot.getArea(); Expression priceExr = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null; final int size = plot.getConnectedPlots().size(); - final double price = priceExr == null ? 0d : priceExr.evalute((double) size); + final double price = priceExr == null ? 0d : priceExr.evaluate((double) size); if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(player) < price) { sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price)); return false; 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..ca28e3f36 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -75,7 +75,7 @@ public enum C { */ CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance " + "and security. PlotSquared will require Java 9 in a future update.", "static.console"), - CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stabability, performance, and features. " + CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stability, performance, and features. " + "Bug fixes and new features are influenced on metrics.", "static.console"), /* * Confirm @@ -368,7 +368,7 @@ public enum C { /* * Unknown Error */ - ERROR("$2An error occured: %s", "Errors"), + ERROR("$2An error occurred: %s", "Errors"), // SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"), // LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"), DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"), diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java index b71f09805..1c31a1b20 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -296,7 +296,7 @@ public class Settings extends Config { public static boolean WORLDEDIT_RESTRICTIONS = true; @Comment("Allow economy to be used") public static boolean ECONOMY = true; - @Comment("Send anonymous usage statistics") + @Comment("Send anonymous usage statistics. Bukkit only setting.") public static boolean METRICS = true; @Comment("Expiry will clear old or simplistic plots") public static boolean PLOT_EXPIRY = false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Expression.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Expression.java index 8cd0c0ce9..c3a3a3660 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Expression.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Expression.java @@ -6,12 +6,12 @@ import com.intellectualcrafters.plot.commands.MainCommand; import javax.script.ScriptException; public abstract class Expression { - public abstract T evalute(T arg); + public abstract T evaluate(T arg); public static Expression constant(final U value) { return new Expression() { @Override - public U evalute(U arg) { + public U evaluate(U arg) { return value; } }; @@ -20,8 +20,8 @@ public abstract class Expression { public static Expression linearDouble(final Double value) { return new Expression() { @Override - public Double evalute(Double arg) { - return (arg.doubleValue() * value.doubleValue()); + public Double evaluate(Double arg) { + return (arg * value); } }; } @@ -29,15 +29,15 @@ public abstract class Expression { public static Expression doubleExpression(final String expression) { try { return constant(Double.parseDouble(expression)); - } catch (Exception ignore) {} + } catch (NumberFormatException ignore) {} if (expression.endsWith("*{arg}")) { try { return linearDouble(Double.parseDouble(expression.substring(0, expression.length() - 6))); - } catch (Exception ignore) {} + } catch (NumberFormatException ignore) {} } return new Expression() { @Override - public Double evalute(Double arg) { + public Double evaluate(Double arg) { DebugExec exec = (DebugExec) MainCommand.getInstance().getCommand(DebugExec.class); try { return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg)); diff --git a/Sponge/build.gradle b/Sponge/build.gradle index 8b036dc26..5300dd804 100644 --- a/Sponge/build.gradle +++ b/Sponge/build.gradle @@ -19,12 +19,18 @@ apply plugin: 'net.minecrell.vanilla.server.library' dependencies { compile project(':Core') compile 'org.spongepowered:spongeapi:5.0.0-SNAPSHOT' + compile 'net.minecrell.mcstats:statslite-sponge:0.2.2' + } sourceCompatibility = 1.8 targetCompatibility = 1.8 repositories { + maven { + name = 'minecrell' + url = 'http://repo.minecrell.net/releases' + } maven { name = 'forge' url = 'http://files.minecraftforge.net/maven' @@ -51,9 +57,9 @@ processResources { shadowJar { dependencies { include(dependency(':Core')) - //include(dependency('org.mcstats.sponge:metrics:R8-SNAPSHOT')) + include dependency('net.minecrell.mcstats:statslite-sponge') } - //relocate 'org.mcstats', 'com.plotsquared.stats' + relocate 'net.minecrell.mcstats', 'com.plotsquared.util.mcstats' archiveName = "${parent.name}-${project.name}-${parent.version}.jar" destinationDir = file '../target' } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 6d5671ebc..f4f1b7456 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -41,7 +41,6 @@ import com.plotsquared.sponge.util.SpongeEconHandler; import com.plotsquared.sponge.util.SpongeEventUtil; import com.plotsquared.sponge.util.SpongeHybridUtils; import com.plotsquared.sponge.util.SpongeInventoryUtil; -import com.plotsquared.sponge.util.SpongeMetrics; import com.plotsquared.sponge.util.SpongeSchematicHandler; import com.plotsquared.sponge.util.SpongeSetupUtils; import com.plotsquared.sponge.util.SpongeTaskManager; @@ -51,6 +50,7 @@ import com.plotsquared.sponge.util.block.SpongeLocalQueue; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeUUIDHandler; +import net.minecrell.mcstats.SpongeStatsLite; import org.slf4j.Logger; import org.spongepowered.api.Game; import org.spongepowered.api.Server; @@ -59,6 +59,7 @@ import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent; +import org.spongepowered.api.event.game.state.GamePreInitializationEvent; import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.profile.GameProfileManager; @@ -90,6 +91,9 @@ public class SpongeMain implements IPlotMain { @Inject private Game game; + @Inject + public SpongeStatsLite stats; + private Server server; @Inject @@ -98,8 +102,7 @@ public class SpongeMain implements IPlotMain { private GameProfileManager resolver; - // @Override - public Logger getLogger() { + private Logger getLogger() { return this.logger; } @@ -122,6 +125,12 @@ public class SpongeMain implements IPlotMain { return THIS; } + @Listener + public void onPreInitialize(GamePreInitializationEvent event) { + getLogger().info("The metrics section in PlotSquared is ignored in favor of the actual metrics reporter configurations."); + this.stats.start(); + } + @Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) { THIS = this; @@ -295,9 +304,6 @@ public class SpongeMain implements IPlotMain { @Override public void startMetrics() { - SpongeMetrics metrics = new SpongeMetrics(this.game, this.plugin); - metrics.start(); - PS.log(C.PREFIX.s() + "&6Metrics enabled."); } @Override From 269e409e3e23778e52eb59da259139c41fdca913 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sun, 17 Jul 2016 23:19:37 -0400 Subject: [PATCH 04/27] 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 05/27] 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 06/27] 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 07/27] 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"); From dda684941221d8f794ff6b7448d981c9f2dd0b01 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sun, 24 Jul 2016 17:42:03 -0400 Subject: [PATCH 08/27] Fix sponge compile --- .../sponge/generator/SpongeAugmentedGenerator.java | 7 ++++--- .../java/com/plotsquared/sponge/util/SpongeUtil.java | 6 ++++-- .../java/com/plotsquared/sponge/util/block/GenChunk.java | 2 +- .../plotsquared/sponge/util/block/SpongeLocalQueue.java | 9 +++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index f71317949..aaa4e65a8 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -5,7 +5,6 @@ import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; import com.plotsquared.sponge.util.SpongeUtil; -import java.util.List; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.ImmutableBiomeArea; @@ -13,6 +12,8 @@ import org.spongepowered.api.world.extent.MutableBlockVolume; import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; +import java.util.List; + public class SpongeAugmentedGenerator implements GenerationPopulator { private static SpongeAugmentedGenerator generator; @@ -44,14 +45,14 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { AugmentedUtils.generate(world.getName(), cx, cz, new DelegateLocalBlockQueue(null) { @Override public boolean setBlock(int x, int y, int z, int id, int data) { - terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data)); + terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data), SpongeUtil.CAUSE); return true; } @Override public PlotBlock getBlock(int x, int y, int z) { BlockState block = terrain.getBlock(bx + x, y, bz + z); - return block == null ? PlotBlock.get(0, 0) : SpongeUtil.getPlotBlock(block); + return SpongeUtil.getPlotBlock(block); } @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index e84d5f89a..ae0bb2e0a 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -35,6 +35,7 @@ import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.serializer.TextSerializers; import org.spongepowered.api.text.translation.Translation; +import org.spongepowered.api.world.BlockChangeFlag; import org.spongepowered.api.world.World; import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeTypes; @@ -303,7 +304,8 @@ public class SpongeUtil extends WorldUtil { StringComparison outer = new StringComparison(); return outer.new ComparisonResult(match, block); - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } return null; } @@ -429,7 +431,7 @@ public class SpongeUtil extends WorldUtil { @Override public void setSign(String worldName, int x, int y, int z, String[] lines) { World world = SpongeUtil.getWorld(worldName); - world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState()); + world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState(), BlockChangeFlag.NONE, CAUSE); Optional block = world.getTileEntity(x, y, z); if (!block.isPresent()) { return; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java index 361258217..f69d19217 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java @@ -52,7 +52,7 @@ public class GenChunk extends ScopedLocalBlockQueue { @Override public boolean setBlock(int x, int y, int z, int id, int data) { modified = true; - this.terrain.setBlock(this.bx + x, y, this.bz + z, SpongeUtil.getBlockState(id, data)); + this.terrain.setBlock(this.bx + x, y, this.bz + z, SpongeUtil.getBlockState(id, data),SpongeUtil.CAUSE); return true; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java index 52aed64b9..60cce20a3 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java @@ -7,9 +7,6 @@ import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; import com.plotsquared.sponge.util.SpongeUtil; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -35,6 +32,10 @@ import org.spongepowered.api.world.extent.UnmodifiableBlockVolume; import org.spongepowered.api.world.extent.worker.MutableBlockVolumeWorker; import org.spongepowered.api.world.extent.worker.procedure.BlockVolumeMapper; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.HashSet; + public class SpongeLocalQueue extends BasicLocalBlockQueue { public SpongeLocalQueue(String world) { @@ -441,7 +442,7 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue { World worldObj = getSpongeWorld(); org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ()); char[][] ids = ((CharLocalChunk) lc).blocks; - MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(); + MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(SpongeUtil.CAUSE); blockWorker.map(new BlockVolumeMapper() { @Override public BlockState map(UnmodifiableBlockVolume volume, int xx, int y, int zz) { From 1a86d5fb9e9d0b51e5a87cb4cf8a84082f3c07d3 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 01:19:29 -0400 Subject: [PATCH 09/27] Added Polar Bear where missing --- .../bukkit/listeners/PlayerEvents.java | 22 ++++++++++--------- .../bukkit/util/BukkitChunkManager.java | 18 ++++++++------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 3cecf4b40..47a6ca301 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -28,16 +28,6 @@ import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.listener.PlayerBlockEventType; import com.plotsquared.listener.PlotListener; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -121,6 +111,17 @@ import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.regex.Pattern; + /** * Player Events involving plots. * @@ -1467,6 +1468,7 @@ public class PlayerEvents extends PlotListener implements Listener { case MINECART_TNT: case BOAT: return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP); + case POLAR_BEAR: case RABBIT: case SHEEP: case MUSHROOM_COW: 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 a73bb63c3..fef2434e0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -17,14 +17,6 @@ import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue; import com.plotsquared.bukkit.object.entity.EntityWrapper; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.DyeColor; @@ -57,6 +49,15 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + public class BukkitChunkManager extends ChunkManager { public static boolean isIn(RegionWrapper region, int x, int z) { @@ -546,6 +547,7 @@ public class BukkitChunkManager extends ChunkManager { case BOAT: count[4]++; break; + case POLAR_BEAR: case RABBIT: case SHEEP: case MUSHROOM_COW: From 5d92701100cfb9a4f2e4826b8c6bd2bd81bc5e33 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:04:17 -0400 Subject: [PATCH 10/27] Fixed deny-teleport flag --- .../src/main/java/com/intellectualcrafters/plot/flag/Flags.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7b8247d25..439d4b0cd 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java @@ -113,7 +113,7 @@ public final class Flags { } }; public static final BooleanFlag SLEEP = new BooleanFlag("sleep"); - public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("teleport-deny"); + public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport"); private static final HashMap> flags; From 290e5c68dc2c90a874d24fd2a738e52224205868 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:42:31 -0400 Subject: [PATCH 11/27] Fix Sponge generation casting --- .../plotsquared/sponge/util/SpongeSetupUtils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java index a72b6574e..e814beaf5 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java @@ -26,7 +26,7 @@ import java.util.Objects; import java.util.Optional; public class SpongeSetupUtils extends SetupUtils { - + @Override public void updateGenerators() { if (!SetupUtils.generators.isEmpty()) { @@ -48,7 +48,7 @@ public class SpongeSetupUtils extends SetupUtils { } } } - + @Override public String getGenerator(PlotArea plotArea) { if (SetupUtils.generators.isEmpty()) { @@ -61,7 +61,7 @@ public class SpongeSetupUtils extends SetupUtils { WorldGenerator generator = world.getWorldGenerator(); throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } - + @Override public String setupWorld(SetupObject object) { SetupUtils.manager.updateGenerators(); @@ -140,16 +140,16 @@ public class SpongeSetupUtils extends SetupUtils { if (object.setupGenerator != null) { // create world with generator GeneratorWrapper gw = SetupUtils.generators.get(object.setupGenerator); - WorldArchetype wgm = (WorldArchetype) gw.getPlatformGenerator(); - + WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator(); + WorldArchetype settings = WorldArchetype.builder() .loadsOnStartup(true) .keepsSpawnLoaded(true) .dimension(DimensionTypes.OVERWORLD) - .generator(GeneratorTypes.OVERWORLD) + .generator(GeneratorTypes.FLAT) .usesMapFeatures(false) .enabled(true) - //.generatorModifiers(wgm) + .generatorModifiers(wgm) .build("PS",object.world); WorldProperties properties = null; try { From 5f8c77a6cdb3c30ccc41fbc07512ce762316d7e6 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:43:11 -0400 Subject: [PATCH 12/27] Change Sponge method behavior --- .../java/com/plotsquared/sponge/object/SpongePlayer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index 8bc5fd9e4..840d3f5ad 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -1,6 +1,7 @@ package com.plotsquared.sponge.object; import com.flowpowered.math.vector.Vector3d; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -111,8 +112,12 @@ public class SpongePlayer extends PlotPlayer { @Override public void setCompassTarget(Location location) { - TargetedLocationData target = this.player.getOrCreate(TargetedLocationData.class).get(); - target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition()); + Optional target = this.player.getOrCreate(TargetedLocationData.class); + if (target.isPresent()) { + target.get().set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition()); + } else { + PS.debug("Failed to set compass target."); + } } @Override From 80ea3e9ce776aa6ba3c10dc3e670455b3af90173 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 20:00:59 -0400 Subject: [PATCH 13/27] Sponge Fixes and minor changes. --- .../com/plotsquared/bukkit/BukkitMain.java | 2 - .../bukkit/listeners/ForceFieldListener.java | 3 +- .../bukkit/listeners/PlayerEvents.java | 2 +- .../com/intellectualcrafters/plot/PS.java | 1 - .../com/plotsquared/sponge/SpongeMain.java | 3 - .../sponge/listener/ForceFieldListener.java | 97 +++++++++++++++++++ .../sponge/listener/MainListener.java | 2 + 7 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 7fb9c2fde..e3152a8a7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -39,7 +39,6 @@ import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.listeners.ChunkListener; import com.plotsquared.bukkit.listeners.EntitySpawnListener; -import com.plotsquared.bukkit.listeners.ForceFieldListener; import com.plotsquared.bukkit.listeners.PlayerEvents; import com.plotsquared.bukkit.listeners.PlayerEvents183; import com.plotsquared.bukkit.listeners.PlayerEvents_1_8; @@ -401,7 +400,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public void registerForceFieldEvents() { - getServer().getPluginManager().registerEvents(new ForceFieldListener(), this); } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java index a4258421c..d32185f23 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -8,14 +8,13 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; import org.bukkit.entity.Player; -import org.bukkit.event.Listener; import org.bukkit.util.Vector; import java.util.HashSet; import java.util.Set; import java.util.UUID; -public class ForceFieldListener implements Listener { +public class ForceFieldListener { private static Set getNearbyPlayers(Player player, Plot plot) { Set players = new HashSet<>(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 47a6ca301..d0a37ee77 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -484,7 +484,7 @@ public class PlayerEvents extends PlotListener implements Listener { pp.deleteMeta("lastplot"); return; } - Plot now = area.getPlot(loc); + Plot now = area.getPlotAbs(loc); Plot lastPlot = pp.getMeta("lastplot"); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot)) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 00c70d52d..b9374448d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -171,7 +171,6 @@ public class PS { this.IMP.registerPlayerEvents(); this.IMP.registerInventoryEvents(); this.IMP.registerPlotPlusEvents(); - this.IMP.registerForceFieldEvents(); } // Required this.IMP.registerWorldEvents(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 0ceef43dc..d895d3eb2 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -242,14 +242,11 @@ public class SpongeMain implements IPlotMain { @Override public void registerPlotPlusEvents() { - // TODO Auto-generated method stub PS.log("registerPlotPlusEvents is not implemented!"); } @Override public void registerForceFieldEvents() { - // TODO Auto-generated method stub - PS.log("registerForceFieldEvents is not implemented!"); } @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java new file mode 100644 index 000000000..0b5e4c3ca --- /dev/null +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java @@ -0,0 +1,97 @@ +package com.plotsquared.sponge.listener; + +import com.flowpowered.math.vector.Vector3d; +import com.intellectualcrafters.plot.flag.Flags; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.plotsquared.sponge.object.SpongePlayer; +import com.plotsquared.sponge.util.SpongeUtil; +import org.spongepowered.api.entity.Entity; +import org.spongepowered.api.entity.EntityTypes; +import org.spongepowered.api.entity.living.player.Player; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class ForceFieldListener { + + private static Set getNearbyPlayers(Player player, Plot plot) { + Set players = new HashSet<>(); + for (Entity nearbyEntity : player.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) { + Player nearbyPlayer = (Player) nearbyEntity; + PlotPlayer plotPlayer; + if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) { + continue; + } + if (!plot.isAdded(plotPlayer.getUUID())) { + players.add(plotPlayer); + } + + } + return players; + } + + private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) { + for (Entity nearbyEntity : player.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) { + Player nearbyPlayer = (Player) nearbyEntity; + PlotPlayer plotPlayer; + if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) { + continue; + } + if (plot.isAdded(plotPlayer.getUUID())) { + return plotPlayer; + } + } + return null; + } + + private static Vector3d calculateVelocity(PlotPlayer player, PlotPlayer e) { + Location playerLocation = player.getLocationFull(); + Location oPlayerLocation = e.getLocation(); + double playerX = playerLocation.getX(); + double playerY = playerLocation.getY(); + double playerZ = playerLocation.getZ(); + double oPlayerX = oPlayerLocation.getX(); + double oPlayerY = oPlayerLocation.getY(); + double oPlayerZ = oPlayerLocation.getZ(); + double x = 0d; + if (playerX < oPlayerX) { + x = 1.0d; + } else if (playerX > oPlayerX) { + x = -1.0d; + } + double y = 0d; + if (playerY < oPlayerY) { + y = 0.5d; + } else if (playerY > oPlayerY) { + y = -0.5d; + } + double z = 0d; + if (playerZ < oPlayerZ) { + z = 1.0d; + } else if (playerZ > oPlayerZ) { + z = -1.0d; + } + return new Vector3d(x, y, z); + } + + public static void handleForcefield(Player player, PlotPlayer plotPlayer, Plot plot) { + if (Flags.FORCEFIELD.isTrue(plot)) { + UUID uuid = plotPlayer.getUUID(); + if (plot.isAdded(uuid)) { + Set players = getNearbyPlayers(player, plot); + for (PlotPlayer oPlayer : players) { + ((SpongePlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer)); + } + } else { + PlotPlayer oPlayer = hasNearbyPermitted(player, plot); + if (oPlayer == null) { + return; + } + player.setVelocity(calculateVelocity(oPlayer, plotPlayer)); + } + } + } +} diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index cd44889ee..c2d256c30 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -662,6 +662,7 @@ public class MainListener { return; } } else if (now.equals(lastPlot)) { + ForceFieldListener.handleForcefield(player, pp, now); return; } else if (!PlotListener.plotEntry(pp, now)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); @@ -711,6 +712,7 @@ public class MainListener { return; } } else if (now.equals(lastPlot)) { + ForceFieldListener.handleForcefield(player, pp, now); return; } else if (!PlotListener.plotEntry(pp, now)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); From 4e019ab796e324fb858215e9a4da741358871a15 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 07:44:47 +1000 Subject: [PATCH 14/27] UUID cache changes --- .../bukkit/uuid/FileUUIDHandler.java | 37 +++++++++++-------- .../com/intellectualcrafters/plot/PS.java | 13 ++++--- .../plot/util/UUIDHandler.java | 19 ++++++---- 3 files changed, 40 insertions(+), 29 deletions(-) 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 16c89a9c1..21bfe8972 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -168,20 +168,23 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { } else { NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); String name = (String) bukkit.get("lastKnownName"); - long last = (long) bukkit.get("lastPlayed"); - if (Settings.UUID.OFFLINE) { - if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) { - uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name); - } else { - long most = (long) compound.get("UUIDMost"); - long least = (long) compound.get("UUIDLeast"); - uuid = new UUID(most, least); + StringWrapper wrap = new StringWrapper(name); + if (!toAdd.containsKey(wrap)) { + long last = (long) bukkit.get("lastPlayed"); + if (Settings.UUID.OFFLINE) { + if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) { + uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name); + } else { + long most = (long) compound.get("UUIDMost"); + long least = (long) compound.get("UUIDLeast"); + uuid = new UUID(most, least); + } } + if (ExpireManager.IMP != null) { + ExpireManager.IMP.storeDate(uuid, last); + } + toAdd.put(wrap, uuid); } - if (ExpireManager.IMP != null) { - ExpireManager.IMP.storeDate(uuid, last); - } - toAdd.put(new StringWrapper(name), uuid); } } catch (Exception ignored) { PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat"); @@ -199,10 +202,12 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { if (last != 0) { String name = op.getName(); StringWrapper wrap = new StringWrapper(name); - UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op); - toAdd.put(wrap, uuid); - if (ExpireManager.IMP != null) { - ExpireManager.IMP.storeDate(uuid, last); + if (!toAdd.containsKey(wrap)) { + UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op); + toAdd.put(wrap, uuid); + if (ExpireManager.IMP != null) { + ExpireManager.IMP.storeDate(uuid, last); + } } } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 00c70d52d..575959576 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -370,13 +370,16 @@ public class PS { @Override public void run() { UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); - for (Plot plot : getPlots()) { - if (plot.hasOwner() && plot.temp != -1) { - if (UUIDHandler.getName(plot.owner) == null) { - UUIDHandler.implementation.unknown.add(plot.owner); + foreachPlotRaw(new RunnableVal() { + @Override + public void run(Plot plot) { + if (plot.hasOwner() && plot.temp != -1) { + if (UUIDHandler.getName(plot.owner) == null) { + UUIDHandler.implementation.unknown.add(plot.owner); + } } } - } + }); startExpiryTasks(); startPlotMeConversion(); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index 0a23aa828..89e7edde3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -59,15 +59,18 @@ public class UUIDHandler { } public static HashSet getAllUUIDS() { - HashSet uuids = new HashSet<>(); - for (Plot plot : PS.get().getPlots()) { - if (plot.hasOwner()) { - uuids.add(plot.owner); - uuids.addAll(plot.getTrusted()); - uuids.addAll(plot.getMembers()); - uuids.addAll(plot.getDenied()); + final HashSet uuids = new HashSet<>(); + PS.get().foreachPlotRaw(new RunnableVal() { + @Override + public void run(Plot plot) { + if (plot.hasOwner()) { + uuids.add(plot.owner); + uuids.addAll(plot.getTrusted()); + uuids.addAll(plot.getMembers()); + uuids.addAll(plot.getDenied()); + } } - } + }); return uuids; } From 0b19cc7d9dd3c2e07eb5fe65a334950d7c334c4e Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 08:02:17 +1000 Subject: [PATCH 15/27] Possible fix + add guest-gamemode flag --- .../com/intellectualcrafters/plot/flag/Flags.java | 10 +++++----- .../java/com/plotsquared/listener/PlotListener.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) 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 7b8247d25..235b3f74a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java @@ -21,6 +21,7 @@ public final class Flags { public static final IntervalFlag FEED = new IntervalFlag("feed"); public static final IntervalFlag HEAL = new IntervalFlag("heal"); public static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode"); + public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode"); public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve(); public static final BooleanFlag REDSTONE = new BooleanFlag("redstone"); public static final BooleanFlag FLY = new BooleanFlag("fly"); @@ -147,8 +148,8 @@ public final class Flags { } public static Flag getFlag(String flag) { - return flags.get(flag); - } + return flags.get(flag); +} public static void registerFlag(final Flag flag) { final Flag duplicate = flags.put(flag.getName(), flag); @@ -164,11 +165,10 @@ public final class Flags { }); PS.get().foreachPlotRaw(new RunnableVal() { @Override public void run(Plot value) { - Object remove = null; if (value.getFlags().containsKey(duplicate)) { - remove = value.getFlags().remove(duplicate); + Object remove = value.getFlags().remove(duplicate); + value.getFlags().put(flag,flag.parseValue("" + remove)); } - value.getFlags().put(flag,flag.parseValue("" + remove)); } }); } diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index 25197fc5f..17f3eee63 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -94,6 +94,17 @@ public class PlotListener { } } } + Optional guestGamemodeFlag = plot.getFlag(Flags.GUEST_GAMEMODE); + if (gamemodeFlag.isPresent()) { + if (player.getGameMode() != gamemodeFlag.get() && !plot.isAdded(player.getUUID())) { + if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { + player.setGameMode(gamemodeFlag.get()); + } else { + MainUtil.sendMessage(player, + StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get())); + } + } + } Optional timeFlag = plot.getFlag(Flags.TIME); if (timeFlag.isPresent()) { try { @@ -171,7 +182,7 @@ public class PlotListener { if (pw == null) { return true; } - if (plot.getFlag(Flags.GAMEMODE).isPresent()) { + if (plot.getFlag(Flags.GAMEMODE).isPresent() || plot.getFlag(Flags.GUEST_GAMEMODE).isPresent()) { if (player.getGameMode() != pw.GAMEMODE) { if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { player.setGameMode(pw.GAMEMODE); From 07dc6a46fb497be9ce6335ee99014fb6419b3af0 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 08:09:57 +1000 Subject: [PATCH 16/27] Remove metrics depend --- Bukkit/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index 0d77e6983..5b759bf95 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -7,7 +7,6 @@ repositories { dependencies { compile project(':Core') compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT' - compile 'org.mcstats.bukkit:metrics:R7' compile 'net.milkbowl.vault:VaultAPI:1.6' } @@ -29,7 +28,6 @@ jar.enabled = false shadowJar { dependencies { include(dependency(':Core')) - include(dependency('org.mcstats.bukkit:metrics:R7')) } relocate('org.mcstats', 'com.plotsquared.stats') archiveName = "${parent.name}-${project.name}-${parent.version}.jar" From 0b5177f19220e395875a3ee92662f9b440644d4b Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 09:23:20 +1000 Subject: [PATCH 17/27] Minor uuid cache changes --- .../java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java | 3 +-- .../sponge/generator/SpongeAugmentedGenerator.java | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) 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 21bfe8972..0542c1f76 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -80,8 +80,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { e.printStackTrace(); } } + HashBiMap toAdd = HashBiMap.create(new HashMap()); if (Settings.UUID.NATIVE_UUID_PROVIDER) { - HashBiMap toAdd = HashBiMap.create(new HashMap()); HashSet all = UUIDHandler.getAllUUIDS(); PS.debug("&aFast mode UUID caching enabled!"); File playerDataFolder = new File(container, world + File.separator + "playerdata"); @@ -124,7 +124,6 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { PS.debug("Failed to cache: " + all.size() + " uuids - slowly processing all files"); } } - HashBiMap toAdd = HashBiMap.create(new HashMap()); HashSet worlds = Sets.newHashSet(world, "world"); HashSet uuids = new HashSet<>(); HashSet names = new HashSet<>(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index aaa4e65a8..dff40db45 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -4,8 +4,11 @@ import com.flowpowered.math.vector.Vector3i; import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import org.spongepowered.api.block.BlockState; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.ImmutableBiomeArea; import org.spongepowered.api.world.extent.MutableBlockVolume; @@ -34,7 +37,9 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { populators.add(generator); return generator; } - + + private Cause cause = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); + @Override public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) { Vector3i min = terrain.getBlockMin(); From 3498f309e86cfeac5a66d47aee9bd985031098df Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 09:47:49 +1000 Subject: [PATCH 18/27] Minor sponge fixes --- Sponge/build.gradle | 4 ++-- Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java | 3 +++ .../sponge/generator/SpongeAugmentedGenerator.java | 2 -- .../src/main/java/com/plotsquared/sponge/util/SpongeUtil.java | 1 + .../main/java/com/plotsquared/sponge/util/block/GenChunk.java | 1 + .../com/plotsquared/sponge/util/block/SpongeLocalQueue.java | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sponge/build.gradle b/Sponge/build.gradle index 5300dd804..747a615cb 100644 --- a/Sponge/build.gradle +++ b/Sponge/build.gradle @@ -14,7 +14,7 @@ buildscript { } } -apply plugin: 'net.minecrell.vanilla.server.library' +apply plugin: 'net.minecraftforge.gradle.forge' dependencies { compile project(':Core') @@ -41,7 +41,7 @@ repositories { } } minecraft { - version = "1.10.2" + version = "2014" mappings = "snapshot_20160629" runDir = 'run' } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index f4f1b7456..67e1b26c7 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -58,6 +58,8 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Listener; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent; import org.spongepowered.api.event.game.state.GamePreInitializationEvent; import org.spongepowered.api.plugin.Plugin; @@ -81,6 +83,7 @@ import java.util.stream.Collectors; public class SpongeMain implements IPlotMain { public static SpongeMain THIS; + public static final Cause CAUSE = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); @Inject public PluginContainer plugin; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index dff40db45..1da76fb80 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -7,8 +7,6 @@ import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import org.spongepowered.api.block.BlockState; -import org.spongepowered.api.event.cause.Cause; -import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.ImmutableBiomeArea; import org.spongepowered.api.world.extent.MutableBlockVolume; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index ae0bb2e0a..e402f430f 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; import net.minecraft.block.Block; import net.minecraft.world.biome.Biome; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java index f69d19217..35d3b53ff 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.object.ChunkWrapper; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.extent.MutableBiomeArea; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java index 60cce20a3..aae589c03 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java @@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; From d23d8c2fd8ceb5cdcc56db5d683e29136be2c870 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 09:54:35 +1000 Subject: [PATCH 19/27] *should use this cause instead --- .../com/plotsquared/sponge/SpongeMain.java | 11 ---------- .../generator/SpongeAugmentedGenerator.java | 1 - .../plotsquared/sponge/util/SpongeUtil.java | 22 +++++++++---------- .../sponge/util/block/SpongeLocalQueue.java | 1 - 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 67e1b26c7..f9545db33 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -58,8 +58,6 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.cause.Cause; -import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent; import org.spongepowered.api.event.game.state.GamePreInitializationEvent; import org.spongepowered.api.plugin.Plugin; @@ -70,20 +68,11 @@ import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGeneratorModifier; -import java.io.File; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; - @Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.5.0-SNAPSHOT") public class SpongeMain implements IPlotMain { public static SpongeMain THIS; - public static final Cause CAUSE = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); @Inject public PluginContainer plugin; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index 1da76fb80..6f0c7106c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -4,7 +4,6 @@ import com.flowpowered.math.vector.Vector3i; import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.world.World; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index e402f430f..42eb503bf 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -15,8 +15,17 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Optional; import net.minecraft.block.Block; import net.minecraft.world.biome.Biome; import org.spongepowered.api.Sponge; @@ -42,17 +51,6 @@ import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.extent.Extent; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Optional; - public class SpongeUtil extends WorldUtil { public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared")); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java index aae589c03..60cce20a3 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java @@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; From adc021109f38f371ba1b03df6f81f27360fb7c77 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 01:19:29 -0400 Subject: [PATCH 20/27] Added Polar Bear where missing --- .../bukkit/util/BukkitChunkManager.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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 a73bb63c3..fef2434e0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -17,14 +17,6 @@ import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue; import com.plotsquared.bukkit.object.entity.EntityWrapper; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.DyeColor; @@ -57,6 +49,15 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + public class BukkitChunkManager extends ChunkManager { public static boolean isIn(RegionWrapper region, int x, int z) { @@ -546,6 +547,7 @@ public class BukkitChunkManager extends ChunkManager { case BOAT: count[4]++; break; + case POLAR_BEAR: case RABBIT: case SHEEP: case MUSHROOM_COW: From 48064da1eee4107257a8ac3ca43a3a14956dee0f Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:04:17 -0400 Subject: [PATCH 21/27] Fixed deny-teleport flag --- .../src/main/java/com/intellectualcrafters/plot/flag/Flags.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 235b3f74a..2be58cd58 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java @@ -114,7 +114,7 @@ public final class Flags { } }; public static final BooleanFlag SLEEP = new BooleanFlag("sleep"); - public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("teleport-deny"); + public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport"); private static final HashMap> flags; From 33ec80c2cbf85a95a50d78667556abf240919396 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:42:31 -0400 Subject: [PATCH 22/27] Fix Sponge generation casting --- .../plotsquared/sponge/util/SpongeSetupUtils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java index a72b6574e..e814beaf5 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java @@ -26,7 +26,7 @@ import java.util.Objects; import java.util.Optional; public class SpongeSetupUtils extends SetupUtils { - + @Override public void updateGenerators() { if (!SetupUtils.generators.isEmpty()) { @@ -48,7 +48,7 @@ public class SpongeSetupUtils extends SetupUtils { } } } - + @Override public String getGenerator(PlotArea plotArea) { if (SetupUtils.generators.isEmpty()) { @@ -61,7 +61,7 @@ public class SpongeSetupUtils extends SetupUtils { WorldGenerator generator = world.getWorldGenerator(); throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } - + @Override public String setupWorld(SetupObject object) { SetupUtils.manager.updateGenerators(); @@ -140,16 +140,16 @@ public class SpongeSetupUtils extends SetupUtils { if (object.setupGenerator != null) { // create world with generator GeneratorWrapper gw = SetupUtils.generators.get(object.setupGenerator); - WorldArchetype wgm = (WorldArchetype) gw.getPlatformGenerator(); - + WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator(); + WorldArchetype settings = WorldArchetype.builder() .loadsOnStartup(true) .keepsSpawnLoaded(true) .dimension(DimensionTypes.OVERWORLD) - .generator(GeneratorTypes.OVERWORLD) + .generator(GeneratorTypes.FLAT) .usesMapFeatures(false) .enabled(true) - //.generatorModifiers(wgm) + .generatorModifiers(wgm) .build("PS",object.world); WorldProperties properties = null; try { From 34c2da55ca046b89a1a1854f6d755165798e7d7a Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:43:11 -0400 Subject: [PATCH 23/27] Change Sponge method behavior --- .../java/com/plotsquared/sponge/object/SpongePlayer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index 8bc5fd9e4..840d3f5ad 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -1,6 +1,7 @@ package com.plotsquared.sponge.object; import com.flowpowered.math.vector.Vector3d; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -111,8 +112,12 @@ public class SpongePlayer extends PlotPlayer { @Override public void setCompassTarget(Location location) { - TargetedLocationData target = this.player.getOrCreate(TargetedLocationData.class).get(); - target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition()); + Optional target = this.player.getOrCreate(TargetedLocationData.class); + if (target.isPresent()) { + target.get().set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition()); + } else { + PS.debug("Failed to set compass target."); + } } @Override From b5ec6232f945342fd806412624c196271ace1eb6 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 20:00:59 -0400 Subject: [PATCH 24/27] Sponge Fixes and minor changes. --- .../com/plotsquared/bukkit/BukkitMain.java | 2 - .../bukkit/listeners/ForceFieldListener.java | 3 +- .../bukkit/listeners/PlayerEvents.java | 2 +- .../com/intellectualcrafters/plot/PS.java | 1 - .../com/plotsquared/sponge/SpongeMain.java | 3 - .../sponge/listener/ForceFieldListener.java | 97 +++++++++++++++++++ .../sponge/listener/MainListener.java | 2 + 7 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 9dc0691f0..c31409455 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -39,7 +39,6 @@ import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; import com.plotsquared.bukkit.listeners.ChunkListener; import com.plotsquared.bukkit.listeners.EntitySpawnListener; -import com.plotsquared.bukkit.listeners.ForceFieldListener; import com.plotsquared.bukkit.listeners.PlayerEvents; import com.plotsquared.bukkit.listeners.PlayerEvents183; import com.plotsquared.bukkit.listeners.PlayerEvents_1_8; @@ -408,7 +407,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public void registerForceFieldEvents() { - getServer().getPluginManager().registerEvents(new ForceFieldListener(), this); } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java index a4258421c..d32185f23 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -8,14 +8,13 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; import org.bukkit.entity.Player; -import org.bukkit.event.Listener; import org.bukkit.util.Vector; import java.util.HashSet; import java.util.Set; import java.util.UUID; -public class ForceFieldListener implements Listener { +public class ForceFieldListener { private static Set getNearbyPlayers(Player player, Plot plot) { Set players = new HashSet<>(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 47a6ca301..d0a37ee77 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -484,7 +484,7 @@ public class PlayerEvents extends PlotListener implements Listener { pp.deleteMeta("lastplot"); return; } - Plot now = area.getPlot(loc); + Plot now = area.getPlotAbs(loc); Plot lastPlot = pp.getMeta("lastplot"); if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot)) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 575959576..334535a10 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -171,7 +171,6 @@ public class PS { this.IMP.registerPlayerEvents(); this.IMP.registerInventoryEvents(); this.IMP.registerPlotPlusEvents(); - this.IMP.registerForceFieldEvents(); } // Required this.IMP.registerWorldEvents(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index f9545db33..6056574db 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -243,14 +243,11 @@ public class SpongeMain implements IPlotMain { @Override public void registerPlotPlusEvents() { - // TODO Auto-generated method stub PS.log("registerPlotPlusEvents is not implemented!"); } @Override public void registerForceFieldEvents() { - // TODO Auto-generated method stub - PS.log("registerForceFieldEvents is not implemented!"); } @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java new file mode 100644 index 000000000..0b5e4c3ca --- /dev/null +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/ForceFieldListener.java @@ -0,0 +1,97 @@ +package com.plotsquared.sponge.listener; + +import com.flowpowered.math.vector.Vector3d; +import com.intellectualcrafters.plot.flag.Flags; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.plotsquared.sponge.object.SpongePlayer; +import com.plotsquared.sponge.util.SpongeUtil; +import org.spongepowered.api.entity.Entity; +import org.spongepowered.api.entity.EntityTypes; +import org.spongepowered.api.entity.living.player.Player; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class ForceFieldListener { + + private static Set getNearbyPlayers(Player player, Plot plot) { + Set players = new HashSet<>(); + for (Entity nearbyEntity : player.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) { + Player nearbyPlayer = (Player) nearbyEntity; + PlotPlayer plotPlayer; + if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) { + continue; + } + if (!plot.isAdded(plotPlayer.getUUID())) { + players.add(plotPlayer); + } + + } + return players; + } + + private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) { + for (Entity nearbyEntity : player.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) { + Player nearbyPlayer = (Player) nearbyEntity; + PlotPlayer plotPlayer; + if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) { + continue; + } + if (plot.isAdded(plotPlayer.getUUID())) { + return plotPlayer; + } + } + return null; + } + + private static Vector3d calculateVelocity(PlotPlayer player, PlotPlayer e) { + Location playerLocation = player.getLocationFull(); + Location oPlayerLocation = e.getLocation(); + double playerX = playerLocation.getX(); + double playerY = playerLocation.getY(); + double playerZ = playerLocation.getZ(); + double oPlayerX = oPlayerLocation.getX(); + double oPlayerY = oPlayerLocation.getY(); + double oPlayerZ = oPlayerLocation.getZ(); + double x = 0d; + if (playerX < oPlayerX) { + x = 1.0d; + } else if (playerX > oPlayerX) { + x = -1.0d; + } + double y = 0d; + if (playerY < oPlayerY) { + y = 0.5d; + } else if (playerY > oPlayerY) { + y = -0.5d; + } + double z = 0d; + if (playerZ < oPlayerZ) { + z = 1.0d; + } else if (playerZ > oPlayerZ) { + z = -1.0d; + } + return new Vector3d(x, y, z); + } + + public static void handleForcefield(Player player, PlotPlayer plotPlayer, Plot plot) { + if (Flags.FORCEFIELD.isTrue(plot)) { + UUID uuid = plotPlayer.getUUID(); + if (plot.isAdded(uuid)) { + Set players = getNearbyPlayers(player, plot); + for (PlotPlayer oPlayer : players) { + ((SpongePlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer)); + } + } else { + PlotPlayer oPlayer = hasNearbyPermitted(player, plot); + if (oPlayer == null) { + return; + } + player.setVelocity(calculateVelocity(oPlayer, plotPlayer)); + } + } + } +} diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index cd44889ee..c2d256c30 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -662,6 +662,7 @@ public class MainListener { return; } } else if (now.equals(lastPlot)) { + ForceFieldListener.handleForcefield(player, pp, now); return; } else if (!PlotListener.plotEntry(pp, now)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); @@ -711,6 +712,7 @@ public class MainListener { return; } } else if (now.equals(lastPlot)) { + ForceFieldListener.handleForcefield(player, pp, now); return; } else if (!PlotListener.plotEntry(pp, now)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED); From 610e204d12b2230788ca4846b84b36412adb7ca6 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Fri, 29 Jul 2016 12:31:45 -0400 Subject: [PATCH 25/27] Fix #1281 , Fix #1282 , and Sponge gradle --- .../com/plotsquared/bukkit/listeners/PlayerEvents.java | 3 +++ .../main/java/com/plotsquared/listener/PlotListener.java | 3 ++- Sponge/build.gradle | 4 ++-- .../src/main/java/com/plotsquared/sponge/SpongeMain.java | 8 ++++++++ build.gradle | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 66eb98c18..b28e1eb6b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1850,6 +1850,9 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) { + if (TaskManager.TELEPORT_QUEUE.contains(event.getPlayer().getName())) { + TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName()); + } PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); pp.unregister(); } diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index 17f3eee63..8b9fc1ced 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -207,7 +207,8 @@ public class PlotListener { for (UUID uuid : plot.getOwners()) { PlotPlayer owner = UUIDHandler.getPlayer(uuid); if ((owner != null) && !owner.getUUID().equals(player.getUUID())) { - MainUtil.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", player.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(owner, C.NOTIFY_LEAVE.s().replace("%player", player.getName()).replace("%plot", plot.getId() + .toString())); } } } diff --git a/Sponge/build.gradle b/Sponge/build.gradle index 747a615cb..5300dd804 100644 --- a/Sponge/build.gradle +++ b/Sponge/build.gradle @@ -14,7 +14,7 @@ buildscript { } } -apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: 'net.minecrell.vanilla.server.library' dependencies { compile project(':Core') @@ -41,7 +41,7 @@ repositories { } } minecraft { - version = "2014" + version = "1.10.2" mappings = "snapshot_20160629" runDir = 'run' } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 6056574db..c3c935995 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -68,6 +68,14 @@ import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGeneratorModifier; +import java.io.File; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + @Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.5.0-SNAPSHOT") public class SpongeMain implements IPlotMain { diff --git a/build.gradle b/build.gradle index 559c46745..58eafd20c 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { git = Grgit.open() revision = "${git.head().abbreviatedId}" } -version = "3.4.5-SNAPSHOT${revision}" +version = "3.4.5-SNAPSHOT-${revision}" description = """PlotSquared""" subprojects { From 09994724db2db3f5128c245427cac898a7d65164 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Fri, 29 Jul 2016 21:40:02 -0400 Subject: [PATCH 26/27] Fix #1277 --- Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index c31409455..1f9bff3ec 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -369,8 +369,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain PlayerEvents main = new PlayerEvents(); getServer().getPluginManager().registerEvents(main, this); try { + getServer().getClass().getMethod("spigot"); getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this); - } catch (Throwable ignore) {} + } catch (NoSuchMethodException ignored) { + PS.debug("Not running Spigot. Skipping EntitySpawnListener event."); + } if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) { try { getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this); From c8419f4a4a3c54c44aa57835bca6e92cbe14e77b Mon Sep 17 00:00:00 2001 From: MattBDev Date: Fri, 29 Jul 2016 21:40:23 -0400 Subject: [PATCH 27/27] Added more Java 8 warnings --- .../main/java/com/intellectualcrafters/plot/util/EventUtil.java | 1 + 1 file changed, 1 insertion(+) 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 60105e290..adeb69181 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -68,6 +68,7 @@ public abstract class EventUtil { } } if (PS.get().update != null && Permissions.hasPermission(player, C.PERMISSION_ADMIN_UPDATE) && Settings.Enabled_Components.UPDATER) { + MainUtil.sendMessage(player,C.CONSOLE_JAVA_OUTDATED_1_8.s()); MainUtil.sendMessage(player, "&6An update for PlotSquared is available: &7/plot update"); } final Plot plot = player.getCurrentPlot();