diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java index 09654b25b..972ba655a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/ListTagBuilder.java @@ -40,6 +40,7 @@ public class ListTagBuilder { * * @return a new builder */ + @SafeVarargs public static ListTagBuilder createWith(final T... entries) { checkNotNull(entries); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java index 670dfbb2f..e1abcdaba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTOutputStream.java @@ -179,8 +179,8 @@ public final class NBTOutputStream implements Closeable { this.os.writeByte(NBTUtils.getTypeCode(clazz)); this.os.writeInt(size); - for (int i = 0; i < size; ++i) { - writeTagPayload(tags.get(i)); + for (Tag tag1 : tags) { + writeTagPayload(tag1); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java index 7e0c610d8..d7251787f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/jnbt/NBTUtils.java @@ -131,7 +131,6 @@ public final class NBTUtils { * @param key the key to look for * @param expected the expected NBT class type * @return child tag - * @throws InvalidFormatException */ public static T getChildTag(final Map items, final String key, final Class expected) throws IllegalArgumentException { if (!items.containsKey(key)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java index 70a64999e..c0c822279 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/CDL.java @@ -247,7 +247,7 @@ public class CDL { if ((names == null) || (names.length() == 0)) { return null; } - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); for (int i = 0; i < ja.length(); i += 1) { final JSONObject jo = ja.optJSONObject(i); if (jo != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java index 4f0cf19b2..cad77b24c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONArray.java @@ -27,7 +27,6 @@ import java.io.Writer; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.Map; /** @@ -145,9 +144,8 @@ public class JSONArray { public JSONArray(final Collection collection) { this.myArrayList = new ArrayList(); if (collection != null) { - final Iterator iter = collection.iterator(); - while (iter.hasNext()) { - this.myArrayList.add(JSONObject.wrap(iter.next())); + for (Object aCollection : collection) { + this.myArrayList.add(JSONObject.wrap(aCollection)); } } } @@ -548,7 +546,7 @@ public class JSONArray { * @throws JSONException if the value is not finite. */ public JSONArray put(final double value) throws JSONException { - final Double d = new Double(value); + final Double d = value; JSONObject.testValidity(d); this.put(d); return this; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java index 07e7f86d1..319aa7032 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONObject.java @@ -164,9 +164,7 @@ public class JSONObject { public JSONObject(final Map map) { this.map = new HashMap(); if (map != null) { - final Iterator> i = map.entrySet().iterator(); - while (i.hasNext()) { - final Entry entry = i.next(); + for (Entry entry : map.entrySet()) { final Object value = entry.getValue(); if (value != null) { this.map.put(entry.getKey(), wrap(value)); @@ -1319,9 +1317,7 @@ public class JSONObject { if (!set.equals(((JSONObject) other).keySet())) { return false; } - final Iterator iterator = set.iterator(); - while (iterator.hasNext()) { - final String name = iterator.next(); + for (String name : set) { final Object valueThis = this.get(name); final Object valueOther = ((JSONObject) other).get(name); if (valueThis instanceof JSONObject) { @@ -1485,7 +1481,11 @@ public class JSONObject { */ @Override protected final Object clone() { - return this; + try { + return super.clone(); + } catch (Exception e) { + return this; + } } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java index 0c75c77f9..416834279 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/json/JSONWriter.java @@ -38,6 +38,10 @@ import java.io.Writer; */ public class JSONWriter { private static final int maxdepth = 200; + /** + * The writer that will receive the output. + */ + protected final Writer writer; /** * The object/array stack. */ @@ -51,10 +55,6 @@ public class JSONWriter { * 'o' (object). */ protected char mode; - /** - * The writer that will receive the output. - */ - protected Writer writer; /** * The comma flag determines if a comma should be output before the next * value. diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 085a2dcff..a04ff1298 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -42,10 +42,8 @@ import com.intellectualcrafters.plot.uuid.PlotUUIDSaver; import com.intellectualcrafters.plot.uuid.UUIDSaver; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; - import me.confuser.barapi.BarAPI; import net.milkbowl.vault.economy.Economy; - import org.bukkit.*; import org.bukkit.command.PluginCommand; import org.bukkit.configuration.file.YamlConfiguration; @@ -80,6 +78,43 @@ public class PlotMain extends JavaPlugin { */ public static final String ADMIN_PERMISSION = "plots.admin"; + /** + * Storage version + */ + public final static int storage_ver = + 1; + /** + * Boolean Flags (material) + */ + public final static HashMap booleanFlags = + new HashMap<>(); + + /** + * Initialize the material flags + */ + static { + booleanFlags.put(Material.WOODEN_DOOR, "wooden_door"); + booleanFlags.put(Material.IRON_DOOR, "iron_door"); + booleanFlags.put(Material.STONE_BUTTON, "stone_button"); + booleanFlags.put(Material.WOOD_BUTTON, "wooden_button"); + booleanFlags.put(Material.LEVER, "lever"); + booleanFlags.put(Material.WOOD_PLATE, "wooden_plate"); + booleanFlags.put(Material.STONE_PLATE, "stone_plate"); + booleanFlags.put(Material.CHEST, "chest"); + booleanFlags.put(Material.TRAPPED_CHEST, "trapped_chest"); + booleanFlags.put(Material.TRAP_DOOR, "trap_door"); + booleanFlags.put(Material.DISPENSER, "dispenser"); + booleanFlags.put(Material.DROPPER, "dropper"); + } + + /** + * All loaded plot worlds + */ + private final static HashMap worlds = new HashMap<>(); + /** + * All world managers + */ + private final static HashMap managers = new HashMap<>(); /** * settings.properties */ @@ -96,11 +131,6 @@ public class PlotMain extends JavaPlugin { * Contains storage options */ public static YamlConfiguration storage; - /** - * Storage version - */ - public static int storage_ver = - 1; /** * MySQL Connection */ @@ -135,30 +165,6 @@ public class PlotMain extends JavaPlugin { */ public static boolean useEconomy = false; - /** - * Boolean Flags (material) - */ - public static HashMap booleanFlags = - new HashMap<>(); - - /** - * Initialize the material flags - */ - static { - booleanFlags.put(Material.WOODEN_DOOR, "wooden_door"); - booleanFlags.put(Material.IRON_DOOR, "iron_door"); - booleanFlags.put(Material.STONE_BUTTON, "stone_button"); - booleanFlags.put(Material.WOOD_BUTTON, "wooden_button"); - booleanFlags.put(Material.LEVER, "lever"); - booleanFlags.put(Material.WOOD_PLATE, "wooden_plate"); - booleanFlags.put(Material.STONE_PLATE, "stone_plate"); - booleanFlags.put(Material.CHEST, "chest"); - booleanFlags.put(Material.TRAPPED_CHEST, "trapped_chest"); - booleanFlags.put(Material.TRAP_DOOR, "trap_door"); - booleanFlags.put(Material.DISPENSER, "dispenser"); - booleanFlags.put(Material.DROPPER, "dropper"); - } - /** * The UUID Saver */ @@ -172,14 +178,6 @@ public class PlotMain extends JavaPlugin { * DO NOT USE EXCEPT FOR DATABASE PURPOSES */ private static LinkedHashMap> plots; - /** - * All loaded plot worlds - */ - private static HashMap worlds = new HashMap<>(); - /** - * All world managers - */ - private static HashMap managers = new HashMap<>(); /** * Check for expired plots @@ -202,12 +200,9 @@ public class PlotMain extends JavaPlugin { * Check a range of permissions e.g. 'plots.plot.<0-100>'
* Returns highest integer in range. * - * @param player - * to check - * @param stub - * to check - * @param range - * tp check + * @param player to check + * @param stub to check + * @param range tp check * @return permitted range */ public static int hasPermissionRange(final Player player, final String stub, final int range) { @@ -230,10 +225,8 @@ public class PlotMain extends JavaPlugin { * - Op has all permissions
* - checks for '*' nodes * - * @param player - * to check - * @param perms - * to check + * @param player to check + * @param perms to check * @return true of player has permissions */ public static boolean hasPermissions(final Player player, final String[] perms) { @@ -266,6 +259,7 @@ public class PlotMain extends JavaPlugin { /** * Get the uuid saver + * * @return uuid saver * @see com.intellectualcrafters.plot.uuid.UUIDSaver; */ @@ -288,10 +282,8 @@ public class PlotMain extends JavaPlugin { * - Op has all permissions
* - checks for '*' nodes * - * @param player - * to check - * @param perm - * to check + * @param player to check + * @param perm to check * @return true if player has the permission */ public static boolean hasPermission(final Player player, final String perm) { @@ -328,6 +320,7 @@ public class PlotMain extends JavaPlugin { /** * Get a sorted list of plots + * * @return sorted list */ public static LinkedHashSet getPlotsSorted() { @@ -339,8 +332,7 @@ public class PlotMain extends JavaPlugin { } /** - * @param player - * player + * @param player player * @return Set Containing the players plots */ public static Set getPlots(final Player player) { @@ -390,8 +382,7 @@ public class PlotMain extends JavaPlugin { } /** - * @param world - * plot world + * @param world plot world * @return plots in world */ public static HashMap getPlots(final World world) { @@ -418,8 +409,7 @@ public class PlotMain extends JavaPlugin { } /** - * @param world - * plotworld(?) + * @param world plotworld(?) * @return true if the world is a plotworld */ public static boolean isPlotWorld(final World world) { @@ -427,8 +417,7 @@ public class PlotMain extends JavaPlugin { } /** - * @param world - * plotworld(?) + * @param world plotworld(?) * @return true if the world is a plotworld */ public static boolean isPlotWorld(final String world) { @@ -436,8 +425,7 @@ public class PlotMain extends JavaPlugin { } /** - * @param world - * World to get manager for + * @param world World to get manager for * @return manager for world */ public static PlotManager getPlotManager(final World world) { @@ -491,8 +479,9 @@ public class PlotMain extends JavaPlugin { /** * Remove a plot - * @param world The Plot World - * @param id The Plot ID + * + * @param world The Plot World + * @param id The Plot ID * @param callEvent Whether or not to call the PlotDeleteEvent * @return true if successful, false if not */ @@ -512,8 +501,7 @@ public class PlotMain extends JavaPlugin { /** * Replace the plot object with an updated version * - * @param plot - * plot object + * @param plot plot object */ public static void updatePlot(final Plot plot) { final String world = plot.world; @@ -545,10 +533,8 @@ public class PlotMain extends JavaPlugin { * - Add new plots to the end.
* - The task then only needs to go through the first few plots * - * @param plugin - * Plugin - * @param async - * Call async? + * @param plugin Plugin + * @param async Call async? */ private static void checkExpired(final JavaPlugin plugin, final boolean async) { if (async) { @@ -633,8 +619,7 @@ public class PlotMain extends JavaPlugin { /** * Send a message to the console. * - * @param string - * message + * @param string message */ public static void sendConsoleSenderMessage(final String string) { if (getMain().getServer().getConsoleSender() == null) { @@ -646,9 +631,10 @@ public class PlotMain extends JavaPlugin { /** * Teleport a player to a plot + * * @param player Player to teleport - * @param from Previous Location - * @param plot Plot to teleport to + * @param from Previous Location + * @param plot Plot to teleport to * @return true if successful */ public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) { @@ -669,8 +655,7 @@ public class PlotMain extends JavaPlugin { /** * Send a message to the console * - * @param c - * message + * @param c message */ @SuppressWarnings("unused") public static void sendConsoleSenderMessage(final C c) { @@ -680,8 +665,7 @@ public class PlotMain extends JavaPlugin { /** * Broadcast publicly * - * @param c - * message + * @param c message */ public static void Broadcast(final C c) { Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())); @@ -699,8 +683,7 @@ public class PlotMain extends JavaPlugin { /** * Broadcast a message to all admins * - * @param c - * message + * @param c message */ public static void BroadcastWithPerms(final C c) { for (final Player player : Bukkit.getOnlinePlayers()) { @@ -713,6 +696,7 @@ public class PlotMain extends JavaPlugin { /** * Reload all translations + * * @throws IOException */ public static void reloadTranslations() throws IOException { @@ -721,6 +705,7 @@ public class PlotMain extends JavaPlugin { /** * Ge the last played time + * * @param uuid UUID for the player * @return last play time as a long */ @@ -968,6 +953,7 @@ public class PlotMain extends JavaPlugin { /** * Create a plotworld config section + * * @param plotworld World to create the section for */ @SuppressWarnings("unused") @@ -1299,9 +1285,10 @@ public class PlotMain extends JavaPlugin { /** * Add a Plot world - * @param world World to add + * + * @param world World to add * @param plotworld PlotWorld Object - * @param manager Plot Manager for the new world + * @param manager Plot Manager for the new world */ public static void addPlotWorld(final String world, final PlotWorld plotworld, final PlotManager manager) { worlds.put(world, plotworld); @@ -1313,6 +1300,7 @@ public class PlotMain extends JavaPlugin { /** * Remove a plot world + * * @param world World to remove */ public static void removePlotWorld(final String world) { @@ -1323,21 +1311,13 @@ public class PlotMain extends JavaPlugin { /** * Get all plots + * * @return All Plos in a hashmap (world, Hashmap contiang ids and objects)) */ public static HashMap> getAllPlotsRaw() { return plots; } - /** - * Set all plots - * - * @param plots New Plot LinkedHashMap - */ - public static void setAllPlotsRaw(final LinkedHashMap> plots) { - PlotMain.plots = plots; - } - /** * Set all plots * @@ -1348,6 +1328,15 @@ public class PlotMain extends JavaPlugin { // PlotMain.plots.putAll(plots); } + /** + * Set all plots + * + * @param plots New Plot LinkedHashMap + */ + public static void setAllPlotsRaw(final LinkedHashMap> plots) { + PlotMain.plots = plots; + } + /** * Get the PlotSquared World Generator * @@ -1595,7 +1584,7 @@ public class PlotMain extends JavaPlugin { } catch (final Exception e) { PlotHelper.canSetFast = false; } - + try { new SendChunk(); PlotHelper.canSendChunk = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 09740b4e7..b50a65ad1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -33,7 +33,7 @@ import org.bukkit.entity.Player; import java.util.UUID; -@SuppressWarnings("deprecated") +@SuppressWarnings("deprecation") public class Denied extends SubCommand { public Denied() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 0fb54aa7e..f4ea43fc0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -53,7 +53,7 @@ public class Inbox extends SubCommand { return false; } - Integer tier = null; + Integer tier; final UUID uuid = plr.getUniqueId(); if (PlotMain.hasPermission(plr, "plots.admin")) { tier = 0; @@ -151,14 +151,13 @@ public class Inbox extends SubCommand { } plot.settings.removeComments(comments); PlayerFunctions.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category"); - return; } else { - final List recipients = Arrays.asList(new String[]{"A", "O", "H", "T", "E"}); + final List recipients = Arrays.asList("A", "O", "H", "T", "E"); int count = 1; final StringBuilder message = new StringBuilder(); String prefix = ""; for (final PlotComment comment : comments) { - message.append(prefix + "[" + count + "]&6[&c" + recipients.get(tier2) + "&6] &7" + comment.senderName + "&f: " + comment.comment); + message.append(prefix).append("[").append(count).append("]&6[&c").append(recipients.get(tier2)).append("&6] &7").append(comment.senderName).append("&f: ").append(comment.comment); prefix = "\n"; count++; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 083c4663b..9559f69c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -103,16 +103,8 @@ public class Info extends SubCommand { // Wildcard player {added} { - if (plot.helpers == null) { - containsEveryone = false; - } else { - containsEveryone = plot.helpers.contains(DBFunc.everyone); - } - if (plot.trusted == null) { - trustedEveryone = false; - } else { - trustedEveryone = plot.trusted.contains(DBFunc.everyone); - } + containsEveryone = plot.helpers != null && plot.helpers.contains(DBFunc.everyone); + trustedEveryone = plot.trusted != null && plot.trusted.contains(DBFunc.everyone); } // Unclaimed? @@ -183,7 +175,7 @@ public class Info extends SubCommand { final String denied = getPlayerList(plot.denied); final String rating = String.format("%.1f", DBFunc.getRatings(plot)); final String flags = "&6" + (StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), "&7, &6") : "none"); - final boolean build = player == null ? true : plot.hasRights(player); + final boolean build = player == null || plot.hasRights(player); String owner = "none"; if (plot.owner != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 39dd43acd..701b06fd8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -49,7 +49,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { public static final String MAIN_PERMISSION = "plots.use"; - private static SubCommand[] _subCommands = + private final static SubCommand[] _subCommands = new SubCommand[]{ new Ban(), new Unban(), new OP(), new DEOP(), @@ -71,7 +71,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { new Comment(), new Database(), new Swap(), new MusicSubcommand()}; - public static ArrayList subCommands = new ArrayList() { + public final static ArrayList subCommands = new ArrayList() { { addAll(Arrays.asList(_subCommands)); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index feacd68a9..c7c637750 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -43,8 +43,8 @@ import java.util.ArrayList; */ public class Merge extends SubCommand { - public static String[] values = new String[]{"north", "east", "south", "west"}; - public static String[] aliases = new String[]{"n", "e", "s", "w"}; + public final static String[] values = new String[]{"north", "east", "south", "west"}; + public final static String[] aliases = new String[]{"n", "e", "s", "w"}; public Merge() { super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index cdc5f1626..6354618fa 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -53,8 +53,8 @@ import java.util.List; */ public class Set extends SubCommand { - public static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"}; - public static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"}; + public final static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"}; + public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"}; public Set() { super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index c58b237a0..38d7e5f0d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -49,7 +49,7 @@ import java.util.Map; */ public class Setup extends SubCommand implements Listener { - public static Map setupMap = new HashMap<>(); + public final static Map setupMap = new HashMap<>(); public Setup() { super("setup", "plots.admin", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false); @@ -208,12 +208,11 @@ public class Setup extends SubCommand implements Listener { } private class SetupObject { - String world; - String plugin; + final String world; + final String plugin; + final ConfigurationNode[] step; int current = 0; - ConfigurationNode[] step; - public SetupObject(final String world, final PlotWorld plotworld, final String plugin) { this.world = world; this.step = plotworld.getSettingNodes(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index 11616b1d6..9ada327a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -60,7 +60,7 @@ public abstract class SubCommand { /** * Is this a player-online command? */ - public boolean isPlayer; + public final boolean isPlayer; /** * @param cmd Command /plot {cmd} <-- That! diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 21c1a6cfb..9c7a874ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -33,7 +33,9 @@ import org.bukkit.World; import org.bukkit.entity.Player; /** - * Created by Citymonstret on 2014-08-01. + * Created 2014-08-01 for PlotSquared + * + * @author Empire92 */ public class Swap extends SubCommand { @@ -76,6 +78,7 @@ public class Swap extends SubCommand { PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); return false; } + assert plot != null; if (plot.id.equals(plotid)) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); PlayerFunctions.sendMessage(plr, C.SWAP_SYNTAX); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 331d9c87e..b7ac340ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -382,7 +382,7 @@ public enum C { * * @see com.intellectualsites.translation.TranslationLanguage */ - protected static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use"); + protected final static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use"); /** * The TranslationManager diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 982fa1b93..b7ea1c113 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -29,71 +29,58 @@ package com.intellectualcrafters.plot.config; */ public class Settings { + /** + * Default kill road mobs: true + */ + public final static boolean KILL_ROAD_MOBS_DEFAULT = true; + /** + * Default mob pathfinding: true + */ + public final static boolean MOB_PATHFINDING_DEFAULT = true; /** * Teleport to path on login */ public static boolean TELEPORT_ON_LOGIN = false; - /** * Mob Cap Enabled */ public static boolean MOB_CAP_ENABLED = false; - /** * The Mob Cap */ public static int MOB_CAP = 20; - /** * Display titles */ public static boolean TITLES = true; - /** * Schematic Save Path */ public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics"; - /** * Max allowed plots */ public static int MAX_PLOTS = 20; - /** * WorldGuard region on claimed plots */ public static boolean WORLDGUARD = false; - /** * metrics */ public static boolean METRICS = true; - /** * plot specific resource pack */ public static String PLOT_SPECIFIC_RESOURCE_PACK = ""; - /** * Kill road mobs? */ public static boolean KILL_ROAD_MOBS; - - /** - * Default kill road mobs: true - */ - public static boolean KILL_ROAD_MOBS_DEFAULT = true; - /** * mob pathfinding? */ public static boolean MOB_PATHFINDING; - - /** - * Default mob pathfinding: true - */ - public static boolean MOB_PATHFINDING_DEFAULT = true; - /** * Delete plots on ban? */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index fff72a0cb..fdce3bb2e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -33,24 +33,43 @@ import java.util.LinkedHashMap; import java.util.UUID; /** + * DB Functions + * + * @author Empire92 * @author Citymonstret */ public class DBFunc { + /** + * The "global" uuid + */ + public static final UUID everyone = UUID.fromString("1-1-3-3-7"); + /** + * Abstract Database Manager + */ public static AbstractDB dbManager; - // TODO MongoDB @Brandon - - public static UUID everyone = UUID.fromString("1-1-3-3-7"); - + /** + * Set the owner of a plot + * @param plot Plot Object + * @param uuid New Owner + */ public static void setOwner(final Plot plot, final UUID uuid) { dbManager.setOwner(plot, uuid); } + /** + * Create all settings + (helpers, denied, trusted) + * @param plots List containing all plot objects + */ public static void createAllSettingsAndHelpers(final ArrayList plots) { dbManager.createAllSettingsAndHelpers(plots); } + /** + * Create all plots + * @param plots A list containing plot objects + */ public static void createPlots(final ArrayList plots) { dbManager.createPlots(plots); } @@ -58,7 +77,7 @@ public class DBFunc { /** * Create a plot * - * @param plot + * @param plot Plot to create */ public static void createPlot(final Plot plot) { dbManager.createPlot(plot); @@ -76,7 +95,7 @@ public class DBFunc { /** * Delete a plot * - * @param plot + * @param plot Plot to delete */ public static void delete(final String world, final Plot plot) { dbManager.delete(world, plot); @@ -85,8 +104,8 @@ public class DBFunc { /** * Create plot settings * - * @param id - * @param plot + * @param id Plot ID + * @param plot Plot Object */ public static void createPlotSettings(final int id, final Plot plot) { dbManager.createPlotSettings(id, plot); @@ -95,8 +114,9 @@ public class DBFunc { /** * Get a plot id * - * @param plot_id - * @return + * @param world World + * @param id2 Plot ID + * @return ID */ /* * public static int getId(String world, PlotId id2) { Statement stmt = @@ -113,7 +133,7 @@ public class DBFunc { } /** - * @return + * @return Plots */ public static LinkedHashMap> getPlots() { return dbManager.getPlots(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java index a495783ed..fa03cf823 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/Database.java @@ -39,7 +39,7 @@ public abstract class Database { /** * Plugin instance, use for plugin.getDataFolder() */ - protected Plugin plugin; + protected final Plugin plugin; /** * Creates a new Database diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/FlatFileManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/FlatFileManager.java deleted file mode 100644 index 916f9b9dd..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/FlatFileManager.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.intellectualcrafters.plot.database; - -/** - * Created by Citymonstret on 2014-09-23. - */ -public class FlatFileManager { -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index ad8574ab6..6c7af04e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -97,9 +97,7 @@ public class MySQL extends Database { final Statement statement = this.connection.createStatement(); - final ResultSet result = statement.executeQuery(query); - - return result; + return statement.executeQuery(query); } @Override @@ -110,9 +108,7 @@ public class MySQL extends Database { final Statement statement = this.connection.createStatement(); - final int result = statement.executeUpdate(query); - - return result; + return statement.executeUpdate(query); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index 166cbe818..c0096a98f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -195,12 +195,12 @@ public class PlotMeConverter { final PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1])); com.intellectualcrafters.plot.object.Plot pl; if (online) { - pl = new com.intellectualcrafters.plot.object.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, + pl = new com.intellectualcrafters.plot.object.Plot(id, plot.getOwnerId(), psAdded, psTrusted, psDenied, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false}); } else { final String owner = plot.getOwner(); - pl = new com.intellectualcrafters.plot.object.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied, + pl = new com.intellectualcrafters.plot.object.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), psAdded, psTrusted, psDenied, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[]{false, false, false, false}); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index fecce6f33..114edfd27 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -383,7 +383,7 @@ public class SQLManager implements AbstractDB { */ @Override public LinkedHashMap> getPlots() { - final LinkedHashMap> newplots = new LinkedHashMap>(); + final LinkedHashMap> newplots = new LinkedHashMap<>(); try { final DatabaseMetaData data = connection.getMetaData(); ResultSet rs = data.getColumns(null, null, prefix + "plot", "plot_id"); @@ -408,12 +408,12 @@ public class SQLManager implements AbstractDB { } catch (final Exception e) { e.printStackTrace(); } - final HashMap plots = new HashMap(); + final HashMap plots = new HashMap<>(); Statement stmt = null; try { - Set worlds = new HashSet(); + Set worlds = new HashSet<>(); if (PlotMain.config.contains("worlds")) { worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false); } @@ -448,7 +448,7 @@ public class SQLManager implements AbstractDB { user = UUID.fromString(o); uuids.put(o, user); } - p = new Plot(plot_id, user, Biome.FOREST, new ArrayList(), new ArrayList(), new ArrayList(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[]{false, false, false, false}); + p = new Plot(plot_id, user, new ArrayList(), new ArrayList(), new ArrayList(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[]{false, false, false, false}); plots.put(id, p); } // stmt.close(); @@ -924,7 +924,6 @@ public class SQLManager implements AbstractDB { h.put(var, val); } stmt.close(); - ; } catch (final SQLException e) { Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id); e.printStackTrace(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java index f9993c829..7b1891b86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLite.java @@ -36,8 +36,8 @@ import java.util.logging.Level; */ public class SQLite extends Database { - private Connection connection; private final String dbLocation; + private Connection connection; /** * Creates a new SQLite instance @@ -98,9 +98,7 @@ public class SQLite extends Database { final Statement statement = this.connection.createStatement(); - final ResultSet result = statement.executeQuery(query); - - return result; + return statement.executeQuery(query); } @Override @@ -111,8 +109,6 @@ public class SQLite extends Database { final Statement statement = this.connection.createStatement(); - final int result = statement.executeUpdate(query); - - return result; + return statement.executeUpdate(query); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/PlotTable.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/PlotTable.java deleted file mode 100644 index 28e3ee383..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/PlotTable.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.intellectualcrafters.plot.database.sqlobjects; - -/** - * Created by Citymonstret on 2014-10-28. - */ -public class PlotTable extends SQLTable { - - public PlotTable() { - super("plots", "hello", null); - } - - @Override - public void create() { - // TODO Auto-generated method stub - - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLField.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLField.java deleted file mode 100644 index 2c44c2c09..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLField.java +++ /dev/null @@ -1,45 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// - -package com.intellectualcrafters.plot.database.sqlobjects; - -/** - * Created by Citymonstret on 2014-10-28. - */ -public class SQLField { - - private final SQLType type; - private final Object value; - - public SQLField(final SQLType type, final Object value) { - this.type = type; - this.value = value; - } - - public SQLType getType() { - return this.type; - } - - public Object getValue() { - return this.value; - } - -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLTable.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLTable.java deleted file mode 100644 index 725d06636..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLTable.java +++ /dev/null @@ -1,50 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// - -package com.intellectualcrafters.plot.database.sqlobjects; - -import com.intellectualcrafters.plot.config.Settings; - -/** - * Created by Citymonstret on 2014-10-28. - */ -public abstract class SQLTable { - - private final String name; - private final SQLField[] fields; - - public SQLTable(final String name, final String primaryKey, final SQLField... fields) { - this.name = Settings.DB.PREFIX + name; - this.fields = fields; - } - - @Override - public String toString() { - return this.name; - } - - public SQLField[] getFields() { - return this.fields; - } - - public abstract void create(); - -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLType.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLType.java deleted file mode 100644 index 071e462b5..000000000 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/sqlobjects/SQLType.java +++ /dev/null @@ -1,61 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// - -package com.intellectualcrafters.plot.database.sqlobjects; - -/** - * Created by Citymonstret on 2014-10-28. - */ -public enum SQLType { - - INTEGER(0, "integer", Integer.class, 11), - VARCHAR("", "varchar", String.class, 300), - BOOL(false, "bool", Boolean.class, 1); - - private Object defaultValue; - private String sqlName; - private Class javaClass; - private int length; - - SQLType(final Object defaultValue, final String sqlName, final Class javaClass, final int length) { - this.defaultValue = defaultValue; - this.sqlName = sqlName; - this.javaClass = javaClass; - this.length = length; - } - - public int getLength() { - return this.length; - } - - @Override - public String toString() { - return this.sqlName; - } - - public Class getJavaClass() { - return this.javaClass; - } - - public Object getDefaultValue() { - return this.defaultValue; - } -} diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index ae8f384b4..c72abb56a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -42,7 +42,7 @@ public class FlagManager { // - Mob cap // - customized plot composition - private static ArrayList flags = new ArrayList<>(); + private final static ArrayList flags = new ArrayList<>(); /** * Register an AbstractFlag with PlotSquared diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 0acaefeed..caca56106 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -10,7 +10,7 @@ public abstract class FlagValue { private Class clazz; public FlagValue() { - this.clazz = (Class) this.getClass(); + this.clazz = (Class) getClass(); } public FlagValue(Class clazz) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java index 32eeb193c..6d6769a61 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotManager.java @@ -33,6 +33,7 @@ import org.bukkit.block.Block; import java.util.ArrayList; +@SuppressWarnings("deprecation") public class DefaultPlotManager extends PlotManager { /** @@ -186,10 +187,7 @@ public class DefaultPlotManager extends PlotManager { @Override public boolean isInPlotAbs(final PlotWorld plotworld, final Location loc, final PlotId plotid) { final PlotId result = getPlotIdAbs(plotworld, loc); - if (result == null) { - return false; - } - return result == plotid; + return result != null && result == plotid; } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java index 188520753..ef898b883 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java @@ -40,49 +40,49 @@ public class DefaultPlotWorld extends PlotWorld { /** * Default Road Height: 64 */ - public static int ROAD_HEIGHT_DEFAULT = 64; + public final static int ROAD_HEIGHT_DEFAULT = 64; /** * Default plot height: 64 */ - public static int PLOT_HEIGHT_DEFAULT = 64; + public final static int PLOT_HEIGHT_DEFAULT = 64; /** * Default Wall Height: 64 */ - public static int WALL_HEIGHT_DEFAULT = 64; + public final static int WALL_HEIGHT_DEFAULT = 64; /** * Default plot width: 32 */ - public static int PLOT_WIDTH_DEFAULT = 32; + public final static int PLOT_WIDTH_DEFAULT = 32; /** * Default road width: 7 */ - public static int ROAD_WIDTH_DEFAULT = 7; + public final static int ROAD_WIDTH_DEFAULT = 7; /** * Default main block: 1 */ - public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 1, (byte) 0)}; + public final static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 1, (byte) 0)}; /** * Default top blocks: {"2"} */ - public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 2, (byte) 0)}; + public final static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[]{new PlotBlock((short) 2, (byte) 0)}; /** * Default wall block: 44 */ - public static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0); - public static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1); + public final static PlotBlock WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 0); + public final static PlotBlock CLAIMED_WALL_BLOCK_DEFAULT = new PlotBlock((short) 44, (byte) 1); /** * Default wall filling: 1 */ - public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0); + public final static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0); /** * Default road stripes: 35 */ - public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0); - public static boolean ROAD_STRIPES_ENABLED_DEFAULT = false; + public final static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0); + public final static boolean ROAD_STRIPES_ENABLED_DEFAULT = false; /** * Default road block: 155 */ - public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0); + public final static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0); /** * Road Height */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/WorldGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/WorldGenerator.java index bc193fc19..cdbd8e63c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/WorldGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/WorldGenerator.java @@ -36,12 +36,14 @@ import java.util.List; import java.util.Random; /** - * @author Citymonstret The default generator is very messy, as we have decided + * The default generator is very messy, as we have decided * to try externalize all calculations from within the loop. - You will * see a lot of slower implementations have a single for loop. - This is * perfectly fine to do, it will just mean world generation may take * somewhat longer - * @auther Empire92 + * + * @author Citymonstret + * @author Empire92 */ public class WorldGenerator extends PlotGenerator { /** @@ -330,7 +332,6 @@ public class WorldGenerator extends PlotGenerator { setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, start, 16, this.floor2); // } if ((roadStartZ <= 16) && (roadStartZ > 1)) { - final int val = roadStartZ; int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; @@ -345,11 +346,10 @@ public class WorldGenerator extends PlotGenerator { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2); - setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2); + setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2); + setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2); } if ((roadStartX <= 16) && (roadStartX > 1)) { - final int val = roadStartX; int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; @@ -364,8 +364,8 @@ public class WorldGenerator extends PlotGenerator { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); // - setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); // + setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); // + setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); // } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java index 95c0179b7..dc30843b1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java @@ -42,24 +42,24 @@ public class XPopulator extends BlockPopulator { * information about how a BlockPopulator works. */ + final int plotsize; + final int pathsize; + final PlotBlock wall; + final PlotBlock wallfilling; + final PlotBlock floor1; + final PlotBlock floor2; + final int size; + final int roadheight; + final int wallheight; + final int plotheight; + final PlotBlock[] plotfloors; + final PlotBlock[] filling; private final DefaultPlotWorld plotworld; - int plotsize; - int pathsize; - PlotBlock wall; - PlotBlock wallfilling; - PlotBlock floor1; - PlotBlock floor2; - int size; + final private double pathWidthLower; Biome biome; - int roadheight; - int wallheight; - int plotheight; - PlotBlock[] plotfloors; - PlotBlock[] filling; private int X; private int Z; private long state; - private double pathWidthLower; public XPopulator(final PlotWorld pw) { this.plotworld = (DefaultPlotWorld) pw; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java index 8abe9c35a..a872f11ac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java @@ -33,7 +33,7 @@ import java.util.Set; @SuppressWarnings({"unused", "deprecation"}) public class EntityListener implements Listener { - public static HashMap>> entityMap = new HashMap<>(); + public final static HashMap>> entityMap = new HashMap<>(); public EntityListener() { BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 72e0e3cdb..55dfc84b4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -733,19 +733,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } } - @EventHandler - public void onChangeWorld(final PlayerChangedWorldEvent event) { - /* - * if (isPlotWorld(event.getFrom()) && - * (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) { - * event.getPlayer().setResourcePack(""); - * } - * else { - * textures(event.getPlayer()); - * } - */ - } - @EventHandler(priority = EventPriority.HIGH) public void BlockCreate(final BlockPlaceEvent event) { final World world = event.getPlayer().getWorld(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index fba3c0185..a6f86ff7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -50,8 +50,8 @@ import java.util.*; @SuppressWarnings({"deprecation", "unused"}) public class PlotPlusListener extends PlotListener implements Listener { - private static HashMap feedRunnable = new HashMap<>(); - private static HashMap healRunnable = new HashMap<>(); + private final static HashMap feedRunnable = new HashMap<>(); + private final static HashMap healRunnable = new HashMap<>(); public static void startRunnable(final JavaPlugin plugin) { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @@ -229,10 +229,10 @@ public class PlotPlusListener extends PlotListener implements Listener { } public static class Interval { - public int interval; - public int amount; + public final int interval; + public final int amount; + public final int max; public int count = 0; - public int max; public Interval(final int interval, final int amount, final int max) { this.interval = interval; @@ -247,7 +247,7 @@ public class PlotPlusListener extends PlotListener implements Listener { * @author Citymonstret */ public static class RecordMeta { - public static List metaList = new ArrayList<>(); + public final static List metaList = new ArrayList<>(); static { for (int x = 3; x < 12; x++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 7a3126e7e..0cda11786 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -45,11 +45,11 @@ public class Plot implements Cloneable { /** * plot ID */ - public PlotId id; + public final PlotId id; /** * plot world */ - public String world; + public final String world; /** * plot owner */ @@ -92,7 +92,6 @@ public class Plot implements Cloneable { * @param plotBiome * @param helpers * @param denied - * * @deprecated */ @Deprecated @@ -144,7 +143,6 @@ public class Plot implements Cloneable { * @param helpers * @param denied * @param merged - * * @deprecated */ @Deprecated diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java index 363065d6c..40cf50e7e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java @@ -25,8 +25,8 @@ package com.intellectualcrafters.plot.object; * @author Empire92 */ public class PlotBlock { - public short id; - public byte data; + public final short id; + public final byte data; public PlotBlock(final short id, final byte data) { this.id = id; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java index 47de42939..c344012cb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHomePosition.java @@ -28,8 +28,8 @@ public enum PlotHomePosition { CENTER("Center", 'c'), DEFAULT("Default", 'd'); - private String string; - private char ch; + private final String string; + private final char ch; PlotHomePosition(final String string, final char ch) { this.string = string; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java index 67df7654a..6dd13795e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotId.java @@ -26,11 +26,11 @@ public class PlotId { /** * x value */ - public Integer x; + public final Integer x; /** * y value */ - public Integer y; + public final Integer y; /** * PlotId class (PlotId x,y values do not correspond to Block locations) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java index 0fcc7a9d2..72b407e6f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSelection.java @@ -38,7 +38,7 @@ import java.util.HashMap; @SuppressWarnings("deprecation") public class PlotSelection { - public static HashMap currentSelection = new HashMap<>(); + public final static HashMap currentSelection = new HashMap<>(); private final PlotBlock[] plotBlocks; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 0c1af3d41..2edbe19ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -39,6 +39,10 @@ import java.util.Set; */ @SuppressWarnings("unused") public class PlotSettings { + /** + * Plot + */ + private final Plot plot; /** * merged plots */ @@ -59,10 +63,6 @@ public class PlotSettings { * Home Position */ private PlotHomePosition position; - /** - * Plot - */ - private Plot plot; /** * Constructor diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 6bd58a650..795abb3e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -42,26 +42,27 @@ public abstract class PlotWorld { // TODO make this configurable // make non static and static_default_valu + add config option @SuppressWarnings("deprecation") - public static ArrayList BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, + public final static ArrayList BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), getMaterial(126)})); - public static boolean AUTO_MERGE_DEFAULT = false; - public static boolean MOB_SPAWNING_DEFAULT = false; - public static Biome PLOT_BIOME_DEFAULT = Biome.FOREST; - public static boolean PLOT_CHAT_DEFAULT = false; - public static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false; - public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false; - public static String SCHEMATIC_FILE_DEFAULT = "null"; - public static List SCHEMATICS_DEFAULT = null; - public static List DEFAULT_FLAGS_DEFAULT = new ArrayList<>(); - public static boolean USE_ECONOMY_DEFAULT = false; - public static double PLOT_PRICE_DEFAULT = 100; - public static double MERGE_PRICE_DEFAULT = 100; - public static double SELL_PRICE_DEFAULT = 75; - public static boolean PVP_DEFAULT = false; - public static boolean PVE_DEFAULT = false; - public static boolean SPAWN_EGGS_DEFAULT = false; - public static boolean SPAWN_CUSTOM_DEFAULT = true; - public static boolean SPAWN_BREEDING_DEFAULT = false; + public final static boolean AUTO_MERGE_DEFAULT = false; + public final static boolean MOB_SPAWNING_DEFAULT = false; + public final static Biome PLOT_BIOME_DEFAULT = Biome.FOREST; + public final static boolean PLOT_CHAT_DEFAULT = false; + public final static boolean SCHEMATIC_CLAIM_SPECIFY_DEFAULT = false; + public final static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false; + public final static String SCHEMATIC_FILE_DEFAULT = "null"; + public final static List SCHEMATICS_DEFAULT = null; + public final static List DEFAULT_FLAGS_DEFAULT = new ArrayList<>(); + public final static boolean USE_ECONOMY_DEFAULT = false; + public final static double PLOT_PRICE_DEFAULT = 100; + public final static double MERGE_PRICE_DEFAULT = 100; + public final static double SELL_PRICE_DEFAULT = 75; + public final static boolean PVP_DEFAULT = false; + public final static boolean PVE_DEFAULT = false; + public final static boolean SPAWN_EGGS_DEFAULT = false; + public final static boolean SPAWN_CUSTOM_DEFAULT = true; + public final static boolean SPAWN_BREEDING_DEFAULT = false; + public final String worldname; public boolean AUTO_MERGE; public boolean MOB_SPAWNING; public Biome PLOT_BIOME; @@ -80,7 +81,6 @@ public abstract class PlotWorld { public boolean SPAWN_EGGS; public boolean SPAWN_CUSTOM; public boolean SPAWN_BREEDING; - public String worldname; public PlotWorld(final String worldname) { this.worldname = worldname; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java index 8393433cf..4b1619bcd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/StringWrapper.java @@ -25,7 +25,7 @@ package com.intellectualcrafters.plot.object; * @author Empire92 */ public class StringWrapper { - public String value; + public final String value; /** * Constructor diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java index 9a2391727..66751a9f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Lag.java @@ -28,14 +28,14 @@ package com.intellectualcrafters.plot.util; */ public class Lag implements Runnable { + /** + * Ticks + */ + public final static long[] T = new long[600]; /** * Tick count */ public static int TC = 0; - /** - * Ticks - */ - public static long[] T = new long[600]; /** * something :_: */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java index 68031c3db..d258f82ae 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Metrics.java @@ -474,9 +474,7 @@ public class Metrics { json.append(':'); json.append('{'); boolean firstGraph = true; - final Iterator iter = this.graphs.iterator(); - while (iter.hasNext()) { - final Graph graph = iter.next(); + for (Graph graph : this.graphs) { final StringBuilder graphJson = new StringBuilder(); graphJson.append('{'); for (final Plotter plotter : graph.getPlotters()) { @@ -541,9 +539,7 @@ public class Metrics { // Is this the first update this hour? if (response.equals("1") || response.contains("This is your first update this hour")) { synchronized (this.graphs) { - final Iterator iter = this.graphs.iterator(); - while (iter.hasNext()) { - final Graph graph = iter.next(); + for (Graph graph : this.graphs) { for (final Plotter plotter : graph.getPlotters()) { plotter.reset(); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java index fb1e4d57a..a15250326 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -29,7 +29,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import org.bukkit.*; -import org.bukkit.block.Biome; import org.bukkit.entity.Player; import org.bukkit.util.ChatPaginator; @@ -176,7 +175,7 @@ public class PlayerFunctions { return plots.get(id); } } - return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), world.getName()); + return new Plot(id, null, new ArrayList(), new ArrayList(), world.getName()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java index 747bf7230..9134c9797 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotHelper.java @@ -26,9 +26,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.*; - import net.milkbowl.vault.economy.Economy; - import org.bukkit.*; import org.bukkit.block.Biome; import org.bukkit.block.Block; @@ -49,10 +47,10 @@ import java.util.UUID; */ @SuppressWarnings({"unused", "javadoc", "deprecation"}) public class PlotHelper { + public final static HashMap runners = new HashMap<>(); public static boolean canSetFast = false; public static boolean canSendChunk = false; public static ArrayList runners_p = new ArrayList<>(); - public static HashMap runners = new HashMap<>(); static long state = 1; /** @@ -860,6 +858,7 @@ public class PlotHelper { /** * Retrieve the location of the default plot home position + * * @param plot Plot * @return the location */ @@ -871,7 +870,8 @@ public class PlotHelper { /** * Get the plot home - * @param w World + * + * @param w World * @param plot Plot Object * @return Plot Home Location * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId) @@ -882,8 +882,9 @@ public class PlotHelper { /** * Refresh the plot chunks + * * @param world World in which the plot is located - * @param plot Plot Object + * @param plot Plot Object */ public static void refreshPlotChunks(final World world, final Plot plot) { final int bottomX = getPlotBottomLoc(world, plot.id).getBlockX(); @@ -897,22 +898,20 @@ public class PlotHelper { final int maxChunkZ = (int) Math.floor((double) topZ / 16); ArrayList chunks = new ArrayList<>(); - + for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { if (canSendChunk) { Chunk chunk = world.getChunkAt(x, z); chunks.add(chunk); - } - else { + } else { world.refreshChunk(x, z); } } } try { SendChunk.sendChunk(chunks); - } - catch (Throwable e) { + } catch (Throwable e) { canSendChunk = false; for (int x = minChunkX; x <= maxChunkX; x++) { for (int z = minChunkZ; z <= maxChunkZ; z++) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java index 70fe2ae40..3c14270de 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlotSquaredException.java @@ -38,7 +38,7 @@ public class PlotSquaredException extends RuntimeException { public static enum PlotError { PLOTMAIN_NULL("The PlotMain instance was null"), MISSING_DEPENDENCY("Missing Dependency"); - private String errorHeader; + private final String errorHeader; PlotError(final String errorHeader) { this.errorHeader = errorHeader; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java index 96b365722..3a69b4f53 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java @@ -426,7 +426,7 @@ public class ReflectionUtils { } public class RefExecutor { - Object e; + final Object e; public RefExecutor(final Object e) { this.e = e; @@ -530,7 +530,7 @@ public class ReflectionUtils { } public class RefExecutor { - Object e; + final Object e; public RefExecutor(final Object e) { this.e = e; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java index e3755d813..6477eb85a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SendChunk.java @@ -1,59 +1,72 @@ package com.intellectualcrafters.plot.util; -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Chunk; - import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import java.util.ArrayList; +import java.util.List; + +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + +/** + * An utility that can be used to send chunks, rather than + * using bukkit code to do so (uses heavy NMS) + * + * @author Empire92 + */ public class SendChunk { - + + // Ref Class private static final RefClass classWorld = getRefClass("{nms}.World"); private static final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); private static final RefClass classChunkCoordIntPair = getRefClass("{nms}.ChunkCoordIntPair"); private static final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); private static final RefClass classChunk = getRefClass("{nms}.Chunk"); - + + // Ref Method private static RefMethod methodGetHandle; - - + + // Ref Field private static RefField chunkCoordIntPairQueue; private static RefField players; private static RefField locX; private static RefField locZ; private static RefField world; - + + // Ref Constructor private static RefConstructor ChunkCoordIntPairCon; - + + /** + * Constructor + * + * @throws NoSuchMethodException + */ public SendChunk() throws NoSuchMethodException { methodGetHandle = classCraftChunk.getMethod("getHandle"); chunkCoordIntPairQueue = classEntityPlayer.getField("chunkCoordIntPairQueue"); - + players = classWorld.getField("players"); locX = classEntityPlayer.getField("locX"); locZ = classEntityPlayer.getField("locZ"); - + world = classChunk.getField("world"); - + ChunkCoordIntPairCon = classChunkCoordIntPair.getConstructor(int.class, int.class); } - + public static void sendChunk(ArrayList chunks) { int diffx, diffz; int view = Bukkit.getServer().getViewDistance() << 4; for (Chunk chunk : chunks) { final Object c = methodGetHandle.of(chunk).call(); - + final Object w = world.of(c).get(); final Object p = players.of(w).get(); - + for (Object ep : (List) p) { int x = ((Double) locX.of(ep).get()).intValue(); int z = ((Double) locZ.of(ep).get()).intValue(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index b849b8f10..9e6d83561 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -68,13 +68,14 @@ public class UUIDHandler { * * @see org.bukkit.Server#getOnlineMode() */ - private static boolean online = Bukkit.getServer().getOnlineMode(); + private final static boolean online = Bukkit.getServer().getOnlineMode(); /** * Map containing names and UUIDs + * * @see com.google.common.collect.BiMap */ - private static BiMap uuidMap = HashBiMap.create(new HashMap()); + private final static BiMap uuidMap = HashBiMap.create(new HashMap()); /** * Get the map containing all names/uuids diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java index 312f15383..a98014f91 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationAsset.java @@ -7,9 +7,9 @@ package com.intellectualsites.translation; */ public class TranslationAsset { - private TranslationObject trans; - private String translated; - private TranslationLanguage lang; + private final TranslationObject trans; + private final String translated; + private final TranslationLanguage lang; public TranslationAsset(TranslationObject trans, String translated, TranslationLanguage lang) { this.trans = trans; diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java index 3f0112adc..d7165244e 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationLanguage.java @@ -2,9 +2,17 @@ package com.intellectualsites.translation; public class TranslationLanguage { - private String countryCode; - private String languageCode; - private String friendlyName; + public static final TranslationLanguage englishAmerican + = (new TranslationLanguage("American English", "us", "en")); + public static final TranslationLanguage englishBritish + = (new TranslationLanguage("British English", "gb", "en")); + public static final TranslationLanguage swedishSwedish + = (new TranslationLanguage("Swedish", "sv", "se")); + public static final TranslationLanguage russianRussian + = (new TranslationLanguage("Russian", "ru", "ru")); + private final String countryCode; + private final String languageCode; + private final String friendlyName; public TranslationLanguage(String friendlyName, String countryCode, String languageCode) { this.friendlyName = friendlyName; @@ -12,6 +20,14 @@ public class TranslationLanguage { this.languageCode = languageCode; } + public static TranslationLanguage[] values() { + return new TranslationLanguage[]{ + englishAmerican, + englishBritish, + swedishSwedish + }; + } + public String getName() { return friendlyName; } @@ -29,22 +45,4 @@ public class TranslationLanguage { /* en_US */ return languageCode.toLowerCase() + "_" + countryCode.toUpperCase(); } - - public static final TranslationLanguage englishAmerican - = (new TranslationLanguage("American English", "us", "en")); - public static final TranslationLanguage englishBritish - = (new TranslationLanguage("British English", "gb", "en")); - public static final TranslationLanguage swedishSwedish - = (new TranslationLanguage("Swedish", "sv", "se")); - public static final TranslationLanguage russianRussian - = (new TranslationLanguage("Russian", "ru", "ru")); - - - public static TranslationLanguage[] values() { - return new TranslationLanguage[]{ - englishAmerican, - englishBritish, - swedishSwedish - }; - } } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java index 9d065036e..59dcce1da 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationManager.java @@ -13,9 +13,13 @@ import java.util.*; public class TranslationManager { /** - * The instance + * Objects */ - private TranslationManager instance; + private final LinkedList translationObjects; + /** + * The translations + */ + private final LinkedHashMap translatedObjects; /** * Constructor @@ -24,34 +28,6 @@ public class TranslationManager { this(new TranslationObject[]{}); } - /** - * Don't use this! - * - * @return this - */ - public TranslationManager instance() { - return this; - } - - /** - * Objects - */ - private LinkedList translationObjects; - - /** - * The translations - */ - private LinkedHashMap translatedObjects; - - /** - * Get the translation objects - * - * @return objects - */ - public List translations() { - return translationObjects; - } - /** * Constructor * @@ -62,7 +38,56 @@ public class TranslationManager { = new LinkedList(Arrays.asList(translationObjects)); this.translatedObjects = new LinkedHashMap(); - instance = this; + } + + public static List transformEnum(Object[] os) { + List eList = new ArrayList(); + for (Object o : os) { + eList.add( + new TranslationObject(o.toString(), o.toString().toLowerCase().replace("_", " "), "", "") + ); + } + return eList; + } + + public static void scan(Class c, TranslationManager manager) throws IllegalAccessException { + Field[] fields = c.getDeclaredFields(); + Annotation annotation; + for (Field field : fields) { + if (field.getType() != String.class || (annotation = field.getAnnotation(Translation.class)) == null) + continue; + Translation t = (Translation) annotation; + String key = field.getName(); + // Make sure we can get the value + field.setAccessible(true); + String defaultValue = (String) field.get(c); + manager.addTranslationObject( + new TranslationObject( + key, + defaultValue, + t.description(), + t.creationDescription() + ) + ); + } + } + + /** + * Don't use this! + * + * @return this + */ + public TranslationManager instance() { + return this; + } + + /** + * Get the translation objects + * + * @return objects + */ + public List translations() { + return translationObjects; } /** @@ -149,38 +174,6 @@ public class TranslationManager { return instance(); } - public static List transformEnum(Object[] os) { - List eList = new ArrayList(); - for (Object o : os) { - eList.add( - new TranslationObject(o.toString(), o.toString().toLowerCase().replace("_", " "), "", "") - ); - } - return eList; - } - - public static void scan(Class c, TranslationManager manager) throws IllegalAccessException { - Field[] fields = c.getDeclaredFields(); - Annotation annotation; - for (Field field : fields) { - if (field.getType() != String.class || (annotation = field.getAnnotation(Translation.class)) == null) - continue; - Translation t = (Translation) annotation; - String key = field.getName(); - // Make sure we can get the value - field.setAccessible(true); - String defaultValue = (String) field.get(c); - manager.addTranslationObject( - new TranslationObject( - key, - defaultValue, - t.description(), - t.creationDescription() - ) - ); - } - } - public TranslationManager debug(PrintStream out) { for (TranslationObject object : translations()) { out.println(object.getKey() + ":"); diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java index ae396b03d..fa6aaa19b 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/TranslationObject.java @@ -31,7 +31,6 @@ public class TranslationObject { } this.key = key.toLowerCase(); this.defaultValue = defaultValue.replace("\n", "&-"); - ; this.description = description; this.creationDescription = creationDescription; } diff --git a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java index 7d14977a3..7e6c0bc66 100644 --- a/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java +++ b/PlotSquared/src/main/java/com/intellectualsites/translation/YamlTranslationFile.java @@ -19,23 +19,18 @@ import java.util.Map; */ public class YamlTranslationFile extends TranslationFile { - private File path; - private TranslationLanguage language; - private String name; + final private TranslationLanguage language; + final private String name; + final private TranslationManager manager; private File file; private HashMap map; private String[] header; private boolean fancyHead = false; private YamlTranslationFile instance; - private TranslationManager manager; - /** - * Reload + * YAML Object */ - public void reload() { - this.map = new HashMap(); - this.read(); - } + private Yaml yaml; /** * Constructor @@ -45,7 +40,6 @@ public class YamlTranslationFile extends TranslationFile { * @param name project name */ public YamlTranslationFile(File path, TranslationLanguage language, String name, TranslationManager manager) { - this.path = path; this.language = language; this.name = name; this.manager = manager; @@ -68,6 +62,14 @@ public class YamlTranslationFile extends TranslationFile { this.instance = this; } + /** + * Reload + */ + public void reload() { + this.map = new HashMap(); + this.read(); + } + /** * Set the header * @@ -164,11 +166,6 @@ public class YamlTranslationFile extends TranslationFile { } } - /** - * YAML Object - */ - private Yaml yaml; - /** * Get the YAML object * diff --git a/PlotSquared/src/test/java/Test1.java b/PlotSquared/src/test/java/Test1.java index 161f8cfbc..6d7ca4c31 100644 --- a/PlotSquared/src/test/java/Test1.java +++ b/PlotSquared/src/test/java/Test1.java @@ -125,8 +125,8 @@ public class Test1 { boolean passed = false; try { Object plot = new Plot(new PlotId(0, 0), DBFunc.everyone, Biome.FOREST, new ArrayList(), new ArrayList(), new ArrayList(), null, PlotHomePosition.DEFAULT, null, "testworld", new boolean[]{false, false, false, false}); - passed = plot != null; - } catch (Throwable e) { + passed = true; + } catch (Throwable ignored) { } return passed; @@ -223,7 +223,6 @@ public class Test1 { plots.get("testworld").put(id, new Plot(id, DBFunc.everyone, - Biome.FOREST, new ArrayList(), new ArrayList(), new ArrayList(),