Updates to docs, code style tweaks, and some code optimizations

This commit is contained in:
MattBDev 2016-06-23 20:12:17 -04:00
parent b587b430b8
commit 5b9dc59abf
30 changed files with 729 additions and 706 deletions

View File

@ -20,17 +20,18 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitUtil; 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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; 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. * 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) { 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 world the world the plot is located in
* @param x The PlotID x coordinate * @param x The PlotID x coordinate
@ -617,7 +618,7 @@ public class PlotAPI {
} }
/** /**
* Get the PlotSquared class. * Gets the PlotSquared class.
* *
* @return 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 world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plot count * @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 world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plots * @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 * @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. * will provide useful functions relating to players.
* *
* @see PlotPlayer#wrap(Object) * @see PlotPlayer#wrap(Object)

View File

@ -71,12 +71,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.WorldEdit; 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.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -92,6 +86,13 @@ import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; 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 final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public static WorldEdit worldEdit; public static WorldEdit worldEdit;
@ -113,7 +114,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
e.printStackTrace(); e.printStackTrace();
PS.debug(StringMan.getString(Bukkit.getBukkitVersion())); PS.debug(StringMan.getString(Bukkit.getBukkitVersion()));
PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\."))); PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
return new int[]{1, 9, 2}; return new int[]{1, 10, 0};
} }
} }
return this.version; 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])}; return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
} }
@Override public String getPluginVersionString() {
return getDescription().getVersion();
}
@Override @Override
public void registerCommands() { public void registerCommands() {
BukkitCommand bukkitCommand = new BukkitCommand(); BukkitCommand bukkitCommand = new BukkitCommand();
@ -275,6 +280,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case FALLING_BLOCK: case FALLING_BLOCK:
// managed elsewhere // managed elsewhere
continue; continue;
case POLAR_BEAR:
case BAT: case BAT:
case BLAZE: case BLAZE:
case CAVE_SPIDER: case CAVE_SPIDER:

View File

@ -18,280 +18,300 @@ import java.util.Map;
*/ */
public abstract class TextualComponent implements Cloneable { public abstract class TextualComponent implements Cloneable {
static { static {
ConfigurationSerialization.registerClass(TextualComponent.ArbitraryTextTypeComponent.class); ConfigurationSerialization.registerClass(TextualComponent.ArbitraryTextTypeComponent.class);
ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class); ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class);
} }
@Override static TextualComponent deserialize(Map<String, Object> map) {
public String toString() { if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) {
return getReadableString(); // 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 null;
* @return The JSON key used to represent text components of this type. }
*/
public abstract String getKey();
/** static boolean isTextKey(String key) {
* @return A readable String return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector");
*/ }
public abstract String getReadableString();
/** static boolean isTranslatableText(TextualComponent component) {
* Clones a textual component instance. return component instanceof ComplexTextTypeComponent && component.getKey().equals("translate");
* 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;
/** /**
* Writes the text data represented by this textual component to the specified JSON writer object. * Create a textual component representing a string literal.
* A new object within the writer is not started. *
* * <p>This is the default type of textual component when a single string
* @param writer The object to which to write the JSON data. * literal is given to a method.
* @throws IOException If an error occurs while writing to the stream. *
*/ * @param textValue The text which will be represented.
public abstract void writeJson(JsonWriter writer) throws IOException; * @return The text component representing the specified literal text.
*/
public static TextualComponent rawText(String textValue) {
return new ArbitraryTextTypeComponent("text", textValue);
}
static TextualComponent deserialize(Map<String, Object> map) { /**
if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) { * Create a textual component representing a localized string.
// Arbitrary text component * The client will see this text component as their localized version of the specified string <em>key</em>, which can be overridden by a
return ArbitraryTextTypeComponent.deserialize(map); * resource pack.
} else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) { * <p>
// Complex JSON object * If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to
return ComplexTextTypeComponent.deserialize(map); * the client.
} * </p>
*
* @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.
* <p>
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
* </p>
*
* @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.
*
* <p><b>This method is currently guaranteed to throw an {@code UnsupportedOperationException}
* as it is only supported on snapshot clients.</b>
*
* @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 <em>not</em> 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
/** return new ComplexTextTypeComponent("score", ImmutableMap.<String, String>builder()
* Internal class used to represent all types of text components. .put("name", playerName)
* Exception validating done is on keys and values. .put("objective", scoreboardObjective)
*/ .build());
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable { }
public ArbitraryTextTypeComponent(String key, String value) { /**
setKey(key); * Create a textual component representing a player name, retrievable by using a standard minecraft selector.
setValue(value); * The client will see the players or entities captured by the specified selector as the text represented by this component.
} * <p>
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
* </p>
*
* @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 return new ArbitraryTextTypeComponent("selector", selector);
public String getKey() { }
return _key;
}
public void setKey(String key) { @Override
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified."); public String toString() {
_key = key; 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."); * @return A readable String
_value = value; */
} 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 { * Writes the text data represented by this textual component to the specified JSON writer object.
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone * A new object within the writer is not started.
return new ArbitraryTextTypeComponent(getKey(), getValue()); *
} * @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 { * Internal class used to represent all types of text components.
writer.name(getKey()).value(getValue()); * Exception validating done is on keys and values.
} */
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
@SuppressWarnings("serial") private String key;
public Map<String, Object> serialize() { private String value;
return new HashMap<String, Object>() {{
put("key", getKey());
put("value", getValue());
}};
}
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) { public ArbitraryTextTypeComponent(String key, String value) {
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString()); setKey(key);
} setValue(value);
}
@Override public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
public String getReadableString() { return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
return getValue(); }
}
}
/** @Override
* Internal class used to represent a text component with a nested JSON value. public String getKey() {
* Exception validating done is on keys and values. return key;
*/ }
private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
public ComplexTextTypeComponent(String key, Map<String, String> values) { public void setKey(String key) {
setKey(key); Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
setValue(values); this.key = key;
} }
@Override public String getValue() {
public String getKey() { return value;
return _key; }
}
public void setKey(String key) { public void setValue(String value) {
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified."); Preconditions.checkArgument(value != null, "The value must be specified.");
_key = key; this.value = value;
} }
public Map<String, String> getValue() { @Override
return _value; 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<String, String> value) { @Override
Preconditions.checkArgument(value != null, "The value must be specified."); public void writeJson(JsonWriter writer) throws IOException {
_value = value; writer.name(getKey()).value(getValue());
} }
private String _key; @Override
private Map<String, String> _value; @SuppressWarnings("serial")
public Map<String, Object> serialize() {
return new HashMap<String, Object>() {
{
put("key", getKey());
put("value", getValue());
}
};
}
@Override @Override
public TextualComponent clone() throws CloneNotSupportedException { public String getReadableString() {
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone return getValue();
return new ComplexTextTypeComponent(getKey(), getValue()); }
} }
@Override /**
public void writeJson(JsonWriter writer) throws IOException { * Internal class used to represent a text component with a nested JSON
writer.name(getKey()); * value.
writer.beginObject(); *
for (Map.Entry<String, String> jsonPair : _value.entrySet()) { * <p>Exception validating done is on keys and values.
writer.name(jsonPair.getKey()).value(jsonPair.getValue()); */
} private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
writer.endObject();
}
@SuppressWarnings("serial") private String key;
public Map<String, Object> serialize() { private Map<String, String> value;
return new java.util.HashMap<String, Object>() {{
put("key", getKey());
for (Map.Entry<String, String> valEntry : getValue().entrySet()) {
put("value." + valEntry.getKey(), valEntry.getValue());
}
}};
}
public static ComplexTextTypeComponent deserialize(Map<String, Object> map) { public ComplexTextTypeComponent(String key, Map<String, String> values) {
String key = null; setKey(key);
Map<String, String> value = new HashMap<String, String>(); setValue(values);
for (Map.Entry<String, Object> 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);
}
@Override public static ComplexTextTypeComponent deserialize(Map<String, Object> map) {
public String getReadableString() { String key = null;
return getKey(); Map<String, String> value = new HashMap<>();
} for (Map.Entry<String, Object> 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);
}
/** @Override
* Create a textual component representing a string literal. public String getKey() {
* This is the default type of textual component when a single string literal is given to a method. return key;
* }
* @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);
}
public void setKey(String key) {
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
this.key = key;
}
/** public Map<String, String> getValue() {
* Create a textual component representing a localized string. return value;
* The client will see this text component as their localized version of the specified string <em>key</em>, which can be overridden by a resource pack. }
* <p>
* 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.
* </p>
*
* @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);
}
private static void throwUnsupportedSnapshot() { public void setValue(Map<String, String> value) {
throw new UnsupportedOperationException("This feature is only supported in snapshot releases."); Preconditions.checkArgument(value != null, "The value must be specified.");
} this.value = value;
}
/** @Override
* Create a textual component representing a scoreboard value. public TextualComponent clone() {
* The client will see their own score for the specified objective as the text represented by this component. // Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
* <p> return new ComplexTextTypeComponent(getKey(), getValue());
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b> }
* </p>
*
* @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
* Create a textual component representing a scoreboard value. public void writeJson(JsonWriter writer) throws IOException {
* The client will see the score of the specified player for the specified objective as the text represented by this component. writer.name(getKey());
* <p> writer.beginObject();
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b> for (Map.Entry<String, String> jsonPair : value.entrySet()) {
* </p> writer.name(jsonPair.getKey()).value(jsonPair.getValue());
* }
* @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. writer.endObject();
* Standard minecraft selectors (@a, @p, etc) are <em>not</em> 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
return new ComplexTextTypeComponent("score", ImmutableMap.<String, String>builder() @Override
.put("name", playerName) @SuppressWarnings("serial")
.put("objective", scoreboardObjective) public Map<String, Object> serialize() {
.build()); return new java.util.HashMap<String, Object>() {
} {
put("key", getKey());
for (Map.Entry<String, String> valEntry : getValue().entrySet()) {
put("value." + valEntry.getKey(), valEntry.getValue());
}
}
};
}
/** @Override
* Create a textual component representing a player name, retrievable by using a standard minecraft selector. public String getReadableString() {
* The client will see the players or entities captured by the specified selector as the text represented by this component. return getKey();
* <p> }
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b> }
* </p>
*
* @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);
}
} }

View File

@ -20,17 +20,18 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue; import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.block.GenChunk; 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.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator; 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<ChunkGenerator> { public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
private final GenChunk chunkSetter; private final GenChunk chunkSetter;
@ -255,7 +256,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
@Override @Override
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) { 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 // Set the chunk location
result.setChunk(new ChunkWrapper(world.getName(), cx, cz)); result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
// Set the result data // Set the result data
@ -303,7 +304,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
@Override @Override
public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid grid) { 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 // Set the chunk location
result.setChunk(new ChunkWrapper(world.getName(), cx, cz)); result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
// Set the result data // Set the result data

View File

@ -1,12 +1,12 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import com.google.common.collect.Iterables;
import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -19,9 +19,9 @@ public class ForceFieldListener implements Listener {
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) { private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer> players = new HashSet<>(); Set<PlotPlayer> 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; 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; continue;
} }
if (!plot.isAdded(plotPlayer.getUUID())) { if (!plot.isAdded(plotPlayer.getUUID())) {
@ -32,15 +32,9 @@ public class ForceFieldListener implements Listener {
} }
private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) { private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) {
if (!(entity instanceof Player)) {
continue;
}
PlotPlayer plotPlayer; PlotPlayer plotPlayer;
if ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) { if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
continue;
}
if (!plot.equals(plotPlayer.getCurrentPlot())) {
continue; continue;
} }
if (plot.isAdded(plotPlayer.getUUID())) { if (plot.isAdded(plotPlayer.getUUID())) {

View File

@ -28,16 +28,6 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType; import com.plotsquared.listener.PlayerBlockEventType;
import com.plotsquared.listener.PlotListener; 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.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -121,6 +111,17 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; 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. * Player Events involving plots.
* *
@ -279,8 +280,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (!(shooter instanceof Player)) { if (!(shooter instanceof Player)) {
return; return;
} }
ThrownPotion potion = (ThrownPotion) entity; Location l = BukkitUtil.getLocation(entity);
Location l = BukkitUtil.getLocation(potion);
if (!PS.get().hasPlotArea(l.getWorld())) { if (!PS.get().hasPlotArea(l.getWorld())) {
return; return;
} }
@ -1283,7 +1283,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void MobSpawn(CreatureSpawnEvent event) { public void creatureSpawnEvent(CreatureSpawnEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
Location location = BukkitUtil.getLocation(entity.getLocation()); Location location = BukkitUtil.getLocation(entity.getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();

View File

@ -52,7 +52,7 @@ public abstract class TitleManager {
abstract void loadClasses(); abstract void loadClasses();
/** /**
* Get title text. * Gets title text.
* *
* @return 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 * @param title Title
*/ */
@ -70,7 +70,7 @@ public abstract class TitleManager {
} }
/** /**
* Get subtitle text. * Gets the subtitle text.
* *
* @return Subtitle text * @return Subtitle text
*/ */
@ -79,7 +79,7 @@ public abstract class TitleManager {
} }
/** /**
* Set subtitle text. * Sets subtitle text.
* *
* @param subtitle 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 * @param color Chat color
*/ */
@ -97,7 +97,7 @@ public abstract class TitleManager {
} }
/** /**
* Set the subtitle color. * Sets the subtitle color.
* *
* @param color Chat 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 * @param time Time
*/ */
@ -115,7 +115,7 @@ public abstract class TitleManager {
} }
/** /**
* Set title fade out time. * Sets title fade out time.
* *
* @param time Time * @param time Time
*/ */
@ -124,7 +124,7 @@ public abstract class TitleManager {
} }
/** /**
* Set title stay time. * Sets title stay time.
* *
* @param time Time * @param time Time
*/ */
@ -133,21 +133,21 @@ public abstract class TitleManager {
} }
/** /**
* Set timings to ticks. * Sets timings to ticks.
*/ */
public final void setTimingsToTicks() { public final void setTimingsToTicks() {
this.ticks = true; this.ticks = true;
} }
/** /**
* Set timings to seconds. * Sets timings to seconds.
*/ */
public final void setTimingsToSeconds() { public final void setTimingsToSeconds() {
this.ticks = false; this.ticks = false;
} }
/** /**
* Send the title to a player. * Sends the title to a player.
* *
* @param player Player * @param player Player
* @throws IllegalArgumentException * @throws IllegalArgumentException
@ -157,18 +157,18 @@ public abstract class TitleManager {
public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException; public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
/** /**
* Broadcast the title to all players. * Broadcasts the title to all players.
* *
* @throws Exception * @throws Exception
*/ */
public final void broadcast() throws Exception { public final void broadcast() throws Exception {
for (Player p : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
send(p); send(player);
} }
} }
/** /**
* Clear the title. * Clears the title.
* *
* @param player Player * @param player Player
* @throws IllegalArgumentException * @throws IllegalArgumentException
@ -178,7 +178,7 @@ public abstract class TitleManager {
public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException; public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
/** /**
* Reset the title settings. * Resets the title settings.
* *
* @param player Player * @param player Player
* @throws IllegalArgumentException * @throws IllegalArgumentException
@ -195,7 +195,7 @@ public abstract class TitleManager {
} }
} }
final Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) { private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
int a; int a;
if (classes != null) { if (classes != null) {
a = classes.length; a = classes.length;
@ -229,7 +229,7 @@ public abstract class TitleManager {
return null; return null;
} }
final boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) { private boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
if (a.length != o.length) { if (a.length != o.length) {
return false; return false;
} }

View File

@ -2,14 +2,14 @@ package com.intellectualcrafters.configuration;
/** /**
* Various settings for controlling the input and output of a {@link * Various settings for controlling the input and output of a {@link
* Configuration} * Configuration}.
*/ */
class ConfigurationOptions { class ConfigurationOptions {
private final Configuration configuration; private final Configuration configuration;
private char pathSeparator = '.'; private char pathSeparator = '.';
private boolean copyDefaults = false; private boolean copyDefaults = false;
protected ConfigurationOptions(final Configuration configuration) { protected ConfigurationOptions(Configuration configuration) {
this.configuration = configuration; this.configuration = configuration;
} }
@ -24,9 +24,9 @@ class ConfigurationOptions {
/** /**
* Gets the char that will be used to separate {@link * Gets the char that will be used to separate {@link
* ConfigurationSection}s * ConfigurationSection}s.
* <p> *
* This value does not affect how the {@link Configuration} is stored, * <p>This value does not affect how the {@link Configuration} is stored,
* only in how you access the data. The default value is '.'. * only in how you access the data. The default value is '.'.
* *
* @return Path separator * @return Path separator
@ -37,15 +37,15 @@ class ConfigurationOptions {
/** /**
* Sets the char that will be used to separate {@link * Sets the char that will be used to separate {@link
* ConfigurationSection}s * ConfigurationSection}s.
* <p> *
* This value does not affect how the {@link Configuration} is stored, * <p>This value does not affect how the {@link Configuration} is stored,
* only in how you access the data. The default value is '.'. * only in how you access the data. The default value is '.'.
* *
* @param value Path separator * @param value Path separator
* @return This object, for chaining * @return This object, for chaining
*/ */
public ConfigurationOptions pathSeparator(final char value) { public ConfigurationOptions pathSeparator(char value) {
pathSeparator = value; pathSeparator = value;
return this; return this;
} }
@ -53,8 +53,8 @@ class ConfigurationOptions {
/** /**
* Checks if the {@link Configuration} should copy values from its default * Checks if the {@link Configuration} should copy values from its default
* {@link Configuration} directly. * {@link Configuration} directly.
* <p> *
* If this is true, all values in the default Configuration will be * <p>If this is true, all values in the default Configuration will be
* directly copied, making it impossible to distinguish between values * directly copied, making it impossible to distinguish between values
* that were set and values that are provided by default. As a result, * that were set and values that are provided by default. As a result,
* {@link ConfigurationSection#contains(String)} will always * {@link ConfigurationSection#contains(String)} will always
@ -71,8 +71,8 @@ class ConfigurationOptions {
/** /**
* Sets if the {@link Configuration} should copy values from its default * Sets if the {@link Configuration} should copy values from its default
* {@link Configuration} directly. * {@link Configuration} directly.
* <p> *
* If this is true, all values in the default Configuration will be * <p>If this is true, all values in the default Configuration will be
* directly copied, making it impossible to distinguish between values * directly copied, making it impossible to distinguish between values
* that were set and values that are provided by default. As a result, * that were set and values that are provided by default. As a result,
* {@link ConfigurationSection#contains(String)} will always * {@link ConfigurationSection#contains(String)} will always
@ -83,7 +83,7 @@ class ConfigurationOptions {
* @param value Whether or not defaults are directly copied * @param value Whether or not defaults are directly copied
* @return This object, for chaining * @return This object, for chaining
*/ */
public ConfigurationOptions copyDefaults(final boolean value) { public ConfigurationOptions copyDefaults(boolean value) {
copyDefaults = value; copyDefaults = value;
return this; return this;
} }

View File

@ -5,18 +5,18 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
* Represents a section of a {@link Configuration} * Represents a section of a {@link Configuration}.
*/ */
public interface ConfigurationSection { public interface ConfigurationSection {
/** /**
* Gets a set containing all keys in this section. * Gets a set containing all keys in this section.
* <p> *
* If deep is set to true, then this will contain all the keys within any * <p>If deep is set to true, then this will contain all the keys within any
* child {@link ConfigurationSection}s (and their children, etc). These * child {@link ConfigurationSection}s (and their children, etc). These
* will be in a valid path notation for you to use. * will be in a valid path notation for you to use.
* <p> *
* If deep is set to false, then this will contain only the keys of any * <p>If deep is set to false, then this will contain only the keys of any
* direct children, and not their own children. * direct children, and not their own children.
* *
* @param deep Whether or not to get a deep list, as opposed to a shallow * @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. * Checks if this {@link ConfigurationSection} contains the given path.
* <p> *
* If the value for the requested path does not exist but a default value * <p>If the value for the requested path does not exist but a default value
* has been specified, this will return true. * has been specified, this will return true.
* *
* @param path Path to check for existence. * @param path Path to check for existence.
* @return True if this section contains the requested path, either via * @return True if this section contains the requested path, either via
* default or being set. * default or being set.
* @throws IllegalArgumentException Thrown when path is null. * @throws IllegalArgumentException Thrown when path is <code>null</code>.
*/ */
boolean contains(String path); boolean contains(String path);
/** /**
* Checks if this {@link ConfigurationSection} has a value set for the * Checks if this {@link ConfigurationSection} has a value set for the
* given path. * given path.
* <p> *
* If the value for the requested path does not exist but a default value * <p>If the value for the requested path does not exist but a default value
* has been specified, this will still return false. * has been specified, this will still return false.
* *
* @param path Path to check for existence. * @param path Path to check for existence.
* @return True if this section contains the requested path, regardless of * @return True if this section contains the requested path, regardless of
* having a default. * having a default.
* @throws IllegalArgumentException Thrown when path is null. * @throws IllegalArgumentException Thrown when path is <code>null</code>.
*/ */
boolean isSet(String path); boolean isSet(String path);
/** /**
* Gets the path of this {@link ConfigurationSection} from its root {@link * Gets the path of this {@link ConfigurationSection} from its root {@link
* Configuration} * Configuration}.
* <p> *
* For any {@link Configuration} themselves, this will return an empty * <p>For any {@link Configuration} themselves, this will return an empty
* string. * string.
* <p> *
* If the section is no longer contained within its root for any reason, * <p>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. * such as being replaced with a different value,
* <p> * this may return <code>null</code>.
* 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()}. * <p>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 * @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 * Gets the name of this individual {@link ConfigurationSection}, in the
* path. * path.
* <p> *
* This will always be the final part of {@link #getCurrentPath()}, unless * <p>This will always be the final part of {@link #getCurrentPath()}, unless
* the section is orphaned. * the section is orphaned.
* *
* @return Name of this section * @return Name of this section
@ -99,12 +100,13 @@ public interface ConfigurationSection {
/** /**
* Gets the root {@link Configuration} that contains this {@link * Gets the root {@link Configuration} that contains this {@link
* ConfigurationSection} * ConfigurationSection}
* <p> *
* For any {@link Configuration} themselves, this will return its own * <p>For any {@link Configuration} themselves, this will return its own
* object. * object.
* <p> *
* If the section is no longer contained within its root for any reason, * <p>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. * such as being replaced with a different value,
* this may return <code>null</code>.
* *
* @return Root configuration containing this section. * @return Root configuration containing this section.
*/ */
@ -113,11 +115,13 @@ public interface ConfigurationSection {
/** /**
* Gets the parent {@link ConfigurationSection} that directly contains * Gets the parent {@link ConfigurationSection} that directly contains
* this {@link ConfigurationSection}. * this {@link ConfigurationSection}.
* <p> *
* For any {@link Configuration} themselves, this will return null. * <p>For any {@link Configuration} themselves, this will return
* <p> * <code>null</code>.
* 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. * <p>If the section is no longer contained within its parent for any reason,
* such as being replaced with a different value, this may
* return <code>null</code>.
* *
* @return Parent section containing this section. * @return Parent section containing this section.
*/ */
@ -125,10 +129,10 @@ public interface ConfigurationSection {
/** /**
* Gets the requested Object by path. * Gets the requested Object by path.
* <p> *
* If the Object does not exist but a default value has been specified, * <p>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 * 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 <code>null</code>.
* *
* @param path Path of the Object to get. * @param path Path of the Object to get.
* @return Requested Object. * @return Requested Object.
@ -138,8 +142,8 @@ public interface ConfigurationSection {
/** /**
* Gets the requested Object by path, returning a default value if not * Gets the requested Object by path, returning a default value if not
* found. * found.
* <p> *
* If the Object does not exist then the specified default value will * <p>If the Object does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}. * {@link Configuration}.
* *
@ -151,11 +155,11 @@ public interface ConfigurationSection {
/** /**
* Sets the specified path to the given value. * Sets the specified path to the given value.
* <p> *
* If value is null, the entry will be removed. Any existing entry will be * <p>If value is <code>null</code>, the entry will be removed. Any
* replaced, regardless of what the new value is. * existing entry will be replaced, regardless of what the new value is.
* <p> *
* Some implementations may have limitations on what you may store. See * <p>Some implementations may have limitations on what you may store. See
* their individual javadoc for details. No implementations should allow * their individual javadoc for details. No implementations should allow
* you to store {@link Configuration}s or {@link ConfigurationSection}s, * you to store {@link Configuration}s or {@link ConfigurationSection}s,
* please use {@link #createSection(String)} for that. * please use {@link #createSection(String)} for that.
@ -167,8 +171,8 @@ public interface ConfigurationSection {
/** /**
* Creates an empty {@link ConfigurationSection} at the specified path. * Creates an empty {@link ConfigurationSection} at the specified path.
* <p> *
* Any value that was previously set at this path will be overwritten. If * <p>Any value that was previously set at this path will be overwritten. If
* the previous value was itself a {@link ConfigurationSection}, it will * the previous value was itself a {@link ConfigurationSection}, it will
* be orphaned. * be orphaned.
* *
@ -180,8 +184,8 @@ public interface ConfigurationSection {
/** /**
* Creates a {@link ConfigurationSection} at the specified path, with * Creates a {@link ConfigurationSection} at the specified path, with
* specified values. * specified values.
* <p> *
* Any value that was previously set at this path will be overwritten. If * <p>Any value that was previously set at this path will be overwritten. If
* the previous value was itself a {@link ConfigurationSection}, it will * the previous value was itself a {@link ConfigurationSection}, it will
* be orphaned. * be orphaned.
* *
@ -195,10 +199,10 @@ public interface ConfigurationSection {
/** /**
* Gets the requested String by path. * Gets the requested String by path.
* <p> *
* If the String does not exist but a default value has been specified, * <p>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 * 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 <code>null</code>.
* *
* @param path Path of the String to get. * @param path Path of the String to get.
* @return Requested String. * @return Requested String.
@ -208,8 +212,8 @@ public interface ConfigurationSection {
/** /**
* Gets the requested String by path, returning a default value if not * Gets the requested String by path, returning a default value if not
* found. * found.
* <p> *
* If the String does not exist then the specified default value will * <p>If the String does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}. * {@link Configuration}.
* *
@ -223,10 +227,10 @@ public interface ConfigurationSection {
/** /**
* Checks if the specified path is a String. * Checks if the specified path is a String.
* *
* <p> If the path exists but is not a String, this will return false. If the * <p>If the path exists but is not a String, this will return false. If
* path does not exist, this will return false. If the path does not exist * the path does not exist, this will return false. If the path does not
* but a default value has been specified, this will check if that default * exist but a default value has been specified, this will check if that
* value is a String and return appropriately.</p> * defaultvalue is a String and return appropriately.
* *
* @param path Path of the String to check. * @param path Path of the String to check.
* @return Whether or not the specified path is a String. * @return Whether or not the specified path is a String.
@ -238,7 +242,7 @@ public interface ConfigurationSection {
* *
* <p>If the int does not exist but a default value has been specified, this * <p>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 * will return the default value. If the int does not exist and no default
* value was specified, this will return 0.</p> * value was specified, this will return 0.
* *
* @param path Path of the int to get. * @param path Path of the int to get.
* @return Requested int. * @return Requested int.
@ -250,7 +254,7 @@ public interface ConfigurationSection {
* *
* <p>If the int does not exist then the specified default value will * <p>If the int does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}.</p> * {@link Configuration}.
* *
* @param path Path of the int to get. * @param path Path of the int to get.
* @param def The default value to return if the path is not found or is * @param def The default value to return if the path is not found or is
@ -265,7 +269,7 @@ public interface ConfigurationSection {
* <p>If the path exists but is not a int, this will return false. If the * <p>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 * 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 * but a default value has been specified, this will check if that default
* value is a int and return appropriately.</p> * value is a int and return appropriately.
* *
* @param path Path of the int to check. * @param path Path of the int to check.
* @return Whether or not the specified path is an int. * @return Whether or not the specified path is an int.
@ -274,8 +278,8 @@ public interface ConfigurationSection {
/** /**
* Gets the requested boolean by path. * Gets the requested boolean by path.
* <p> *
* If the boolean does not exist but a default value has been specified, * <p>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 * this will return the default value. If the boolean does not exist and
* no default value was specified, this will return false. * 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 * Gets the requested boolean by path, returning a default value if not
* found. * found.
* <p> *
* If the boolean does not exist then the specified default value will * <p>If the boolean does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}. * {@link Configuration}.
* *
@ -301,8 +305,8 @@ public interface ConfigurationSection {
/** /**
* Checks if the specified path is a boolean. * Checks if the specified path is a boolean.
* <p> *
* If the path exists but is not a boolean, this will return false. If the * <p>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 * 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 * but a default value has been specified, this will check if that default
* value is a boolean and return appropriately. * value is a boolean and return appropriately.
@ -314,8 +318,8 @@ public interface ConfigurationSection {
/** /**
* Gets the requested double by path. * Gets the requested double by path.
* <p> *
* If the double does not exist but a default value has been specified, * <p>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 * this will return the default value. If the double does not exist and no
* default value was specified, this will return 0. * 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 * Gets the requested double by path, returning a default value if not
* found. * found.
* <p> *
* If the double does not exist then the specified default value will * <p>If the double does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}. * {@link Configuration}.
* *
@ -341,8 +345,8 @@ public interface ConfigurationSection {
/** /**
* Checks if the specified path is a double. * Checks if the specified path is a double.
* <p> *
* If the path exists but is not a double, this will return false. If the * <p>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 * 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 * but a default value has been specified, this will check if that default
* value is a double and return appropriately. * value is a double and return appropriately.
@ -354,8 +358,8 @@ public interface ConfigurationSection {
/** /**
* Gets the requested long by path. * Gets the requested long by path.
* <p> *
* If the long does not exist but a default value has been specified, this * <p>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 * will return the default value. If the long does not exist and no
* default value was specified, this will return 0. * 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 * Gets the requested long by path, returning a default value if not
* found. * found.
* <p> *
* If the long does not exist then the specified default value will * <p>If the long does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}. * {@link Configuration}.
* *
@ -381,8 +385,8 @@ public interface ConfigurationSection {
/** /**
* Checks if the specified path is a long. * Checks if the specified path is a long.
* <p> *
* If the path exists but is not a long, this will return false. If the * <p>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 * 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 * but a default value has been specified, this will check if that default
* value is a long and return appropriately. * value is a long and return appropriately.
@ -396,8 +400,8 @@ public interface ConfigurationSection {
/** /**
* Gets the requested List by path. * Gets the requested List by path.
* <p> *
* If the List does not exist but a default value has been specified, this * <p>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 * will return the default value. If the List does not exist and no
* default value was specified, this will return null. * 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 * Gets the requested List by path, returning a default value if not
* found. * found.
* <p> *
* If the List does not exist then the specified default value will * <p>If the List does not exist then the specified default value will
* returned regardless of if a default has been identified in the root * returned regardless of if a default has been identified in the root
* {@link Configuration}. * {@link Configuration}.
* *
@ -423,8 +427,8 @@ public interface ConfigurationSection {
/** /**
* Checks if the specified path is a List. * Checks if the specified path is a List.
* <p> *
* If the path exists but is not a List, this will return false. If the * <p>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 * 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 * but a default value has been specified, this will check if that default
* value is a List and return appropriately. * value is a List and return appropriately.
@ -436,12 +440,12 @@ public interface ConfigurationSection {
/** /**
* Gets the requested List of String by path. * Gets the requested List of String by path.
* <p> *
* If the List does not exist but a default value has been specified, this * <p>If the List does not exist but a default value has been specified,
* will return the default value. If the List does not exist and no * this will return the default value. If the List does not exist and no
* default value was specified, this will return an empty List. * default value was specified, this will return an empty List.
* <p> *
* This method will attempt to cast any values into a String if possible, * <p>This method will attempt to cast any values into a String if possible,
* but may miss any values out if they are not compatible. * but may miss any values out if they are not compatible.
* *
* @param path Path of the List to get. * @param path Path of the List to get.
@ -451,13 +455,13 @@ public interface ConfigurationSection {
/** /**
* Gets the requested List of Integer by path. * Gets the requested List of Integer by path.
* <p> *
* If the List does not exist but a default value has been specified, this * <p>If the List does not exist but a default value has been specified,
* will return the default value. If the List does not exist and no * this will return the default value. If the List does not exist and no
* default value was specified, this will return an empty List. * default value was specified, this will return an empty List.
* <p> *
* This method will attempt to cast any values into a Integer if possible, * <p>This method will attempt to cast any values into a Integer if
* but may miss any values out if they are not compatible. * possible, but may miss any values out if they are not compatible.
* *
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Integer. * @return Requested List of Integer.
@ -556,12 +560,10 @@ public interface ConfigurationSection {
/** /**
* Gets the requested List of Short by path. * Gets the requested List of Short by path.
* <p> * <p> 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 * will return the default value. If the List does not exist and no
* default value was specified, this will return an empty List. * default value was specified, this will return an empty List.
* <p> * <p> 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. * but may miss any values out if they are not compatible.
* *
* @param path Path of the List to get. * @param path Path of the List to get.
@ -571,13 +573,12 @@ public interface ConfigurationSection {
/** /**
* Gets the requested List of Maps by path. * Gets the requested List of Maps by path.
* <p> *
* If the List does not exist but a default value has been specified, this * <p>If the List does not exist but a default value has been specified,
* will return the default value. If the List does not exist and no * this will return the default value. If the List does not exist and no
* default value was specified, this will return an empty List. * default value was specified, this will return an empty List.
* <p> * <p>This method will attempt to cast any values into a Map if possible,
* This method will attempt to cast any values into a Map if possible, but * but may miss any values out if they are not compatible.
* may miss any values out if they are not compatible.
* *
* @param path Path of the List to get. * @param path Path of the List to get.
* @return Requested List of Maps. * @return Requested List of Maps.
@ -586,11 +587,11 @@ public interface ConfigurationSection {
/** /**
* Gets the requested ConfigurationSection by path. * Gets the requested ConfigurationSection by path.
* <p> *
* If the ConfigurationSection does not exist but a default value has been * <p>If the ConfigurationSection does not exist but a default value has
* specified, this will return the default value. If the * been specified, this will return the default value. If the
* ConfigurationSection does not exist and no default value was specified, * ConfigurationSection does not exist and no default value was specified,
* this will return null. * this will return <code>null</code>.
* *
* @param path Path of the ConfigurationSection to get. * @param path Path of the ConfigurationSection to get.
* @return Requested ConfigurationSection. * @return Requested ConfigurationSection.
@ -599,8 +600,8 @@ public interface ConfigurationSection {
/** /**
* Checks if the specified path is a ConfigurationSection. * Checks if the specified path is a ConfigurationSection.
* <p> *
* If the path exists but is not a ConfigurationSection, this will return * <p>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 * 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 * does not exist but a default value has been specified, this will check
* if that default value is a ConfigurationSection and return * if that default value is a ConfigurationSection and return
@ -614,10 +615,10 @@ public interface ConfigurationSection {
/** /**
* Gets the equivalent {@link ConfigurationSection} from the default * Gets the equivalent {@link ConfigurationSection} from the default
* {@link Configuration} defined in {@link #getRoot()}. * {@link Configuration} defined in {@link #getRoot()}.
* <p> *
* If the root contains no defaults, or the defaults doesn't contain a * <p>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 * 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 <code>null</code>.
* *
* @return Equivalent section in root configuration * @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. * Sets the default value in the root at the given path as provided.
* <p> *
* If no source {@link Configuration} was provided as a default * <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to * collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default value. * hold the new default value.
* <p>
* If value is null, the value will be removed from the default
* Configuration source.
* <p>
* 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. * <p>If value is <code>null</code>, the value will be removed from the
* @param value Value to set the default to. * default Configuration source.
* @throws IllegalArgumentException Thrown if path is null. *
* <p>If the value as returned by {@link #getDefaultSection()} is
* <code>null</code>, 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 <code>null</code>
*/ */
void addDefault(String path, Object value); void addDefault(String path, Object value);
} }

View File

@ -1,7 +1,7 @@
package com.intellectualcrafters.configuration; 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") @SuppressWarnings("serial")
public class InvalidConfigurationException extends Exception { public class InvalidConfigurationException extends Exception {
@ -18,7 +18,7 @@ public class InvalidConfigurationException extends Exception {
* *
* @param msg The details of the exception. * @param msg The details of the exception.
*/ */
public InvalidConfigurationException(final String msg) { public InvalidConfigurationException(String msg) {
super(msg); super(msg);
} }
@ -28,7 +28,7 @@ public class InvalidConfigurationException extends Exception {
* *
* @param cause The cause of the exception. * @param cause The cause of the exception.
*/ */
public InvalidConfigurationException(final Throwable cause) { public InvalidConfigurationException(Throwable cause) {
super(cause); super(cause);
} }
@ -39,7 +39,7 @@ public class InvalidConfigurationException extends Exception {
* @param cause The cause of the exception. * @param cause The cause of the exception.
* @param msg The details 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); super(msg, cause);
} }
} }

View File

@ -2,10 +2,10 @@ package com.intellectualcrafters.configuration;
/** /**
* Various settings for controlling the input and output of a {@link * Various settings for controlling the input and output of a {@link
* MemoryConfiguration} * MemoryConfiguration}.
*/ */
public class MemoryConfigurationOptions extends ConfigurationOptions { public class MemoryConfigurationOptions extends ConfigurationOptions {
protected MemoryConfigurationOptions(final MemoryConfiguration configuration) { protected MemoryConfigurationOptions(MemoryConfiguration configuration) {
super(configuration); super(configuration);
} }
@ -15,13 +15,13 @@ public class MemoryConfigurationOptions extends ConfigurationOptions {
} }
@Override @Override
public MemoryConfigurationOptions copyDefaults(final boolean value) { public MemoryConfigurationOptions copyDefaults(boolean value) {
super.copyDefaults(value); super.copyDefaults(value);
return this; return this;
} }
@Override @Override
public MemoryConfigurationOptions pathSeparator(final char value) { public MemoryConfigurationOptions pathSeparator(char value) {
super.pathSeparator(value); super.pathSeparator(value);
return this; return this;
} }

View File

@ -21,8 +21,8 @@ public class MemorySection implements ConfigurationSection {
/** /**
* Creates an empty MemorySection for use as a root {@link Configuration} * Creates an empty MemorySection for use as a root {@link Configuration}
* section. * section.
* <p> *
* Note that calling this without being yourself a {@link Configuration} * <p>Note that calling this without being yourself a {@link Configuration}
* will throw an exception! * will throw an exception!
* *
* @throws IllegalStateException Thrown if this is not a {@link * @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 * Creates a full path to the given {@link ConfigurationSection} from its
* root {@link Configuration}. * root {@link Configuration}.
* <p> *
* You may use this method for any given {@link ConfigurationSection}, not * <p>You may use this method for any given {@link ConfigurationSection}, not
* only {@link MemorySection}. * only {@link MemorySection}.
* *
* @param section Section to create a path for. * @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 * Creates a relative path to the given {@link ConfigurationSection} from
* the given relative section. * the given relative section.
* <p> *
* You may use this method for any given {@link ConfigurationSection}, not * <p>You may use this method for any given {@link ConfigurationSection}, not
* only {@link MemorySection}. * only {@link MemorySection}.
* *
* @param section Section to create a path for. * @param section Section to create a path for.
@ -292,7 +292,8 @@ public class MemorySection implements ConfigurationSection {
char separator = root.options().pathSeparator(); char separator = root.options().pathSeparator();
// i1 is the leading (higher) index // i1 is the leading (higher) index
// i2 is the trailing (lower) index // i2 is the trailing (lower) index
int i1 = -1, i2; int i1 = -1;
int i2;
ConfigurationSection section = this; ConfigurationSection section = this;
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) { while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
String node = path.substring(i2, i1); String node = path.substring(i2, i1);
@ -374,7 +375,8 @@ public class MemorySection implements ConfigurationSection {
char separator = root.options().pathSeparator(); char separator = root.options().pathSeparator();
// i1 is the leading (higher) index // i1 is the leading (higher) index
// i2 is the trailing (lower) index // i2 is the trailing (lower) index
int i1 = -1, i2; int i1 = -1;
int i2;
ConfigurationSection section = this; ConfigurationSection section = this;
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) { while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
String node = path.substring(i2, i1); String node = path.substring(i2, i1);

View File

@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets;
/** /**
* This is a base class for all File based implementations of {@link * This is a base class for all File based implementations of {@link
* Configuration} * Configuration}.
*/ */
public abstract class FileConfiguration extends MemoryConfiguration { public abstract class FileConfiguration extends MemoryConfiguration {
@ -39,18 +39,17 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/** /**
* Saves this {@link FileConfiguration} to the specified location. * Saves this {@link FileConfiguration} to the specified location.
* <p> *
* If the file does not exist, it will be created. If already exists, it * <p>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 * will be overwritten. If it cannot be overwritten or created, an
* exception will be thrown. * exception will be thrown.
* <p> *
* This method will save using the system default encoding, or possibly * <p>This method will save using the system default encoding, or possibly
* using UTF8. * using UTF8.
* *
* @param file File to save to. * @param file File to save to.
* @throws IOException Thrown when the given file cannot be written to for * @throws IOException Thrown when the given file cannot be written to for
* any reason. * any reason.
* @throws IllegalArgumentException Thrown when file is null.
*/ */
public void save(File file) throws IOException { public void save(File file) throws IOException {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
@ -71,14 +70,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/** /**
* Loads this {@link FileConfiguration} from the specified location. * Loads this {@link FileConfiguration} from the specified location.
* <p> *
* All the values contained within this configuration will be removed, * <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded * leaving only settings and defaults, and the new values will be loaded
* from the given file. * from the given file.
* <p> *
* If the file cannot be loaded for any reason, an exception will be * <p>If the file cannot be loaded for any reason, an exception will be
* thrown. * thrown.
* <p>
* *
* @param file File to load from. * @param file File to load from.
* @throws FileNotFoundException Thrown when the given file cannot be * @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. * Loads this {@link FileConfiguration} from the specified reader.
* <p> *
* All the values contained within this configuration will be removed, * <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded * leaving only settings and defaults, and the new values will be loaded
* from the given stream. * from the given stream.
* *
@ -109,7 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* @throws IOException thrown when underlying reader throws an IOException * @throws IOException thrown when underlying reader throws an IOException
* @throws InvalidConfigurationException thrown when the reader does not * @throws InvalidConfigurationException thrown when the reader does not
* represent a valid Configuration * represent a valid Configuration
* @throws IllegalArgumentException thrown when reader is null
*/ */
public void load(Reader reader) throws IOException, InvalidConfigurationException { 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. * Loads this {@link FileConfiguration} from the specified location.
* <p> *
* All the values contained within this configuration will be removed, * <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded * leaving only settings and defaults, and the new values will be loaded
* from the given file. * from the given file.
* <p> *
* If the file cannot be loaded for any reason, an exception will be * <p>If the file cannot be loaded for any reason, an exception will be
* thrown. * thrown.
* *
* @param file File to load from. * @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 * Loads this {@link FileConfiguration} from the specified string, as
* opposed to from file. * opposed to from file.
* <p> *
* All the values contained within this configuration will be removed, * <p>All the values contained within this configuration will be removed,
* leaving only settings and defaults, and the new values will be loaded * leaving only settings and defaults, and the new values will be loaded
* from the given string. * from the given string.
* <p> *
* If the string is invalid in any way, an exception will be thrown. * <p>If the string is invalid in any way, an exception will be thrown.
* *
* @param contents Contents of a Configuration to load. * @param contents Contents of a Configuration to load.
* @throws InvalidConfigurationException Thrown if the specified string is * @throws InvalidConfigurationException Thrown if the specified string is
* invalid. * invalid.
* @throws IllegalArgumentException Thrown if contents is null.
*/ */
public abstract void loadFromString(String contents) throws InvalidConfigurationException; public abstract void loadFromString(String contents) throws InvalidConfigurationException;
/** /**
* Compiles the header for this {@link FileConfiguration} and returns the * Compiles the header for this {@link FileConfiguration} and returns the
* result. * result.
* <p> *
* This will use the header from {@link #options()} -> {@link * <p>This will use the header from {@link #options()} -> {@link
* FileConfigurationOptions#header()}, respecting the rules of {@link * FileConfigurationOptions#header()}, respecting the rules of {@link
* FileConfigurationOptions#copyHeader()} if set. * FileConfigurationOptions#copyHeader()} if set.
* *

View File

@ -6,13 +6,13 @@ import com.intellectualcrafters.configuration.MemoryConfigurationOptions;
/** /**
* Various settings for controlling the input and output of a {@link * Various settings for controlling the input and output of a {@link
* FileConfiguration} * FileConfiguration}.
*/ */
public class FileConfigurationOptions extends MemoryConfigurationOptions { public class FileConfigurationOptions extends MemoryConfigurationOptions {
private String header = null; private String header = null;
private boolean copyHeader = true; private boolean copyHeader = true;
protected FileConfigurationOptions(final MemoryConfiguration configuration) { protected FileConfigurationOptions(MemoryConfiguration configuration) {
super(configuration); super(configuration);
} }
@ -22,28 +22,28 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
} }
@Override @Override
public FileConfigurationOptions copyDefaults(final boolean value) { public FileConfigurationOptions copyDefaults(boolean value) {
super.copyDefaults(value); super.copyDefaults(value);
return this; return this;
} }
@Override @Override
public FileConfigurationOptions pathSeparator(final char value) { public FileConfigurationOptions pathSeparator(char value) {
super.pathSeparator(value); super.pathSeparator(value);
return this; return this;
} }
/** /**
* Gets the header that will be applied to the top of the saved output. * Gets the header that will be applied to the top of the saved output.
* <p> *
* This header will be commented out and applied directly at the top of * <p>This header will be commented out and applied directly at the top of
* the generated output of the {@link FileConfiguration}. It is not * the generated output of the {@link FileConfiguration}. It is not
* required to include a newline at the end of the header as it will * 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 * automatically be applied, but you may include one if you wish for extra
* spacing. * spacing.
* <p> *
* Null is a valid value which will indicate that no header is to be * <p><code>null</code> is a valid value which will indicate that no header]
* applied. The default value is null. * is to be applied. The default value is <code>null</code>.
* *
* @return Header * @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. * Sets the header that will be applied to the top of the saved output.
* <p> *
* This header will be commented out and applied directly at the top of * <p>This header will be commented out and applied directly at the top of
* the generated output of the {@link FileConfiguration}. It is not * the generated output of the {@link FileConfiguration}. It is not
* required to include a newline at the end of the header as it will * 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 * automatically be applied, but you may include one if you wish for extra
* spacing. * spacing.
* <p> *
* Null is a valid value which will indicate that no header is to be * <p><code>null</code> is a valid value which will indicate that no header
* applied. * is to be applied.
* *
* @param value New header * @param value New header
* @return This object, for chaining * @return This object, for chaining
*/ */
public FileConfigurationOptions header(final String value) { public FileConfigurationOptions header(String value) {
header = value; header = value;
return this; return this;
} }
/** /**
* Gets whether or not the header should be copied from a default source. * Gets whether or not the header should be copied from a default source.
* <p> *
* If this is true, if a default {@link FileConfiguration} is passed to * <p>If this is true, if a default {@link FileConfiguration} is passed to
* {@link * {@link FileConfiguration#setDefaults(Configuration)}
* FileConfiguration#setDefaults(Configuration)}
* then upon saving it will use the header from that config, instead of * then upon saving it will use the header from that config, instead of
* the one provided here. * the one provided here.
* <p> *
* If no default is set on the configuration, or the default is not of * <p>If no default is set on the configuration, or the default is not of
* type FileConfiguration, or that config has no header ({@link #header()} * type FileConfiguration, or that config has no header ({@link #header()}
* returns null) then the header specified in this configuration will be * returns null) then the header specified in this configuration will be
* used. * used.
* <p> *
* Defaults to true. * <p>Defaults to true.
* *
* @return Whether or not to copy the header * @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. * Sets whether or not the header should be copied from a default source.
* <p> *
* If this is true, if a default {@link FileConfiguration} is passed to * <p>If this is true, if a default {@link FileConfiguration} is passed to
* {@link * {@link FileConfiguration#setDefaults(Configuration)}
* FileConfiguration#setDefaults(Configuration)}
* then upon saving it will use the header from that config, instead of * then upon saving it will use the header from that config, instead of
* the one provided here. * the one provided here.
* <p> *
* If no default is set on the configuration, or the default is not of * <p>If no default is set on the configuration, or the default is not of
* type FileConfiguration, or that config has no header ({@link #header()} * type FileConfiguration, or that config has no header ({@link #header()}
* returns null) then the header specified in this configuration will be * returns null) then the header specified in this configuration will be
* used. * used.
* <p> *
* Defaults to true. * <p>Defaults to true.
* *
* @param value Whether or not to copy the header * @param value Whether or not to copy the header
* @return This object, for chaining * @return This object, for chaining
*/ */
public FileConfigurationOptions copyHeader(final boolean value) { public FileConfigurationOptions copyHeader(boolean value) {
copyHeader = value; copyHeader = value;
return this; return this;

View File

@ -29,12 +29,12 @@ public class YamlConfiguration extends FileConfiguration {
/** /**
* Creates a new {@link YamlConfiguration}, loading from the given file. * Creates a new {@link YamlConfiguration}, loading from the given file.
* <p> *
* Any errors loading the Configuration will be logged and then ignored. * <p>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 * If the specified input is not a valid config, a blank config will be
* returned. * returned.
* <p> *
* The encoding used may follow the system dependent default. * <p>The encoding used may follow the system dependent default.
* *
* @param file Input file * @param file Input file
* @return Resulting configuration * @return Resulting configuration
@ -45,7 +45,7 @@ public class YamlConfiguration extends FileConfiguration {
throw new NullPointerException("File cannot be null"); throw new NullPointerException("File cannot be null");
} }
final YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
try { try {
config.load(file); config.load(file);
@ -62,7 +62,7 @@ public class YamlConfiguration extends FileConfiguration {
PS.debug("&c============ Full stacktrace ============"); PS.debug("&c============ Full stacktrace ============");
ex.printStackTrace(); ex.printStackTrace();
PS.debug("&c========================================="); PS.debug("&c=========================================");
} catch (final IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -72,8 +72,8 @@ public class YamlConfiguration extends FileConfiguration {
/** /**
* Creates a new {@link YamlConfiguration}, loading from the given reader. * Creates a new {@link YamlConfiguration}, loading from the given reader.
* <p> *
* Any errors loading the Configuration will be logged and then ignored. * <p>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 * If the specified input is not a valid config, a blank config will be
* returned. * returned.
* *
@ -81,16 +81,16 @@ public class YamlConfiguration extends FileConfiguration {
* @return resulting configuration * @return resulting configuration
* @throws IllegalArgumentException Thrown if stream is null * @throws IllegalArgumentException Thrown if stream is null
*/ */
public static YamlConfiguration loadConfiguration(final Reader reader) { public static YamlConfiguration loadConfiguration(Reader reader) {
if (reader == null) { if (reader == null) {
throw new NullPointerException("Reader cannot be null"); throw new NullPointerException("Reader cannot be null");
} }
final YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
try { try {
config.load(reader); config.load(reader);
} catch (final IOException | InvalidConfigurationException ex) { } catch (IOException | InvalidConfigurationException ex) {
PS.debug("Cannot load configuration from stream"); PS.debug("Cannot load configuration from stream");
ex.printStackTrace(); ex.printStackTrace();
} }
@ -104,7 +104,7 @@ public class YamlConfiguration extends FileConfiguration {
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
final String header = buildHeader(); String header = buildHeader();
String dump = yaml.dump(getValues(false)); String dump = yaml.dump(getValues(false));
if (dump.equals(BLANK_CONFIG)) { if (dump.equals(BLANK_CONFIG)) {
@ -115,7 +115,7 @@ public class YamlConfiguration extends FileConfiguration {
} }
@Override @Override
public void loadFromString(final String contents) throws InvalidConfigurationException { public void loadFromString(String contents) throws InvalidConfigurationException {
if (contents == null) { if (contents == null) {
throw new NullPointerException("Contents cannot be null"); throw new NullPointerException("Contents cannot be null");
} }
@ -123,13 +123,13 @@ public class YamlConfiguration extends FileConfiguration {
Map<?, ?> input; Map<?, ?> input;
try { try {
input = (Map<?, ?>) yaml.load(contents); input = (Map<?, ?>) yaml.load(contents);
} catch (final YAMLException e) { } catch (YAMLException e) {
throw new InvalidConfigurationException(e); throw new InvalidConfigurationException(e);
} catch (final ClassCastException ignored) { } catch (ClassCastException ignored) {
throw new InvalidConfigurationException("Top level is not a Map."); throw new InvalidConfigurationException("Top level is not a Map.");
} }
final String header = parseHeader(contents); String header = parseHeader(contents);
if (!header.isEmpty()) { if (!header.isEmpty()) {
options().header(header); options().header(header);
} }
@ -139,10 +139,10 @@ public class YamlConfiguration extends FileConfiguration {
} }
} }
protected void convertMapsToSections(final Map<?, ?> input, final ConfigurationSection section) { protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) {
for (final Map.Entry<?, ?> entry : input.entrySet()) { for (Map.Entry<?, ?> entry : input.entrySet()) {
final String key = entry.getKey().toString(); String key = entry.getKey().toString();
final Object value = entry.getValue(); Object value = entry.getValue();
if (value instanceof Map) { if (value instanceof Map) {
convertMapsToSections((Map<?, ?>) value, section.createSection(key)); convertMapsToSections((Map<?, ?>) value, section.createSection(key));
@ -152,14 +152,14 @@ public class YamlConfiguration extends FileConfiguration {
} }
} }
protected String parseHeader(final String input) { protected String parseHeader(String input) {
final String[] lines = input.split("\r?\n", -1); String[] lines = input.split("\r?\n", -1);
final StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
boolean readingHeader = true; boolean readingHeader = true;
boolean foundHeader = false; boolean foundHeader = false;
for (int i = 0; (i < lines.length) && readingHeader; i++) { for (int i = 0; (i < lines.length) && readingHeader; i++) {
final String line = lines[i]; String line = lines[i];
if (line.startsWith(COMMENT_PREFIX)) { if (line.startsWith(COMMENT_PREFIX)) {
if (i > 0) { if (i > 0) {
@ -183,14 +183,14 @@ public class YamlConfiguration extends FileConfiguration {
@Override @Override
protected String buildHeader() { protected String buildHeader() {
final String header = options().header(); String header = options().header();
if (options().copyHeader()) { if (options().copyHeader()) {
final Configuration def = getDefaults(); Configuration def = getDefaults();
if (def instanceof FileConfiguration) { if (def instanceof FileConfiguration) {
final FileConfiguration fileDefaults = (FileConfiguration) def; FileConfiguration fileDefaults = (FileConfiguration) def;
final String defaultsHeader = fileDefaults.buildHeader(); String defaultsHeader = fileDefaults.buildHeader();
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) { if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
return defaultsHeader; return defaultsHeader;
@ -202,8 +202,8 @@ public class YamlConfiguration extends FileConfiguration {
return ""; return "";
} }
final StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
final String[] lines = header.split("\r?\n", -1); String[] lines = header.split("\r?\n", -1);
boolean startedHeader = false; boolean startedHeader = false;
for (int i = lines.length - 1; i >= 0; i--) { for (int i = lines.length - 1; i >= 0; i--) {

View File

@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.util.block.QueueProvider; import com.intellectualcrafters.plot.util.block.QueueProvider;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -51,17 +52,23 @@ public interface IPlotMain extends ILogger {
* Disable the implementation. * Disable the implementation.
* *
* <ul> * <ul>
* <li>If a full disable isn't feasibly, just disable what it can.</li> * <li>If a full disable isn't feasibly, just disable what it can.
* </ul> * </ul>
*/ */
void disable(); void disable();
/** /**
* Get the version of the PlotSquared being used. * Get the version of the PlotSquared being used.
* @return * @return the plugin version
*/ */
int[] getPluginVersion(); 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. * Get the version of Minecraft that is running.
* @return * @return
@ -231,7 +238,7 @@ public interface IPlotMain extends ILogger {
/** /**
* Get the name of the server. * Get the name of the server.
* @return The server name * @return the server name
*/ */
String getServerName(); String getServerName();

View File

@ -1,5 +1,7 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import static com.intellectualcrafters.plot.PS.log;
import com.intellectualcrafters.json.JSONArray; import com.intellectualcrafters.json.JSONArray;
import com.intellectualcrafters.json.JSONObject; import com.intellectualcrafters.json.JSONObject;
import com.intellectualcrafters.plot.util.HttpUtil; import com.intellectualcrafters.plot.util.HttpUtil;
@ -7,8 +9,7 @@ import com.intellectualcrafters.plot.util.StringMan;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import static com.intellectualcrafters.plot.PS.log;
public class Updater { public class Updater {
@ -31,8 +32,10 @@ public class Updater {
} }
// If current version >= update // If current version >= update
if (PS.get().checkVersion(PS.get().getVersion(), version)) { if (PS.get().checkVersion(PS.get().getVersion(), version)) {
PS.debug("&7PlotSquared is already up to date!"); if (!PS.get().IMP.getPluginVersionString().contains("-SNAPSHOT") || !Arrays.equals(PS.get().getVersion(), version)) {
return null; PS.debug("&7PlotSquared is already up to date!");
return null;
}
} }
log("&6PlotSquared " + StringMan.join(split, ".") + " is available:"); log("&6PlotSquared " + StringMan.join(split, ".") + " is available:");
log("&8 - &3Use: &7/plot update"); log("&8 - &3Use: &7/plot update");

View File

@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set; import java.util.Set;
@CommandDeclaration( @CommandDeclaration(
@ -43,7 +44,9 @@ public class Buy extends Command {
Set<Plot> plots = plot.getConnectedPlots(); Set<Plot> plots = plot.getConnectedPlots();
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS); checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS);
Optional<Double> flag = plot.getFlag(Flags.PRICE); Optional<Double> 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(); final double price = flag.get();
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT); checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
player.withdraw(price); player.withdraw(price);

View File

@ -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 @Override
public HashMap<String, HashMap<PlotId, Plot>> getPlots() { public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
@ -2560,9 +2560,7 @@ public class SQLManager implements AbstractDB {
} }
set.add(cluster); set.add(cluster);
} }
/* //Getting helpers
* Getting helpers
*/
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`"); resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
while (resultSet.next()) { while (resultSet.next()) {
id = resultSet.getInt("cluster_id"); 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."); 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`"); resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
while (resultSet.next()) { while (resultSet.next()) {
id = resultSet.getInt("cluster_id"); id = resultSet.getInt("cluster_id");

View File

@ -213,7 +213,7 @@ public class FlagManager {
/** /**
* Removes a flag from a certain plot. * 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 * @param id the flag to remove
* @return true if the plot contained the flag and was removed successfully * @return true if the plot contained the flag and was removed successfully
*/ */

View File

@ -21,6 +21,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis; import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
import java.io.File; import java.io.File;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -34,7 +34,7 @@ public class ConsolePlayer extends PlotPlayer {
@Override @Override
public Location getLocation() { public Location getLocation() {
return this.<Location>getMeta("location"); return this.getMeta("location");
} }
@Override @Override
@ -110,14 +110,14 @@ public class ConsolePlayer extends PlotPlayer {
@Override @Override
public void setTime(long time) {} public void setTime(long time) {}
@Override
public void setFlight(boolean fly) {}
@Override @Override
public boolean getFlight() { public boolean getFlight() {
return true; return true;
} }
@Override
public void setFlight(boolean fly) {}
@Override @Override
public void playMusic(Location location, int id) {} public void playMusic(Location location, int id) {}

View File

@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.area.QuadMap; import com.intellectualcrafters.plot.util.area.QuadMap;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue; import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue; import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -91,10 +92,6 @@ public abstract class PlotArea {
this.worldhash = worldName.hashCode(); this.worldhash = worldName.hashCode();
} }
public LocalBlockQueue getQueue(boolean autoQueue) {
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
}
/** /**
* Create a new PlotArea object with no functionality/information. * Create a new PlotArea object with no functionality/information.
* - Mainly used during startup before worlds are created as a temporary object * - Mainly used during startup before worlds are created as a temporary object
@ -106,10 +103,16 @@ public abstract class PlotArea {
@Override @Override
public void loadConfiguration(ConfigurationSection config) {} public void loadConfiguration(ConfigurationSection config) {}
@Override @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 * Returns the region for this PlotArea or a RegionWrapper encompassing
* the whole world if none exists. * the whole world if none exists.
@ -142,7 +145,7 @@ public abstract class PlotArea {
/** /**
* Returns the minimum value of a {@link PlotId}. * Returns the minimum value of a {@link PlotId}.
* @return * @return the minimum value for a {@link PlotId}
*/ */
public PlotId getMin() { public PlotId getMin() {
return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min; 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. * Returns the max PlotId.
* @return * @return the maximum value for a {@link PlotId}
*/ */
public PlotId getMax() { public PlotId getMax() {
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max; 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. * Get the implementation independent generator for this area.
* *
* @return * @return the {@link IndependentPlotGenerator}
*/ */
public IndependentPlotGenerator getGenerator() { public IndependentPlotGenerator getGenerator() {
return this.generator; return this.generator;
@ -183,8 +186,8 @@ public abstract class PlotArea {
/** /**
* Check if a PlotArea is compatible (move/copy etc). * Check if a PlotArea is compatible (move/copy etc).
* @param plotArea * @param plotArea the {@code PlotArea} to compare
* @return * @return true if both areas are compatible
*/ */
public boolean isCompatible(PlotArea plotArea) { public boolean isCompatible(PlotArea plotArea) {
ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds"); ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds");
@ -303,7 +306,7 @@ public abstract class PlotArea {
public abstract void loadConfiguration(ConfigurationSection config); public abstract void loadConfiguration(ConfigurationSection config);
/** /**
* Saving core PlotArea settings * Saving core PlotArea settings.
* *
* @param config Configuration Section * @param config Configuration Section
*/ */
@ -381,9 +384,9 @@ public abstract class PlotArea {
public abstract ConfigurationNode[] getSettingNodes(); public abstract ConfigurationNode[] getSettingNodes();
/** /**
* Get the Plot at a location. * Gets the {@code Plot} at a location.
* @param location * @param location the location
* @return Plot * @return the {@code Plot} or null if none exists
*/ */
public Plot getPlotAbs(Location location) { public Plot getPlotAbs(Location location) {
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ()); 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. * Gets the base plot at a location.
* @param location * @param location the location
* @return base Plot * @return base Plot
*/ */
public Plot getPlot(Location location) { public Plot getPlot(Location location) {
@ -407,9 +410,9 @@ public abstract class PlotArea {
} }
/** /**
* Get the base owned plot at a location. * Get the owned base plot at a location.
* @param location * @param location the location
* @return base Plot or null * @return the base plot or null
*/ */
public Plot getOwnedPlot(Location location) { public Plot getOwnedPlot(Location location) {
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ()); 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. * Get the owned plot at a location.
* @param location * @param location the location
* @return Plot or null * @return Plot or null
*/ */
public Plot getOwnedPlotAbs(Location location) { public Plot getOwnedPlotAbs(Location location) {
@ -435,8 +438,8 @@ public abstract class PlotArea {
/** /**
* Get the owned Plot at a PlotId. * Get the owned Plot at a PlotId.
* @param id * @param id the {@code PlotId}
* @return Plot or null * @return the plot or null
*/ */
public Plot getOwnedPlotAbs(PlotId id) { public Plot getOwnedPlotAbs(PlotId id) {
return this.plots.get(id); return this.plots.get(id);
@ -473,8 +476,8 @@ public abstract class PlotArea {
return myPlots; return myPlots;
} }
public Set<Plot> getPlots(final UUID uuid) { public Set<Plot> getPlots(UUID uuid) {
final HashSet<Plot> myplots = new HashSet<>(); HashSet<Plot> myplots = new HashSet<>();
for (Plot plot : getPlots()) { for (Plot plot : getPlots()) {
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
if (plot.isOwner(uuid)) { if (plot.isOwner(uuid)) {
@ -488,11 +491,19 @@ public abstract class PlotArea {
public Set<Plot> getPlots(PlotPlayer player) { public Set<Plot> getPlots(PlotPlayer player) {
return getPlots(player.getUUID()); return getPlots(player.getUUID());
} }
/**
* A collection of the claimed plots in this {@code PlotArea}.
* @return a collection of claimed plots
*/
public Collection<Plot> getPlots() {
return this.plots.values();
}
public Set<Plot> getPlotsAbs(PlotPlayer player) { public Set<Plot> getPlotsAbs(PlotPlayer player) {
return player != null ? getPlotsAbs(player.getUUID()) : new HashSet<Plot>(); return player != null ? getPlotsAbs(player.getUUID()) : new HashSet<Plot>();
} }
public int getPlotCount(UUID uuid) { public int getPlotCount(UUID uuid) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) { if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
int count = 0; int count = 0;
@ -520,7 +531,7 @@ public abstract class PlotArea {
} }
return plot; return plot;
} }
public Plot getPlot(PlotId id) { public Plot getPlot(PlotId id) {
Plot plot = getOwnedPlotAbs(id); Plot plot = getOwnedPlotAbs(id);
if (plot == null) { 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; return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null;
} }
public PlotCluster getFirstIntersectingCluster(PlotId pos1, PlotId pos2) { public PlotCluster getFirstIntersectingCluster(PlotId pos1, PlotId pos2) {
if (this.clusters == null) { if (this.clusters == null) {
return null; return null;
@ -564,13 +575,13 @@ public abstract class PlotArea {
public PlotCluster getCluster(PlotId id) { public PlotCluster getCluster(PlotId id) {
return this.clusters != null ? this.clusters.get(id.x, id.y) : null; return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
} }
public PlotManager getPlotManager() { public PlotManager getPlotManager() {
return this.manager; return this.manager;
} }
/** /**
* Session only plot metadata (session is until the server stops)<br> * Session only plot metadata (session is until the server stops).
* <br> * <br>
* For persistent metadata use the flag system * For persistent metadata use the flag system
* @see FlagManager * @see FlagManager
@ -583,7 +594,7 @@ public abstract class PlotArea {
} }
this.meta.put(key, value); this.meta.put(key, value);
} }
/** /**
* Get the metadata for a key<br> * Get the metadata for a key<br>
* <br> * <br>
@ -598,14 +609,6 @@ public abstract class PlotArea {
return null; return null;
} }
/**
* A collection of the claimed plots in this {@code PlotArea}.
* @return
*/
public Collection<Plot> getPlots() {
return this.plots.values();
}
public Set<Plot> getBasePlots() { public Set<Plot> getBasePlots() {
HashSet<Plot> myPlots = new HashSet<>(getPlots()); HashSet<Plot> myPlots = new HashSet<>(getPlots());
Iterator<Plot> iterator = myPlots.iterator(); Iterator<Plot> iterator = myPlots.iterator();
@ -662,10 +665,10 @@ public abstract class PlotArea {
} }
/** /**
* Check if the plots in a selection are unowned * Check if the plots in a selection are unowned.
* @param pos1 * @param pos1 first corner of selection
* @param pos2 * @param pos2 second corner of selection
* @return * @return are plots in selection unowned
*/ */
public boolean isUnowned(PlotId pos1, PlotId pos2) { public boolean isUnowned(PlotId pos1, PlotId pos2) {
int area = (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1); 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() { public void setupBorder() {
if (!this.WORLD_BORDER) { if (!this.WORLD_BORDER) {
@ -722,7 +725,7 @@ public abstract class PlotArea {
} }
/** /**
* Delete the metadata for a key<br> * Delete the metadata for a key.
* - metadata is session only * - metadata is session only
* - deleting other plugin's metadata may cause issues * - deleting other plugin's metadata may cause issues
* @param key * @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.<br> * 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 * i.e. A selection of billions of plots will work fine
* @param pos1 * @param pos1 first corner of selection
* @param pos2 * @param pos2 second corner of selection
* @return * @return the plots in the selection which are owned
*/ */
public HashSet<Plot> getPlotSelectionOwned(PlotId pos1, PlotId pos2) { public HashSet<Plot> getPlotSelectionOwned(PlotId pos1, PlotId pos2) {
int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);

View File

@ -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} * @return the plot the player is standing on or null if standing on a road or not in a {@link PlotArea}
*/ */
public Plot getCurrentPlot() { public Plot getCurrentPlot() {
Plot value = (Plot) getMeta("lastplot"); Plot value = getMeta("lastplot");
if (value == null && !Settings.Enabled_Components.EVENTS) { if (value == null && !Settings.Enabled_Components.EVENTS) {
return getLocation().getPlot(); return getLocation().getPlot();
} }
@ -248,7 +248,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* *
* @return UUID * @return UUID
*/ */
public abstract UUID getUUID(); @Override public abstract UUID getUUID();
public boolean canTeleport(Location loc) { public boolean canTeleport(Location loc) {
Location current = getLocationFull(); Location current = getLocationFull();
@ -285,7 +285,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
/** /**
* Retrieves the player attribute. * Retrieves t player attribute.
* *
* @param key * @param key
* @return the attribute will be either true or false * @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 * @param weather the weather visible to the player
*/ */
public abstract void setWeather(PlotWeather weather); 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 void setTime(long time);
public abstract boolean getFlight();
/** /**
* Set the player's fly mode. * Set the player's fly mode.
* @param fly if the player can fly * @param fly if the player can fly
*/ */
public abstract void setFlight(boolean fly); public abstract void setFlight(boolean fly);
public abstract boolean getFlight();
/** /**
* Play music at a location for the player. * Play music at a location for the player.
* @param location where to play the music * @param location where to play the music
@ -464,7 +464,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
public abstract void stopSpectating(); public abstract void stopSpectating();
/** /**
* The amount of money this player has * The amount of money this Player has.
* @return * @return
*/ */
public double getMoney() { public double getMoney() {

View File

@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.RunnableVal;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -702,11 +703,11 @@ public class MainUtil {
expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l)); expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l));
} }
} }
// } else if (ExpireManager.IMP != null) { //} else if (ExpireManager.IMP != null) {
// long timestamp = ExpireManager.IMP.getTimestamp(plot.owner); //long timestamp = ExpireManager.IMP.getTimestamp(plot.owner);
// long compared = System.currentTimeMillis() - timestamp; //long compared = System.currentTimeMillis() - timestamp;
// long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared); //long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared);
// expires = String.format("%d days", l); //expires = String.format("%d days", l);
} }
} }
} else { } else {

View File

@ -9,19 +9,7 @@ public class MathMan {
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT); 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 INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
private static final float[] atan2 = new float[ATAN2_COUNT]; private static final float[] atan2 = new float[ATAN2_COUNT];
private static final int[] table = {
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 = {
0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57, 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, 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, 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 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) { public static long pairInt(int x, int y) {
return (((long)x) << 32) | (y & 0xffffffffL); return (((long)x) << 32) | (y & 0xffffffffL);
} }
@ -191,7 +190,8 @@ public class MathMan {
} }
public static final float atan2(float y, float x) { public static final float atan2(float y, float x) {
float add, mul; float add;
float mul;
if (x < 0.0f) { if (x < 0.0f) {
if (y < 0.0f) { if (y < 0.0f) {
@ -229,7 +229,7 @@ public class MathMan {
} }
public static double sqrtApprox(double d) { 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) { public static float invSqrt(float x) {
@ -302,7 +302,7 @@ public class MathMan {
return x % y; return x % y;
} }
public static boolean isPowerOfTwo(int x) { public static boolean isPowerOfTwo(int number) {
return (x & (x - 1)) == 0; return (number & (number - 1)) == 0;
} }
} }

View File

@ -51,13 +51,6 @@ import com.plotsquared.sponge.util.block.SpongeLocalQueue;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeUUIDHandler; 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.slf4j.Logger;
import org.spongepowered.api.Game; import org.spongepowered.api.Game;
import org.spongepowered.api.Server; 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.WorldGenerator;
import org.spongepowered.api.world.gen.WorldGeneratorModifier; 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.", @Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.",
url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3") url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
public class SpongeMain implements IPlotMain { 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}; 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 @Override
public int[] getServerVersion() { public int[] getServerVersion() {
PS.log("Checking minecraft version: Sponge: "); PS.log("Checking minecraft version: Sponge: ");

View File

@ -443,7 +443,7 @@ public class MainListener {
public void onBlockBreak(ChangeBlockEvent.Break event) { public void onBlockBreak(ChangeBlockEvent.Break event) {
Player player = SpongeUtil.getCause(event.getCause(), Player.class); Player player = SpongeUtil.getCause(event.getCause(), Player.class);
if (player == null) { if (player == null) {
// SpongeUtil.printCause("break", event.getCause()); //SpongeUtil.printCause("break", event.getCause());
return; return;
} }
PlotPlayer pp = SpongeUtil.getPlayer(player); PlotPlayer pp = SpongeUtil.getPlayer(player);
@ -486,36 +486,29 @@ public class MainListener {
} }
} }
} }
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() { event.filter(l -> {
Location loc1 = SpongeUtil.getLocation(worldName, l);
@Override Plot plot1 = loc1.getPlot();
public boolean test(org.spongepowered.api.world.Location<World> l) { if (plot1 == null) {
Location loc = SpongeUtil.getLocation(worldName, l); return loc1.getPlotAbs() == null || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD);
Plot plot = loc.getPlot(); }
if (plot == null) { if (!plot1.hasOwner()) {
if (loc.getPlotAbs() == null) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
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)) {
return true; return true;
} else {
com.google.common.base.Optional<HashSet<PlotBlock>> 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<HashSet<PlotBlock>> 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) { public void onBlockPlace(ChangeBlockEvent.Place event) {
Player player = SpongeUtil.getCause(event.getCause(), Player.class); Player player = SpongeUtil.getCause(event.getCause(), Player.class);
if (player == null) { if (player == null) {
// SpongeUtil.printCause("place", event.getCause()); //SpongeUtil.printCause("place", event.getCause());
return; return;
} }
PlotPlayer pp = SpongeUtil.getPlayer(player); PlotPlayer pp = SpongeUtil.getPlayer(player);
@ -552,9 +545,9 @@ public class MainListener {
return; return;
} else { } else {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
com.google.common.base.Optional<HashSet<PlotBlock>> BUILD = plot.getFlag(Flags.PLACE); com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
BlockState state = pos.getState(); 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); event.setCancelled(true);
return; return;
} }
@ -575,10 +568,7 @@ public class MainListener {
Location loc = SpongeUtil.getLocation(worldName, l); Location loc = SpongeUtil.getLocation(worldName, l);
Plot plot = loc.getPlot(); Plot plot = loc.getPlot();
if (plot == null) { if (plot == null) {
if (loc.getPlotAbs() == null) { return loc.getPlotAbs() == null || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD);
return true;
}
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) { 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)) { if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
return true; return true;
} else { } else {
com.google.common.base.Optional<HashSet<PlotBlock>> build = plot.getFlag(Flags.PLACE); com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
BlockState state = l.getBlock(); BlockState state = l.getBlock();
if (build.isPresent() && build.get().contains(SpongeUtil.getPlotBlock(state))) { if (place.isPresent() && place.get().contains(SpongeUtil.getPlotBlock(state))) {
return true; return true;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
@ -627,12 +617,7 @@ public class MainListener {
// Delayed // Delayed
// Async // Async
TaskManager.runTaskLaterAsync(new Runnable() { TaskManager.runTaskLaterAsync(() -> EventUtil.manager.doJoinTask(pp), 20);
@Override
public void run() {
EventUtil.manager.doJoinTask(pp);
}
}, 20);
} }
@Listener @Listener

View File

@ -74,7 +74,7 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) { if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
setMeta("lastMessage", message); setMeta("lastMessage", message);
setMeta("lastMessageTime", System.currentTimeMillis()); setMeta("lastMessageTime", System.currentTimeMillis());
this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message)); this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
@ -162,23 +162,21 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void setTime(long time) { public void setTime(long time) {
// TODO Auto-generated method stub
if (time != Long.MAX_VALUE) {} else {}
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); 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 @Override
public boolean getFlight() { public boolean getFlight() {
Optional<Boolean> flying = player.get(Keys.CAN_FLY); Optional<Boolean> flying = player.get(Keys.CAN_FLY);
return flying.isPresent() && flying.get(); 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 @Override
public void playMusic(Location location, int id) { public void playMusic(Location location, int id) {
switch (id) { switch (id) {

View File

@ -19,7 +19,7 @@ ext {
git = Grgit.open() git = Grgit.open()
revision = "-${git.head().abbreviatedId}" revision = "-${git.head().abbreviatedId}"
} }
version = "3.4.3${revision}" version = "3.4.4-SNAPSHOT;${revision}"
description = """PlotSquared""" description = """PlotSquared"""
subprojects { subprojects {
@ -31,6 +31,8 @@ subprojects {
dependencies { dependencies {
compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') { compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') {
exclude(module: 'bukkit-classloader-check') exclude(module: 'bukkit-classloader-check')
exclude(module: 'mockito-core')
exclude(module: 'dummypermscompat')
} }
compile 'com.google.guava:guava:10.0' compile 'com.google.guava:guava:10.0'
} }