Tidy code.

This commit is contained in:
MattBDev 2016-05-12 17:09:35 -04:00
parent 7947c3fdd7
commit 0958b57e46
54 changed files with 167 additions and 181 deletions

View File

@ -704,7 +704,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
try { try {
writeJson(json); writeJson(json);
json.close(); json.close();
} catch (IOException e) { } catch (IOException ignored) {
throw new RuntimeException("invalid message"); throw new RuntimeException("invalid message");
} }
this.jsonString = string.toString(); this.jsonString = string.toString();

View File

@ -284,7 +284,7 @@ public abstract class TextualComponent implements Cloneable {
@Override @Override
@SuppressWarnings("serial") @SuppressWarnings("serial")
public Map<String, Object> serialize() { public Map<String, Object> serialize() {
return new java.util.HashMap<String, Object>() { return new HashMap<String, Object>() {
{ {
put("key", getKey()); put("key", getKey());
for (Map.Entry<String, String> valEntry : getValue().entrySet()) { for (Map.Entry<String, String> valEntry : getValue().entrySet()) {

View File

@ -67,7 +67,7 @@ public class DebugUUID extends SubCommand {
try { try {
Class<?> clazz = Class.forName(args[0]); Class<?> clazz = Class.forName(args[0]);
newWrapper = (UUIDWrapper) clazz.newInstance(); newWrapper = (UUIDWrapper) clazz.newInstance();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { } catch (ClassNotFoundException | IllegalAccessException | InstantiationException ignored) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert <lower|offline|online>"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert <lower|offline|online>");
return false; return false;
} }

View File

@ -94,9 +94,7 @@ public class LikePlotMeConverter {
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared"); content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
content = content.replaceAll("PlotMe", "PlotSquared"); content = content.replaceAll("PlotMe", "PlotSquared");
Files.write(path, content.getBytes(StandardCharsets.UTF_8)); Files.write(path, content.getBytes(StandardCharsets.UTF_8));
} catch (IOException ignored) { } catch (IOException ignored) {}
//ignored
}
} }
public boolean run(APlotMeConnector connector) { public boolean run(APlotMeConnector connector) {

View File

@ -41,9 +41,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
} }
return new SQLite(dataFolder + File.separator + "plots.db").openConnection(); return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
} }
} catch (SQLException | ClassNotFoundException ignored) { } catch (SQLException | ClassNotFoundException e) {
//ignored e.printStackTrace();
ignored.printStackTrace();
} }
return null; return null;
} }
@ -116,7 +115,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
} }
} }
if (owner == null) { if (owner == null) {
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + '\'');
continue; continue;
} }
} }

View File

@ -143,9 +143,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
if (data != null) { if (data != null) {
return; return;
} }
} catch (Throwable e) { } catch (Throwable ignored) {}
//ignored
}
// Populator spillage // Populator spillage
short[][] tmp = cg.generateExtBlockSections(w, r, result.getX(), result.getZ(), grid); short[][] tmp = cg.generateExtBlockSections(w, r, result.getX(), result.getZ(), grid);
if (tmp != null) { if (tmp != null) {

View File

@ -49,7 +49,7 @@ public class ChunkListener implements Listener {
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
this.mustSave = classChunk.getField("mustSave"); this.mustSave = classChunk.getField("mustSave");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable e) { } catch (Throwable ignored) {
PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc"); PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc");
Settings.CHUNK_PROCESSOR_GC = false; Settings.CHUNK_PROCESSOR_GC = false;
Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE = false; Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE = false;

View File

@ -36,10 +36,10 @@ public class ForceFieldListener implements Listener {
private PlotPlayer hasNearbyPermitted(Player player, Plot plot) { private PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
PlotPlayer pp;
if (!(entity instanceof Player)) { if (!(entity instanceof Player)) {
continue; continue;
} }
PlotPlayer pp;
if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) { if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) {
continue; continue;
} }

View File

@ -11,7 +11,7 @@ public class DefaultTitle extends AbstractTitle {
try { try {
DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out); DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (Throwable e) { } catch (Exception ignored) {
AbstractTitle.TITLE_CLASS = new DefaultTitle_183(); AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
} }

View File

@ -11,7 +11,7 @@ public class DefaultTitle_183 extends AbstractTitle {
try { try {
DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out); DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (Exception e) { } catch (Exception ignored) {
AbstractTitle.TITLE_CLASS = new HackTitle(); AbstractTitle.TITLE_CLASS = new HackTitle();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
} }

View File

@ -19,7 +19,7 @@ public class DefaultTitle_19 extends AbstractTitle {
playerObj.sendTitle("", ""); playerObj.sendTitle("", "");
} }
}, delay * 20); }, delay * 20);
} catch (Throwable e) { } catch (Throwable ignored) {
AbstractTitle.TITLE_CLASS = new DefaultTitle(); AbstractTitle.TITLE_CLASS = new DefaultTitle();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
} }

View File

