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 {
writeJson(json);
json.close();
} catch (IOException e) {
} catch (IOException ignored) {
throw new RuntimeException("invalid message");
}
this.jsonString = string.toString();

View File

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

View File

@ -67,7 +67,7 @@ public class DebugUUID extends SubCommand {
try {
Class<?> clazz = Class.forName(args[0]);
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>");
return false;
}

View File

@ -94,9 +94,7 @@ public class LikePlotMeConverter {
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
content = content.replaceAll("PlotMe", "PlotSquared");
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
} catch (IOException ignored) {
//ignored
}
} catch (IOException ignored) {}
}
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();
}
} catch (SQLException | ClassNotFoundException ignored) {
//ignored
ignored.printStackTrace();
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
@ -116,7 +115,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
}
}
if (owner == null) {
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + '\'');
continue;
}
}

View File

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

View File

@ -49,7 +49,7 @@ public class ChunkListener implements Listener {
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
this.mustSave = classChunk.getField("mustSave");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable e) {
} catch (Throwable ignored) {
PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc");
Settings.CHUNK_PROCESSOR_GC = 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) {
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
PlotPlayer pp;
if (!(entity instanceof Player)) {
continue;
}
PlotPlayer pp;
if ((pp = BukkitUtil.getPlayer((Player) entity)) == null) {
continue;
}

View File

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

View File

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

View File

@ -19,7 +19,7 @@ public class DefaultTitle_19 extends AbstractTitle {
playerObj.sendTitle("", "");
}
}, delay * 20);
} catch (Throwable e) {
} catch (Throwable ignored) {
AbstractTitle.TITLE_CLASS = new DefaultTitle();
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.
*
* @throws java.io.IOException
*/
public void enable() {
// 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.
*
*/
public void disable() {
// 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
*
* @return an unmodifiable {@link java.util.Set} of the plotter objects
* @return an unmodifiable {@link Set} of the plotter objects
*/
public Set<Plotter> getPlotters() {
return Collections.unmodifiableSet(this.plotters);

View File

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

View File

@ -51,7 +51,6 @@ public class SendChunk {
this.methodInitLighting = classChunk.getMethod("initLighting");
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
//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)) {
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class);
} else {
@ -65,7 +64,7 @@ public class SendChunk {
}
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<>();
int view = Bukkit.getServer().getViewDistance();
for (Chunk chunk : chunks) {
@ -126,9 +125,9 @@ public class SendChunk {
public void run() {
try {
chunk.unload(true, false);
} catch (Throwable e) {
} catch (Throwable ignored) {
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 - $4" + worldName + "/level.dat or " + worldName
+ "/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(
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username)"
+ ")")) {
+ ')')) {
stmt.execute();
} catch (SQLException e) {
e.printStackTrace();
@ -176,7 +176,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
String id = (String) jsonProfile.get("id");
String name = (String) jsonProfile.get("name");
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));
} catch (IOException | ParseException e) {
e.printStackTrace();
@ -231,7 +231,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
statement.setString(1, name.value);
statement.setString(2, uuid.toString());
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) {
e.printStackTrace();
}