diff --git a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index a32508267..519de20ef 100644 --- a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -20,17 +20,18 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.bukkit.util.BukkitUtil; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.UUID; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; /** * PlotSquared API. @@ -378,9 +379,9 @@ public class PlotAPI { } /** - * Register a flag for use in plots. + * Registers a flag for use in plots. * - * @param flag the flag being registered + * @param flag the flag to register * */ public void addFlag(Flag flag) { @@ -388,7 +389,7 @@ public class PlotAPI { } /** - * Get a plot based on the ID. + * Gets a plot based on the ID. * * @param world the world the plot is located in * @param x The PlotID x coordinate @@ -617,7 +618,7 @@ public class PlotAPI { } /** - * Get the PlotSquared class. + * Gets the PlotSquared class. * * @return PlotSquared Class * @@ -628,7 +629,7 @@ public class PlotAPI { } /** - * Get the player plot count. + * Gets the player plot count. * * @param world Specify the world we want to select the plots from * @param player Player, for whom we're getting the plot count @@ -644,7 +645,7 @@ public class PlotAPI { } /** - * Get a collection containing the players plots. + * Gets a collection containing the players plots. * * @param world Specify the world we want to select the plots from * @param player Player, for whom we're getting the plots @@ -663,7 +664,7 @@ public class PlotAPI { } /** - * Get the numbers of plots, which the player is able to build in. + * Gets the number of plots, which the player is able to build in. * * @param player player, for whom we're getting the plots * @@ -676,7 +677,7 @@ public class PlotAPI { } /** - * Get the PlotPlayer for a player. The PlotPlayer is usually cached and + * Gets the PlotPlayer for a player. The PlotPlayer is usually cached and * will provide useful functions relating to players. * * @see PlotPlayer#wrap(Object) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 8870b64cd..e28de55a4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -71,12 +71,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.sk89q.worldedit.WorldEdit; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -92,6 +86,13 @@ import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; + public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static WorldEdit worldEdit; @@ -113,7 +114,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain e.printStackTrace(); PS.debug(StringMan.getString(Bukkit.getBukkitVersion())); PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\."))); - return new int[]{1, 9, 2}; + return new int[]{1, 10, 0}; } } return this.version; @@ -158,6 +159,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])}; } + @Override public String getPluginVersionString() { + return getDescription().getVersion(); + } + @Override public void registerCommands() { BukkitCommand bukkitCommand = new BukkitCommand(); @@ -275,6 +280,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain case FALLING_BLOCK: // managed elsewhere continue; + case POLAR_BEAR: case BAT: case BLAZE: case CAVE_SPIDER: diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java index 002aea95b..44005ed39 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java @@ -18,280 +18,300 @@ import java.util.Map; */ public abstract class TextualComponent implements Cloneable { - static { - ConfigurationSerialization.registerClass(TextualComponent.ArbitraryTextTypeComponent.class); - ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class); - } + static { + ConfigurationSerialization.registerClass(TextualComponent.ArbitraryTextTypeComponent.class); + ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class); + } - @Override - public String toString() { - return getReadableString(); - } + static TextualComponent deserialize(Map map) { + if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) { + // Arbitrary text component + return ArbitraryTextTypeComponent.deserialize(map); + } else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) { + // Complex JSON object + return ComplexTextTypeComponent.deserialize(map); + } - /** - * @return The JSON key used to represent text components of this type. - */ - public abstract String getKey(); + return null; + } - /** - * @return A readable String - */ - public abstract String getReadableString(); + static boolean isTextKey(String key) { + return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector"); + } - /** - * Clones a textual component instance. - * The returned object should not reference this textual component instance, but should maintain the same key and value. - */ - @Override - public abstract TextualComponent clone() throws CloneNotSupportedException; + static boolean isTranslatableText(TextualComponent component) { + return component instanceof ComplexTextTypeComponent && component.getKey().equals("translate"); + } - /** - * Writes the text data represented by this textual component to the specified JSON writer object. - * A new object within the writer is not started. - * - * @param writer The object to which to write the JSON data. - * @throws IOException If an error occurs while writing to the stream. - */ - public abstract void writeJson(JsonWriter writer) throws IOException; + /** + * Create a textual component representing a string literal. + * + *

This is the default type of textual component when a single string + * literal is given to a method. + * + * @param textValue The text which will be represented. + * @return The text component representing the specified literal text. + */ + public static TextualComponent rawText(String textValue) { + return new ArbitraryTextTypeComponent("text", textValue); + } - static TextualComponent deserialize(Map map) { - if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) { - // Arbitrary text component - return ArbitraryTextTypeComponent.deserialize(map); - } else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) { - // Complex JSON object - return ComplexTextTypeComponent.deserialize(map); - } + /** + * Create a textual component representing a localized string. + * The client will see this text component as their localized version of the specified string key, which can be overridden by a + * resource pack. + *

+ * If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to + * the client. + *

+ * + * @param translateKey The string key which maps to localized text. + * @return The text component representing the specified localized text. + */ + public static TextualComponent localizedText(String translateKey) { + return new ArbitraryTextTypeComponent("translate", translateKey); + } - return null; - } + private static void throwUnsupportedSnapshot() { + throw new UnsupportedOperationException("This feature is only supported in snapshot releases."); + } - static boolean isTextKey(String key) { - return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector"); - } + /** + * Create a textual component representing a scoreboard value. + * The client will see their own score for the specified objective as the text represented by this component. + *

+ * This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients. + *

+ * + * @param scoreboardObjective The name of the objective for which to display the score. + * @return The text component representing the specified scoreboard score (for the viewing player), or {@code null} if an error occurs during + * JSON serialization. + */ + public static TextualComponent objectiveScore(String scoreboardObjective) { + return objectiveScore("*", scoreboardObjective); + } - static boolean isTranslatableText(TextualComponent component) { - return component instanceof ComplexTextTypeComponent && ((ComplexTextTypeComponent) component).getKey().equals("translate"); - } + /** + * Create a textual component representing a scoreboard value. + * The client will see the score of the specified player for the specified objective as the text represented by this component. + * + *

This method is currently guaranteed to throw an {@code UnsupportedOperationException} + * as it is only supported on snapshot clients. + * + * @param playerName The name of the player whos score will be shown. If + * this string represents the single-character sequence + * "*", the viewing player's score will be displayed. + * Standard minecraft selectors (@a, @p, etc) + * are not supported. + * @param scoreboardObjective The name of the objective for + * which to display the score. + * @return The text component representing the specified scoreboard score + * for the specified player, or {@code null} if an error occurs during JSON serialization. + */ + public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) { + throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE + // OVERLOADS documentation accordingly - /** - * Internal class used to represent all types of text components. - * Exception validating done is on keys and values. - */ - private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable { + return new ComplexTextTypeComponent("score", ImmutableMap.builder() + .put("name", playerName) + .put("objective", scoreboardObjective) + .build()); + } - public ArbitraryTextTypeComponent(String key, String value) { - setKey(key); - setValue(value); - } + /** + * Create a textual component representing a player name, retrievable by using a standard minecraft selector. + * The client will see the players or entities captured by the specified selector as the text represented by this component. + *

+ * This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients. + *

+ * + * @param selector The minecraft player or entity selector which will capture the entities whose string representations will be displayed in + * the place of this text component. + * @return The text component representing the name of the entities captured by the selector. + */ + public static TextualComponent selector(String selector) { + throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE + // OVERLOADS documentation accordingly - @Override - public String getKey() { - return _key; - } + return new ArbitraryTextTypeComponent("selector", selector); + } - public void setKey(String key) { - Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified."); - _key = key; - } + @Override + public String toString() { + return getReadableString(); + } - public String getValue() { - return _value; - } + /** + * @return The JSON key used to represent text components of this type. + */ + public abstract String getKey(); - public void setValue(String value) { - Preconditions.checkArgument(value != null, "The value must be specified."); - _value = value; - } + /** + * @return A readable String + */ + public abstract String getReadableString(); - private String _key; - private String _value; + /** + * Clones a textual component instance. + * The returned object should not reference this textual component instance, but should maintain the same key and value. + */ + @Override + public abstract TextualComponent clone() throws CloneNotSupportedException; - @Override - public TextualComponent clone() throws CloneNotSupportedException { - // Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone - return new ArbitraryTextTypeComponent(getKey(), getValue()); - } + /** + * Writes the text data represented by this textual component to the specified JSON writer object. + * A new object within the writer is not started. + * + * @param writer The object to which to write the JSON data. + * @throws IOException If an error occurs while writing to the stream. + */ + public abstract void writeJson(JsonWriter writer) throws IOException; - @Override - public void writeJson(JsonWriter writer) throws IOException { - writer.name(getKey()).value(getValue()); - } + /** + * Internal class used to represent all types of text components. + * Exception validating done is on keys and values. + */ + private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable { - @SuppressWarnings("serial") - public Map serialize() { - return new HashMap() {{ - put("key", getKey()); - put("value", getValue()); - }}; - } + private String key; + private String value; - public static ArbitraryTextTypeComponent deserialize(Map map) { - return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString()); - } + public ArbitraryTextTypeComponent(String key, String value) { + setKey(key); + setValue(value); + } - @Override - public String getReadableString() { - return getValue(); - } - } + public static ArbitraryTextTypeComponent deserialize(Map map) { + return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString()); + } - /** - * Internal class used to represent a text component with a nested JSON value. - * Exception validating done is on keys and values. - */ - private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable { + @Override + public String getKey() { + return key; + } - public ComplexTextTypeComponent(String key, Map values) { - setKey(key); - setValue(values); - } + public void setKey(String key) { + Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified."); + this.key = key; + } - @Override - public String getKey() { - return _key; - } + public String getValue() { + return value; + } - public void setKey(String key) { - Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified."); - _key = key; - } + public void setValue(String value) { + Preconditions.checkArgument(value != null, "The value must be specified."); + this.value = value; + } - public Map getValue() { - return _value; - } + @Override + public TextualComponent clone() throws CloneNotSupportedException { + // Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone + return new ArbitraryTextTypeComponent(getKey(), getValue()); + } - public void setValue(Map value) { - Preconditions.checkArgument(value != null, "The value must be specified."); - _value = value; - } + @Override + public void writeJson(JsonWriter writer) throws IOException { + writer.name(getKey()).value(getValue()); + } - private String _key; - private Map _value; + @Override + @SuppressWarnings("serial") + public Map serialize() { + return new HashMap() { + { + put("key", getKey()); + put("value", getValue()); + } + }; + } - @Override - public TextualComponent clone() throws CloneNotSupportedException { - // Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone - return new ComplexTextTypeComponent(getKey(), getValue()); - } + @Override + public String getReadableString() { + return getValue(); + } + } - @Override - public void writeJson(JsonWriter writer) throws IOException { - writer.name(getKey()); - writer.beginObject(); - for (Map.Entry jsonPair : _value.entrySet()) { - writer.name(jsonPair.getKey()).value(jsonPair.getValue()); - } - writer.endObject(); - } + /** + * Internal class used to represent a text component with a nested JSON + * value. + * + *

Exception validating done is on keys and values. + */ + private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable { - @SuppressWarnings("serial") - public Map serialize() { - return new java.util.HashMap() {{ - put("key", getKey()); - for (Map.Entry valEntry : getValue().entrySet()) { - put("value." + valEntry.getKey(), valEntry.getValue()); - } - }}; - } + private String key; + private Map value; - public static ComplexTextTypeComponent deserialize(Map map) { - String key = null; - Map value = new HashMap(); - for (Map.Entry valEntry : map.entrySet()) { - if (valEntry.getKey().equals("key")) { - key = (String) valEntry.getValue(); - } else if (valEntry.getKey().startsWith("value.")) { - value.put(((String) valEntry.getKey()).substring(6) /* Strips out the value prefix */, valEntry.getValue().toString()); - } - } - return new ComplexTextTypeComponent(key, value); - } + public ComplexTextTypeComponent(String key, Map values) { + setKey(key); + setValue(values); + } - @Override - public String getReadableString() { - return getKey(); - } - } + public static ComplexTextTypeComponent deserialize(Map map) { + String key = null; + Map value = new HashMap<>(); + for (Map.Entry valEntry : map.entrySet()) { + if (valEntry.getKey().equals("key")) { + key = (String) valEntry.getValue(); + } else if (valEntry.getKey().startsWith("value.")) { + value.put(valEntry.getKey().substring(6) /* Strips out the value prefix */, valEntry.getValue().toString()); + } + } + return new ComplexTextTypeComponent(key, value); + } - /** - * Create a textual component representing a string literal. - * This is the default type of textual component when a single string literal is given to a method. - * - * @param textValue The text which will be represented. - * @return The text component representing the specified literal text. - */ - public static TextualComponent rawText(String textValue) { - return new ArbitraryTextTypeComponent("text", textValue); - } + @Override + public String getKey() { + return key; + } + public void setKey(String key) { + Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified."); + this.key = key; + } - /** - * Create a textual component representing a localized string. - * The client will see this text component as their localized version of the specified string key, which can be overridden by a resource pack. - *

- * If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to the client. - *

- * - * @param translateKey The string key which maps to localized text. - * @return The text component representing the specified localized text. - */ - public static TextualComponent localizedText(String translateKey) { - return new ArbitraryTextTypeComponent("translate", translateKey); - } + public Map getValue() { + return value; + } - private static void throwUnsupportedSnapshot() { - throw new UnsupportedOperationException("This feature is only supported in snapshot releases."); - } + public void setValue(Map value) { + Preconditions.checkArgument(value != null, "The value must be specified."); + this.value = value; + } - /** - * Create a textual component representing a scoreboard value. - * The client will see their own score for the specified objective as the text represented by this component. - *

- * This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients. - *

- * - * @param scoreboardObjective The name of the objective for which to display the score. - * @return The text component representing the specified scoreboard score (for the viewing player), or {@code null} if an error occurs during JSON serialization. - */ - public static TextualComponent objectiveScore(String scoreboardObjective) { - return objectiveScore("*", scoreboardObjective); - } + @Override + public TextualComponent clone() { + // Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone + return new ComplexTextTypeComponent(getKey(), getValue()); + } - /** - * Create a textual component representing a scoreboard value. - * The client will see the score of the specified player for the specified objective as the text represented by this component. - *

- * This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients. - *

- * - * @param playerName The name of the player whos score will be shown. If this string represents the single-character sequence "*", the viewing player's score will be displayed. - * Standard minecraft selectors (@a, @p, etc) are not supported. - * @param scoreboardObjective The name of the objective for which to display the score. - * @return The text component representing the specified scoreboard score for the specified player, or {@code null} if an error occurs during JSON serialization. - */ - public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) { - throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE OVERLOADS documentation accordingly + @Override + public void writeJson(JsonWriter writer) throws IOException { + writer.name(getKey()); + writer.beginObject(); + for (Map.Entry jsonPair : value.entrySet()) { + writer.name(jsonPair.getKey()).value(jsonPair.getValue()); + } + writer.endObject(); + } - return new ComplexTextTypeComponent("score", ImmutableMap.builder() - .put("name", playerName) - .put("objective", scoreboardObjective) - .build()); - } + @Override + @SuppressWarnings("serial") + public Map serialize() { + return new java.util.HashMap() { + { + put("key", getKey()); + for (Map.Entry valEntry : getValue().entrySet()) { + put("value." + valEntry.getKey(), valEntry.getValue()); + } + } + }; + } - /** - * Create a textual component representing a player name, retrievable by using a standard minecraft selector. - * The client will see the players or entities captured by the specified selector as the text represented by this component. - *

- * This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients. - *

- * - * @param selector The minecraft player or entity selector which will capture the entities whose string representations will be displayed in the place of this text component. - * @return The text component representing the name of the entities captured by the selector. - */ - public static TextualComponent selector(String selector) { - throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE OVERLOADS documentation accordingly - - return new ArbitraryTextTypeComponent("selector", selector); - } + @Override + public String getReadableString() { + return getKey(); + } + } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index 3abd55d98..fc4087c81 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -20,17 +20,18 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.block.GenChunk; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Random; -import java.util.Set; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; +import java.util.Set; + public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper { private final GenChunk chunkSetter; @@ -255,7 +256,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap @Override public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) { - GenChunk result = (GenChunk) this.chunkSetter; + GenChunk result = this.chunkSetter; // Set the chunk location result.setChunk(new ChunkWrapper(world.getName(), cx, cz)); // Set the result data @@ -303,7 +304,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap @Override public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid grid) { - GenChunk result = (GenChunk) this.chunkSetter; + GenChunk result = this.chunkSetter; // Set the chunk location result.setChunk(new ChunkWrapper(world.getName(), cx, cz)); // Set the result data 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 29d0ecf1c..a4258421c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -1,12 +1,12 @@ package com.plotsquared.bukkit.listeners; +import com.google.common.collect.Iterables; 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.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.util.Vector; @@ -19,9 +19,9 @@ public class ForceFieldListener implements Listener { private static Set getNearbyPlayers(Player player, Plot plot) { Set players = new HashSet<>(); - for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { + for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) { PlotPlayer plotPlayer; - if (!(entity instanceof Player) || ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(plotPlayer.getCurrentPlot())) { + if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) { continue; } if (!plot.isAdded(plotPlayer.getUUID())) { @@ -32,15 +32,9 @@ public class ForceFieldListener implements Listener { } private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) { - for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { - if (!(entity instanceof Player)) { - continue; - } + for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) { PlotPlayer plotPlayer; - if ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) { - continue; - } - if (!plot.equals(plotPlayer.getCurrentPlot())) { + if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) { continue; } if (plot.isAdded(plotPlayer.getUUID())) { 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 a90a7548d..5c4cd4dcb 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. * @@ -279,8 +280,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (!(shooter instanceof Player)) { return; } - ThrownPotion potion = (ThrownPotion) entity; - Location l = BukkitUtil.getLocation(potion); + Location l = BukkitUtil.getLocation(entity); if (!PS.get().hasPlotArea(l.getWorld())) { return; } @@ -1283,7 +1283,7 @@ public class PlayerEvents extends PlotListener implements Listener { } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void MobSpawn(CreatureSpawnEvent event) { + public void creatureSpawnEvent(CreatureSpawnEvent event) { Entity entity = event.getEntity(); Location location = BukkitUtil.getLocation(entity.getLocation()); PlotArea area = location.getPlotArea(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java index 5f66d4b2d..ba75b71b6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java @@ -52,7 +52,7 @@ public abstract class TitleManager { abstract void loadClasses(); /** - * Get title text. + * Gets title text. * * @return Title text */ @@ -61,7 +61,7 @@ public abstract class TitleManager { } /** - * Set title text. + * Sets the text for the title. * * @param title Title */ @@ -70,7 +70,7 @@ public abstract class TitleManager { } /** - * Get subtitle text. + * Gets the subtitle text. * * @return Subtitle text */ @@ -79,7 +79,7 @@ public abstract class TitleManager { } /** - * Set subtitle text. + * Sets subtitle text. * * @param subtitle Subtitle text */ @@ -88,7 +88,7 @@ public abstract class TitleManager { } /** - * Set the title color. + * Sets the title color. * * @param color Chat color */ @@ -97,7 +97,7 @@ public abstract class TitleManager { } /** - * Set the subtitle color. + * Sets the subtitle color. * * @param color Chat color */ @@ -106,7 +106,7 @@ public abstract class TitleManager { } /** - * Set title fade in time. + * Sets title fade in time. * * @param time Time */ @@ -115,7 +115,7 @@ public abstract class TitleManager { } /** - * Set title fade out time. + * Sets title fade out time. * * @param time Time */ @@ -124,7 +124,7 @@ public abstract class TitleManager { } /** - * Set title stay time. + * Sets title stay time. * * @param time Time */ @@ -133,21 +133,21 @@ public abstract class TitleManager { } /** - * Set timings to ticks. + * Sets timings to ticks. */ public final void setTimingsToTicks() { this.ticks = true; } /** - * Set timings to seconds. + * Sets timings to seconds. */ public final void setTimingsToSeconds() { this.ticks = false; } /** - * Send the title to a player. + * Sends the title to a player. * * @param player Player * @throws IllegalArgumentException @@ -157,18 +157,18 @@ public abstract class TitleManager { public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException; /** - * Broadcast the title to all players. + * Broadcasts the title to all players. * * @throws Exception */ public final void broadcast() throws Exception { - for (Player p : Bukkit.getOnlinePlayers()) { - send(p); + for (Player player : Bukkit.getOnlinePlayers()) { + send(player); } } /** - * Clear the title. + * Clears the title. * * @param player Player * @throws IllegalArgumentException @@ -178,7 +178,7 @@ public abstract class TitleManager { public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException; /** - * Reset the title settings. + * Resets the title settings. * * @param player Player * @throws IllegalArgumentException @@ -195,7 +195,7 @@ public abstract class TitleManager { } } - final Class[] toPrimitiveTypeArray(Class[] classes) { + private Class[] toPrimitiveTypeArray(Class[] classes) { int a; if (classes != null) { a = classes.length; @@ -229,7 +229,7 @@ public abstract class TitleManager { return null; } - final boolean equalsTypeArray(Class[] a, Class[] o) { + private boolean equalsTypeArray(Class[] a, Class[] o) { if (a.length != o.length) { return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java index 4a594be0a..445d1e938 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationOptions.java @@ -2,14 +2,14 @@ package com.intellectualcrafters.configuration; /** * Various settings for controlling the input and output of a {@link - * Configuration} + * Configuration}. */ class ConfigurationOptions { private final Configuration configuration; private char pathSeparator = '.'; private boolean copyDefaults = false; - protected ConfigurationOptions(final Configuration configuration) { + protected ConfigurationOptions(Configuration configuration) { this.configuration = configuration; } @@ -24,9 +24,9 @@ class ConfigurationOptions { /** * Gets the char that will be used to separate {@link - * ConfigurationSection}s - *

- * This value does not affect how the {@link Configuration} is stored, + * ConfigurationSection}s. + * + *

This value does not affect how the {@link Configuration} is stored, * only in how you access the data. The default value is '.'. * * @return Path separator @@ -37,15 +37,15 @@ class ConfigurationOptions { /** * Sets the char that will be used to separate {@link - * ConfigurationSection}s - *

- * This value does not affect how the {@link Configuration} is stored, + * ConfigurationSection}s. + * + *

This value does not affect how the {@link Configuration} is stored, * only in how you access the data. The default value is '.'. * * @param value Path separator * @return This object, for chaining */ - public ConfigurationOptions pathSeparator(final char value) { + public ConfigurationOptions pathSeparator(char value) { pathSeparator = value; return this; } @@ -53,8 +53,8 @@ class ConfigurationOptions { /** * Checks if the {@link Configuration} should copy values from its default * {@link Configuration} directly. - *

- * If this is true, all values in the default Configuration will be + * + *

If this is true, all values in the default Configuration will be * directly copied, making it impossible to distinguish between values * that were set and values that are provided by default. As a result, * {@link ConfigurationSection#contains(String)} will always @@ -71,8 +71,8 @@ class ConfigurationOptions { /** * Sets if the {@link Configuration} should copy values from its default * {@link Configuration} directly. - *

- * If this is true, all values in the default Configuration will be + * + *

If this is true, all values in the default Configuration will be * directly copied, making it impossible to distinguish between values * that were set and values that are provided by default. As a result, * {@link ConfigurationSection#contains(String)} will always @@ -83,7 +83,7 @@ class ConfigurationOptions { * @param value Whether or not defaults are directly copied * @return This object, for chaining */ - public ConfigurationOptions copyDefaults(final boolean value) { + public ConfigurationOptions copyDefaults(boolean value) { copyDefaults = value; return this; } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationSection.java b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationSection.java index 7d16d3c9e..661898269 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationSection.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/ConfigurationSection.java @@ -5,18 +5,18 @@ import java.util.Map; import java.util.Set; /** - * Represents a section of a {@link Configuration} + * Represents a section of a {@link Configuration}. */ public interface ConfigurationSection { /** * Gets a set containing all keys in this section. - *

- * If deep is set to true, then this will contain all the keys within any + * + *

If deep is set to true, then this will contain all the keys within any * child {@link ConfigurationSection}s (and their children, etc). These * will be in a valid path notation for you to use. - *

- * If deep is set to false, then this will contain only the keys of any + * + *

If deep is set to false, then this will contain only the keys of any * direct children, and not their own children. * * @param deep Whether or not to get a deep list, as opposed to a shallow @@ -43,43 +43,44 @@ public interface ConfigurationSection { /** * Checks if this {@link ConfigurationSection} contains the given path. - *

- * If the value for the requested path does not exist but a default value + * + *

If the value for the requested path does not exist but a default value * has been specified, this will return true. * * @param path Path to check for existence. * @return True if this section contains the requested path, either via * default or being set. - * @throws IllegalArgumentException Thrown when path is null. + * @throws IllegalArgumentException Thrown when path is null. */ boolean contains(String path); /** * Checks if this {@link ConfigurationSection} has a value set for the * given path. - *

- * If the value for the requested path does not exist but a default value + * + *

If the value for the requested path does not exist but a default value * has been specified, this will still return false. * * @param path Path to check for existence. * @return True if this section contains the requested path, regardless of * having a default. - * @throws IllegalArgumentException Thrown when path is null. + * @throws IllegalArgumentException Thrown when path is null. */ boolean isSet(String path); /** * Gets the path of this {@link ConfigurationSection} from its root {@link - * Configuration} - *

- * For any {@link Configuration} themselves, this will return an empty + * Configuration}. + * + *

For any {@link Configuration} themselves, this will return an empty * string. - *

- * If the section is no longer contained within its root for any reason, - * such as being replaced with a different value, this may return null. - *

- * To retrieve the single name of this section, that is, the final part of - * the path returned by this method, you may use {@link #getName()}. + * + *

If the section is no longer contained within its root for any reason, + * such as being replaced with a different value, + * this may return null. + * + *

To retrieve the single name of this section, that is, the final part + * of the path returned by this method, you may use {@link #getName()}. * * @return Path of this section relative to its root */ @@ -88,8 +89,8 @@ public interface ConfigurationSection { /** * Gets the name of this individual {@link ConfigurationSection}, in the * path. - *

- * This will always be the final part of {@link #getCurrentPath()}, unless + * + *

This will always be the final part of {@link #getCurrentPath()}, unless * the section is orphaned. * * @return Name of this section @@ -99,12 +100,13 @@ public interface ConfigurationSection { /** * Gets the root {@link Configuration} that contains this {@link * ConfigurationSection} - *

- * For any {@link Configuration} themselves, this will return its own + * + *

For any {@link Configuration} themselves, this will return its own * object. - *

- * If the section is no longer contained within its root for any reason, - * such as being replaced with a different value, this may return null. + * + *

If the section is no longer contained within its root for any reason, + * such as being replaced with a different value, + * this may return null. * * @return Root configuration containing this section. */ @@ -113,11 +115,13 @@ public interface ConfigurationSection { /** * Gets the parent {@link ConfigurationSection} that directly contains * this {@link ConfigurationSection}. - *

- * For any {@link Configuration} themselves, this will return null. - *

- * If the section is no longer contained within its parent for any reason, - * such as being replaced with a different value, this may return null. + * + *

For any {@link Configuration} themselves, this will return + * null. + * + *

If the section is no longer contained within its parent for any reason, + * such as being replaced with a different value, this may + * return null. * * @return Parent section containing this section. */ @@ -125,10 +129,10 @@ public interface ConfigurationSection { /** * Gets the requested Object by path. - *

- * If the Object does not exist but a default value has been specified, + * + *

If the Object does not exist but a default value has been specified, * this will return the default value. If the Object does not exist and no - * default value was specified, this will return null. + * default value was specified, this will return null. * * @param path Path of the Object to get. * @return Requested Object. @@ -138,8 +142,8 @@ public interface ConfigurationSection { /** * Gets the requested Object by path, returning a default value if not * found. - *

- * If the Object does not exist then the specified default value will + * + *

If the Object does not exist then the specified default value will * returned regardless of if a default has been identified in the root * {@link Configuration}. * @@ -151,11 +155,11 @@ public interface ConfigurationSection { /** * Sets the specified path to the given value. - *

- * If value is null, the entry will be removed. Any existing entry will be - * replaced, regardless of what the new value is. - *

- * Some implementations may have limitations on what you may store. See + * + *

If value is null, the entry will be removed. Any + * existing entry will be replaced, regardless of what the new value is. + * + *

Some implementations may have limitations on what you may store. See * their individual javadoc for details. No implementations should allow * you to store {@link Configuration}s or {@link ConfigurationSection}s, * please use {@link #createSection(String)} for that. @@ -167,8 +171,8 @@ public interface ConfigurationSection { /** * Creates an empty {@link ConfigurationSection} at the specified path. - *

- * Any value that was previously set at this path will be overwritten. If + * + *

Any value that was previously set at this path will be overwritten. If * the previous value was itself a {@link ConfigurationSection}, it will * be orphaned. * @@ -180,8 +184,8 @@ public interface ConfigurationSection { /** * Creates a {@link ConfigurationSection} at the specified path, with * specified values. - *

- * Any value that was previously set at this path will be overwritten. If + * + *

Any value that was previously set at this path will be overwritten. If * the previous value was itself a {@link ConfigurationSection}, it will * be orphaned. * @@ -195,10 +199,10 @@ public interface ConfigurationSection { /** * Gets the requested String by path. - *

- * If the String does not exist but a default value has been specified, + * + *

If the String does not exist but a default value has been specified, * this will return the default value. If the String does not exist and no - * default value was specified, this will return null. + * default value was specified, this will return null. * * @param path Path of the String to get. * @return Requested String. @@ -208,8 +212,8 @@ public interface ConfigurationSection { /** * Gets the requested String by path, returning a default value if not * found. - *

- * If the String does not exist then the specified default value will + * + *

If the String does not exist then the specified default value will * returned regardless of if a default has been identified in the root * {@link Configuration}. * @@ -223,10 +227,10 @@ public interface ConfigurationSection { /** * Checks if the specified path is a String. * - *

If the path exists but is not a String, this will return false. If the - * path does not exist, this will return false. If the path does not exist - * but a default value has been specified, this will check if that default - * value is a String and return appropriately.

+ *

If the path exists but is not a String, this will return false. If + * the path does not exist, this will return false. If the path does not + * exist but a default value has been specified, this will check if that + * defaultvalue is a String and return appropriately. * * @param path Path of the String to check. * @return Whether or not the specified path is a String. @@ -238,7 +242,7 @@ public interface ConfigurationSection { * *

If the int does not exist but a default value has been specified, this * will return the default value. If the int does not exist and no default - * value was specified, this will return 0.

+ * value was specified, this will return 0. * * @param path Path of the int to get. * @return Requested int. @@ -250,7 +254,7 @@ public interface ConfigurationSection { * *

If the int does not exist then the specified default value will * returned regardless of if a default has been identified in the root - * {@link Configuration}.

+ * {@link Configuration}. * * @param path Path of the int to get. * @param def The default value to return if the path is not found or is @@ -265,7 +269,7 @@ public interface ConfigurationSection { *

If the path exists but is not a int, this will return false. If the * path does not exist, this will return false. If the path does not exist * but a default value has been specified, this will check if that default - * value is a int and return appropriately.

+ * value is a int and return appropriately. * * @param path Path of the int to check. * @return Whether or not the specified path is an int. @@ -274,8 +278,8 @@ public interface ConfigurationSection { /** * Gets the requested boolean by path. - *

- * If the boolean does not exist but a default value has been specified, + * + *

If the boolean does not exist but a default value has been specified, * this will return the default value. If the boolean does not exist and * no default value was specified, this will return false. * @@ -287,8 +291,8 @@ public interface ConfigurationSection { /** * Gets the requested boolean by path, returning a default value if not * found. - *

- * If the boolean does not exist then the specified default value will + * + *

If the boolean does not exist then the specified default value will * returned regardless of if a default has been identified in the root * {@link Configuration}. * @@ -301,8 +305,8 @@ public interface ConfigurationSection { /** * Checks if the specified path is a boolean. - *

- * If the path exists but is not a boolean, this will return false. If the + * + *

If the path exists but is not a boolean, this will return false. If the * path does not exist, this will return false. If the path does not exist * but a default value has been specified, this will check if that default * value is a boolean and return appropriately. @@ -314,8 +318,8 @@ public interface ConfigurationSection { /** * Gets the requested double by path. - *

- * If the double does not exist but a default value has been specified, + * + *

If the double does not exist but a default value has been specified, * this will return the default value. If the double does not exist and no * default value was specified, this will return 0. * @@ -327,8 +331,8 @@ public interface ConfigurationSection { /** * Gets the requested double by path, returning a default value if not * found. - *

- * If the double does not exist then the specified default value will + * + *

If the double does not exist then the specified default value will * returned regardless of if a default has been identified in the root * {@link Configuration}. * @@ -341,8 +345,8 @@ public interface ConfigurationSection { /** * Checks if the specified path is a double. - *

- * If the path exists but is not a double, this will return false. If the + * + *

If the path exists but is not a double, this will return false. If the * path does not exist, this will return false. If the path does not exist * but a default value has been specified, this will check if that default * value is a double and return appropriately. @@ -354,8 +358,8 @@ public interface ConfigurationSection { /** * Gets the requested long by path. - *

- * If the long does not exist but a default value has been specified, this + * + *

If the long does not exist but a default value has been specified, this * will return the default value. If the long does not exist and no * default value was specified, this will return 0. * @@ -367,8 +371,8 @@ public interface ConfigurationSection { /** * Gets the requested long by path, returning a default value if not * found. - *

- * If the long does not exist then the specified default value will + * + *

If the long does not exist then the specified default value will * returned regardless of if a default has been identified in the root * {@link Configuration}. * @@ -381,8 +385,8 @@ public interface ConfigurationSection { /** * Checks if the specified path is a long. - *

- * If the path exists but is not a long, this will return false. If the + * + *

If the path exists but is not a long, this will return false. If the * path does not exist, this will return false. If the path does not exist * but a default value has been specified, this will check if that default * value is a long and return appropriately. @@ -396,8 +400,8 @@ public interface ConfigurationSection { /** * Gets the requested List by path. - *

- * If the List does not exist but a default value has been specified, this + * + *

If the List does not exist but a default value has been specified, this * will return the default value. If the List does not exist and no * default value was specified, this will return null. * @@ -409,8 +413,8 @@ public interface ConfigurationSection { /** * Gets the requested List by path, returning a default value if not * found. - *

- * If the List does not exist then the specified default value will + * + *

If the List does not exist then the specified default value will * returned regardless of if a default has been identified in the root * {@link Configuration}. * @@ -423,8 +427,8 @@ public interface ConfigurationSection { /** * Checks if the specified path is a List. - *

- * If the path exists but is not a List, this will return false. If the + * + *

If the path exists but is not a List, this will return false. If the * path does not exist, this will return false. If the path does not exist * but a default value has been specified, this will check if that default * value is a List and return appropriately. @@ -436,12 +440,12 @@ public interface ConfigurationSection { /** * Gets the requested List of String by path. - *

- * If the List does not exist but a default value has been specified, this - * will return the default value. If the List does not exist and no + * + *

If the List does not exist but a default value has been specified, + * this will return the default value. If the List does not exist and no * default value was specified, this will return an empty List. - *

- * This method will attempt to cast any values into a String if possible, + * + *

This method will attempt to cast any values into a String if possible, * but may miss any values out if they are not compatible. * * @param path Path of the List to get. @@ -451,13 +455,13 @@ public interface ConfigurationSection { /** * Gets the requested List of Integer by path. - *

- * If the List does not exist but a default value has been specified, this - * will return the default value. If the List does not exist and no + * + *

If the List does not exist but a default value has been specified, + * this will return the default value. If the List does not exist and no * default value was specified, this will return an empty List. - *

- * This method will attempt to cast any values into a Integer if possible, - * but may miss any values out if they are not compatible. + * + *

This method will attempt to cast any values into a Integer if + * possible, but may miss any values out if they are not compatible. * * @param path Path of the List to get. * @return Requested List of Integer. @@ -556,12 +560,10 @@ public interface ConfigurationSection { /** * Gets the requested List of Short by path. - *

- * If the List does not exist but a default value has been specified, this + *

If the List does not exist but a default value has been specified, this * will return the default value. If the List does not exist and no * default value was specified, this will return an empty List. - *

- * This method will attempt to cast any values into a Short if possible, + *

This method will attempt to cast any values into a Short if possible, * but may miss any values out if they are not compatible. * * @param path Path of the List to get. @@ -571,13 +573,12 @@ public interface ConfigurationSection { /** * Gets the requested List of Maps by path. - *

- * If the List does not exist but a default value has been specified, this - * will return the default value. If the List does not exist and no + * + *

If the List does not exist but a default value has been specified, + * this will return the default value. If the List does not exist and no * default value was specified, this will return an empty List. - *

- * This method will attempt to cast any values into a Map if possible, but - * may miss any values out if they are not compatible. + *

This method will attempt to cast any values into a Map if possible, + * but may miss any values out if they are not compatible. * * @param path Path of the List to get. * @return Requested List of Maps. @@ -586,11 +587,11 @@ public interface ConfigurationSection { /** * Gets the requested ConfigurationSection by path. - *

- * If the ConfigurationSection does not exist but a default value has been - * specified, this will return the default value. If the + * + *

If the ConfigurationSection does not exist but a default value has + * been specified, this will return the default value. If the * ConfigurationSection does not exist and no default value was specified, - * this will return null. + * this will return null. * * @param path Path of the ConfigurationSection to get. * @return Requested ConfigurationSection. @@ -599,8 +600,8 @@ public interface ConfigurationSection { /** * Checks if the specified path is a ConfigurationSection. - *

- * If the path exists but is not a ConfigurationSection, this will return + * + *

If the path exists but is not a ConfigurationSection, this will return * false. If the path does not exist, this will return false. If the path * does not exist but a default value has been specified, this will check * if that default value is a ConfigurationSection and return @@ -614,10 +615,10 @@ public interface ConfigurationSection { /** * Gets the equivalent {@link ConfigurationSection} from the default * {@link Configuration} defined in {@link #getRoot()}. - *

- * If the root contains no defaults, or the defaults doesn't contain a + * + *

If the root contains no defaults, or the defaults doesn't contain a * value for this path, or the value at this path is not a {@link - * ConfigurationSection} then this will return null. + * ConfigurationSection} then this will return null. * * @return Equivalent section in root configuration */ @@ -625,21 +626,21 @@ public interface ConfigurationSection { /** * Sets the default value in the root at the given path as provided. - *

- * If no source {@link Configuration} was provided as a default + * + *

If no source {@link Configuration} was provided as a default * collection, then a new {@link MemoryConfiguration} will be created to * hold the new default value. - *

- * If value is null, the value will be removed from the default - * Configuration source. - *

- * If the value as returned by {@link #getDefaultSection()} is null, then - * this will create a new section at the path, replacing anything that may - * have existed there previously. * - * @param path Path of the value to set. - * @param value Value to set the default to. - * @throws IllegalArgumentException Thrown if path is null. + *

If value is null, the value will be removed from the + * default Configuration source. + * + *

If the value as returned by {@link #getDefaultSection()} is + * null, then this will create a new section at the path, + * replacing anything that may have existed there previously. + * + * @param path Path of the value to set + * @param value Value to set the default to + * @throws IllegalArgumentException Thrown if path is null */ void addDefault(String path, Object value); } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/InvalidConfigurationException.java b/Core/src/main/java/com/intellectualcrafters/configuration/InvalidConfigurationException.java index 00791c3ce..f98b241af 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/InvalidConfigurationException.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/InvalidConfigurationException.java @@ -1,7 +1,7 @@ package com.intellectualcrafters.configuration; /** - * Exception thrown when attempting to load an invalid {@link Configuration} + * Exception thrown when attempting to load an invalid {@link Configuration}. */ @SuppressWarnings("serial") public class InvalidConfigurationException extends Exception { @@ -18,7 +18,7 @@ public class InvalidConfigurationException extends Exception { * * @param msg The details of the exception. */ - public InvalidConfigurationException(final String msg) { + public InvalidConfigurationException(String msg) { super(msg); } @@ -28,7 +28,7 @@ public class InvalidConfigurationException extends Exception { * * @param cause The cause of the exception. */ - public InvalidConfigurationException(final Throwable cause) { + public InvalidConfigurationException(Throwable cause) { super(cause); } @@ -39,7 +39,7 @@ public class InvalidConfigurationException extends Exception { * @param cause The cause of the exception. * @param msg The details of the exception. */ - public InvalidConfigurationException(final String msg, final Throwable cause) { + public InvalidConfigurationException(String msg, Throwable cause) { super(msg, cause); } } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/MemoryConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/MemoryConfigurationOptions.java index d395c0a7b..b2df5e134 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/MemoryConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/MemoryConfigurationOptions.java @@ -2,10 +2,10 @@ package com.intellectualcrafters.configuration; /** * Various settings for controlling the input and output of a {@link - * MemoryConfiguration} + * MemoryConfiguration}. */ public class MemoryConfigurationOptions extends ConfigurationOptions { - protected MemoryConfigurationOptions(final MemoryConfiguration configuration) { + protected MemoryConfigurationOptions(MemoryConfiguration configuration) { super(configuration); } @@ -15,13 +15,13 @@ public class MemoryConfigurationOptions extends ConfigurationOptions { } @Override - public MemoryConfigurationOptions copyDefaults(final boolean value) { + public MemoryConfigurationOptions copyDefaults(boolean value) { super.copyDefaults(value); return this; } @Override - public MemoryConfigurationOptions pathSeparator(final char value) { + public MemoryConfigurationOptions pathSeparator(char value) { super.pathSeparator(value); return this; } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java index fe4897319..8aad3c8d9 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java @@ -21,8 +21,8 @@ public class MemorySection implements ConfigurationSection { /** * Creates an empty MemorySection for use as a root {@link Configuration} * section. - *

- * Note that calling this without being yourself a {@link Configuration} + * + *

Note that calling this without being yourself a {@link Configuration} * will throw an exception! * * @throws IllegalStateException Thrown if this is not a {@link @@ -121,8 +121,8 @@ public class MemorySection implements ConfigurationSection { /** * Creates a full path to the given {@link ConfigurationSection} from its * root {@link Configuration}. - *

- * You may use this method for any given {@link ConfigurationSection}, not + * + *

You may use this method for any given {@link ConfigurationSection}, not * only {@link MemorySection}. * * @param section Section to create a path for. @@ -136,8 +136,8 @@ public class MemorySection implements ConfigurationSection { /** * Creates a relative path to the given {@link ConfigurationSection} from * the given relative section. - *

- * You may use this method for any given {@link ConfigurationSection}, not + * + *

You may use this method for any given {@link ConfigurationSection}, not * only {@link MemorySection}. * * @param section Section to create a path for. @@ -292,7 +292,8 @@ public class MemorySection implements ConfigurationSection { char separator = root.options().pathSeparator(); // i1 is the leading (higher) index // i2 is the trailing (lower) index - int i1 = -1, i2; + int i1 = -1; + int i2; ConfigurationSection section = this; while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) { String node = path.substring(i2, i1); @@ -374,7 +375,8 @@ public class MemorySection implements ConfigurationSection { char separator = root.options().pathSeparator(); // i1 is the leading (higher) index // i2 is the trailing (lower) index - int i1 = -1, i2; + int i1 = -1; + int i2; ConfigurationSection section = this; while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) { String node = path.substring(i2, i1); diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java index dcdec3c34..ff132d4f5 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfiguration.java @@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets; /** * This is a base class for all File based implementations of {@link - * Configuration} + * Configuration}. */ public abstract class FileConfiguration extends MemoryConfiguration { @@ -39,18 +39,17 @@ public abstract class FileConfiguration extends MemoryConfiguration { /** * Saves this {@link FileConfiguration} to the specified location. - *

- * If the file does not exist, it will be created. If already exists, it + * + *

If the file does not exist, it will be created. If already exists, it * will be overwritten. If it cannot be overwritten or created, an * exception will be thrown. - *

- * This method will save using the system default encoding, or possibly + * + *

This method will save using the system default encoding, or possibly * using UTF8. * * @param file File to save to. * @throws IOException Thrown when the given file cannot be written to for * any reason. - * @throws IllegalArgumentException Thrown when file is null. */ public void save(File file) throws IOException { file.getParentFile().mkdirs(); @@ -71,14 +70,13 @@ public abstract class FileConfiguration extends MemoryConfiguration { /** * Loads this {@link FileConfiguration} from the specified location. - *

- * All the values contained within this configuration will be removed, + * + *

All the values contained within this configuration will be removed, * leaving only settings and defaults, and the new values will be loaded * from the given file. - *

- * If the file cannot be loaded for any reason, an exception will be + * + *

If the file cannot be loaded for any reason, an exception will be * thrown. - *

* * @param file File to load from. * @throws FileNotFoundException Thrown when the given file cannot be @@ -100,8 +98,8 @@ public abstract class FileConfiguration extends MemoryConfiguration { /** * Loads this {@link FileConfiguration} from the specified reader. - *

- * All the values contained within this configuration will be removed, + * + *

All the values contained within this configuration will be removed, * leaving only settings and defaults, and the new values will be loaded * from the given stream. * @@ -109,7 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration { * @throws IOException thrown when underlying reader throws an IOException * @throws InvalidConfigurationException thrown when the reader does not * represent a valid Configuration - * @throws IllegalArgumentException thrown when reader is null */ public void load(Reader reader) throws IOException, InvalidConfigurationException { @@ -129,12 +126,12 @@ public abstract class FileConfiguration extends MemoryConfiguration { /** * Loads this {@link FileConfiguration} from the specified location. - *

- * All the values contained within this configuration will be removed, + * + *

All the values contained within this configuration will be removed, * leaving only settings and defaults, and the new values will be loaded * from the given file. - *

- * If the file cannot be loaded for any reason, an exception will be + * + *

If the file cannot be loaded for any reason, an exception will be * thrown. * * @param file File to load from. @@ -156,25 +153,24 @@ public abstract class FileConfiguration extends MemoryConfiguration { /** * Loads this {@link FileConfiguration} from the specified string, as * opposed to from file. - *

- * All the values contained within this configuration will be removed, + * + *

All the values contained within this configuration will be removed, * leaving only settings and defaults, and the new values will be loaded * from the given string. - *

- * If the string is invalid in any way, an exception will be thrown. + * + *

If the string is invalid in any way, an exception will be thrown. * * @param contents Contents of a Configuration to load. * @throws InvalidConfigurationException Thrown if the specified string is * invalid. - * @throws IllegalArgumentException Thrown if contents is null. */ public abstract void loadFromString(String contents) throws InvalidConfigurationException; /** * Compiles the header for this {@link FileConfiguration} and returns the * result. - *

- * This will use the header from {@link #options()} -> {@link + * + *

This will use the header from {@link #options()} -> {@link * FileConfigurationOptions#header()}, respecting the rules of {@link * FileConfigurationOptions#copyHeader()} if set. * diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java index 01eb1bf48..d99eab2da 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/FileConfigurationOptions.java @@ -6,13 +6,13 @@ import com.intellectualcrafters.configuration.MemoryConfigurationOptions; /** * Various settings for controlling the input and output of a {@link - * FileConfiguration} + * FileConfiguration}. */ public class FileConfigurationOptions extends MemoryConfigurationOptions { private String header = null; private boolean copyHeader = true; - protected FileConfigurationOptions(final MemoryConfiguration configuration) { + protected FileConfigurationOptions(MemoryConfiguration configuration) { super(configuration); } @@ -22,28 +22,28 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { } @Override - public FileConfigurationOptions copyDefaults(final boolean value) { + public FileConfigurationOptions copyDefaults(boolean value) { super.copyDefaults(value); return this; } @Override - public FileConfigurationOptions pathSeparator(final char value) { + public FileConfigurationOptions pathSeparator(char value) { super.pathSeparator(value); return this; } /** * Gets the header that will be applied to the top of the saved output. - *

- * This header will be commented out and applied directly at the top of + * + *

This header will be commented out and applied directly at the top of * the generated output of the {@link FileConfiguration}. It is not * required to include a newline at the end of the header as it will * automatically be applied, but you may include one if you wish for extra * spacing. - *

- * Null is a valid value which will indicate that no header is to be - * applied. The default value is null. + * + *

null is a valid value which will indicate that no header] + * is to be applied. The default value is null. * * @return Header */ @@ -53,39 +53,38 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { /** * Sets the header that will be applied to the top of the saved output. - *

- * This header will be commented out and applied directly at the top of + * + *

This header will be commented out and applied directly at the top of * the generated output of the {@link FileConfiguration}. It is not * required to include a newline at the end of the header as it will * automatically be applied, but you may include one if you wish for extra * spacing. - *

- * Null is a valid value which will indicate that no header is to be - * applied. + * + *

null is a valid value which will indicate that no header + * is to be applied. * * @param value New header * @return This object, for chaining */ - public FileConfigurationOptions header(final String value) { + public FileConfigurationOptions header(String value) { header = value; return this; } /** * Gets whether or not the header should be copied from a default source. - *

- * If this is true, if a default {@link FileConfiguration} is passed to - * {@link - * FileConfiguration#setDefaults(Configuration)} + * + *

If this is true, if a default {@link FileConfiguration} is passed to + * {@link FileConfiguration#setDefaults(Configuration)} * then upon saving it will use the header from that config, instead of * the one provided here. - *

- * If no default is set on the configuration, or the default is not of + * + *

If no default is set on the configuration, or the default is not of * type FileConfiguration, or that config has no header ({@link #header()} * returns null) then the header specified in this configuration will be * used. - *

- * Defaults to true. + * + *

Defaults to true. * * @return Whether or not to copy the header */ @@ -95,24 +94,23 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions { /** * Sets whether or not the header should be copied from a default source. - *

- * If this is true, if a default {@link FileConfiguration} is passed to - * {@link - * FileConfiguration#setDefaults(Configuration)} + * + *

If this is true, if a default {@link FileConfiguration} is passed to + * {@link FileConfiguration#setDefaults(Configuration)} * then upon saving it will use the header from that config, instead of * the one provided here. - *

- * If no default is set on the configuration, or the default is not of + * + *

If no default is set on the configuration, or the default is not of * type FileConfiguration, or that config has no header ({@link #header()} * returns null) then the header specified in this configuration will be * used. - *

- * Defaults to true. + * + *

Defaults to true. * * @param value Whether or not to copy the header * @return This object, for chaining */ - public FileConfigurationOptions copyHeader(final boolean value) { + public FileConfigurationOptions copyHeader(boolean value) { copyHeader = value; return this; diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java index 59ad896c1..418a9dc75 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java @@ -29,12 +29,12 @@ public class YamlConfiguration extends FileConfiguration { /** * Creates a new {@link YamlConfiguration}, loading from the given file. - *

- * Any errors loading the Configuration will be logged and then ignored. + * + *

Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. - *

- * The encoding used may follow the system dependent default. + * + *

The encoding used may follow the system dependent default. * * @param file Input file * @return Resulting configuration @@ -45,7 +45,7 @@ public class YamlConfiguration extends FileConfiguration { throw new NullPointerException("File cannot be null"); } - final YamlConfiguration config = new YamlConfiguration(); + YamlConfiguration config = new YamlConfiguration(); try { config.load(file); @@ -62,7 +62,7 @@ public class YamlConfiguration extends FileConfiguration { PS.debug("&c============ Full stacktrace ============"); ex.printStackTrace(); PS.debug("&c========================================="); - } catch (final IOException e) { + } catch (IOException e) { e.printStackTrace(); } } @@ -72,8 +72,8 @@ public class YamlConfiguration extends FileConfiguration { /** * Creates a new {@link YamlConfiguration}, loading from the given reader. - *

- * Any errors loading the Configuration will be logged and then ignored. + * + *

Any errors loading the Configuration will be logged and then ignored. * If the specified input is not a valid config, a blank config will be * returned. * @@ -81,16 +81,16 @@ public class YamlConfiguration extends FileConfiguration { * @return resulting configuration * @throws IllegalArgumentException Thrown if stream is null */ - public static YamlConfiguration loadConfiguration(final Reader reader) { + public static YamlConfiguration loadConfiguration(Reader reader) { if (reader == null) { throw new NullPointerException("Reader cannot be null"); } - final YamlConfiguration config = new YamlConfiguration(); + YamlConfiguration config = new YamlConfiguration(); try { config.load(reader); - } catch (final IOException | InvalidConfigurationException ex) { + } catch (IOException | InvalidConfigurationException ex) { PS.debug("Cannot load configuration from stream"); ex.printStackTrace(); } @@ -104,7 +104,7 @@ public class YamlConfiguration extends FileConfiguration { yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - final String header = buildHeader(); + String header = buildHeader(); String dump = yaml.dump(getValues(false)); if (dump.equals(BLANK_CONFIG)) { @@ -115,7 +115,7 @@ public class YamlConfiguration extends FileConfiguration { } @Override - public void loadFromString(final String contents) throws InvalidConfigurationException { + public void loadFromString(String contents) throws InvalidConfigurationException { if (contents == null) { throw new NullPointerException("Contents cannot be null"); } @@ -123,13 +123,13 @@ public class YamlConfiguration extends FileConfiguration { Map input; try { input = (Map) yaml.load(contents); - } catch (final YAMLException e) { + } catch (YAMLException e) { throw new InvalidConfigurationException(e); - } catch (final ClassCastException ignored) { + } catch (ClassCastException ignored) { throw new InvalidConfigurationException("Top level is not a Map."); } - final String header = parseHeader(contents); + String header = parseHeader(contents); if (!header.isEmpty()) { options().header(header); } @@ -139,10 +139,10 @@ public class YamlConfiguration extends FileConfiguration { } } - protected void convertMapsToSections(final Map input, final ConfigurationSection section) { - for (final Map.Entry entry : input.entrySet()) { - final String key = entry.getKey().toString(); - final Object value = entry.getValue(); + protected void convertMapsToSections(Map input, ConfigurationSection section) { + for (Map.Entry entry : input.entrySet()) { + String key = entry.getKey().toString(); + Object value = entry.getValue(); if (value instanceof Map) { convertMapsToSections((Map) value, section.createSection(key)); @@ -152,14 +152,14 @@ public class YamlConfiguration extends FileConfiguration { } } - protected String parseHeader(final String input) { - final String[] lines = input.split("\r?\n", -1); - final StringBuilder result = new StringBuilder(); + protected String parseHeader(String input) { + String[] lines = input.split("\r?\n", -1); + StringBuilder result = new StringBuilder(); boolean readingHeader = true; boolean foundHeader = false; for (int i = 0; (i < lines.length) && readingHeader; i++) { - final String line = lines[i]; + String line = lines[i]; if (line.startsWith(COMMENT_PREFIX)) { if (i > 0) { @@ -183,14 +183,14 @@ public class YamlConfiguration extends FileConfiguration { @Override protected String buildHeader() { - final String header = options().header(); + String header = options().header(); if (options().copyHeader()) { - final Configuration def = getDefaults(); + Configuration def = getDefaults(); if (def instanceof FileConfiguration) { - final FileConfiguration fileDefaults = (FileConfiguration) def; - final String defaultsHeader = fileDefaults.buildHeader(); + FileConfiguration fileDefaults = (FileConfiguration) def; + String defaultsHeader = fileDefaults.buildHeader(); if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) { return defaultsHeader; @@ -202,8 +202,8 @@ public class YamlConfiguration extends FileConfiguration { return ""; } - final StringBuilder builder = new StringBuilder(); - final String[] lines = header.split("\r?\n", -1); + StringBuilder builder = new StringBuilder(); + String[] lines = header.split("\r?\n", -1); boolean startedHeader = false; for (int i = lines.length - 1; i >= 0; i--) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index aeacc6a88..205677391 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.block.QueueProvider; + import java.io.File; import java.util.List; @@ -51,17 +52,23 @@ public interface IPlotMain extends ILogger { * Disable the implementation. * *

    - *
  • If a full disable isn't feasibly, just disable what it can.
  • + *
  • If a full disable isn't feasibly, just disable what it can. *
*/ void disable(); /** * Get the version of the PlotSquared being used. - * @return + * @return the plugin version */ int[] getPluginVersion(); + /** + * Get the version of the PlotSquared being used as a string. + * @return the plugin version as a string + */ + String getPluginVersionString(); + /** * Get the version of Minecraft that is running. * @return @@ -231,7 +238,7 @@ public interface IPlotMain extends ILogger { /** * Get the name of the server. - * @return The server name + * @return the server name */ String getServerName(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/Updater.java b/Core/src/main/java/com/intellectualcrafters/plot/Updater.java index f7406c9ee..c0005876d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/Updater.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/Updater.java @@ -1,5 +1,7 @@ package com.intellectualcrafters.plot; +import static com.intellectualcrafters.plot.PS.log; + import com.intellectualcrafters.json.JSONArray; import com.intellectualcrafters.json.JSONObject; import com.intellectualcrafters.plot.util.HttpUtil; @@ -7,8 +9,7 @@ import com.intellectualcrafters.plot.util.StringMan; import java.net.MalformedURLException; import java.net.URL; - -import static com.intellectualcrafters.plot.PS.log; +import java.util.Arrays; public class Updater { @@ -31,8 +32,10 @@ public class Updater { } // If current version >= update if (PS.get().checkVersion(PS.get().getVersion(), version)) { - PS.debug("&7PlotSquared is already up to date!"); - return null; + if (!PS.get().IMP.getPluginVersionString().contains("-SNAPSHOT") || !Arrays.equals(PS.get().getVersion(), version)) { + PS.debug("&7PlotSquared is already up to date!"); + return null; + } } log("&6PlotSquared " + StringMan.join(split, ".") + " is available:"); log("&8 - &3Use: &7/plot update"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 691ef2499..1912df3fb 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.CommandDeclaration; + import java.util.Set; @CommandDeclaration( @@ -43,7 +44,9 @@ public class Buy extends Command { Set plots = plot.getConnectedPlots(); checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS); Optional flag = plot.getFlag(Flags.PRICE); - checkTrue(flag.isPresent(), C.NOT_FOR_SALE); + if (!flag.isPresent()) { + throw new CommandException(C.NOT_FOR_SALE); + } final double price = flag.get(); checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT); player.withdraw(price); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index d558326e2..0d91604ba 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1583,7 +1583,7 @@ public class SQLManager implements AbstractDB { } /** - * Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap + * Load all plots, helpers, denied, trusted, and every setting from DB into a {@link HashMap}. */ @Override public HashMap> getPlots() { @@ -2560,9 +2560,7 @@ public class SQLManager implements AbstractDB { } set.add(cluster); } - /* - * Getting helpers - */ + //Getting helpers resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`"); while (resultSet.next()) { id = resultSet.getInt("cluster_id"); @@ -2579,9 +2577,7 @@ public class SQLManager implements AbstractDB { PS.debug("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry."); } } - /* - * Getting invited - */ + // Getting invited resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`"); while (resultSet.next()) { id = resultSet.getInt("cluster_id"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 41ca264ab..aa8154feb 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -213,7 +213,7 @@ public class FlagManager { /** * Removes a flag from a certain plot. - * @param plot the plot to remove the flag from + * @param origin the plot to remove the flag from * @param id the flag to remove * @return true if the plot contained the flag and was removed successfully */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index 4c8064435..ecb6b5b1d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -21,6 +21,7 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.intellectualcrafters.plot.util.expiry.PlotAnalysis; + import java.io.File; import java.util.ArrayDeque; import java.util.ArrayList; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java index 3d09a95d4..56aa130d7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java @@ -34,7 +34,7 @@ public class ConsolePlayer extends PlotPlayer { @Override public Location getLocation() { - return this.getMeta("location"); + return this.getMeta("location"); } @Override @@ -110,14 +110,14 @@ public class ConsolePlayer extends PlotPlayer { @Override public void setTime(long time) {} - @Override - public void setFlight(boolean fly) {} - @Override public boolean getFlight() { return true; } + @Override + public void setFlight(boolean fly) {} + @Override public void playMusic(Location location, int id) {} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index d9bb65fe5..aff675458 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.area.QuadMap; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.LocalBlockQueue; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -91,10 +92,6 @@ public abstract class PlotArea { this.worldhash = worldName.hashCode(); } - public LocalBlockQueue getQueue(boolean autoQueue) { - return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue); - } - /** * Create a new PlotArea object with no functionality/information. * - Mainly used during startup before worlds are created as a temporary object @@ -106,10 +103,16 @@ public abstract class PlotArea { @Override public void loadConfiguration(ConfigurationSection config) {} @Override - public ConfigurationNode[] getSettingNodes() {return null;} + public ConfigurationNode[] getSettingNodes() { + return null; + } }; } + public LocalBlockQueue getQueue(boolean autoQueue) { + return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue); + } + /** * Returns the region for this PlotArea or a RegionWrapper encompassing * the whole world if none exists. @@ -142,7 +145,7 @@ public abstract class PlotArea { /** * Returns the minimum value of a {@link PlotId}. - * @return + * @return the minimum value for a {@link PlotId} */ public PlotId getMin() { return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min; @@ -150,7 +153,7 @@ public abstract class PlotArea { /** * Returns the max PlotId. - * @return + * @return the maximum value for a {@link PlotId} */ public PlotId getMax() { return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max; @@ -159,7 +162,7 @@ public abstract class PlotArea { /** * Get the implementation independent generator for this area. * - * @return + * @return the {@link IndependentPlotGenerator} */ public IndependentPlotGenerator getGenerator() { return this.generator; @@ -183,8 +186,8 @@ public abstract class PlotArea { /** * Check if a PlotArea is compatible (move/copy etc). - * @param plotArea - * @return + * @param plotArea the {@code PlotArea} to compare + * @return true if both areas are compatible */ public boolean isCompatible(PlotArea plotArea) { ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds"); @@ -303,7 +306,7 @@ public abstract class PlotArea { public abstract void loadConfiguration(ConfigurationSection config); /** - * Saving core PlotArea settings + * Saving core PlotArea settings. * * @param config Configuration Section */ @@ -381,9 +384,9 @@ public abstract class PlotArea { public abstract ConfigurationNode[] getSettingNodes(); /** - * Get the Plot at a location. - * @param location - * @return Plot + * Gets the {@code Plot} at a location. + * @param location the location + * @return the {@code Plot} or null if none exists */ public Plot getPlotAbs(Location location) { PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ()); @@ -394,8 +397,8 @@ public abstract class PlotArea { } /** - * Get the base plot at a location. - * @param location + * Gets the base plot at a location. + * @param location the location * @return base Plot */ public Plot getPlot(Location location) { @@ -407,9 +410,9 @@ public abstract class PlotArea { } /** - * Get the base owned plot at a location. - * @param location - * @return base Plot or null + * Get the owned base plot at a location. + * @param location the location + * @return the base plot or null */ public Plot getOwnedPlot(Location location) { PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ()); @@ -422,7 +425,7 @@ public abstract class PlotArea { /** * Get the owned plot at a location. - * @param location + * @param location the location * @return Plot or null */ public Plot getOwnedPlotAbs(Location location) { @@ -435,8 +438,8 @@ public abstract class PlotArea { /** * Get the owned Plot at a PlotId. - * @param id - * @return Plot or null + * @param id the {@code PlotId} + * @return the plot or null */ public Plot getOwnedPlotAbs(PlotId id) { return this.plots.get(id); @@ -473,8 +476,8 @@ public abstract class PlotArea { return myPlots; } - public Set getPlots(final UUID uuid) { - final HashSet myplots = new HashSet<>(); + public Set getPlots(UUID uuid) { + HashSet myplots = new HashSet<>(); for (Plot plot : getPlots()) { if (plot.isBasePlot()) { if (plot.isOwner(uuid)) { @@ -488,11 +491,19 @@ public abstract class PlotArea { public Set getPlots(PlotPlayer player) { return getPlots(player.getUUID()); } - + + /** + * A collection of the claimed plots in this {@code PlotArea}. + * @return a collection of claimed plots + */ + public Collection getPlots() { + return this.plots.values(); + } + public Set getPlotsAbs(PlotPlayer player) { return player != null ? getPlotsAbs(player.getUUID()) : new HashSet(); } - + public int getPlotCount(UUID uuid) { if (!Settings.Done.COUNTS_TOWARDS_LIMIT) { int count = 0; @@ -520,7 +531,7 @@ public abstract class PlotArea { } return plot; } - + public Plot getPlot(PlotId id) { Plot plot = getOwnedPlotAbs(id); if (plot == null) { @@ -548,7 +559,7 @@ public abstract class PlotArea { } return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null; } - + public PlotCluster getFirstIntersectingCluster(PlotId pos1, PlotId pos2) { if (this.clusters == null) { return null; @@ -564,13 +575,13 @@ public abstract class PlotArea { public PlotCluster getCluster(PlotId id) { return this.clusters != null ? this.clusters.get(id.x, id.y) : null; } - + public PlotManager getPlotManager() { return this.manager; } - + /** - * Session only plot metadata (session is until the server stops)
+ * Session only plot metadata (session is until the server stops). *
* For persistent metadata use the flag system * @see FlagManager @@ -583,7 +594,7 @@ public abstract class PlotArea { } this.meta.put(key, value); } - + /** * Get the metadata for a key
*
@@ -598,14 +609,6 @@ public abstract class PlotArea { return null; } - /** - * A collection of the claimed plots in this {@code PlotArea}. - * @return - */ - public Collection getPlots() { - return this.plots.values(); - } - public Set getBasePlots() { HashSet myPlots = new HashSet<>(getPlots()); Iterator iterator = myPlots.iterator(); @@ -662,10 +665,10 @@ public abstract class PlotArea { } /** - * Check if the plots in a selection are unowned - * @param pos1 - * @param pos2 - * @return + * Check if the plots in a selection are unowned. + * @param pos1 first corner of selection + * @param pos2 second corner of selection + * @return are plots in selection unowned */ public boolean isUnowned(PlotId pos1, PlotId pos2) { int area = (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1); @@ -706,7 +709,7 @@ public abstract class PlotArea { } /** - * Setup the plot border for a world (usually done when the world is created) + * Setup the plot border for a world (usually done when the world is created). */ public void setupBorder() { if (!this.WORLD_BORDER) { @@ -722,7 +725,7 @@ public abstract class PlotArea { } /** - * Delete the metadata for a key
+ * Delete the metadata for a key. * - metadata is session only * - deleting other plugin's metadata may cause issues * @param key @@ -819,11 +822,11 @@ public abstract class PlotArea { } /** - * Get a set of owned plots within a selection (chooses the best algorithm based on selection size.
+ * Get a set of owned plots within a selection (chooses the best algorithm based on selection size. * i.e. A selection of billions of plots will work fine - * @param pos1 - * @param pos2 - * @return + * @param pos1 first corner of selection + * @param pos2 second corner of selection + * @return the plots in the selection which are owned */ public HashSet getPlotSelectionOwned(PlotId pos1, PlotId pos2) { int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 920960ac0..fde9b5b84 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -116,7 +116,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { * @return the plot the player is standing on or null if standing on a road or not in a {@link PlotArea} */ public Plot getCurrentPlot() { - Plot value = (Plot) getMeta("lastplot"); + Plot value = getMeta("lastplot"); if (value == null && !Settings.Enabled_Components.EVENTS) { return getLocation().getPlot(); } @@ -248,7 +248,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { * * @return UUID */ - public abstract UUID getUUID(); + @Override public abstract UUID getUUID(); public boolean canTeleport(Location loc) { Location current = getLocationFull(); @@ -285,7 +285,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { /** - * Retrieves the player attribute. + * Retrieves t player attribute. * * @param key * @return the attribute will be either true or false @@ -306,7 +306,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { } /** - * Set the player's local weather. + * Sets the local weather for this Player. * @param weather the weather visible to the player */ public abstract void setWeather(PlotWeather weather); @@ -329,14 +329,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { */ public abstract void setTime(long time); + public abstract boolean getFlight(); + /** * Set the player's fly mode. * @param fly if the player can fly */ public abstract void setFlight(boolean fly); - public abstract boolean getFlight(); - /** * Play music at a location for the player. * @param location where to play the music @@ -464,7 +464,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { public abstract void stopSpectating(); /** - * The amount of money this player has + * The amount of money this Player has. * @return */ public double getMoney() { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 3622067a3..aaa9676d2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; + import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -702,11 +703,11 @@ public class MainUtil { expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l)); } } -// } else if (ExpireManager.IMP != null) { -// long timestamp = ExpireManager.IMP.getTimestamp(plot.owner); -// long compared = System.currentTimeMillis() - timestamp; -// long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared); -// expires = String.format("%d days", l); + //} else if (ExpireManager.IMP != null) { + //long timestamp = ExpireManager.IMP.getTimestamp(plot.owner); + //long compared = System.currentTimeMillis() - timestamp; + //long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared); + //expires = String.format("%d days", l); } } } else { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MathMan.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MathMan.java index eddd75621..ff06178b6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MathMan.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MathMan.java @@ -9,19 +9,7 @@ public class MathMan { private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT); private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1); private static final float[] atan2 = new float[ATAN2_COUNT]; - - static { - for (int i = 0; i < ATAN2_DIM; i++) { - for (int j = 0; j < ATAN2_DIM; j++) { - float x0 = (float) i / ATAN2_DIM; - float y0 = (float) j / ATAN2_DIM; - - atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0); - } - } - } - - private final static int[] table = { + private static final int[] table = { 0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57, 59, 61, 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 81, 83, 84, 86, 87, 89, 90, 91, 93, 94, 96, 97, 98, 99, 101, 102, @@ -43,6 +31,17 @@ public class MathMan { 253, 254, 254, 255 }; + static { + for (int i = 0; i < ATAN2_DIM; i++) { + for (int j = 0; j < ATAN2_DIM; j++) { + float x0 = (float) i / ATAN2_DIM; + float y0 = (float) j / ATAN2_DIM; + + atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0); + } + } + } + public static long pairInt(int x, int y) { return (((long)x) << 32) | (y & 0xffffffffL); } @@ -191,7 +190,8 @@ public class MathMan { } public static final float atan2(float y, float x) { - float add, mul; + float add; + float mul; if (x < 0.0f) { if (y < 0.0f) { @@ -229,7 +229,7 @@ public class MathMan { } public static double sqrtApprox(double d) { - return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61)); + return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1L << 52)) >> 1) + (1L << 61)); } public static float invSqrt(float x) { @@ -302,7 +302,7 @@ public class MathMan { return x % y; } - public static boolean isPowerOfTwo(int x) { - return (x & (x - 1)) == 0; + public static boolean isPowerOfTwo(int number) { + return (number & (number - 1)) == 0; } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index a627a83d7..0ceef43dc 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -51,13 +51,6 @@ 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 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; import org.slf4j.Logger; import org.spongepowered.api.Game; import org.spongepowered.api.Server; @@ -74,6 +67,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.3.3") public class SpongeMain implements IPlotMain { @@ -165,6 +166,10 @@ public class SpongeMain implements IPlotMain { return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0}; } + @Override public String getPluginVersionString() { + return this.plugin.getVersion().orElse(""); + } + @Override public int[] getServerVersion() { PS.log("Checking minecraft version: Sponge: "); 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 fa8d13584..cd44889ee 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -443,7 +443,7 @@ public class MainListener { public void onBlockBreak(ChangeBlockEvent.Break event) { Player player = SpongeUtil.getCause(event.getCause(), Player.class); if (player == null) { -// SpongeUtil.printCause("break", event.getCause()); + //SpongeUtil.printCause("break", event.getCause()); return; } PlotPlayer pp = SpongeUtil.getPlayer(player); @@ -486,36 +486,29 @@ public class MainListener { } } } - event.filter(new Predicate>() { - - @Override - public boolean test(org.spongepowered.api.world.Location l) { - Location loc = SpongeUtil.getLocation(worldName, l); - Plot plot = loc.getPlot(); - if (plot == null) { - if (loc.getPlotAbs() == null) { - return true; - } - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD); - } - if (!plot.hasOwner()) { - if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { - return true; - } - MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED); - return false; - } - if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) { + event.filter(l -> { + Location loc1 = SpongeUtil.getLocation(worldName, l); + Plot plot1 = loc1.getPlot(); + if (plot1 == null) { + return loc1.getPlotAbs() == null || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD); + } + if (!plot1.hasOwner()) { + if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) { return true; - } else { - com.google.common.base.Optional> destroy = plot.getFlag(Flags.BREAK); - BlockState state = l.getBlock(); - if (destroy.isPresent() && destroy.get().contains(SpongeUtil.getPlotBlock(state))) { - return true; - } - MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER); - return false; } + MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED); + return false; + } + if (plot1.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) { + return true; + } else { + com.google.common.base.Optional> destroy = plot1.getFlag(Flags.BREAK); + BlockState state = l.getBlock(); + if (destroy.isPresent() && destroy.get().contains(SpongeUtil.getPlotBlock(state))) { + return true; + } + MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER); + return false; } }); } @@ -524,7 +517,7 @@ public class MainListener { public void onBlockPlace(ChangeBlockEvent.Place event) { Player player = SpongeUtil.getCause(event.getCause(), Player.class); if (player == null) { -// SpongeUtil.printCause("place", event.getCause()); + //SpongeUtil.printCause("place", event.getCause()); return; } PlotPlayer pp = SpongeUtil.getPlayer(player); @@ -552,9 +545,9 @@ public class MainListener { return; } else { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); - com.google.common.base.Optional> BUILD = plot.getFlag(Flags.PLACE); + com.google.common.base.Optional> place = plot.getFlag(Flags.PLACE); BlockState state = pos.getState(); - if (!BUILD.isPresent() || !BUILD.get().contains(SpongeUtil.getPlotBlock(state))) { + if (!place.isPresent() || !place.get().contains(SpongeUtil.getPlotBlock(state))) { event.setCancelled(true); return; } @@ -575,10 +568,7 @@ public class MainListener { Location loc = SpongeUtil.getLocation(worldName, l); Plot plot = loc.getPlot(); if (plot == null) { - if (loc.getPlotAbs() == null) { - return true; - } - return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD); + return loc.getPlotAbs() == null || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD); } if (!plot.hasOwner()) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) { @@ -590,9 +580,9 @@ public class MainListener { if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) { return true; } else { - com.google.common.base.Optional> build = plot.getFlag(Flags.PLACE); + com.google.common.base.Optional> place = plot.getFlag(Flags.PLACE); BlockState state = l.getBlock(); - if (build.isPresent() && build.get().contains(SpongeUtil.getPlotBlock(state))) { + if (place.isPresent() && place.get().contains(SpongeUtil.getPlotBlock(state))) { return true; } MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); @@ -627,12 +617,7 @@ public class MainListener { // Delayed // Async - TaskManager.runTaskLaterAsync(new Runnable() { - @Override - public void run() { - EventUtil.manager.doJoinTask(pp); - } - }, 20); + TaskManager.runTaskLaterAsync(() -> EventUtil.manager.doJoinTask(pp), 20); } @Listener 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 9a306993f..8bc5fd9e4 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -74,7 +74,7 @@ public class SpongePlayer extends PlotPlayer { @Override public void sendMessage(String message) { - if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.getMeta("lastMessageTime") > 5000)) { + if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.getMeta("lastMessageTime") > 5000)) { setMeta("lastMessage", message); setMeta("lastMessageTime", System.currentTimeMillis()); this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message)); @@ -162,23 +162,21 @@ public class SpongePlayer extends PlotPlayer { @Override public void setTime(long time) { - // TODO Auto-generated method stub - if (time != Long.MAX_VALUE) {} else {} throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } - @Override - public void setFlight(boolean fly) { - this.player.offer(Keys.IS_FLYING, fly); - this.player.offer(Keys.CAN_FLY, fly); - } - @Override public boolean getFlight() { Optional flying = player.get(Keys.CAN_FLY); return flying.isPresent() && flying.get(); } + @Override + public void setFlight(boolean fly) { + this.player.offer(Keys.IS_FLYING, fly); + this.player.offer(Keys.CAN_FLY, fly); + } + @Override public void playMusic(Location location, int id) { switch (id) { diff --git a/build.gradle b/build.gradle index 7d3156f77..9c1ebc179 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ ext { git = Grgit.open() revision = "-${git.head().abbreviatedId}" } -version = "3.4.3${revision}" +version = "3.4.4-SNAPSHOT;${revision}" description = """PlotSquared""" subprojects { @@ -31,6 +31,8 @@ subprojects { dependencies { compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') { exclude(module: 'bukkit-classloader-check') + exclude(module: 'mockito-core') + exclude(module: 'dummypermscompat') } compile 'com.google.guava:guava:10.0' }