@ -255,8 +255,6 @@ public class Metrics {
/** /**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws java.io.IOException
*/ */
public void enable() { public void enable() {
// Enable Task, if it is not running // Enable Task, if it is not running
@ -267,7 +265,6 @@ public class Metrics {
/** /**
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
*
*/ */
public void disable() { public void disable() {
// Disable Task, if it is running // Disable Task, if it is running
@ -499,7 +496,7 @@ public class Metrics {
/** /**
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph * Gets an <b>unmodifiable</b> set of the plotter objects in the graph
* *
* @return an unmodifiable {@link java.util.Set} of the plotter objects * @return an unmodifiable {@link Set} of the plotter objects
*/ */
public Set<Plotter> getPlotters() { public Set<Plotter> getPlotters() {
return Collections.unmodifiableSet(this.plotters); return Collections.unmodifiableSet(this.plotters);

View File

@ -20,6 +20,7 @@ import java.io.DataInput;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -160,7 +161,7 @@ public class NbtFactory {
/** /**
* Load the content of a file from a stream. * Load the content of a file from a stream.
* *
* Use {@link Files#newInputStreamSupplier(java.io.File)} to provide a stream from a file. * Use {@link Files#newInputStreamSupplier(File)} to provide a stream from a file.
* @param stream - the stream supplier. * @param stream - the stream supplier.
* @param option - whether or not to decompress the input stream. * @param option - whether or not to decompress the input stream.
* @return The decoded NBT compound. * @return The decoded NBT compound.
@ -195,7 +196,7 @@ public class NbtFactory {
/** /**
* Save the content of a NBT compound to a stream. * Save the content of a NBT compound to a stream.
* *
* Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a stream supplier to a file. * Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file.
* @param source - the NBT compound to save. * @param source - the NBT compound to save.
* @param stream - the stream. * @param stream - the stream.
* @param option - whether or not to compress the output. * @param option - whether or not to compress the output.
@ -284,7 +285,7 @@ public class NbtFactory {
Constructor<?> caller = INSTANCE.CRAFT_STACK.getDeclaredConstructor(ItemStack.class); Constructor<?> caller = INSTANCE.CRAFT_STACK.getDeclaredConstructor(ItemStack.class);
caller.setAccessible(true); caller.setAccessible(true);
return (ItemStack) caller.newInstance(stack); return (ItemStack) caller.newInstance(stack);
} catch (Exception e) { } catch (Exception ignored) {
throw new IllegalStateException("Unable to convert " + stack + " + to a CraftItemStack."); throw new IllegalStateException("Unable to convert " + stack + " + to a CraftItemStack.");
} }
} }
@ -396,9 +397,7 @@ public class NbtFactory {
try { try {
this.STREAM_TOOLS = loader.loadClass(nmsPackage + ".NBTCompressedStreamTools"); this.STREAM_TOOLS = loader.loadClass(nmsPackage + ".NBTCompressedStreamTools");
this.READ_LIMITER_CLASS = loader.loadClass(nmsPackage + ".NBTReadLimiter"); this.READ_LIMITER_CLASS = loader.loadClass(nmsPackage + ".NBTReadLimiter");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException ignored) {}
// Ignore - we will detect this later
}
} }
private String getPackageName() { private String getPackageName() {
@ -435,12 +434,10 @@ public class NbtFactory {
if (value instanceof Wrapper) { if (value instanceof Wrapper) {
return ((Wrapper) value).getHandle(); return ((Wrapper) value).getHandle();
} else if (value instanceof List) { } else if (value instanceof List) {
throw new IllegalArgumentException("Can only insert a WrappedList."); throw new IllegalArgumentException("Can only insert a WrappedList.");
} else if (value instanceof Map) { } else if (value instanceof Map) {
throw new IllegalArgumentException("Can only insert a WrappedCompound."); throw new IllegalArgumentException("Can only insert a WrappedCompound.");
} else { } else {
return createNbtTag(getPrimitiveType(value), value); return createNbtTag(getPrimitiveType(value), value);
} }
@ -652,7 +649,7 @@ public class NbtFactory {
* All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following: * All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following:
* <ul> * <ul>
* <li>Primitive types</li> * <li>Primitive types</li>
* <li>{@link java.lang.String String}</li> * <li>{@link String String}</li>
* <li>{@link NbtList}</li> * <li>{@link NbtList}</li>
* <li>{@link NbtCompound}</li> * <li>{@link NbtCompound}</li>
* </ul> * </ul>
@ -773,7 +770,7 @@ public class NbtFactory {
/** /**
* Save the content of a NBT compound to a stream. * Save the content of a NBT compound to a stream.
* <p> * <p>
* Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a stream supplier to a file. * Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file.
* @param stream - the output stream. * @param stream - the output stream.
* @param option - whether or not to compress the output. * @param option - whether or not to compress the output.
* @throws IOException If anything went wrong. * @throws IOException If anything went wrong.

View File

@ -51,7 +51,6 @@ public class SendChunk {
this.methodInitLighting = classChunk.getMethod("initLighting"); this.methodInitLighting = classChunk.getMethod("initLighting");
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
//TODO in 1.7.10 this is PacketPlayOutMapChunk(Chunk chunk, boolean flag, int i, int version) //TODO in 1.7.10 this is PacketPlayOutMapChunk(Chunk chunk, boolean flag, int i, int version)
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) { if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) {
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class); this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class);
} else { } else {
@ -65,7 +64,7 @@ public class SendChunk {
} }
public void sendChunk(Collection<Chunk> input) { public void sendChunk(Collection<Chunk> input) {
HashSet<Chunk> chunks = new HashSet<Chunk>(input); HashSet<Chunk> chunks = new HashSet<>(input);
HashMap<String, ArrayList<Chunk>> map = new HashMap<>(); HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
int view = Bukkit.getServer().getViewDistance(); int view = Bukkit.getServer().getViewDistance();
for (Chunk chunk : chunks) { for (Chunk chunk : chunks) {
@ -126,9 +125,9 @@ public class SendChunk {
public void run() { public void run() {
try { try {
chunk.unload(true, false); chunk.unload(true, false);
} catch (Throwable e) { } catch (Throwable ignored) {
String worldName = chunk.getWorld().getName(); String worldName = chunk.getWorld().getName();
PS.debug("$4Could not save chunk: " + worldName + ";" + chunk.getX() + ";" + chunk.getZ()); PS.debug("$4Could not save chunk: " + worldName + ';' + chunk.getX() + ";" + chunk.getZ());
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)"); PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
PS.debug("$3 - $4" + worldName + "/level.dat or " + worldName PS.debug("$3 - $4" + worldName + "/level.dat or " + worldName
+ "/level_old.dat may be corrupt (try repairing or removing these)"); + "/level_old.dat may be corrupt (try repairing or removing these)");

View File

@ -50,7 +50,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
try (PreparedStatement stmt = getConnection().prepareStatement( try (PreparedStatement stmt = getConnection().prepareStatement(
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username)" "CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username)"
+ ")")) { + ')')) {
stmt.execute(); stmt.execute();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
@ -176,7 +176,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
String id = (String) jsonProfile.get("id"); String id = (String) jsonProfile.get("id");
String name = (String) jsonProfile.get("name"); String name = (String) jsonProfile.get("name");
ifFetch.value = UUID.fromString( ifFetch.value = UUID.fromString(
id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id id.substring(0, 8) + '-' + id.substring(8, 12) + '-' + id.substring(12, 16) + '-' + id.substring(16, 20) + '-' + id
.substring(20, 32)); .substring(20, 32));
} catch (IOException | ParseException e) { } catch (IOException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
@ -231,7 +231,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
statement.setString(1, name.value); statement.setString(1, name.value);
statement.setString(2, uuid.toString()); statement.setString(2, uuid.toString());
statement.execute(); statement.execute();
PS.debug(C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + "'"); PS.debug(C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + '\'');
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -57,9 +57,9 @@ class ConfigurationOptions {
* If this is true, all values in the default Configuration will be * If this is true, all values in the default Configuration will be
* directly copied, making it impossible to distinguish between values * 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(java.lang.String)} will always * {@link ConfigurationSection#contains(String)} will always
* return the same value as {@link * return the same value as {@link
* ConfigurationSection#isSet(java.lang.String)}. The default value is * ConfigurationSection#isSet(String)}. The default value is
* false. * false.
* *
* @return Whether or not defaults are directly copied * @return Whether or not defaults are directly copied
@ -75,9 +75,9 @@ class ConfigurationOptions {
* If this is true, all values in the default Configuration will be * If this is true, all values in the default Configuration will be
* directly copied, making it impossible to distinguish between values * 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(java.lang.String)} will always * {@link ConfigurationSection#contains(String)} will always
* return the same value as {@link * return the same value as {@link
* ConfigurationSection#isSet(java.lang.String)}. The default value is * ConfigurationSection#isSet(String)}. The default value is
* false. * false.
* *
* @param value Whether or not defaults are directly copied * @param value Whether or not defaults are directly copied

View File

@ -1,5 +1,6 @@
package com.intellectualcrafters.configuration.file; package com.intellectualcrafters.configuration.file;
import com.intellectualcrafters.configuration.Configuration;
import com.intellectualcrafters.configuration.MemoryConfiguration; import com.intellectualcrafters.configuration.MemoryConfiguration;
import com.intellectualcrafters.configuration.MemoryConfigurationOptions; import com.intellectualcrafters.configuration.MemoryConfigurationOptions;
@ -75,7 +76,7 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
* <p> * <p>
* If this is true, if a default {@link FileConfiguration} is passed to * If this is true, if a default {@link FileConfiguration} is passed to
* {@link * {@link
* FileConfiguration#setDefaults(com.intellectualcrafters.configuration.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> * <p>
@ -97,7 +98,7 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
* <p> * <p>
* If this is true, if a default {@link FileConfiguration} is passed to * If this is true, if a default {@link FileConfiguration} is passed to
* {@link * {@link
* FileConfiguration#setDefaults(com.intellectualcrafters.configuration.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> * <p>

View File

@ -75,7 +75,7 @@ public final class ListTag extends Tag {
public Tag getIfExists(int index) { public Tag getIfExists(int index) {
try { try {
return this.value.get(index); return this.value.get(index);
} catch (NoSuchElementException e) { } catch (NoSuchElementException ignored) {
return null; return null;
} }
} }

View File

@ -181,7 +181,7 @@ public final class NBTInputStream implements Closeable {
} }
return new IntArrayTag(name, data); return new IntArrayTag(name, data);
default: default:
throw new IOException("Invalid tag type: " + type + "."); throw new IOException("Invalid tag type: " + type + '.');
} }
} }

View File

@ -100,7 +100,7 @@ public final class NBTOutputStream implements Closeable {
writeIntArrayTagPayload((IntArrayTag) tag); writeIntArrayTagPayload((IntArrayTag) tag);
break; break;
default: default:
throw new IOException("Invalid tag type: " + type + "."); throw new IOException("Invalid tag type: " + type + '.');
} }
} }

View File

@ -179,7 +179,7 @@ public class JSONArray {
Object object = get(index); Object object = get(index);
try { try {
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
throw new JSONException("JSONArray[" + index + "] is not a number."); throw new JSONException("JSONArray[" + index + "] is not a number.");
} }
} }
@ -197,7 +197,7 @@ public class JSONArray {
Object object = get(index); Object object = get(index);
try { try {
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
throw new JSONException("JSONArray[" + index + "] is not a number."); throw new JSONException("JSONArray[" + index + "] is not a number.");
} }
} }
@ -249,7 +249,7 @@ public class JSONArray {
Object object = get(index); Object object = get(index);
try { try {
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
throw new JSONException("JSONArray[" + index + "] is not a number."); throw new JSONException("JSONArray[" + index + "] is not a number.");
} }
} }
@ -348,7 +348,7 @@ public class JSONArray {
public boolean optBoolean(int index, boolean defaultValue) { public boolean optBoolean(int index, boolean defaultValue) {
try { try {
return getBoolean(index); return getBoolean(index);
} catch (JSONException e) { } catch (JSONException ignored) {
return defaultValue; return defaultValue;
} }
} }
@ -377,7 +377,7 @@ public class JSONArray {
public double optDouble(int index, double defaultValue) { public double optDouble(int index, double defaultValue) {
try { try {
return getDouble(index); return getDouble(index);
} catch (JSONException e) { } catch (JSONException ignored) {
return defaultValue; return defaultValue;
} }
} }
@ -406,7 +406,7 @@ public class JSONArray {
public int optInt(int index, int defaultValue) { public int optInt(int index, int defaultValue) {
try { try {
return getInt(index); return getInt(index);
} catch (JSONException e) { } catch (JSONException ignored) {
return defaultValue; return defaultValue;
} }
} }
@ -460,7 +460,7 @@ public class JSONArray {
public long optLong(int index, long defaultValue) { public long optLong(int index, long defaultValue) {
try { try {
return getLong(index); return getLong(index);
} catch (JSONException e) { } catch (JSONException ignored) {
return defaultValue; return defaultValue;
} }
} }
@ -778,7 +778,7 @@ public class JSONArray {
public String toString() { public String toString() {
try { try {
return this.toString(0); return this.toString(0);
} catch (JSONException e) { } catch (JSONException ignored) {
return null; return null;
} }
} }

View File

@ -61,7 +61,7 @@ class XML {
} }
for (char c : string.toCharArray()) { for (char c : string.toCharArray()) {
if (Character.isWhitespace(c)) { if (Character.isWhitespace(c)) {
throw new JSONException("'" + string + "' contains a space character."); throw new JSONException('\'' + string + "' contains a space character.");
} }
} }
} }
@ -369,8 +369,8 @@ class XML {
return sb.toString(); return sb.toString();
} else { } else {
string = escape(object.toString()); string = escape(object.toString());
return (tagName == null) ? "\"" + string + "\"" : return (tagName == null) ? '"' + string + '"' :
string.isEmpty() ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">"; string.isEmpty() ? '<' + tagName + "/>" : '<' + tagName + '>' + string + "</" + tagName + '>';
} }
} }
} }

View File

@ -1,5 +1,7 @@
package com.intellectualcrafters.json; package com.intellectualcrafters.json;
import java.util.HashMap;
/** /**
* The XMLTokener extends the JSONTokener to provide additional methods for the parsing of XML texts. * The XMLTokener extends the JSONTokener to provide additional methods for the parsing of XML texts.
* *
@ -10,9 +12,9 @@ public class XMLTokener extends JSONTokener {
/** /**
* The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot. * The table of entity values. It initially contains Character values for amp, apos, gt, lt, quot.
*/ */
public static final java.util.HashMap<String, Character> entity; public static final HashMap<String, Character> entity;
static { static {
entity = new java.util.HashMap<String, Character>(8); entity = new HashMap<>(8);
entity.put("amp", XML.AMP); entity.put("amp", XML.AMP);
entity.put("apos", XML.APOS); entity.put("apos", XML.APOS);
entity.put("gt", XML.GT); entity.put("gt", XML.GT);
@ -37,16 +39,14 @@ public class XMLTokener extends JSONTokener {
* @throws JSONException If the <code>]]&gt;</code> is not found. * @throws JSONException If the <code>]]&gt;</code> is not found.
*/ */
public String nextCDATA() throws JSONException { public String nextCDATA() throws JSONException {
char c;
int i;
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (;;) { for (;;) {
c = next(); char c = next();
if (end()) { if (end()) {
throw syntaxError("Unclosed CDATA"); throw syntaxError("Unclosed CDATA");
} }
sb.append(c); sb.append(c);
i = sb.length() - 3; int i = sb.length() - 3;
if ((i >= 0) && (sb.charAt(i) == ']') && (sb.charAt(i + 1) == ']') && (sb.charAt(i + 2) == '>')) { if ((i >= 0) && (sb.charAt(i) == ']') && (sb.charAt(i + 1) == ']') && (sb.charAt(i + 2) == '>')) {
sb.setLength(i); sb.setLength(i);
return sb.toString(); return sb.toString();
@ -64,7 +64,6 @@ public class XMLTokener extends JSONTokener {
*/ */
public Object nextContent() throws JSONException { public Object nextContent() throws JSONException {
char c; char c;
StringBuilder sb;
do { do {
c = next(); c = next();
} while (Character.isWhitespace(c)); } while (Character.isWhitespace(c));
@ -74,14 +73,14 @@ public class XMLTokener extends JSONTokener {
if (c == '<') { if (c == '<') {
return XML.LT; return XML.LT;
} }
sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (;;) { for (;;) {
if ((c == '<') || (c == 0)) { if ((c == '<') || (c == 0)) {
back(); back();
return sb.toString().trim(); return sb.toString().trim();
} }
if (c == '&') { if (c == '&') {
sb.append(nextEntity(c)); sb.append(nextEntity('&'));
} else { } else {
sb.append(c); sb.append(c);
} }
@ -113,7 +112,7 @@ public class XMLTokener extends JSONTokener {
} }
final String string = sb.toString(); final String string = sb.toString();
final Object object = entity.get(string); final Object object = entity.get(string);
return object != null ? object : ampersand + string + ";"; return object != null ? object : ampersand + string + ';';
} }
/** /**
@ -126,10 +125,10 @@ public class XMLTokener extends JSONTokener {
*/ */
public Object nextMeta() throws JSONException { public Object nextMeta() throws JSONException {
char c; char c;
char q;
do { do {
c = next(); c = next();
} while (Character.isWhitespace(c)); } while (Character.isWhitespace(c));
char q;
switch (c) { switch (c) {
case 0: case 0:
throw syntaxError("Misshaped meta tag"); throw syntaxError("Misshaped meta tag");
@ -190,11 +189,11 @@ public class XMLTokener extends JSONTokener {
*/ */
public Object nextToken() throws JSONException { public Object nextToken() throws JSONException {
char c; char c;
char q;
StringBuilder sb;
do { do {
c = next(); c = next();
} while (Character.isWhitespace(c)); } while (Character.isWhitespace(c));
char q;
StringBuilder sb;
switch (c) { switch (c) {
case 0: case 0:
throw syntaxError("Misshaped element"); throw syntaxError("Misshaped element");
@ -224,7 +223,7 @@ public class XMLTokener extends JSONTokener {
return sb.toString(); return sb.toString();
} }
if (c == '&') { if (c == '&') {
sb.append(nextEntity(c)); sb.append(nextEntity('&'));
} else { } else {
sb.append(c); sb.append(c);
} }
@ -268,11 +267,8 @@ public class XMLTokener extends JSONTokener {
* @throws JSONException * @throws JSONException
*/ */
public boolean skipPast(final String to) throws JSONException { public boolean skipPast(final String to) throws JSONException {
boolean b;
char c; char c;
int i; int i;
int j;
int offset = 0;
final int length = to.length(); final int length = to.length();
final char[] circle = new char[length]; final char[] circle = new char[length];
/* /*
@ -287,9 +283,9 @@ public class XMLTokener extends JSONTokener {
circle[i] = c; circle[i] = c;
} }
/* We will loop, possibly for all of the remaining characters. */ /* We will loop, possibly for all of the remaining characters. */
for (;;) { for (int offset = 0; ;) {
j = offset; int j = offset;
b = true; boolean b = true;
/* Compare the circle buffer with the to string. */ /* Compare the circle buffer with the to string. */
for (i = 0; i < length; i += 1) { for (i = 0; i < length; i += 1) {
if (circle[j] != to.charAt(i)) { if (circle[j] != to.charAt(i)) {

View File

@ -51,7 +51,7 @@ public class DebugClaimTest extends SubCommand {
args[2].split(";"); args[2].split(";");
min = PlotId.fromString(args[1]); min = PlotId.fromString(args[1]);
max = PlotId.fromString(args[2]); max = PlotId.fromString(args[2]);
} catch (Exception e) { } catch (Exception ignored) {
return !MainUtil.sendMessage(plr, return !MainUtil.sendMessage(plr,
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion " "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion "
+ "will only check the plots in the selected area."); + "will only check the plots in the selected area.");

View File

@ -187,7 +187,7 @@ public class DebugExec extends SubCommand {
double threshold; double threshold;
try { try {
threshold = Integer.parseInt(args[1]) / 100d; threshold = Integer.parseInt(args[1]) / 100d;
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
MainUtil.sendMessage(player, "$2Invalid threshold: " + args[1]); MainUtil.sendMessage(player, "$2Invalid threshold: " + args[1]);
MainUtil.sendMessage(player, "$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100"); MainUtil.sendMessage(player, "$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100");
return false; return false;

View File

@ -30,7 +30,7 @@ public class DebugPaste extends SubCommand {
String latestLOG; String latestLOG;
try { try {
latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log")); latestLOG = HastebinUtility.upload(new File(PS.get().IMP.getDirectory(), "../../logs/latest.log"));
} catch (IOException e) { } catch (IOException ignored) {
MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore"); MainUtil.sendMessage(plr, "&clatest.log is too big to be pasted, will ignore");
latestLOG = "too big :("; latestLOG = "too big :(";
} }
@ -38,12 +38,12 @@ public class DebugPaste extends SubCommand {
b.append( b.append(
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your " "# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
+ "problem\n\n# We will start with some informational files\n"); + "problem\n\n# We will start with some informational files\n");
b.append("links.settings_yml: ").append(settingsYML).append("\n"); b.append("links.settings_yml: ").append(settingsYML).append('\n');
b.append("links.latest_log: ").append(latestLOG).append("\n"); b.append("links.latest_log: ").append(latestLOG).append('\n');
b.append("\n# Server Information\n"); b.append("\n# Server Information\n");
int[] sVersion = PS.get().IMP.getServerVersion(); int[] sVersion = PS.get().IMP.getServerVersion();
b.append("version.server: ").append(sVersion[0]).append('.').append(sVersion[1]).append('.').append(sVersion[2]).append("\n"); b.append("version.server: ").append(sVersion[0]).append('.').append(sVersion[1]).append('.').append(sVersion[2]).append('\n');
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(";").append(!Settings.OFFLINE_MODE).append("\n"); b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';').append(!Settings.OFFLINE_MODE).append('\n');
b.append("plugins:"); b.append("plugins:");
for (String id : PS.get().IMP.getPluginIds()) { for (String id : PS.get().IMP.getPluginIds()) {
String[] split = id.split(":"); String[] split = id.split(":");
@ -51,13 +51,13 @@ public class DebugPaste extends SubCommand {
String enabled = split.length == 2 ? split[1] : "unknown"; String enabled = split.length == 2 ? split[1] : "unknown";
String name = split2[0]; String name = split2[0];
String version = split2.length == 2 ? split2[1] : "unknown"; String version = split2.length == 2 ? split2[1] : "unknown";
b.append("\n ").append(name).append(":\n ").append("version: '").append(version).append("'").append("\n enabled: ") b.append("\n ").append(name).append(":\n ").append("version: '").append(version).append('\'').append("\n enabled: ")
.append(enabled); .append(enabled);
} }
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n"); b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
b.append("memory.free: ").append(runtime.freeMemory()).append("\n"); b.append("memory.free: ").append(runtime.freeMemory()).append('\n');
b.append("memory.max: ").append(runtime.maxMemory()).append("\n"); b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n"); b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
b.append("java.version: '").append(System.getProperty("java.version")).append("'\n"); b.append("java.version: '").append(System.getProperty("java.version")).append("'\n");

View File

@ -37,7 +37,7 @@ public class DebugRoadRegen extends SubCommand {
if (MathMan.isInteger(args[0])) { if (MathMan.isInteger(args[0])) {
try { try {
extend = Integer.parseInt(args[0]); extend = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (NumberFormatException ignored) {
C.NOT_VALID_NUMBER.send(player, "(0, <EXTEND HEIGHT>)"); C.NOT_VALID_NUMBER.send(player, "(0, <EXTEND HEIGHT>)");
return false; return false;
} }
@ -45,7 +45,7 @@ public class DebugRoadRegen extends SubCommand {
} }
boolean result = HybridUtils.manager.regenerateRoad(plotworld, chunk, extend); boolean result = HybridUtils.manager.regenerateRoad(plotworld, chunk, extend);
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed")); "&6Regenerating chunk: " + chunk.x + ',' + chunk.z + "\n&6 - Result: " + (result ? "&aSuccess" : "&cFailed"));
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads"); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
} else { } else {
HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager(); HybridPlotManager manager = (HybridPlotManager) plotworld.getPlotManager();

View File

@ -95,8 +95,8 @@ public class FlagCmd extends SubCommand {
return false; return false;
} }
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " "); String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase())) { if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + value.toLowerCase())) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + value.toLowerCase()); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + value.toLowerCase());
return false; return false;
} }
Object parsed = flag.parseValue(value); Object parsed = flag.parseValue(value);
@ -127,8 +127,8 @@ public class FlagCmd extends SubCommand {
return false; return false;
} }
for (String entry : args[2].split(",")) { for (String entry : args[2].split(",")) {
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) { if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + entry)) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + entry);
return false; return false;
} }
} }
@ -167,8 +167,8 @@ public class FlagCmd extends SubCommand {
return false; return false;
} }
for (String entry : args[2].split(",")) { for (String entry : args[2].split(",")) {
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) { if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + entry)) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + entry);
return false; return false;
} }
} }

View File

@ -47,7 +47,7 @@ public class Inbox extends SubCommand {
StringBuilder string = new StringBuilder(); StringBuilder string = new StringBuilder();
string.append(StringMan string.append(StringMan
.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") .replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all")
+ "\n"); + '\n');
// This might work xD // This might work xD
for (int x = page * 12; x < max; x++) { for (int x = page * 12; x < max; x++) {
@ -58,9 +58,8 @@ public class Inbox extends SubCommand {
} else { } else {
color = "&7"; color = "&7";
} }
string.append( string.append("&8[&7#").append(x + 1).append("&8][&7").append(comment.world).append(';').append(comment.id).append("&8][&6")
"&8[&7#" + (x + 1) + "&8][&7" + comment.world + ";" + comment.id + "&8][&6" + comment.senderName + "&8]" + color + comment.comment .append(comment.senderName).append("&8]").append(color).append(comment.comment).append('\n');
+ "\n");
} }
MainUtil.sendMessage(player, string.toString()); MainUtil.sendMessage(player, string.toString());
} }
@ -71,7 +70,8 @@ public class Inbox extends SubCommand {
if (plot == null) { if (plot == null) {
sendMessage(player, C.NOT_IN_PLOT); sendMessage(player, C.NOT_IN_PLOT);
return false; return false;
} else if (!plot.hasOwner()) { }
if (!plot.hasOwner()) {
sendMessage(player, C.PLOT_UNOWNED); sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
@ -98,7 +98,7 @@ public class Inbox extends SubCommand {
} else { } else {
color = ""; color = "";
} }
sendMessage(player, C.INBOX_ITEM, color + inbox.toString() + " (" + total + "/" + unread + ")"); sendMessage(player, C.INBOX_ITEM, color + inbox.toString() + " (" + total + '/' + unread + ')');
return; return;
} }
} }
@ -135,7 +135,7 @@ public class Inbox extends SubCommand {
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + ""); sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
return false; return false;
} }
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete <index>"); sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete <index>");
return false; return false;
} }
@ -171,7 +171,7 @@ public class Inbox extends SubCommand {
default: default:
try { try {
page = Integer.parseInt(args[1]); page = Integer.parseInt(args[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]"); sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
return false; return false;
} }

View File

@ -31,7 +31,7 @@ public class RegenAllRoads extends SubCommand {
if (args.length == 2) { if (args.length == 2) {
try { try {
height = Integer.parseInt(args[1]); height = Integer.parseInt(args[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException ignored) {
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)"); MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
return false; return false;

View File

@ -68,7 +68,7 @@ public class Save extends SubCommand {
int size = (corners[1].getX() - corners[0].getX()) + 1; int size = (corners[1].getX() - corners[0].getX()) + 1;
PlotId id = plot.getId(); PlotId id = plot.getId();
String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", ""); String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name; final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size + '_' + name;
UUID uuid = plr.getUUID(); UUID uuid = plr.getUUID();
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() { SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
@Override @Override

View File

@ -101,7 +101,7 @@ public class Set extends SubCommand {
} }
} }
} }
} catch (Exception e2) { } catch (Exception ignored) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material); MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, material);
return false; return false;
} }

View File

@ -9,7 +9,7 @@ import com.plotsquared.general.commands.Command;
/** /**
* SubCommand class * SubCommand class
* @see com.plotsquared.general.commands.Command(com.plotsquared.general.commands.Command, boolean) * @see Command(Command, boolean)
* @Deprecated In favor of normal Command class * @Deprecated In favor of normal Command class
*/ */
public abstract class SubCommand extends Command { public abstract class SubCommand extends Command {

View File

@ -27,7 +27,7 @@ public class Update extends SubCommand {
} else if (args.length == 1) { } else if (args.length == 1) {
try { try {
url = new URL(args[0]); url = new URL(args[0]);
} catch (MalformedURLException e) { } catch (MalformedURLException ignored) {
MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]); MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]);
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
return false; return false;

View File

@ -89,7 +89,7 @@ public class Visit extends SubCommand {
} }
} }
if (page < 1 || page > unsorted.size()) { if (page < 1 || page > unsorted.size()) {
sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ")"); sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ')');
return false; return false;
} }
List<Plot> plots = PS.get().sortPlotsByTemp(unsorted); List<Plot> plots = PS.get().sortPlotsByTemp(unsorted);

View File

@ -35,7 +35,7 @@ public class ConfigurationNode {
try { try {
Object result = this.type.parseString(string); Object result = this.type.parseString(string);
return result != null; return result != null;
} catch (Exception e) { } catch (Exception ignored) {
return false; return false;
} }
} }
@ -51,13 +51,15 @@ public class ConfigurationNode {
public Object getValue() { public Object getValue() {
if (this.value instanceof String[]) { if (this.value instanceof String[]) {
return Arrays.asList((String[]) this.value); return Arrays.asList((String[]) this.value);
} else if (this.value instanceof Object[]) { }
List<String> values = new ArrayList<String>(); if (this.value instanceof Object[]) {
List<String> values = new ArrayList<>();
for (Object value : (Object[]) this.value) { for (Object value : (Object[]) this.value) {
values.add(value.toString()); values.add(value.toString());
} }
return values; return values;
} else if (this.value instanceof PlotBlock) { }
if (this.value instanceof PlotBlock) {
return this.value.toString(); return this.value.toString();
} }
return this.value; return this.value;

View File

@ -11,7 +11,6 @@ import com.intellectualcrafters.plot.object.comment.PlotComment;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -58,7 +57,7 @@ public class DBFunc {
} }
} }
return false; return false;
} catch (SQLException e) { } catch (SQLException ignored) {
return false; return false;
} }
} }

View File

@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.database;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
/** /**
* Abstract Database class, serves as a base for any connection method (MySQL, SQLite, etc.) * Abstract Database class, serves as a base for any connection method (MySQL, SQLite, etc.)
@ -64,12 +65,12 @@ public abstract class Database {
/** /**
* Executes an Update SQL Query. * Executes an Update SQL Query.
* See {@link java.sql.Statement#executeUpdate(String)}. * See {@link Statement#executeUpdate(String)}.
* If the connection is closed, it will be opened. * If the connection is closed, it will be opened.
* *
* @param query Query to be run * @param query Query to be run
* *
* @return Result Code, see {@link java.sql.Statement#executeUpdate(String)} * @return Result Code, see {@link Statement#executeUpdate(String)}
* *
* @throws SQLException If the query cannot be executed * @throws SQLException If the query cannot be executed
* @throws ClassNotFoundException If the driver cannot be found; see {@link #openConnection()} * @throws ClassNotFoundException If the driver cannot be found; see {@link #openConnection()}

View File

@ -45,7 +45,7 @@ public class MySQL extends Database {
public Connection forceConnection() throws SQLException, ClassNotFoundException { public Connection forceConnection() throws SQLException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
this.connection = this.connection =
DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password);
return this.connection; return this.connection;
} }
@ -55,9 +55,9 @@ public class MySQL extends Database {
return this.connection; return this.connection;
} }
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
PS.debug("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database); PS.debug("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database);
this.connection = this.connection =
DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password);
return this.connection; return this.connection;
} }

View File

@ -1467,9 +1467,7 @@ public class SQLManager implements AbstractDB {
if (this.mySQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) { if (this.mySQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
try (Statement stmt = this.connection.createStatement()) { try (Statement stmt = this.connection.createStatement()) {
stmt.executeUpdate("ALTER TABLE `" + this.prefix + "plots` DROP INDEX `unique_alias`"); stmt.executeUpdate("ALTER TABLE `" + this.prefix + "plots` DROP INDEX `unique_alias`");
} catch (SQLException ignore) { } catch (SQLException ignored) {}
//ignored
}
} }
DatabaseMetaData data = this.connection.getMetaData(); DatabaseMetaData data = this.connection.getMetaData();
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id"); ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id");

View File

@ -13,7 +13,7 @@ public class DoubleFlag extends Flag<Double> {
@Override public Double parseValue(String value) { @Override public Double parseValue(String value) {
try { try {
return Double.parseDouble(value); return Double.parseDouble(value);
} catch (IllegalArgumentException e) { } catch (NumberFormatException ignored) {
return null; return null;
} }

View File

@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotSettings;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -32,7 +33,7 @@ public class FlagManager {
/** /**
* Some events can be called millions of times each second (e.g. physics) and reusing is a lot faster. * Some events can be called millions of times each second (e.g. physics) and reusing is a lot faster.
*/ */
private static Optional MUTABLE_OPTIONAL; private static final Optional MUTABLE_OPTIONAL;
private static Field MUTABLE_OPTIONAL_FIELD; private static Field MUTABLE_OPTIONAL_FIELD;
static { static {
MUTABLE_OPTIONAL = Optional.of(new Object()); MUTABLE_OPTIONAL = Optional.of(new Object());
@ -51,7 +52,9 @@ public class FlagManager {
try { try {
MUTABLE_OPTIONAL_FIELD.set(MUTABLE_OPTIONAL, value); MUTABLE_OPTIONAL_FIELD.set(MUTABLE_OPTIONAL, value);
return MUTABLE_OPTIONAL; return MUTABLE_OPTIONAL;
} catch (IllegalAccessException e) {e.printStackTrace();} } catch (IllegalAccessException e) {
e.printStackTrace();
}
} }
return Optional.of(value); return Optional.of(value);
} }
@ -97,9 +100,9 @@ public class FlagManager {
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) { for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
Flag<?> flag = entry.getKey(); Flag<?> flag = entry.getKey();
if (i != 0) { if (i != 0) {
flag_string.append(","); flag_string.append(',');
} }
flag_string.append(flag.getName() + ":" + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
i++; i++;
} }
return flag_string.toString(); return flag_string.toString();

View File

@ -17,7 +17,7 @@ public class IntegerFlag extends Flag<Integer> {
@Override public Integer parseValue(String value) { @Override public Integer parseValue(String value) {
try { try {
return Integer.parseInt(value); return Integer.parseInt(value);
} catch (IllegalArgumentException e) { } catch (NumberFormatException ignored) {
return null; return null;
} }
} }

View File

@ -18,7 +18,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
@Override @Override
public void loadConfiguration(ConfigurationSection config) { public void loadConfiguration(ConfigurationSection config) {
if (!config.contains("plot.height")) { if (!config.contains("plot.height")) {
PS.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ")"); PS.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ')');
} }
this.PLOT_WIDTH = config.getInt("plot.size"); this.PLOT_WIDTH = config.getInt("plot.size");
this.ROAD_WIDTH = config.getInt("road.width"); this.ROAD_WIDTH = config.getInt("road.width");

View File

@ -24,8 +24,8 @@ public class BO3 {
public void addChild(BO3 child) { public void addChild(BO3 child) {
ChunkLoc childloc = child.getLoc(); ChunkLoc childloc = child.getLoc();
this.children.append("Branch(").append(childloc.x - this.chunk.x).append(",0,").append(childloc.z - this.chunk.z).append(",") this.children.append("Branch(").append(childloc.x - this.chunk.x).append(",0,").append(childloc.z - this.chunk.z).append(',')
.append(this.name).append("_").append(childloc.x).append("_").append(childloc.z).append(")\n"); .append(this.name).append('_').append(childloc.x).append('_').append(childloc.z).append(")\n");
} }
public ChunkLoc getLoc() { public ChunkLoc getLoc() {
@ -43,9 +43,9 @@ public class BO3 {
public void addBlock(int x, int y, int z, PlotBlock block) { public void addBlock(int x, int y, int z, PlotBlock block) {
if (block.data == 0) { if (block.data == 0) {
// Block(-3,1,-2,AIR) // Block(-3,1,-2,AIR)
this.blocks.append("Block(").append(x).append(",").append(y).append(",").append(z).append(",").append(block.id).append(")\n"); this.blocks.append("Block(").append(x).append(',').append(y).append(',').append(z).append(',').append(block.id).append(")\n");
} else { } else {
this.blocks.append("Block(").append(x).append(",").append(y).append(",").append(z).append(",").append(block.id).append(":") this.blocks.append("Block(").append(x).append(',').append(y).append(',').append(z).append(',').append(block.id).append(':')
.append(block.data).append(")\n"); .append(block.data).append(")\n");
} }
} }
@ -66,7 +66,7 @@ public class BO3 {
if (this.chunk.x == 0 && this.chunk.z == 0) { if (this.chunk.x == 0 && this.chunk.z == 0) {
return this.name + ".bo3"; return this.name + ".bo3";
} else { } else {
return this.name + ("_" + this.chunk.x + "_" + this.chunk.z) + ".bo3"; return this.name + ("_" + this.chunk.x + '_' + this.chunk.z) + ".bo3";
} }
} }
} }

View File

@ -276,7 +276,7 @@ public class BO3Handler {
if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) { if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) {
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3"); bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3");
} else { } else {
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3"); bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + '_' + bo3.getLoc().x + '_' + bo3.getLoc().z + ".bo3");
} }
bo3File.createNewFile(); bo3File.createNewFile();
Files.write(bo3File.toPath(), StringMan.join(lines, System.getProperty("line.separator")).getBytes(), StandardOpenOption.WRITE); Files.write(bo3File.toPath(), StringMan.join(lines, System.getProperty("line.separator")).getBytes(), StandardOpenOption.WRITE);

View File

@ -137,7 +137,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_BREAK.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_BREAK.s()));
case BREAK_HANGING: case BREAK_HANGING:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
@ -261,7 +261,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_HANGING_INTERACT.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_HANGING_INTERACT.s()));
} }
return true; return true;
} }
@ -287,7 +287,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_MISC_INTERACT.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_MISC_INTERACT.s()));
} }
return true; return true;
} }
@ -312,7 +312,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_VEHICLE_USE.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + '/' + C.FLAG_VEHICLE_USE.s()));
} }
return true; return true;
} }
@ -337,7 +337,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + "/" + C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MOB_PLACE.s() + '/' + C.FLAG_PLACE.s()));
} }
return true; return true;
} }
@ -364,7 +364,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + "/" + C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_MISC_PLACE.s() + '/' + C.FLAG_PLACE.s()));
} }
return true; return true;
@ -390,7 +390,7 @@ public abstract class EventUtil {
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
return true; return true;
} }
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + "/" + C.FLAG_PLACE.s())); return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_VEHICLE_PLACE.s() + '/' + C.FLAG_PLACE.s()));
} }
return true; return true;
default: default:

