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

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

View File

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

View File

@ -1,7 +1,7 @@
package com.intellectualcrafters.configuration;
/**
* Exception thrown when attempting to load an invalid {@link Configuration}
* Exception thrown when attempting to load an invalid {@link Configuration}.
*/
@SuppressWarnings("serial")
public class InvalidConfigurationException extends Exception {
@ -18,7 +18,7 @@ public class InvalidConfigurationException extends Exception {
*
* @param msg The details of the exception.
*/
public InvalidConfigurationException(final String msg) {
public InvalidConfigurationException(String msg) {
super(msg);
}
@ -28,7 +28,7 @@ public class InvalidConfigurationException extends Exception {
*
* @param cause The cause of the exception.
*/
public InvalidConfigurationException(final Throwable cause) {
public InvalidConfigurationException(Throwable cause) {
super(cause);
}
@ -39,7 +39,7 @@ public class InvalidConfigurationException extends Exception {
* @param cause The cause of the exception.
* @param msg The details of the exception.
*/
public InvalidConfigurationException(final String msg, final Throwable cause) {
public InvalidConfigurationException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

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

View File

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

View File

@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets;
/**
* This is a base class for all File based implementations of {@link
* Configuration}
* Configuration}.
*/
public abstract class FileConfiguration extends MemoryConfiguration {
@ -39,18 +39,17 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/**
* Saves this {@link FileConfiguration} to the specified location.
* <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
* 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.
*
* @param file File to save to.
* @throws IOException Thrown when the given file cannot be written to for
* any reason.
* @throws IllegalArgumentException Thrown when file is null.
*/
public void save(File file) throws IOException {
file.getParentFile().mkdirs();
@ -71,14 +70,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/**
* Loads this {@link FileConfiguration} from the specified location.
* <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
* 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.
* <p>
*
* @param file File to load from.
* @throws FileNotFoundException Thrown when the given file cannot be
@ -100,8 +98,8 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/**
* Loads this {@link FileConfiguration} from the specified reader.
* <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
* from the given stream.
*
@ -109,7 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
* @throws IOException thrown when underlying reader throws an IOException
* @throws InvalidConfigurationException thrown when the reader does not
* represent a valid Configuration
* @throws IllegalArgumentException thrown when reader is null
*/
public void load(Reader reader) throws IOException, InvalidConfigurationException {
@ -129,12 +126,12 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/**
* Loads this {@link FileConfiguration} from the specified location.
* <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
* 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.
*
* @param file File to load from.
@ -156,25 +153,24 @@ public abstract class FileConfiguration extends MemoryConfiguration {
/**
* Loads this {@link FileConfiguration} from the specified string, as
* opposed to from file.
* <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
* 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.
* @throws InvalidConfigurationException Thrown if the specified string is
* invalid.
* @throws IllegalArgumentException Thrown if contents is null.
*/
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
/**
* Compiles the header for this {@link FileConfiguration} and returns the
* result.
* <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#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
* FileConfiguration}
* FileConfiguration}.
*/
public class FileConfigurationOptions extends MemoryConfigurationOptions {
private String header = null;
private boolean copyHeader = true;
protected FileConfigurationOptions(final MemoryConfiguration configuration) {
protected FileConfigurationOptions(MemoryConfiguration configuration) {
super(configuration);
}
@ -22,28 +22,28 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
}
@Override
public FileConfigurationOptions copyDefaults(final boolean value) {
public FileConfigurationOptions copyDefaults(boolean value) {
super.copyDefaults(value);
return this;
}
@Override
public FileConfigurationOptions pathSeparator(final char value) {
public FileConfigurationOptions pathSeparator(char value) {
super.pathSeparator(value);
return this;
}
/**
* Gets the header that will be applied to the top of the saved output.
* <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
* required to include a newline at the end of the header as it will
* automatically be applied, but you may include one if you wish for extra
* spacing.
* <p>
* Null is a valid value which will indicate that no header is to be
* applied. The default value is null.
*
* <p><code>null</code> is a valid value which will indicate that no header]
* is to be applied. The default value is <code>null</code>.
*
* @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.
* <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
* required to include a newline at the end of the header as it will
* automatically be applied, but you may include one if you wish for extra
* spacing.
* <p>
* Null is a valid value which will indicate that no header is to be
* applied.
*
* <p><code>null</code> is a valid value which will indicate that no header
* is to be applied.
*
* @param value New header
* @return This object, for chaining
*/
public FileConfigurationOptions header(final String value) {
public FileConfigurationOptions header(String value) {
header = value;
return this;
}
/**
* Gets whether or not the header should be copied from a default source.
* <p>
* If this is true, if a default {@link FileConfiguration} is passed to
* {@link
* FileConfiguration#setDefaults(Configuration)}
*
* <p>If this is true, if a default {@link FileConfiguration} is passed to
* {@link FileConfiguration#setDefaults(Configuration)}
* then upon saving it will use the header from that config, instead of
* the one provided here.
* <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()}
* returns null) then the header specified in this configuration will be
* used.
* <p>
* Defaults to true.
*
* <p>Defaults to true.
*
* @return Whether or not to copy the header
*/
@ -95,24 +94,23 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
/**
* Sets whether or not the header should be copied from a default source.
* <p>
* If this is true, if a default {@link FileConfiguration} is passed to
* {@link
* FileConfiguration#setDefaults(Configuration)}
*
* <p>If this is true, if a default {@link FileConfiguration} is passed to
* {@link FileConfiguration#setDefaults(Configuration)}
* then upon saving it will use the header from that config, instead of
* the one provided here.
* <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()}
* returns null) then the header specified in this configuration will be
* used.
* <p>
* Defaults to true.
*
* <p>Defaults to true.
*
* @param value Whether or not to copy the header
* @return This object, for chaining
*/
public FileConfigurationOptions copyHeader(final boolean value) {
public FileConfigurationOptions copyHeader(boolean value) {
copyHeader = value;
return this;

View File

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

View File

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

View File

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

View File

@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration(
@ -43,7 +44,9 @@ public class Buy extends Command {
Set<Plot> plots = plot.getConnectedPlots();
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS);
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();
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
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
public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
@ -2560,9 +2560,7 @@ public class SQLManager implements AbstractDB {
}
set.add(cluster);
}
/*
* Getting helpers
*/
//Getting helpers
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
while (resultSet.next()) {
id = resultSet.getInt("cluster_id");
@ -2579,9 +2577,7 @@ public class SQLManager implements AbstractDB {
PS.debug("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry.");
}
}
/*
* Getting invited
*/
// Getting invited
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
while (resultSet.next()) {
id = resultSet.getInt("cluster_id");

View File

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

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.LocalBlockQueue;
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
import java.io.File;
import java.util.ArrayDeque;
import java.util.ArrayList;

View File

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

View File

@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.area.QuadMap;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@ -91,10 +92,6 @@ public abstract class PlotArea {
this.worldhash = worldName.hashCode();
}
public LocalBlockQueue getQueue(boolean autoQueue) {
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
}
/**
* Create a new PlotArea object with no functionality/information.
* - Mainly used during startup before worlds are created as a temporary object
@ -106,10 +103,16 @@ public abstract class PlotArea {
@Override
public void loadConfiguration(ConfigurationSection config) {}
@Override
public ConfigurationNode[] getSettingNodes() {return null;}
public ConfigurationNode[] getSettingNodes() {
return null;
}
};
}
public LocalBlockQueue getQueue(boolean autoQueue) {
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
}
/**
* Returns the region for this PlotArea or a RegionWrapper encompassing
* the whole world if none exists.
@ -142,7 +145,7 @@ public abstract class PlotArea {
/**
* Returns the minimum value of a {@link PlotId}.
* @return
* @return the minimum value for a {@link PlotId}
*/
public PlotId getMin() {
return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
@ -150,7 +153,7 @@ public abstract class PlotArea {
/**
* Returns the max PlotId.
* @return
* @return the maximum value for a {@link PlotId}
*/
public PlotId getMax() {
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
@ -159,7 +162,7 @@ public abstract class PlotArea {
/**
* Get the implementation independent generator for this area.
*
* @return
* @return the {@link IndependentPlotGenerator}
*/
public IndependentPlotGenerator getGenerator() {
return this.generator;
@ -183,8 +186,8 @@ public abstract class PlotArea {
/**
* Check if a PlotArea is compatible (move/copy etc).
* @param plotArea
* @return
* @param plotArea the {@code PlotArea} to compare
* @return true if both areas are compatible
*/
public boolean isCompatible(PlotArea plotArea) {
ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds");
@ -303,7 +306,7 @@ public abstract class PlotArea {
public abstract void loadConfiguration(ConfigurationSection config);
/**
* Saving core PlotArea settings
* Saving core PlotArea settings.
*
* @param config Configuration Section
*/
@ -381,9 +384,9 @@ public abstract class PlotArea {
public abstract ConfigurationNode[] getSettingNodes();
/**
* Get the Plot at a location.
* @param location
* @return Plot
* Gets the {@code Plot} at a location.
* @param location the location
* @return the {@code Plot} or null if none exists
*/
public Plot getPlotAbs(Location location) {
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ());
@ -394,8 +397,8 @@ public abstract class PlotArea {
}
/**
* Get the base plot at a location.
* @param location
* Gets the base plot at a location.
* @param location the location
* @return base Plot
*/
public Plot getPlot(Location location) {
@ -407,9 +410,9 @@ public abstract class PlotArea {
}
/**
* Get the base owned plot at a location.
* @param location
* @return base Plot or null
* Get the owned base plot at a location.
* @param location the location
* @return the base plot or null
*/
public Plot getOwnedPlot(Location location) {
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ());
@ -422,7 +425,7 @@ public abstract class PlotArea {
/**
* Get the owned plot at a location.
* @param location
* @param location the location
* @return Plot or null
*/
public Plot getOwnedPlotAbs(Location location) {
@ -435,8 +438,8 @@ public abstract class PlotArea {
/**
* Get the owned Plot at a PlotId.
* @param id
* @return Plot or null
* @param id the {@code PlotId}
* @return the plot or null
*/
public Plot getOwnedPlotAbs(PlotId id) {
return this.plots.get(id);
@ -473,8 +476,8 @@ public abstract class PlotArea {
return myPlots;
}
public Set<Plot> getPlots(final UUID uuid) {
final HashSet<Plot> myplots = new HashSet<>();
public Set<Plot> getPlots(UUID uuid) {
HashSet<Plot> myplots = new HashSet<>();
for (Plot plot : getPlots()) {
if (plot.isBasePlot()) {
if (plot.isOwner(uuid)) {
@ -488,11 +491,19 @@ public abstract class PlotArea {
public Set<Plot> getPlots(PlotPlayer player) {
return getPlots(player.getUUID());
}
/**
* A collection of the claimed plots in this {@code PlotArea}.
* @return a collection of claimed plots
*/
public Collection<Plot> getPlots() {
return this.plots.values();
}
public Set<Plot> getPlotsAbs(PlotPlayer player) {
return player != null ? getPlotsAbs(player.getUUID()) : new HashSet<Plot>();
}
public int getPlotCount(UUID uuid) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
int count = 0;
@ -520,7 +531,7 @@ public abstract class PlotArea {
}
return plot;
}
public Plot getPlot(PlotId id) {
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
@ -548,7 +559,7 @@ public abstract class PlotArea {
}
return this.clusters != null ? this.clusters.get(plot.getId().x, plot.getId().y) : null;
}
public PlotCluster getFirstIntersectingCluster(PlotId pos1, PlotId pos2) {
if (this.clusters == null) {
return null;
@ -564,13 +575,13 @@ public abstract class PlotArea {
public PlotCluster getCluster(PlotId id) {
return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
}
public PlotManager getPlotManager() {
return this.manager;
}
/**
* Session only plot metadata (session is until the server stops)<br>
* Session only plot metadata (session is until the server stops).
* <br>
* For persistent metadata use the flag system
* @see FlagManager
@ -583,7 +594,7 @@ public abstract class PlotArea {
}
this.meta.put(key, value);
}
/**
* Get the metadata for a key<br>
* <br>
@ -598,14 +609,6 @@ public abstract class PlotArea {
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() {
HashSet<Plot> myPlots = new HashSet<>(getPlots());
Iterator<Plot> iterator = myPlots.iterator();
@ -662,10 +665,10 @@ public abstract class PlotArea {
}
/**
* Check if the plots in a selection are unowned
* @param pos1
* @param pos2
* @return
* Check if the plots in a selection are unowned.
* @param pos1 first corner of selection
* @param pos2 second corner of selection
* @return are plots in selection unowned
*/
public boolean isUnowned(PlotId pos1, PlotId pos2) {
int area = (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1);
@ -706,7 +709,7 @@ public abstract class PlotArea {
}
/**
* Setup the plot border for a world (usually done when the world is created)
* Setup the plot border for a world (usually done when the world is created).
*/
public void setupBorder() {
if (!this.WORLD_BORDER) {
@ -722,7 +725,7 @@ public abstract class PlotArea {
}
/**
* Delete the metadata for a key<br>
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
* @param key
@ -819,11 +822,11 @@ public abstract class PlotArea {
}
/**
* Get a set of owned plots within a selection (chooses the best algorithm based on selection size.<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
* @param pos1
* @param pos2
* @return
* @param pos1 first corner of selection
* @param pos2 second corner of selection
* @return the plots in the selection which are owned
*/
public HashSet<Plot> getPlotSelectionOwned(PlotId pos1, PlotId pos2) {
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}
*/
public Plot getCurrentPlot() {
Plot value = (Plot) getMeta("lastplot");
Plot value = getMeta("lastplot");
if (value == null && !Settings.Enabled_Components.EVENTS) {
return getLocation().getPlot();
}
@ -248,7 +248,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*
* @return UUID
*/
public abstract UUID getUUID();
@Override public abstract UUID getUUID();
public boolean canTeleport(Location loc) {
Location current = getLocationFull();
@ -285,7 +285,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
/**
* Retrieves the player attribute.
* Retrieves t player attribute.
*
* @param key
* @return the attribute will be either true or false
@ -306,7 +306,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
}
/**
* Set the player's local weather.
* Sets the local weather for this Player.
* @param weather the weather visible to the player
*/
public abstract void setWeather(PlotWeather weather);
@ -329,14 +329,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/
public abstract void setTime(long time);
public abstract boolean getFlight();
/**
* Set the player's fly mode.
* @param fly if the player can fly
*/
public abstract void setFlight(boolean fly);
public abstract boolean getFlight();
/**
* Play music at a location for the player.
* @param location where to play the music
@ -464,7 +464,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
public abstract void stopSpectating();
/**
* The amount of money this player has
* The amount of money this Player has.
* @return
*/
public double getMoney() {

View File

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

View File

@ -9,19 +9,7 @@ public class MathMan {
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
private static final float[] atan2 = new float[ATAN2_COUNT];
static {
for (int i = 0; i < ATAN2_DIM; i++) {
for (int j = 0; j < ATAN2_DIM; j++) {
float x0 = (float) i / ATAN2_DIM;
float y0 = (float) j / ATAN2_DIM;
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
}
}
}
private final static int[] table = {
private static final int[] table = {
0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57,
59, 61, 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 81, 83,
84, 86, 87, 89, 90, 91, 93, 94, 96, 97, 98, 99, 101, 102,
@ -43,6 +31,17 @@ public class MathMan {
253, 254, 254, 255
};
static {
for (int i = 0; i < ATAN2_DIM; i++) {
for (int j = 0; j < ATAN2_DIM; j++) {
float x0 = (float) i / ATAN2_DIM;
float y0 = (float) j / ATAN2_DIM;
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
}
}
}
public static long pairInt(int x, int y) {
return (((long)x) << 32) | (y & 0xffffffffL);
}
@ -191,7 +190,8 @@ public class MathMan {
}
public static final float atan2(float y, float x) {
float add, mul;
float add;
float mul;
if (x < 0.0f) {
if (y < 0.0f) {
@ -229,7 +229,7 @@ public class MathMan {
}
public static double sqrtApprox(double d) {
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1L << 52)) >> 1) + (1L << 61));
}
public static float invSqrt(float x) {
@ -302,7 +302,7 @@ public class MathMan {
return x % y;
}
public static boolean isPowerOfTwo(int x) {
return (x & (x - 1)) == 0;
public static boolean isPowerOfTwo(int number) {
return (number & (number - 1)) == 0;
}
}