From bb4ecb94a13ae7a3b2ffbf9f48fe5b51f4306c24 Mon Sep 17 00:00:00 2001 From: MattBDev Date: Sun, 20 Mar 2016 19:35:40 -0400 Subject: [PATCH] Cleanup --- .../com/plotsquared/bukkit/BukkitMain.java | 10 ++-- .../bukkit/chat/TextualComponent.java | 2 +- .../database/plotme/APlotMeConnector.java | 8 +-- .../bukkit/listeners/ForceFieldListener.java | 26 +++++---- .../bukkit/util/BukkitChunkManager.java | 58 ++++++++++++++++--- .../bukkit/util/BukkitHybridUtils.java | 49 ++++++++-------- .../bukkit/util/BukkitSchematicHandler.java | 25 +++++--- .../bukkit/util/block/FastQueue_1_9.java | 4 +- .../bukkit/uuid/SQLUUIDHandler.java | 39 ++++++------- .../configuration/MemorySection.java | 12 ++-- .../configuration/file/YamlConfiguration.java | 10 ++-- .../intellectualcrafters/json/JSONObject.java | 6 +- .../json/JSONTokener.java | 2 +- .../plot/commands/Area.java | 2 +- .../plot/commands/Auto.java | 4 +- .../plot/commands/Chat.java | 2 +- .../plot/commands/Database.java | 2 +- .../plot/commands/Delete.java | 2 +- .../plot/commands/GenerateDocs.java | 17 +++--- .../plot/commands/Inbox.java | 16 +++-- .../plot/commands/Save.java | 10 ++-- .../plot/commands/SetHome.java | 2 +- .../plot/commands/Setup.java | 2 +- .../plot/database/SQLManager.java | 12 ++-- .../plot/generator/ClassicPlotManager.java | 22 +++---- .../plot/generator/GeneratorWrapper.java | 23 ++++---- .../plot/generator/HybridUtils.java | 36 +++++++++--- .../plot/generator/SquarePlotManager.java | 36 ++++++------ .../plot/object/Plot.java | 5 +- .../plot/object/PlotAnalysis.java | 30 +++++----- .../plot/object/comment/InboxOwner.java | 22 +++---- .../plot/object/comment/InboxPublic.java | 22 +++---- .../plot/util/CmdConfirm.java | 2 +- .../plot/util/ExpireManager.java | 21 +++---- .../plot/util/Permissions.java | 10 ++-- .../plot/util/PlotGamemode.java | 2 +- .../plot/util/PlotWeather.java | 2 +- .../plot/util/SchematicHandler.java | 12 ++-- .../plot/util/SetQueue.java | 2 +- .../general/commands/CommandManager.java | 8 ++- .../com/plotsquared/sponge/SpongeMain.java | 6 +- .../generator/SpongeAugmentedGenerator.java | 7 ++- .../plotsquared/sponge/util/SpongeUtil.java | 4 +- 43 files changed, 334 insertions(+), 260 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 8925bb2bd..ea860c27b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -497,19 +497,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { UUIDWrapper wrapper; if (Settings.OFFLINE_MODE) { if (Settings.UUID_LOWERCASE) { - wrapper = (new LowerOfflineUUIDWrapper()); + wrapper = new LowerOfflineUUIDWrapper(); } else { - wrapper = (new OfflineUUIDWrapper()); + wrapper = new OfflineUUIDWrapper(); } Settings.OFFLINE_MODE = true; } else if (checkVersion) { - wrapper = (new DefaultUUIDWrapper()); + wrapper = new DefaultUUIDWrapper(); Settings.OFFLINE_MODE = false; } else { if (Settings.UUID_LOWERCASE) { - wrapper = (new LowerOfflineUUIDWrapper()); + wrapper = new LowerOfflineUUIDWrapper(); } else { - wrapper = (new OfflineUUIDWrapper()); + wrapper = new OfflineUUIDWrapper(); } Settings.OFFLINE_MODE = true; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java index 333af35ac..41491ff87 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java @@ -70,7 +70,7 @@ public abstract class TextualComponent implements Cloneable { } static boolean isTranslatableText(final TextualComponent component) { - return (component instanceof ComplexTextTypeComponent) && ((ComplexTextTypeComponent) component).getKey().equals("translate"); + return (component instanceof ComplexTextTypeComponent) && component.getKey().equals("translate"); } /** diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java index 559dbb202..8e8a559c2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java @@ -53,16 +53,16 @@ public abstract class APlotMeConnector { public Location getPlotTopLocAbs(final int path, final int plot, final PlotId plotid) { final int px = plotid.x; final int pz = plotid.y; - final int x = (px * (path + plot)) - ((int) Math.floor(path / 2)) - 1; - final int z = (pz * (path + plot)) - ((int) Math.floor(path / 2)) - 1; + final int x = (px * (path + plot)) - (int) Math.floor(path / 2) - 1; + final int z = (pz * (path + plot)) - (int) Math.floor(path / 2) - 1; return new Location(null, x, 256, z); } public Location getPlotBottomLocAbs(final int path, final int plot, final PlotId plotid) { final int px = plotid.x; final int pz = plotid.y; - final int x = (px * (path + plot)) - plot - ((int) Math.floor(path / 2)) - 1; - final int z = (pz * (path + plot)) - plot - ((int) Math.floor(path / 2)) - 1; + final int x = (px * (path + plot)) - plot - (int) Math.floor(path / 2) - 1; + final int z = (pz * (path + plot)) - plot - (int) Math.floor(path / 2) - 1; return new Location(null, x, 1, z); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java index f3bf16a19..12f941c81 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -20,16 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.plotsquared.bukkit.listeners; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.util.Vector; - import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -37,8 +27,18 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.events.PlayerEnterPlotEvent; import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** -/** */ public class ForceFieldListener implements Listener { private Set getNearbyPlayers(final Player player, final Plot plot) { @@ -73,17 +73,19 @@ public class ForceFieldListener implements Listener { Location oPlayerLocation = e.getLocation(); final double playerX = playerLocation.getX(), playerY = playerLocation.getY(), playerZ = playerLocation.getZ(), oPlayerX = oPlayerLocation.getX(), oPlayerY = oPlayerLocation.getY(), oPlayerZ = oPlayerLocation .getZ(); - double x = 0d, y = 0d, z = 0d; + double x = 0d; if (playerX < oPlayerX) { x = 1.0d; } else if (playerX > oPlayerX) { x = -1.0d; } + double y = 0d; if (playerY < oPlayerY) { y = 0.5d; } else if (playerY > oPlayerY) { y = -0.5d; } + double z = 0d; if (playerZ < oPlayerZ) { z = 1.0d; } else if (playerZ > oPlayerZ) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index bc0809699..6fcb63c60 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -2,19 +2,64 @@ package com.plotsquared.bukkit.util; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.generator.AugmentedUtils; -import com.intellectualcrafters.plot.object.*; +import com.intellectualcrafters.plot.object.BlockLoc; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotArea; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotLoc; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.PlotChunk; +import com.intellectualcrafters.plot.util.SetQueue; +import com.intellectualcrafters.plot.util.StringMan; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.bukkit.object.entity.EntityWrapper; -import org.bukkit.*; -import org.bukkit.block.*; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Note; +import org.bukkit.SkullType; +import org.bukkit.World; +import org.bukkit.block.Banner; +import org.bukkit.block.Beacon; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.block.BrewingStand; +import org.bukkit.block.Chest; +import org.bukkit.block.CommandBlock; +import org.bukkit.block.CreatureSpawner; +import org.bukkit.block.Dispenser; +import org.bukkit.block.Dropper; +import org.bukkit.block.Furnace; +import org.bukkit.block.Hopper; +import org.bukkit.block.Jukebox; +import org.bukkit.block.NoteBlock; +import org.bukkit.block.Sign; +import org.bukkit.block.Skull; import org.bukkit.block.banner.Pattern; -import org.bukkit.entity.*; +import org.bukkit.entity.Animals; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; public class BukkitChunkManager extends ChunkManager { @@ -595,7 +640,6 @@ public class BukkitChunkManager extends ChunkManager { } } while (SetQueue.IMP.forceChunkSet()) { - ; } restoreBlocks(world1, 0, 0); restoreEntities(world1, 0, 0); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java index eccd69cda..c07183d6f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java @@ -1,18 +1,5 @@ package com.plotsquared.bukkit.util; -import java.util.HashSet; -import java.util.Random; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.generator.ChunkGenerator; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; -import org.bukkit.material.Directional; -import org.bukkit.material.MaterialData; - import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotAnalysis; @@ -23,6 +10,18 @@ import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.TaskManager; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.block.Block; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.ChunkGenerator.BiomeGrid; +import org.bukkit.material.Directional; +import org.bukkit.material.MaterialData; + +import java.util.HashSet; +import java.util.Random; public class BukkitHybridUtils extends HybridUtils { @@ -90,8 +89,8 @@ public class BukkitHybridUtils extends HybridUtils { final int X = value[0]; final int Z = value[1]; final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid); - final int xb = ((X) << 4) - bx; - final int zb = ((Z) << 4) - bz; + final int xb = (X << 4) - bx; + final int zb = (Z << 4) - bz; for (int i = 0; i < result.length; i++) { if (result[i] == null) { for (int j = 0; j < 4096; j++) { @@ -196,11 +195,11 @@ public class BukkitHybridUtils extends HybridUtils { analysis.air = (int) (MathMan.getMean(air) * 100); analysis.variety = (int) (MathMan.getMean(variety) * 100); - analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes)); - analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces)); - analysis.data_sd = (int) (MathMan.getSD(data, analysis.data)); - analysis.air_sd = (int) (MathMan.getSD(air, analysis.air)); - analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety)); + analysis.changes_sd = (int) MathMan.getSD(changes, analysis.changes); + analysis.faces_sd = (int) MathMan.getSD(faces, analysis.faces); + analysis.data_sd = (int) MathMan.getSD(data, analysis.data); + analysis.air_sd = (int) MathMan.getSD(air, analysis.air); + analysis.variety_sd = (int) MathMan.getSD(variety, analysis.variety); System.gc(); System.gc(); whenDone.value = analysis; @@ -222,24 +221,24 @@ public class BukkitHybridUtils extends HybridUtils { final int Z = value[1]; worldObj.loadChunk(X, Z); int minX; - int minZ; - int maxX; - int maxZ; if (X == cbx) { minX = bx & 15; } else { minX = 0; } + int minZ; if (Z == cbz) { minZ = bz & 15; } else { minZ = 0; } + int maxX; if (X == ctx) { maxX = tx & 15; } else { maxX = 16; } + int maxZ; if (Z == ctz) { maxZ = tz & 15; } else { @@ -249,8 +248,8 @@ public class BukkitHybridUtils extends HybridUtils { final int cbx = X << 4; final int cbz = Z << 4; - final int xb = (cbx) - bx; - final int zb = (cbz) - bz; + final int xb = cbx - bx; + final int zb = cbz - bz; for (int x = minX; x <= maxX; x++) { final int xx = cbx + x; for (int z = minZ; z <= maxZ; z++) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java index 76a08dd65..1b07ba7d7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java @@ -20,7 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.plotsquared.bukkit.util; -import com.intellectualcrafters.jnbt.*; +import com.intellectualcrafters.jnbt.ByteArrayTag; +import com.intellectualcrafters.jnbt.CompoundTag; +import com.intellectualcrafters.jnbt.IntTag; +import com.intellectualcrafters.jnbt.ListTag; +import com.intellectualcrafters.jnbt.ShortTag; +import com.intellectualcrafters.jnbt.StringTag; +import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.RegionWrapper; @@ -35,8 +41,13 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockState; -import java.util.*; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; /** * Schematic Handler @@ -73,7 +84,7 @@ public class BukkitSchematicHandler extends SchematicHandler { schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0)); schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0)); // Arrays of data types - final List tileEntities = new ArrayList<>(); + final List tileEntities = new ArrayList<>(); final byte[] blocks = new byte[width * height * length]; final byte[] blockData = new byte[width * height * length]; // Queue @@ -126,7 +137,7 @@ public class BukkitSchematicHandler extends SchematicHandler { @Override public void run() { final long start = System.currentTimeMillis(); - while ((!chunks.isEmpty()) && ((System.currentTimeMillis() - start) < 20)) { + while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) { // save schematics final ChunkLoc chunk = chunks.remove(0); final Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z); @@ -154,7 +165,7 @@ public class BukkitSchematicHandler extends SchematicHandler { } for (int y = sy; y <= Math.min(255, ey); y++) { final int ry = y - sy; - final int i1 = (ry * width * length); + final int i1 = ry * width * length; for (int z = zzb; z <= zzt; z++) { final int rz = z - bz; final int i2 = i1 + (rz * width); @@ -275,7 +286,7 @@ public class BukkitSchematicHandler extends SchematicHandler { final StateWrapper wrapper = new StateWrapper(state); final CompoundTag rawTag = wrapper.getTag(); if (rawTag != null) { - final Map values = new HashMap(); + final Map values = new HashMap<>(); for (final Entry entry : rawTag.getValue().entrySet()) { values.put(entry.getKey(), entry.getValue()); } @@ -283,7 +294,7 @@ public class BukkitSchematicHandler extends SchematicHandler { values.put("x", new IntTag("x", x)); values.put("y", new IntTag("y", y)); values.put("z", new IntTag("z", z)); - final CompoundTag tileEntityTag = new CompoundTag(values); + CompoundTag tileEntityTag = new CompoundTag(values); tileEntities.add(tileEntityTag); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java index e4bcafbd5..e2ec065a2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java @@ -227,10 +227,8 @@ public class FastQueue_1_9 extends SlowQueue { int x = MainUtil.x_loc[j][k]; int y = MainUtil.y_loc[j][k]; int z = MainUtil.z_loc[j][k]; - int id = n; Object iblock = methodGetByCombinedId.call((int) n); setType.call(x, y & 15, z, iblock); - continue; } } } @@ -317,7 +315,7 @@ public class FastQueue_1_9 extends SlowQueue { methodInitLighting.of(c).call(); - if ((bc.getTotalRelight() == 0 && !fixAll)) { + if (bc.getTotalRelight() == 0 && !fixAll) { return true; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java index f8ead1ff3..2af1fffbb 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -1,22 +1,5 @@ package com.plotsquared.bukkit.uuid; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayDeque; -import java.util.Collections; -import java.util.HashMap; -import java.util.UUID; - -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; - import com.google.common.collect.HashBiMap; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; @@ -29,6 +12,22 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.uuid.UUIDWrapper; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayDeque; +import java.util.Collections; +import java.util.HashMap; +import java.util.UUID; public class SQLUUIDHandler extends UUIDHandlerImplementation { @@ -76,11 +75,9 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { final HashBiMap toAdd = HashBiMap.create(new HashMap()); final PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`"); final ResultSet resultSet = statement.executeQuery(); - StringWrapper username; - UUID uuid; while (resultSet.next()) { - username = new StringWrapper(resultSet.getString("username")); - uuid = UUID.fromString(resultSet.getString("uuid")); + StringWrapper username = new StringWrapper(resultSet.getString("username")); + UUID uuid = UUID.fromString(resultSet.getString("uuid")); toAdd.put(new StringWrapper(username.value), uuid); } statement.close(); diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java index bce9578f5..6099d235f 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/MemorySection.java @@ -76,7 +76,7 @@ public class MemorySection implements ConfigurationSection { } catch (NumberFormatException ignored) { } } else if (obj instanceof List) { - final List val = ((List) obj); + final List val = (List) obj; if (!val.isEmpty()) { return toDouble(val.get(0), def); } @@ -94,7 +94,7 @@ public class MemorySection implements ConfigurationSection { } catch (NumberFormatException ignored) { } } else if (obj instanceof List) { - final List val = ((List) obj); + final List val = (List) obj; if (!val.isEmpty()) { return toInt(val.get(0), def); } @@ -112,7 +112,7 @@ public class MemorySection implements ConfigurationSection { } catch (NumberFormatException ignored) { } } else if (obj instanceof List) { - final List val = ((List) obj); + final List val = (List) obj; if (!val.isEmpty()) { return toLong(val.get(0), def); } @@ -166,7 +166,7 @@ public class MemorySection implements ConfigurationSection { builder.insert(0, parent.getName()); } - if ((key != null) && (!key.isEmpty())) { + if ((key != null) && !key.isEmpty()) { if (builder.length() > 0) { builder.append(separator); } @@ -528,7 +528,7 @@ public class MemorySection implements ConfigurationSection { final List result = new ArrayList<>(); for (final Object object : list) { - if ((object instanceof String) || (isPrimitiveWrapper(object))) { + if ((object instanceof String) || isPrimitiveWrapper(object)) { result.add(String.valueOf(object)); } } @@ -819,7 +819,7 @@ public class MemorySection implements ConfigurationSection { for (final Map.Entry entry : sec.map.entrySet()) { output.add(createPath(section, entry.getKey(), this)); - if ((deep) && (entry.getValue() instanceof ConfigurationSection)) { + if (deep && (entry.getValue() instanceof ConfigurationSection)) { final ConfigurationSection subsection = (ConfigurationSection) entry.getValue(); mapChildrenKeys(output, subsection, deep); } diff --git a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java index 34fb066c9..d1e9c11e7 100644 --- a/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java +++ b/Core/src/main/java/com/intellectualcrafters/configuration/file/YamlConfiguration.java @@ -159,7 +159,7 @@ public class YamlConfiguration extends FileConfiguration { boolean readingHeader = true; boolean foundHeader = false; - for (int i = 0; (i < lines.length) && (readingHeader); i++) { + for (int i = 0; (i < lines.length) && readingHeader; i++) { final String line = lines[i]; if (line.startsWith(COMMENT_PREFIX)) { @@ -172,7 +172,7 @@ public class YamlConfiguration extends FileConfiguration { } foundHeader = true; - } else if ((foundHeader) && (line.isEmpty())) { + } else if (foundHeader && line.isEmpty()) { result.append("\n"); } else if (foundHeader) { readingHeader = false; @@ -189,11 +189,11 @@ public class YamlConfiguration extends FileConfiguration { if (options().copyHeader()) { final Configuration def = getDefaults(); - if ((def != null) && (def instanceof FileConfiguration)) { + if (def != null && def instanceof FileConfiguration) { final FileConfiguration filedefaults = (FileConfiguration) def; final String defaultsHeader = filedefaults.buildHeader(); - if ((defaultsHeader != null) && (!defaultsHeader.isEmpty())) { + if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) { return defaultsHeader; } } @@ -210,7 +210,7 @@ public class YamlConfiguration extends FileConfiguration { for (int i = lines.length - 1; i >= 0; i--) { builder.insert(0, "\n"); - if ((startedHeader) || (!lines[i].isEmpty())) { + if (startedHeader || !lines[i].isEmpty()) { builder.insert(0, lines[i]); builder.insert(0, COMMENT_PREFIX); startedHeader = true; diff --git a/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java b/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java index c090c1967..7233d9979 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java +++ b/Core/src/main/java/com/intellectualcrafters/json/JSONObject.java @@ -363,7 +363,7 @@ public class JSONObject { } public static Writer quote(final String string, final Writer w) throws IOException { - if ((string == null) || (string.isEmpty())) { + if ((string == null) || string.isEmpty()) { w.write("\"\""); return w; } @@ -427,7 +427,7 @@ public class JSONObject { */ public static Object stringToValue(final String string) { Double d; - if (string.equals("")) { + if (string.isEmpty()) { return string; } if (string.equalsIgnoreCase("true")) { @@ -1115,7 +1115,7 @@ public class JSONObject { } else if (name.startsWith("is")) { key = name.substring(2); } - if ((!key.isEmpty()) && Character.isUpperCase(key.charAt(0)) && (method.getParameterTypes().length == 0)) { + if (!key.isEmpty() && Character.isUpperCase(key.charAt(0)) && (method.getParameterTypes().length == 0)) { if (key.length() == 1) { key = key.toLowerCase(); } else if (!Character.isUpperCase(key.charAt(1))) { diff --git a/Core/src/main/java/com/intellectualcrafters/json/JSONTokener.java b/Core/src/main/java/com/intellectualcrafters/json/JSONTokener.java index b6ad424e0..0563977b4 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/JSONTokener.java +++ b/Core/src/main/java/com/intellectualcrafters/json/JSONTokener.java @@ -342,7 +342,7 @@ public class JSONTokener { } back(); string = sb.toString().trim(); - if ("".equals(string)) { + if (string != null && string.isEmpty()) { throw syntaxError("Missing value"); } return JSONObject.stringToValue(string); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index 72baa1387..ae8c035bc 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -318,7 +318,7 @@ public class Area extends SubCommand { region = area.getRegion().toString(); } else { name = area.worldname; - percent = claimed == 0 ? 0 : (100d * claimed) / (Integer.MAX_VALUE); + percent = claimed == 0 ? 0 : (100d * claimed) / Integer.MAX_VALUE; region = "N/A"; } String value = "&r$1NAME: " + name diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 7d2bef836..775138cad 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -109,7 +109,7 @@ public class Auto extends SubCommand { final int diff = currentPlots - plr.getAllowedPlots(); if ((diff + (size_x * size_z)) > 0) { if (diff < 0) { - MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + ""); + MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + ""); return false; } else if (plr.hasPersistentMeta("grantedPlots")) { int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots")); @@ -185,7 +185,7 @@ public class Auto extends SubCommand { for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { Plot plot = plotarea.getPlotAbs(new PlotId(i, j)); - final boolean teleport = ((i == end.x) && (j == end.y)); + final boolean teleport = (i == end.x) && (j == end.y); plot.claim(plr, teleport, null); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java index 1b23c5a2c..9874cbf94 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Chat.java @@ -14,6 +14,6 @@ public class Chat extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, final String... args) { - return MainCommand.onCommand(player, "plot", new String[] { "toggle", "chat" }); + return MainCommand.onCommand(player, "plot", "toggle", "chat"); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java index d56462616..853fe0d03 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -85,7 +85,7 @@ public class Database extends SubCommand { MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]"); return false; } - File file = MainUtil.getFile(PS.get().IMP.getDirectory(), (args[1].endsWith(".db")) ? args[1] : args[1] + ".db"); + File file = MainUtil.getFile(PS.get().IMP.getDirectory(), args[1].endsWith(".db") ? args[1] : args[1] + ".db"); if (!file.exists()) { MainUtil.sendMessage(player, "&6Database does not exist: " + file); return false; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 647bfbfcc..3cd2f4828 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -90,7 +90,7 @@ public class Delete extends SubCommand { } } }; - if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { + if (Settings.CONFIRM_DELETE && !Permissions.hasPermission(plr, "plots.confirm.bypass")) { CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run); } else { TaskManager.runTask(run); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java index f6110e670..635af7030 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java @@ -17,7 +17,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class GenerateDocs { - public static void main(final String[] args) { + + public static void main(String[] args) { MainCommand.getInstance().addCommand(new WE_Anywhere()); MainCommand.getInstance().addCommand(new Cluster()); final ArrayList> commands = MainCommand.getInstance().getCommands(); @@ -39,8 +40,8 @@ public class GenerateDocs { printCommand(command); } } - - public static void printCommand(final Command command) { + + public static void printCommand(Command command) { try { final String clazz = command.getClass().getSimpleName(); final String name = command.getCommand(); @@ -129,8 +130,8 @@ public class GenerateDocs { return new ArrayList<>(usages); } - public static List getPerms(final String cmd, final List lines) { - final HashSet perms = new HashSet(); + public static List getPerms(String cmd, List lines) { + final HashSet perms = new HashSet<>(); final Pattern p = Pattern.compile("\"([^\"]*)\""); final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)"); String last = null; @@ -202,13 +203,13 @@ public class GenerateDocs { } return new ArrayList<>(perms); } - - public static String getComments(final List lines) { + + public static String getComments(List lines) { final StringBuilder result = new StringBuilder(); for (String line : lines) { line = line.trim(); if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) { - line = (line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "")).trim(); + line = line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "").trim(); result.append(line + "\n"); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 1d0576f99..b583af95a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -44,7 +44,7 @@ requiredType = RequiredType.NONE) public class Inbox extends SubCommand { public void displayComments(final PlotPlayer player, final List oldComments, int page) { - if ((oldComments == null) || (oldComments.isEmpty())) { + if ((oldComments == null) || oldComments.isEmpty()) { MainUtil.sendMessage(player, C.INBOX_EMPTY); return; } @@ -65,10 +65,10 @@ public class Inbox extends SubCommand { } final StringBuilder string = new StringBuilder(); string.append(StringMan.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + "\n"); - PlotComment c; + // This might work xD - for (int x = (page * 12); x < max; x++) { - c = comments[x]; + for (int x = page * 12; x < max; x++) { + PlotComment c = comments[x]; String color; if (player.getName().equals(c.senderName)) { color = "&a"; @@ -152,12 +152,11 @@ public class Inbox extends SubCommand { if (!inbox.getComments(plot, new RunnableVal>() { @Override public void run(List value) { - final List comments = value; - if (index > comments.size()) { + if (index > value.size()) { sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + ""); return; } - final PlotComment comment = comments.get(index - 1); + final PlotComment comment = value.get(index - 1); inbox.removeComment(plot, comment); plot.getSettings().removeComment(comment); MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment); @@ -199,8 +198,7 @@ public class Inbox extends SubCommand { if (!inbox.getComments(plot, new RunnableVal>() { @Override public void run(List value) { - final List comments = value; - displayComments(player, comments, page); + displayComments(player, value, page); } })) { if (plot == null) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java index 31fda1af0..712b689df 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java @@ -1,9 +1,5 @@ package com.intellectualcrafters.plot.commands; -import java.net.URL; -import java.util.List; -import java.util.UUID; - import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; @@ -19,6 +15,10 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.general.commands.CommandDeclaration; +import java.net.URL; +import java.util.List; +import java.util.UUID; + @CommandDeclaration(command = "save", aliases = { "backup" }, description = "Save your plot", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, permission = "plots.save") public class Save extends SubCommand { @@ -73,7 +73,7 @@ public class Save extends SubCommand { return; } MainUtil.sendMessage(plr, C.SAVE_SUCCESS); - final List schematics = (List) plr.getMeta("plot_schematics"); + final List schematics = plr.getMeta("plot_schematics"); if (schematics != null) { schematics.add(file); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/SetHome.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/SetHome.java index 803b3c194..2469ac249 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/SetHome.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/SetHome.java @@ -52,7 +52,7 @@ public class SetHome extends SetCommand { Plot base = plot.getBasePlot(false); Location bot = base.getBottomAbs(); Location loc = plr.getLocationFull(); - BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());; + BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch()); base.setHome(rel); return MainUtil.sendMessage(plr, C.POSITION_SET); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 9f04cff40..ba37ac891 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -66,7 +66,7 @@ public class Setup extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { // going through setup - SetupObject object = (SetupObject) plr.getMeta("setup"); + SetupObject object = plr.getMeta("setup"); if (object == null) { object = new SetupObject(); plr.setMeta("setup", object); 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 0c571995b..1886fdc7e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -841,7 +841,7 @@ public class SQLManager implements AbstractDB { stmt.setNull((i * 10) + 4, 4); // custom_time stmt.setNull((i * 10) + 5, 4); // time stmt.setNull((i * 10) + 6, 4); // deny_entry - if (pair.settings.getAlias().equals("")) { + if (pair.settings.getAlias().isEmpty()) { stmt.setNull((i * 10) + 7, 4); } else { stmt.setString((i * 10) + 7, pair.settings.getAlias()); @@ -909,7 +909,7 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException { - stmt.setInt((i) + 1, id); + stmt.setInt(i + 1, id); } @Override @@ -1467,7 +1467,7 @@ public class SQLManager implements AbstractDB { return Integer.MAX_VALUE; } - public void updateTables(int[] oldVersion) { + @Override public void updateTables(int[] oldVersion) { try { if (MYSQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) { try (Statement stmt = connection.createStatement()) { @@ -1575,12 +1575,12 @@ public class SQLManager implements AbstractDB { @Override public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException { - stmt.setInt((i) + 1, obj); + stmt.setInt(i + 1, obj); } @Override public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException { - stmt.setInt((i) + 1, obj); + stmt.setInt(i + 1, obj); } @Override @@ -2584,7 +2584,7 @@ public class SQLManager implements AbstractDB { final Integer m = r.getInt("merged"); final boolean[] merged = new boolean[4]; for (int i = 0; i < 4; i++) { - merged[3 - i] = ((m) & (1 << i)) != 0; + merged[3 - i] = (m & (1 << i)) != 0; } cluster.settings.setMerged(merged); String[] flags_string; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java index 881a14bc6..9642875a3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotManager.java @@ -1,7 +1,5 @@ package com.intellectualcrafters.plot.generator; -import java.util.ArrayList; - import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotArea; @@ -12,6 +10,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SetQueue; +import java.util.ArrayList; + /** * A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot) */ @@ -57,7 +57,7 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) { - final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld); + final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; setWallFilling(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_FILLING }); if ((dpw.WALL_BLOCK.id != 0) || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) { setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK }); @@ -142,7 +142,7 @@ public class ClassicPlotManager extends SquarePlotManager { final PseudoRandom random = new PseudoRandom(); if (!plot.getMerged(0)) { int z = bottom.getZ(); - for (int x = bottom.getX(); x <= (top.getX()); x++) { + for (int x = bottom.getX(); x <= top.getX(); x++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -150,7 +150,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(3)) { int x = bottom.getX(); - for (int z = bottom.getZ(); z <= (top.getZ()); z++) { + for (int z = bottom.getZ(); z <= top.getZ(); z++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -159,7 +159,7 @@ public class ClassicPlotManager extends SquarePlotManager { if (!plot.getMerged(2)) { int z = top.getZ(); - for (int x = bottom.getX(); x <= (top.getX()); x++) { + for (int x = bottom.getX(); x <= top.getX(); x++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -167,7 +167,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(1)) { int x = top.getX(); - for (int z = bottom.getZ(); z <= (top.getZ()); z++) { + for (int z = bottom.getZ(); z <= top.getZ(); z++) { for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -194,7 +194,7 @@ public class ClassicPlotManager extends SquarePlotManager { final PseudoRandom random = new PseudoRandom(); if (!plot.getMerged(0)) { int z = bot.getZ(); - for (int x = bot.getX(); x < (top.getX()); x++) { + for (int x = bot.getX(); x < top.getX(); x++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -202,7 +202,7 @@ public class ClassicPlotManager extends SquarePlotManager { } if (!plot.getMerged(3)) { int x = bot.getX(); - for (int z = bot.getZ(); z < (top.getZ()); z++) { + for (int z = bot.getZ(); z < top.getZ(); z++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } @@ -239,13 +239,13 @@ public class ClassicPlotManager extends SquarePlotManager { final int y = dpw.WALL_HEIGHT + 1; if (!plot.getMerged(0)) { int z = bot.getZ(); - for (int x = bot.getX(); x < (top.getX()); x++) { + for (int x = bot.getX(); x < top.getX(); x++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } } if (!plot.getMerged(3)) { int x = bot.getX(); - for (int z = bot.getZ(); z < (top.getZ()); z++) { + for (int z = bot.getZ(); z < top.getZ(); z++) { SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/GeneratorWrapper.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/GeneratorWrapper.java index a5a1a7e1f..7dee024a6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/GeneratorWrapper.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/GeneratorWrapper.java @@ -23,17 +23,16 @@ package com.intellectualcrafters.plot.generator; import com.intellectualcrafters.plot.object.PlotArea; public interface GeneratorWrapper { - public IndependentPlotGenerator getPlotGenerator(); - - public T getPlatformGenerator(); - public void augment(PlotArea area); - - public boolean isFull(); - - @Override - public String toString(); - - @Override - public boolean equals(Object obj); + IndependentPlotGenerator getPlotGenerator(); + + T getPlatformGenerator(); + + void augment(PlotArea area); + + boolean isFull(); + + @Override String toString(); + + @Override boolean equals(Object obj); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java index a9772792d..a2d0c8f6a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java @@ -5,12 +5,32 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.*; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.object.ChunkLoc; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotAnalysis; +import com.intellectualcrafters.plot.object.PlotArea; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.RegionWrapper; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.SetQueue; +import com.intellectualcrafters.plot.util.TaskManager; import java.io.File; -import java.util.*; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; public abstract class HybridUtils { @@ -188,7 +208,7 @@ public abstract class HybridUtils { if ((count.intValue() % 20) == 0) { PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%"); } - if ((regions.isEmpty()) && (chunks.isEmpty())) { + if (regions.isEmpty() && chunks.isEmpty()) { HybridUtils.UPDATE = false; PS.debug(C.PREFIX.s() + "Finished road conversion"); // CANCEL TASK @@ -230,8 +250,8 @@ public abstract class HybridUtils { TaskManager.runTaskLater(task, 600); return; } - if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) { - while ((System.currentTimeMillis() < diff) && (!chunks.isEmpty())) { + if (((System.currentTimeMillis() - baseTime - last.get()) < 1500) && (last.get() != 0)) { + while ((System.currentTimeMillis() < diff) && !chunks.isEmpty()) { Iterator iter = chunks.iterator(); final ChunkLoc chunk = iter.next(); iter.remove(); @@ -374,12 +394,12 @@ public abstract class HybridUtils { final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER; final boolean lx = absX < plotworld.PATH_WIDTH_UPPER; final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER; - condition = (!gx || !gz || !lx || !lz); + condition = !gx || !gz || !lx || !lz; } if (condition) { final int sy = plotworld.ROAD_HEIGHT; final HashMap blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ)); - for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) { + for (short y = (short) plotworld.ROAD_HEIGHT; y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) { SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0); } if (blocks != null) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 0f2e85a4f..2b79bf7a5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -41,17 +41,17 @@ public abstract class SquarePlotManager extends GridPlotManager { @Override public Location getPlotTopLocAbs(final PlotArea plotworld, final PlotId plotid) { - final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); + final SquarePlotWorld dpw = (SquarePlotWorld) plotworld; final int px = plotid.x; final int pz = plotid.y; - final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; + final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1; + final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1; return new Location(plotworld.worldname, x, Math.min(plotworld.MAX_BUILD_HEIGHT, 255), z); } @Override public PlotId getPlotIdAbs(final PlotArea plotworld, int x, final int y, int z) { - final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); + final SquarePlotWorld dpw = (SquarePlotWorld) plotworld; if (dpw.ROAD_OFFSET_X != 0) { x -= dpw.ROAD_OFFSET_X; } @@ -73,20 +73,20 @@ public abstract class SquarePlotManager extends GridPlotManager { } final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH; int idx; - int idz; if (x < 0) { - idx = (x / size); + idx = x / size; x = size + (x % size); } else { idx = (x / size) + 1; - x = (x % size); + x = x % size; } + int idz; if (z < 0) { - idz = (z / size); + idz = z / size; z = size + (z % size); } else { idz = (z / size) + 1; - z = (z % size); + z = z % size; } return ((z <= pathWidthLower) || (z > end) || (x <= pathWidthLower) || (x > end)) ? null : new PlotId(idx, idz); } @@ -94,7 +94,7 @@ public abstract class SquarePlotManager extends GridPlotManager { @Override public PlotId getPlotId(final PlotArea plotworld, int x, final int y, int z) { try { - final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); + final SquarePlotWorld dpw = (SquarePlotWorld) plotworld; if (plotworld == null) { return null; } @@ -117,23 +117,23 @@ public abstract class SquarePlotManager extends GridPlotManager { int dx; int rx; if (x < 0) { - dx = (x / size); + dx = x / size; rx = size + (x % size); } else { dx = (x / size) + 1; - rx = (x % size); + rx = x % size; } int dz; int rz; if (z < 0) { - dz = (z / size); + dz = z / size; rz = size + (z % size); } else { dz = (z / size) + 1; - rz = (z % size); + rz = z % size; } PlotId id = new PlotId(dx, dz); - boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) }; + boolean[] merged = new boolean[]{rz <= pathWidthLower, rx > end, rz > end, rx <= pathWidthLower}; int hash = MainUtil.hash(merged); // Not merged, and no need to check if it is if (hash == 0) { @@ -182,11 +182,11 @@ public abstract class SquarePlotManager extends GridPlotManager { */ @Override public Location getPlotBottomLocAbs(final PlotArea plotworld, final PlotId plotid) { - final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld); + final SquarePlotWorld dpw = (SquarePlotWorld) plotworld; final int px = plotid.x; final int pz = plotid.y; - final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)); - final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)); + final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2); + final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2); return new Location(plotworld.worldname, x, plotworld.MIN_BUILD_HEIGHT, z); } } 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 f90ad70e9..def675e92 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -765,10 +765,7 @@ public class Plot { } public boolean clear(final boolean checkRunning, final boolean isDelete, final Runnable whenDone) { - if (checkRunning && (this.getRunning() != 0)) { - return false; - } - if (!EventUtil.manager.callClear(this)) { + if (checkRunning && (this.getRunning() != 0) || !EventUtil.manager.callClear(this)) { return false; } final HashSet regions = this.getRegions(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java index 3c34bdf13..ef2435242 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java @@ -84,7 +84,7 @@ public class PlotAnalysis { PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data"); while (iter.hasNext()) { final Plot plot = iter.next(); - if ((plot.getSettings().ratings == null) || (plot.getSettings().getRatings().isEmpty())) { + if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) { iter.remove(); } else { plot.addRunning(); @@ -126,7 +126,7 @@ public class PlotAnalysis { final int i = mi.intValue(); final Plot plot = plots.get(i); ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100); - PS.debug(" | " + plot + " (rating) " + (ratings[i])); + PS.debug(" | " + plot + " (rating) " + ratings[i]); } } }); @@ -236,7 +236,7 @@ public class PlotAnalysis { final int[] variance_air = square(sd_air); final int sum_air = sum(variance_air); final double factor_air = getCC(n, sum_air); - PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) ((factor_air * 1000) / MathMan.getMean(air)); + PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air)); PS.debug(" - | air " + factor_air); final int[] rank_variety = rank(variety); @@ -244,7 +244,7 @@ public class PlotAnalysis { final int[] variance_variety = square(sd_variety); final int sum_variety = sum(variance_variety); final double factor_variety = getCC(n, sum_variety); - PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) ((factor_variety * 1000) / MathMan.getMean(variety)); + PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) (factor_variety * 1000 / MathMan.getMean(variety)); PS.debug(" - | variety " + factor_variety); final int[] rank_changes_sd = rank(changes_sd); @@ -303,7 +303,7 @@ public class PlotAnalysis { } } int optimal_complexity = Integer.MAX_VALUE; - if ((min > 0) && (max < 102400)) { // If low size, use my fast ranking algorithm + if (min > 0 && max < 102400) { // If low size, use my fast ranking algorithm final int[] rank_complexity = rank(complexity, max + 1); for (int i = 0; i < n; i++) { if (rank_complexity[i] == optimal_index) { @@ -542,16 +542,16 @@ public class PlotAnalysis { if (complexity != 0) { return complexity; } - complexity = ((changes) * MODIFIERS.changes) - + ((faces) * MODIFIERS.faces) - + ((data) * MODIFIERS.data) - + ((air) * MODIFIERS.air) - + ((variety) * MODIFIERS.variety) - + ((changes_sd) * MODIFIERS.changes_sd) - + ((faces_sd) * MODIFIERS.faces_sd) - + ((data_sd) * MODIFIERS.data_sd) - + ((air_sd) * MODIFIERS.air_sd) - + ((variety_sd) * MODIFIERS.variety_sd); + complexity = (changes * MODIFIERS.changes) + + (faces * MODIFIERS.faces) + + (data * MODIFIERS.data) + + (air * MODIFIERS.air) + + (variety * MODIFIERS.variety) + + (changes_sd * MODIFIERS.changes_sd) + + (faces_sd * MODIFIERS.faces_sd) + + (data_sd * MODIFIERS.data_sd) + + (air_sd * MODIFIERS.air_sd) + + (variety_sd * MODIFIERS.variety_sd); return complexity; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java b/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java index 6d938df3a..ee56f2cdf 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java @@ -1,8 +1,5 @@ package com.intellectualcrafters.plot.object.comment; -import java.util.ArrayList; -import java.util.List; - import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -10,6 +7,9 @@ import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; +import java.util.ArrayList; +import java.util.List; + public class InboxOwner extends CommentInbox { @Override @@ -17,10 +17,10 @@ public class InboxOwner extends CommentInbox { if (plot == null) { return Permissions.hasPermission(player, "plots.inbox.read." + toString()); } - return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions + return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions .hasPermission(player, "plots.inbox.read." + toString() - + ".other"))); + + ".other")); } @Override @@ -28,9 +28,10 @@ public class InboxOwner extends CommentInbox { if (plot == null) { return Permissions.hasPermission(player, "plots.inbox.write." + toString()); } - return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write." + return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions + .hasPermission(player, "plots.inbox.write." + toString() - + ".other"))); + + ".other")); } @Override @@ -38,9 +39,10 @@ public class InboxOwner extends CommentInbox { if (plot == null) { return Permissions.hasPermission(player, "plots.inbox.modify." + toString()); } - return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions + .hasPermission(player, "plots.inbox.modify." + toString() - + ".other"))); + + ".other")); } @Override @@ -59,7 +61,7 @@ public class InboxOwner extends CommentInbox { public void run(List value) { whenDone.value = value; if (value != null) { - for (final PlotComment comment : (ArrayList) value) { + for (final PlotComment comment : value) { plot.getSettings().addComment(comment); } } else { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java b/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java index 50d9a23b8..a58195f76 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java @@ -1,8 +1,5 @@ package com.intellectualcrafters.plot.object.comment; -import java.util.ArrayList; -import java.util.List; - import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -10,6 +7,9 @@ import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; +import java.util.ArrayList; +import java.util.List; + public class InboxPublic extends CommentInbox { @Override @@ -17,10 +17,10 @@ public class InboxPublic extends CommentInbox { if (plot == null) { return Permissions.hasPermission(player, "plots.inbox.read." + toString()); } - return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions + return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions .hasPermission(player, "plots.inbox.read." + toString() - + ".other"))); + + ".other")); } @Override @@ -28,9 +28,10 @@ public class InboxPublic extends CommentInbox { if (plot == null) { return Permissions.hasPermission(player, "plots.inbox.write." + toString()); } - return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write." + return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions + .hasPermission(player, "plots.inbox.write." + toString() - + ".other"))); + + ".other")); } @Override @@ -38,9 +39,10 @@ public class InboxPublic extends CommentInbox { if (plot == null) { return Permissions.hasPermission(player, "plots.inbox.modify." + toString()); } - return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify." + return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions + .hasPermission(player, "plots.inbox.modify." + toString() - + ".other"))); + + ".other")); } @Override @@ -59,7 +61,7 @@ public class InboxPublic extends CommentInbox { public void run(List value) { whenDone.value = value; if (value != null) { - for (final PlotComment comment : (ArrayList) value) { + for (final PlotComment comment : value) { plot.getSettings().addComment(comment); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/CmdConfirm.java b/Core/src/main/java/com/intellectualcrafters/plot/util/CmdConfirm.java index aad301155..385e50e9a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/CmdConfirm.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/CmdConfirm.java @@ -6,7 +6,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; public class CmdConfirm { public static CmdInstance getPending(final PlotPlayer player) { - return player.getMeta("cmdConfirm"); + return player.getMeta("cmdConfirm"); } public static void removePending(final PlotPlayer player) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index af78b4302..9988818a7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -54,20 +54,22 @@ public class ExpireManager { public void confirmExpiry(final PlotPlayer pp) { if (Settings.AUTO_CLEAR_CONFIRMATION && plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) { final int num = plotsToDelete.size(); - Iterator iter = plotsToDelete.iterator(); - while (iter.hasNext()) { - final Plot current = iter.next(); + for (final Plot current : plotsToDelete) { if (isExpired(current)) { TaskManager.runTask(new Runnable() { @Override public void run() { pp.teleport(current.getCenter()); PlotMessage msg = new PlotMessage() - .text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired").tooltip("/plot list expired") + .text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired") + .tooltip("/plot list expired") //.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired") - .text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete").tooltip("/plot delete") - .text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d").tooltip("/plot set keep 1d") - .text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true").tooltip("/plot set keep true"); + .text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete") + .tooltip("/plot delete") + .text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d") + .tooltip("/plot set keep 1d") + .text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true") + .tooltip("/plot set keep true"); msg.send(pp); } }); @@ -75,7 +77,6 @@ public class ExpireManager { } } plotsToDelete.clear(); - return; } } @@ -247,7 +248,7 @@ public class ExpireManager { return false; } final long compared = System.currentTimeMillis() - last; - if (compared >= (TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS))) { + if (compared >= TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS)) { return true; } } @@ -266,7 +267,7 @@ public class ExpireManager { return false; } } else if (value instanceof Long) { - if (((Long) value) > System.currentTimeMillis()) { + if ((Long) value > System.currentTimeMillis()) { return false; } } else { // Invalid? diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/Core/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 5815d510b..e4bba25f2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -1,12 +1,12 @@ package com.intellectualcrafters.plot.util; -import java.util.HashMap; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.general.commands.CommandCaller; +import java.util.HashMap; + /** * The Permissions class handles checking user permissions.
* - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)
@@ -34,7 +34,7 @@ public class Permissions { if (!Settings.PERMISSION_CACHING) { return hasPermission((CommandCaller) player, perm); } - HashMap map = (HashMap) player.getMeta("perm"); + HashMap map = player.getMeta("perm"); if (map != null) { Boolean result = map.get(perm); if (result != null) { @@ -63,7 +63,7 @@ public class Permissions { final String[] nodes = perm.split("\\."); final StringBuilder n = new StringBuilder(); for (int i = 0; i <= (nodes.length - 1); i++) { - n.append(nodes[i] + (".")); + n.append(nodes[i] + "."); if (!perm.equals(n + C.PERMISSION_STAR.s())) { if (player.hasPermission(n + C.PERMISSION_STAR.s())) { return true; @@ -106,7 +106,7 @@ public class Permissions { final String[] nodes = stub.split("\\."); final StringBuilder n = new StringBuilder(); for (int i = 0; i < (nodes.length - 1); i++) { - n.append(nodes[i] + (".")); + n.append(nodes[i] + "."); if (!stub.equals(n + C.PERMISSION_STAR.s())) { if (player.hasPermission(n + C.PERMISSION_STAR.s())) { return Integer.MAX_VALUE; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/PlotGamemode.java b/Core/src/main/java/com/intellectualcrafters/plot/util/PlotGamemode.java index 2e2fc6200..6df304d43 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/PlotGamemode.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/PlotGamemode.java @@ -1,5 +1,5 @@ package com.intellectualcrafters.plot.util; public enum PlotGamemode { - ADVENTURE, SURVIVAL, CREATIVE, SPECTATOR; + ADVENTURE, SURVIVAL, CREATIVE, SPECTATOR } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/PlotWeather.java b/Core/src/main/java/com/intellectualcrafters/plot/util/PlotWeather.java index 799798a9f..918d7f4e8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/PlotWeather.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/PlotWeather.java @@ -1,5 +1,5 @@ package com.intellectualcrafters.plot.util; public enum PlotWeather { - RAIN, CLEAR, RESET; + RAIN, CLEAR, RESET } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index d92907c18..27fbef2c8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.schematic.PlotItem; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -166,7 +167,8 @@ public abstract class SchematicHandler { final int HEIGHT = demensions.getY(); // Validate dimensions RegionWrapper region = plot.getLargestRegion(); - if ((((region.maxX - region.minX + x_offset) + 1) < WIDTH) || (((region.maxZ - region.minZ + z_offset) + 1) < LENGTH) || (HEIGHT > 256)) { + if (((region.maxX - region.minX + x_offset + 1) < WIDTH) || ((region.maxZ - region.minZ + z_offset + 1) < LENGTH) || (HEIGHT + > 256)) { PS.debug("Schematic is too large"); PS.debug("(" + WIDTH + "," + LENGTH + "," + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + "," + (region.maxZ - region.minZ) + ",256)"); TaskManager.runTask(whenDone); @@ -451,7 +453,7 @@ public abstract class SchematicHandler { final List blockStates = ListTag.class.cast(tagMap.get("TileEntities")).getValue(); for (final Tag stateTag : blockStates) { try { - final CompoundTag ct = ((CompoundTag) stateTag); + final CompoundTag ct = (CompoundTag) stateTag; final Map state = ct.getValue(); final short x = IntTag.class.cast(state.get("x")).getValue().shortValue(); final short y = IntTag.class.cast(state.get("y")).getValue().shortValue(); @@ -782,15 +784,15 @@ public abstract class SchematicHandler { int dz = schematicDimension.getZ(); for (int y = y1; y <= y2; y++) { - int yy = y >= 0 ? (y < dy ? y : y - dy) : y + dy; + int yy = y >= 0 ? y < dy ? y : y - dy : y + dy; int i1 = yy * dx * dz; int j1 = (y - y1) * width * length; for (int z = z1; z <= z2; z++) { - int zz = z >= 0 ? (z < dz ? z : z - dz) : z + dz; + int zz = z >= 0 ? z < dz ? z : z - dz : z + dz; int i2 = i1 + zz * dx; int j2 = j1 + (z - z1) * width; for (int x = x1; x <= x2; x++) { - int xx = x >= 0 ? (x < dx ? x : x - dx) : x + dx; + int xx = x >= 0 ? x < dx ? x : x - dx : x + dx; int i3 = i2 + xx; int j3 = j2 + (x - x1); ids2[j3] = ids[i3]; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java index b12926ad6..e6dace181 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java @@ -179,7 +179,7 @@ public class SetQueue { return false; } final ChunkWrapper other = (ChunkWrapper) obj; - return ((x == other.x) && (z == other.z) && (StringMan.isEqual(world, other.world))); + return (x == other.x) && (z == other.z) && StringMan.isEqual(world, other.world); } @Override diff --git a/Core/src/main/java/com/plotsquared/general/commands/CommandManager.java b/Core/src/main/java/com/plotsquared/general/commands/CommandManager.java index 377421832..5b5b428a6 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/CommandManager.java +++ b/Core/src/main/java/com/plotsquared/general/commands/CommandManager.java @@ -85,10 +85,14 @@ public class CommandManager { } public int handle(final T plr, String input) { - if ((initialCharacter != null) && !input.startsWith(initialCharacter + "")) { + if (initialCharacter != null && !input.startsWith(initialCharacter + "")) { return CommandHandlingOutput.NOT_COMMAND; } - input = initialCharacter == null ? input : input.substring(1); + if (initialCharacter == null) { + input = input; + } else { + input = input.substring(1); + } final String[] parts = input.split(" "); String[] args; final String command = parts[0].toLowerCase(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 6ee5fbb86..522e6217e 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -338,12 +338,8 @@ public class SpongeMain implements IPlotMain { GenerationPopulator gen = wg.getBaseGenerationPopulator(); if (gen instanceof SpongePlotGenerator) { PS.get().loadWorld(worldname, (SpongePlotGenerator) gen); - } else if (gen != null) { - throw new UnsupportedOperationException("NOT IMPLEMENTED YET!"); } else { - if (PS.get().config.contains("worlds." + worldname)) { - PS.get().loadWorld(worldname, null); - } + throw new UnsupportedOperationException("NOT IMPLEMENTED YET!"); } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index 332b1f3f7..fca8a7213 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -18,9 +18,10 @@ import java.util.List; public class SpongeAugmentedGenerator implements GenerationPopulator { private static SpongeAugmentedGenerator generator; - - private SpongeAugmentedGenerator() {}; - + + private SpongeAugmentedGenerator() { + } + public static SpongeAugmentedGenerator get(World world) { WorldGenerator wg = world.getWorldGenerator(); List populators = wg.getGenerationPopulators(); 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 b69b0adef..3f163e62d 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -86,7 +86,7 @@ public class SpongeUtil extends WorldUtil { System.out.println(method + ": " + cause.toString()); System.out.println(method + ": " + cause.getClass()); System.out.println(method + ": " + StringMan.getString(cause.all())); - System.out.println(method + ": " + (cause.root())); + System.out.println(method + ": " + cause.root()); } public static void initBiomeCache() { @@ -291,7 +291,7 @@ public class SpongeUtil extends WorldUtil { id = Short.parseShort(split[0]); match = 0; } else { - List types = ReflectionUtils.getStaticFields(BlockTypes.class); + List types = ReflectionUtils.getStaticFields(BlockTypes.class); final StringComparison.ComparisonResult comparison = new StringComparison(name, types.toArray(new BlockType[types.size()])) { @Override