View File

@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
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;
@ -152,7 +153,7 @@ public class MainUtil {
String param = "value"; String param = "value";
writer.append(CRLF).append(param).append(CRLF).flush(); writer.append(CRLF).append(param).append(CRLF).flush();
writer.append("--" + boundary).append(CRLF); writer.append("--" + boundary).append(CRLF);
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + "\"").append(CRLF); writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + '"').append(CRLF);
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF); writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF);
writer.append("Content-Transfer-Encoding: binary").append(CRLF); writer.append("Content-Transfer-Encoding: binary").append(CRLF);
writer.append(CRLF).flush(); writer.append(CRLF).flush();
@ -737,16 +738,14 @@ public class MainUtil {
String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get()); String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get());
StringBuilder flags = new StringBuilder(); StringBuilder flags = new StringBuilder();
{ HashMap<Flag<?>, Object> flagMap = FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true);
HashMap<Flag<?>, Object> flagMap = FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true); if (flagMap.isEmpty()) {
if (flagMap.isEmpty()) { flags.append(C.NONE.s());
flags.append(C.NONE.s()); } else {
} else { String prefix = "";
String prefix = ""; for (Entry<Flag<?>, Object> entry : flagMap.entrySet()) {
for (Entry<Flag<?>, Object> entry : flagMap.entrySet()) { flags.append(prefix).append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), entry.getValue()));
flags.append(prefix).append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), entry.getValue())); prefix = ", ";
prefix = ", ";
}
} }
} }
boolean build = plot.isAdded(player.getUUID()); boolean build = plot.isAdded(player.getUUID());
@ -755,7 +754,7 @@ public class MainUtil {
info = info.replace("%id%", plot.getId().toString()); info = info.replace("%id%", plot.getId().toString());
info = info.replace("%alias%", alias); info = info.replace("%alias%", alias);
info = info.replace("%num%", num + ""); info = info.replace("%num%", String.valueOf(num));
info = info.replace("%desc%", description); info = info.replace("%desc%", description);
info = info.replace("%biome%", biome); info = info.replace("%biome%", biome);
info = info.replace("%owner%", owner); info = info.replace("%owner%", owner);
@ -766,7 +765,7 @@ public class MainUtil {
info = info.replace("%denied%", denied); info = info.replace("%denied%", denied);
info = info.replace("%expires%", expires); info = info.replace("%expires%", expires);
info = info.replace("%flags%", flags); info = info.replace("%flags%", flags);
info = info.replace("%build%", build + ""); info = info.replace("%build%", String.valueOf(build));
info = info.replace("%desc%", "No description set."); info = info.replace("%desc%", "No description set.");
if (info.contains("%rating%")) { if (info.contains("%rating%")) {
final String newInfo = info; final String newInfo = info;

View File

@ -80,7 +80,7 @@ public abstract class SchematicHandler {
} }
final String name; final String name;
if (namingScheme == null) { if (namingScheme == null) {
name = plot.getId().x + ";" + plot.getId().y + "," + plot.getArea() + "," + o; name = plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + o;
} else { } else {
name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.getId().toString()).replaceAll("%idx%", plot.getId().x + "").replaceAll("%idy%", plot.getId().y + "") name = namingScheme.replaceAll("%owner%", o).replaceAll("%id%", plot.getId().toString()).replaceAll("%idx%", plot.getId().x + "").replaceAll("%idy%", plot.getId().y + "")
.replaceAll("%world%", plot.getArea().toString()); .replaceAll("%world%", plot.getArea().toString());
@ -170,7 +170,7 @@ public abstract class SchematicHandler {
if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ((region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ((region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT
> 256)) { > 256)) {
PS.debug("Schematic is too large"); PS.debug("Schematic is too large");
PS.debug("(" + WIDTH + "," + LENGTH + "," + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + "," + (region.maxZ - region.minZ) + ",256)"); PS.debug("(" + WIDTH + ',' + LENGTH + ',' + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + ',' + (region.maxZ - region.minZ) + ",256)");
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }

View File

@ -26,7 +26,7 @@ public class UUIDHandler {
* *
* @return map with names + uuids * @return map with names + uuids
* *
* @see com.google.common.collect.BiMap * @see BiMap
*/ */
public static BiMap<StringWrapper, UUID> getUuidMap() { public static BiMap<StringWrapper, UUID> getUuidMap() {
return implementation.getUUIDMap(); return implementation.getUUIDMap();
@ -39,7 +39,7 @@ public class UUIDHandler {
* *
* @return true of the uuid is cached * @return true of the uuid is cached
* *
* @see com.google.common.collect.BiMap#containsValue(Object) * @see BiMap#containsValue(Object)
*/ */
public static boolean uuidExists(UUID uuid) { public static boolean uuidExists(UUID uuid) {
return implementation.uuidExists(uuid); return implementation.uuidExists(uuid);
@ -52,7 +52,7 @@ public class UUIDHandler {
* *
* @return true of the name is cached * @return true of the name is cached
* *
* @see com.google.common.collect.BiMap#containsKey(Object) * @see BiMap#containsKey(Object)
*/ */
public static boolean nameExists(StringWrapper name) { public static boolean nameExists(StringWrapper name) {
return implementation.nameExists(name); return implementation.nameExists(name);

View File

@ -124,7 +124,7 @@ public abstract class WorldUtil {
} }
public File getMcr(String world, int x, int z) { public File getMcr(String world, int x, int z) {
File file = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region" + File.separator + "r." + x + "." + z + ".mca"); File file = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
if (file.exists()) { if (file.exists()) {
return file; return file;
} }

View File

@ -44,11 +44,16 @@ public class PlotListener {
EventUtil.manager.callEntry(pp, plot); EventUtil.manager.callEntry(pp, plot);
if (plot.hasOwner()) { if (plot.hasOwner()) {
Map<Flag<?>, Object> flags = FlagManager.getPlotFlags(plot); Map<Flag<?>, Object> flags = FlagManager.getPlotFlags(plot);
int size = flags.size();
boolean titles = Settings.TITLES; boolean titles = Settings.TITLES;
final String greeting; final String greeting;
if (size != 0) { if (flags.isEmpty()) {
if (titles) {
greeting = "";
} else {
return true;
}
} else {
Optional<Boolean> titleFlag = plot.getFlag(Flags.TITLES); Optional<Boolean> titleFlag = plot.getFlag(Flags.TITLES);
if (titleFlag.isPresent()) { if (titleFlag.isPresent()) {
titles = titleFlag.get(); titles = titleFlag.get();
@ -97,7 +102,7 @@ public class PlotListener {
try { try {
long time = timeFlag.get(); long time = timeFlag.get();
pp.setTime(time); pp.setTime(time);
} catch (Exception e) { } catch (Exception ignored) {
FlagManager.removePlotFlag(plot, Flags.TIME); FlagManager.removePlotFlag(plot, Flags.TIME);
} }
} }
@ -133,10 +138,6 @@ public class PlotListener {
} }
} }
CommentManager.sendTitle(pp, plot); CommentManager.sendTitle(pp, plot);
} else if (titles) {
greeting = "";
} else {
return true;
} }
if (titles) { if (titles) {
if (!C.TITLE_ENTERED_PLOT.s().isEmpty() || !C.TITLE_ENTERED_PLOT_SUB.s().isEmpty()) { if (!C.TITLE_ENTERED_PLOT.s().isEmpty() || !C.TITLE_ENTERED_PLOT_SUB.s().isEmpty()) {
@ -146,7 +147,7 @@ public class PlotListener {
Plot lastPlot = pp.getMeta("lastplot"); Plot lastPlot = pp.getMeta("lastplot");
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) { if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
Map<String, String> replacements = new HashMap<>(); Map<String, String> replacements = new HashMap<>();
replacements.put("%x%", lastPlot.getId().x + ""); replacements.put("%x%", String.valueOf(lastPlot.getId().x));
replacements.put("%z%", lastPlot.getId().y + ""); replacements.put("%z%", lastPlot.getId().y + "");
replacements.put("%world%", plot.getArea().toString()); replacements.put("%world%", plot.getArea().toString());
replacements.put("%greeting%", greeting); replacements.put("%greeting%", greeting);

View File

@ -76,6 +76,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3") @Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
public class SpongeMain implements IPlotMain { public class SpongeMain implements IPlotMain {
@ -258,7 +259,7 @@ public class SpongeMain implements IPlotMain {
try { try {
Class.forName("com.sk89q.worldedit.WorldEdit"); Class.forName("com.sk89q.worldedit.WorldEdit");
return true; return true;
} catch (Throwable e) { } catch (ClassNotFoundException ignored) {
return false; return false;
} }
} }
@ -306,7 +307,7 @@ public class SpongeMain implements IPlotMain {
Metrics metrics = new Metrics(this.game, this.plugin); Metrics metrics = new Metrics(this.game, this.plugin);
metrics.start(); metrics.start();
log(C.PREFIX.s() + "&6Metrics enabled."); log(C.PREFIX.s() + "&6Metrics enabled.");
} catch (IOException e) { } catch (IOException ignored) {
log(C.PREFIX.s() + "&cFailed to load up metrics."); log(C.PREFIX.s() + "&cFailed to load up metrics.");
} }
} }
@ -376,7 +377,7 @@ public class SpongeMain implements IPlotMain {
try { try {
MainUtil.canSendChunk = true; MainUtil.canSendChunk = true;
return new FastQueue(); return new FastQueue();
} catch (Throwable e) { } catch (RuntimeException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -412,10 +413,7 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public List<String> getPluginIds() { public List<String> getPluginIds() {
ArrayList<String> names = new ArrayList<>(); return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true)
for (PluginContainer plugin : this.game.getPluginManager().getPlugins()) { .collect(Collectors.toCollection(ArrayList::new));
names.add(plugin.getName() + ";" + plugin.getVersion() + ":" + true);
}
return names;
} }
} }

View File

@ -30,7 +30,7 @@ public class SpongeCommand implements CommandCallable {
UUID uuid = UUID.fromString(id); UUID uuid = UUID.fromString(id);
Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get(); Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
pp = SpongeUtil.getPlayer(player); pp = SpongeUtil.getPlayer(player);
} catch (Exception e) { } catch (Exception ignored) {
pp = ConsolePlayer.getConsole(); pp = ConsolePlayer.getConsole();
} }
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" ")); MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));