From 9596544f97fde5295d34c69b606e5fab600c402e Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 29 Feb 2016 20:13:18 -0500 Subject: [PATCH] Cleanup Code I also updated the build.gradle and pom to 1.9 bukkit --- Bukkit/build.gradle | 2 +- .../database/plotme/LikePlotMeConverter.java | 4 +- .../bukkit/listeners/ChunkListener.java | 1 - .../plotsquared/bukkit/util/BukkitUtil.java | 3 -- .../ConfigurationSerialization.java | 2 +- .../plot/commands/Claim.java | 1 - .../plot/commands/Condense.java | 4 -- .../plot/commands/DebugPaste.java | 3 +- .../plot/database/SQLManager.java | 18 +++---- .../plot/object/Location.java | 3 -- .../plot/object/Plot.java | 11 ++--- .../sponge/listener/MainListener.java | 8 +-- .../plotsquared/sponge/util/SpongeUtil.java | 49 ++++++++++--------- pom.xml | 2 +- 14 files changed, 46 insertions(+), 65 deletions(-) diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index a77b77d5e..688a9a340 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -1,6 +1,6 @@ dependencies { compile project(':Core') - compile 'org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT' + compile 'org.bukkit:bukkit:1.9-R0.1-SNAPSHOT' compile 'net.milkbowl.vault:VaultAPI:1.5' } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java index 83742401a..d1c9396ab 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java @@ -223,14 +223,14 @@ public class LikePlotMeConverter { PS.get().config.set("worlds." + world + ".road.width", pathwidth); Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // - if ((pathheight == null) || (pathheight == 0)) { + if (pathheight == 0) { pathheight = 64; } PS.get().config.set("worlds." + world + ".road.height", pathheight); PS.get().config.set("worlds." + world + ".wall.height", pathheight); PS.get().config.set("worlds." + world + ".plot.height", pathheight); Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // - if ((plotsize == null) || (plotsize == 0)) { + if (plotsize == 0) { plotsize = 32; } PS.get().config.set("worlds." + world + ".plot.size", plotsize); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java index 5cfda088c..525783450 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java @@ -157,7 +157,6 @@ public class ChunkListener implements Listener { final int z = Z << 4; final int x2 = x + 15; final int z2 = z + 15; - Thread thread = new Thread(); Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs(); if (plot != null && plot.hasOwner()) { return false; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 47f95df22..3cd94bd06 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -171,9 +171,6 @@ public class BukkitUtil extends WorldUtil { public int getBiomeFromString(final String biomeStr) { try { final Biome biome = Biome.valueOf(biomeStr.toUpperCase()); - if (biome == null) { - return -1; - } return Arrays.asList(Biome.values()).indexOf(biome); } catch (final IllegalArgumentException e) { return -1; diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java b/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java index 5e7da368b..ba3ae6736 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/serialization/ConfigurationSerialization.java @@ -246,7 +246,7 @@ public class ConfigurationSerialization { final SerializableAs alias = clazz.getAnnotation(SerializableAs.class); - if ((alias != null) && (alias.value() != null)) { + if (alias != null) { return alias.value(); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 748718555..ede8545ad 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -92,7 +92,6 @@ public class Claim extends SubCommand { return sendMessage(plr, C.NOT_IN_PLOT); } final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(loc.getWorld()); - boolean removeGrantedPlot = false; int grants = 0; if (currentPlots >= plr.getAllowedPlots()) { if (plr.hasPersistentMeta("grantedPlots")) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 2014f89f2..ccf202221 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -65,10 +65,6 @@ public class Condense extends SubCommand { MainUtil.sendMessage(plr, "TASK ALREADY STARTED"); return false; } - if (args.length == 2) { - MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " start "); - return false; - } if (!MathMan.isInteger(args[2])) { MainUtil.sendMessage(plr, "INVALID RADIUS"); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java index aa428356e..edf7c3b15 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java @@ -12,6 +12,7 @@ import com.plotsquared.general.commands.CommandDeclaration; import java.io.File; import java.io.IOException; +import java.util.Arrays; @CommandDeclaration( command = "debugpaste", @@ -41,7 +42,7 @@ public class DebugPaste extends SubCommand { b.append("links.settings_yml: '").append(settingsYML).append("'\n"); b.append("links.latest_log: '").append(latestLOG).append("'\n"); b.append("\n# YAAAS! Now let us move on to the server info\n"); - b.append("version.server: '").append(PS.get().IMP.getServerVersion()).append("'\n"); + b.append("version.server: '").append(Arrays.toString(PS.get().IMP.getServerVersion())).append("'\n"); b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper() + ";" + !Settings.OFFLINE_MODE).append("\n"); b.append("plugins:"); for (String id : PS.get().IMP.getPluginIds()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 770e7b63b..d94d7f9e4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -464,20 +464,14 @@ public class SQLManager implements AbstractDB { final Plot plot = plotMap.get(plotId); if (plot != null) { settings.add(new SettingsPair(id, plot.getSettings())); - if (plot.getDenied() != null) { - for (final UUID uuid : plot.getDenied()) { - denied.add(new UUIDPair(id, uuid)); - } + for (final UUID uuid : plot.getDenied()) { + denied.add(new UUIDPair(id, uuid)); } - if (plot.getMembers() != null) { - for (final UUID uuid : plot.getMembers()) { - trusted.add(new UUIDPair(id, uuid)); - } + for (final UUID uuid : plot.getMembers()) { + trusted.add(new UUIDPair(id, uuid)); } - if (plot.getTrusted() != null) { - for (final UUID uuid : plot.getTrusted()) { - helpers.add(new UUIDPair(id, uuid)); - } + for (final UUID uuid : plot.getTrusted()) { + helpers.add(new UUIDPair(id, uuid)); } } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java index bf7bf0fa0..c93dcd710 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -203,9 +203,6 @@ public class Location implements Cloneable, Comparable { @Override public int compareTo(final Location o) { - if (o == null) { - throw new NullPointerException("Specified object was null"); - } if (x == o.getX() && y == o.getY() || z == o.getZ()) { return 0; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 0be644775..b10d033fd 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -357,7 +357,7 @@ public class Plot { */ public HashSet getOwners() { if (owner == null) { - return new HashSet(); + return new HashSet<>(); } if (isMerged()) { HashSet plots = getConnectedPlots(); @@ -910,16 +910,15 @@ public class Plot { }); return; } - final String rename = name == null ? "unknown" : name; final PlotManager manager = this.area.getPlotManager(); if (this.area.ALLOW_SIGNS) { final Location loc = manager.getSignLoc(this.area, this); final String id = this.id.x + ";" + this.id.y; final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id), - C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", rename), - C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", rename), - C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", rename) }; + C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name), + C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name), + C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name) }; WorldUtil.IMP.setSign(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), lines); } } @@ -1242,7 +1241,7 @@ public class Plot { */ public void setSign() { if (this.owner == null) { - this.setSign(null); + this.setSign("unknown"); return; } this.setSign(UUIDHandler.getName(this.owner)); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index e95077de0..e619f404c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -214,9 +214,7 @@ public class MainListener { if (cap == 0) { return false; } - if (mobs == null) { - mobs = plot.countEntities(); - } + mobs = plot.countEntities(); if (mobs[3] >= cap) { return false; } @@ -260,9 +258,7 @@ public class MainListener { if (cap == 0) { return false; } - if (mobs == null) { - mobs = plot.countEntities(); - } + mobs = plot.countEntities(); if (mobs[4] >= cap) { return false; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index e06b7a742..32e08eb2c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -9,7 +9,12 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.schematic.PlotItem; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.ReflectionUtils; +import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.StringMan; +import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; import net.minecraft.block.Block; @@ -29,7 +34,6 @@ import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.serializer.TextSerializers; -import org.spongepowered.api.text.translation.Translatable; import org.spongepowered.api.text.translation.Translation; import org.spongepowered.api.world.World; import org.spongepowered.api.world.biome.BiomeType; @@ -38,7 +42,11 @@ import org.spongepowered.api.world.extent.Extent; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Optional; public class SpongeUtil extends WorldUtil { @@ -103,28 +111,23 @@ public class SpongeUtil extends WorldUtil { } public static Translation getTranslation(final String m) { - return new Translatable() { + return new Translation() { + @Override - public Translation getTranslation() { - return new Translation() { - - @Override - public String getId() { - return m; - } - - @Override - public String get(final Locale l, final Object... args) { - return m; - } - - @Override - public String get(final Locale l) { - return m; - } - }; + public String getId() { + return m; } - }.getTranslation(); + + @Override + public String get(final Locale l, final Object... args) { + return m; + } + + @Override + public String get(final Locale l) { + return m; + } + }; } private static HashMap stateMap; diff --git a/pom.xml b/pom.xml index 56946c731..02f0ea872 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ org.bukkit bukkit - 1.8.8-R0.1-SNAPSHOT + 1.9-SNAPSHOT com.sk89q