From 65ddb12701b7a505afe15565d31008c0e1f0aba2 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 16 Mar 2016 10:15:38 -0400 Subject: [PATCH] Beginning rewrite of Flags and various cleanups --- .../com/plotsquared/bukkit/BukkitMain.java | 5 +- .../plotme/ClassicPlotMeConnector.java | 5 +- .../intellectualcrafters/plot/IPlotMain.java | 8 +- .../com/intellectualcrafters/plot/PS.java | 14 +- .../plot/commands/plugin.java | 8 +- .../plot/database/SQLManager.java | 129 ++++++++---------- .../plot/flag/AbstractFlag.java | 3 - .../plot/flag/BooleanFlag.java | 8 ++ .../intellectualcrafters/plot/flag/Flag.java | 13 +- .../plot/object/Plot.java | 3 - .../plot/object/PlotBlock.java | 7 +- .../plot/util/ExpireManager.java | 6 +- .../com/plotsquared/sponge/SpongeMain.java | 37 ++++- 13 files changed, 135 insertions(+), 111 deletions(-) create mode 100644 Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 6fce37ca5..708b62382 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -163,9 +163,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } @Override - public int[] getPluginVersion() { - final String[] split = getDescription().getVersion().split("\\."); - return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) }; + public String getPluginVersion() { + return getDescription().getVersion(); } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java index 2a88003d8..65a7d2cb2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java @@ -32,10 +32,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { @Override public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) { this.plugin = plugin.toLowerCase(); - prefix = plotConfig.getString("mySQLprefix"); - if (prefix == null) { - prefix = plugin.toLowerCase(); - } + prefix = plotConfig.getString("mySQLprefix", plugin.toLowerCase()); try { if (plotConfig.getBoolean("usemySQL")) { final String user = plotConfig.getString("mySQLuname"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 16e9ca76c..28f361da2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -1,8 +1,5 @@ package com.intellectualcrafters.plot; -import java.io.File; -import java.util.List; - import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; @@ -20,6 +17,9 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.WorldUtil; +import java.io.File; +import java.util.List; + public interface IPlotMain { /** @@ -57,7 +57,7 @@ public interface IPlotMain { * Get the version of the PlotSquared being used * @return */ - int[] getPluginVersion(); + String getPluginVersion(); /** * Get the version of Minecraft that is running diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 85790408e..efa1eb823 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -126,7 +126,7 @@ public class PS { // private: private File storageFile; private File FILE = null; // This file - private int[] VERSION = null; + private String VERSION = null; private String PLATFORM = null; private String LAST_VERSION; private Database database; @@ -278,8 +278,8 @@ public class PS { final URL url = Updater.getUpdate(); if (url != null) { update = url; - } else if ((LAST_VERSION != null) && !StringMan.join(VERSION, ".").equals(LAST_VERSION)) { - log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, ".")); + } else if ((LAST_VERSION != null) && !VERSION.equals(LAST_VERSION)) { + log("&aThanks for updating from: " + LAST_VERSION + " to " + VERSION); } } }); @@ -383,7 +383,7 @@ public class PS { * Get the current PlotSquared version * @return current version in config or null */ - public int[] getVersion() { + public String getVersion() { return VERSION; } @@ -2037,7 +2037,7 @@ public class PS { */ public void setupConfig() { LAST_VERSION = config.getString("version"); - config.set("version", StringMan.join(VERSION, ".")); + config.set("version", VERSION); config.set("platform", PLATFORM); final Map options = new HashMap<>(); @@ -2362,7 +2362,7 @@ public class PS { * Setup the storage file (load + save missing nodes) */ private void setupStorage() { - storage.set("version", StringMan.join(VERSION, ".")); + storage.set("version", VERSION); final Map options = new HashMap<>(9); options.put("mysql.use", false); options.put("sqlite.use", true); @@ -2414,7 +2414,7 @@ public class PS { * Setup the style.yml file */ private void setupStyle() { - style.set("version", StringMan.join(VERSION, ".")); + style.set("version", VERSION); final Map o = new HashMap<>(); o.put("color.1", "6"); o.put("color.2", "7"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index 17cbee36c..6959bb66e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -23,18 +23,18 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = { "version" }, category = CommandCategory.INFO) +@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = "version", + category = CommandCategory.INFO) public class plugin extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { - MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), "."))); + MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", PS.get().IMP.getPluginVersion())); MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"); MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"); - MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update)); + MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? PS.get().IMP.getPluginVersion() : PS.get().update)); return true; } } 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 8963e09fa..376e48193 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -180,11 +180,11 @@ public class SQLManager implements AbstractDB { public synchronized Queue getGlobalTasks() { return globalTasks; } - + public synchronized Queue getNotifyTasks() { return notifyTasks; } - + public synchronized void addPlotTask(Plot plot, UniqueStatement task) { if (plot == null) { plot = new Plot(null, new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE)); @@ -274,17 +274,17 @@ public class SQLManager implements AbstractDB { } tasks.add(task); } - + public synchronized void addGlobalTask(final Runnable task) { getGlobalTasks().add(task); } - + public synchronized void addNotifyTask(final Runnable task) { if (task != null) { getNotifyTasks().add(task); } } - + public boolean sendBatch() { try { if (!getGlobalTasks().isEmpty()) { @@ -426,11 +426,11 @@ public class SQLManager implements AbstractDB { } return false; } - + public Connection getConnection() { return connection; } - + /** * Set Plot owner * @@ -454,7 +454,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void createPlotsAndData(final ArrayList myList, final Runnable whenDone) { addGlobalTask(new Runnable() { @@ -549,7 +549,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Create a plot * @@ -592,7 +592,7 @@ public class SQLManager implements AbstractDB { }; setBulk(myList, mod, whenDone); } - + /** * Create a plot * @@ -655,7 +655,7 @@ public class SQLManager implements AbstractDB { }; setBulk(myList, mod, whenDone); } - + public void setBulk(final ArrayList objList, final StmtMod mod, final Runnable whenDone) { final int size = objList.size(); if (size == 0) { @@ -774,7 +774,7 @@ public class SQLManager implements AbstractDB { whenDone.run(); } } - + public void createSettings(final ArrayList myList, final Runnable whenDone) { final StmtMod mod = new StmtMod() { @Override @@ -885,7 +885,7 @@ public class SQLManager implements AbstractDB { } }); } - + public void createEmptySettings(final ArrayList myList, final Runnable whenDone) { final StmtMod mod = new StmtMod() { @Override @@ -939,7 +939,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Create a plot * @@ -963,7 +963,7 @@ public class SQLManager implements AbstractDB { } }); } - + public void commit() { try { if (CLOSED) { @@ -977,7 +977,7 @@ public class SQLManager implements AbstractDB { e.printStackTrace(); } } - + @Override public void createPlotAndSettings(final Plot plot, final Runnable whenDone) { addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) { @@ -1022,7 +1022,7 @@ public class SQLManager implements AbstractDB { }); addNotifyTask(whenDone); } - + /** * Create tables * @@ -1243,7 +1243,7 @@ public class SQLManager implements AbstractDB { stmt.clearBatch(); stmt.close(); } - + @Override public void deleteSettings(final Plot plot) { addPlotTask(plot, new UniqueStatement("delete_plot_settings") { @@ -1258,7 +1258,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void deleteHelpers(final Plot plot) { if (plot.getTrusted().isEmpty()) { @@ -1276,7 +1276,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void deleteTrusted(final Plot plot) { if (plot.getMembers().isEmpty()) { @@ -1294,7 +1294,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void deleteDenied(final Plot plot) { if (plot.getDenied().isEmpty()) { @@ -1312,7 +1312,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void deleteComments(final Plot plot) { addPlotTask(plot, new UniqueStatement("delete_plot_comments") { @@ -1328,7 +1328,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void deleteRatings(final Plot plot) { if (Settings.CACHE_RATINGS && plot.getSettings().getRatings().isEmpty()) { @@ -1393,7 +1393,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public int getClusterId(final PlotCluster cluster) { if (cluster.temp > 0) { @@ -1553,7 +1553,7 @@ public class SQLManager implements AbstractDB { } } - + public void deleteRows(final ArrayList rowIds, final String table, final String column) { setBulk(rowIds, new StmtMod() { @@ -1891,7 +1891,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void swapPlots(final Plot p1, final Plot p2) { final int id1 = getId(p1); @@ -1925,7 +1925,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void movePlot(final Plot original, final Plot newPlot) { addPlotTask(original, new UniqueStatement("movePlot") { @@ -1944,7 +1944,7 @@ public class SQLManager implements AbstractDB { }); addPlotTask(newPlot, null); } - + @Override public void setFlags(final Plot plot, final Collection flags) { final String flag_string = FlagManager.toString(flags); @@ -1961,7 +1961,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setAlias(final Plot plot, final String alias) { addPlotTask(plot, new UniqueStatement("setAlias") { @@ -1977,7 +1977,7 @@ public class SQLManager implements AbstractDB { } }); } - + /** * Purge all plots with the following database IDs */ @@ -2025,7 +2025,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void purge(final PlotArea area, final Set plots) { addGlobalTask(new Runnable() { @@ -2058,7 +2058,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setPosition(final Plot plot, final String position) { addPlotTask(plot, new UniqueStatement("setPosition") { @@ -2074,7 +2074,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void removeComment(final Plot plot, final PlotComment comment) { addPlotTask(plot, new UniqueStatement("removeComment") { @@ -2102,7 +2102,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void clearInbox(final Plot plot, final String inbox) { addPlotTask(plot, new UniqueStatement("clearInbox") { @@ -2126,7 +2126,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void getComments(final Plot plot, final String inbox, final RunnableVal> whenDone) { addPlotTask(plot, new UniqueStatement("getComments_" + plot) { @@ -2177,7 +2177,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setComment(final Plot plot, final PlotComment comment) { addPlotTask(plot, new UniqueStatement("setComment") { @@ -2197,7 +2197,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void removeTrusted(final Plot plot, final UUID uuid) { addPlotTask(plot, new UniqueStatement("removeTrusted") { @@ -2213,7 +2213,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void removeMember(final Plot plot, final UUID uuid) { addPlotTask(plot, new UniqueStatement("removeMember") { @@ -2229,7 +2229,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setTrusted(final Plot plot, final UUID uuid) { addPlotTask(plot, new UniqueStatement("setTrusted") { @@ -2245,7 +2245,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setMember(final Plot plot, final UUID uuid) { addPlotTask(plot, new UniqueStatement("setMember") { @@ -2261,7 +2261,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void removeDenied(final Plot plot, final UUID uuid) { addPlotTask(plot, new UniqueStatement("removeDenied") { @@ -2277,7 +2277,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setDenied(final Plot plot, final UUID uuid) { addPlotTask(plot, new UniqueStatement("setDenied") { @@ -2293,7 +2293,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public HashMap getRatings(final Plot plot) { final HashMap map = new HashMap<>(); @@ -2313,7 +2313,7 @@ public class SQLManager implements AbstractDB { } return map; } - + @Override public void setRating(final Plot plot, final UUID rater, final int value) { addPlotTask(plot, new UniqueStatement("setRating") { @@ -2330,7 +2330,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void delete(final PlotCluster cluster) { final int id = getClusterId(cluster); @@ -2666,7 +2666,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setClusterName(final PlotCluster cluster, final String name) { addClusterTask(cluster, new UniqueStatement("setClusterName") { @@ -2683,7 +2683,7 @@ public class SQLManager implements AbstractDB { }); cluster.settings.setAlias(name); } - + @Override public void removeHelper(final PlotCluster cluster, final UUID uuid) { addClusterTask(cluster, new UniqueStatement("removeHelper") { @@ -2699,7 +2699,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setHelper(final PlotCluster cluster, final UUID uuid) { addClusterTask(cluster, new UniqueStatement("setHelper") { @@ -2715,7 +2715,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void createCluster(final PlotCluster cluster) { addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) { @@ -2761,7 +2761,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) { final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y); @@ -2785,7 +2785,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setPosition(final PlotCluster cluster, final String position) { addClusterTask(cluster, new UniqueStatement("setPosition") { @@ -2801,7 +2801,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void removeInvited(final PlotCluster cluster, final UUID uuid) { addClusterTask(cluster, new UniqueStatement("removeInvited") { @@ -2817,7 +2817,7 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public void setInvited(final PlotCluster cluster, final UUID uuid) { addClusterTask(cluster, new UniqueStatement("setInvited") { @@ -2833,14 +2833,14 @@ public class SQLManager implements AbstractDB { } }); } - + @Override public boolean deleteTables() { - try { + try (Statement stmt = connection.createStatement(); + PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`")) { close(); CLOSED = false; SQLManager.this.connection = database.forceConnection(); - final Statement stmt = connection.createStatement(); stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster`"); @@ -2852,9 +2852,6 @@ public class SQLManager implements AbstractDB { stmt.addBatch("DROP TABLE `" + prefix + "plot_denied`"); stmt.executeBatch(); stmt.clearBatch(); - stmt.close(); - - final PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`"); statement.executeUpdate(); statement.close(); } catch (ClassNotFoundException | SQLException e) { @@ -2862,7 +2859,7 @@ public class SQLManager implements AbstractDB { } return true; } - + @Override public void validateAllPlots(final Set toValidate) { try { @@ -2990,7 +2987,7 @@ public class SQLManager implements AbstractDB { } commit(); } - + @Override public void replaceWorld(final String oldWorld, final String newWorld, final PlotId min, final PlotId max) { addGlobalTask(new Runnable() { @@ -3001,7 +2998,6 @@ public class SQLManager implements AbstractDB { stmt.setString(1, newWorld); stmt.setString(2, oldWorld); stmt.executeUpdate(); - stmt.close(); } catch (SQLException e) { e.printStackTrace(); } @@ -3009,14 +3005,12 @@ public class SQLManager implements AbstractDB { stmt.setString(1, newWorld); stmt.setString(2, oldWorld); stmt.executeUpdate(); - stmt.close(); } catch (SQLException e) { e.printStackTrace(); } } else { try (PreparedStatement stmt = connection.prepareStatement("UPDATE `" - + prefix - + "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) { + + prefix + "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) { stmt.setString(1, newWorld); stmt.setString(2, oldWorld); stmt.setInt(3, min.x); @@ -3024,7 +3018,6 @@ public class SQLManager implements AbstractDB { stmt.setInt(5, min.y); stmt.setInt(6, max.y); stmt.executeUpdate(); - stmt.close(); } catch (SQLException e) { e.printStackTrace(); } @@ -3038,7 +3031,6 @@ public class SQLManager implements AbstractDB { stmt.setInt(5, min.x); stmt.setInt(6, min.y); stmt.executeUpdate(); - stmt.close(); } catch (SQLException e) { e.printStackTrace(); } @@ -3071,14 +3063,13 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate( "UPDATE `" + prefix + "plot_trusted` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '" + old.toString() + "'"); - stmt.close(); } catch (SQLException e) { e.printStackTrace(); } } }); } - + @Override public void close() { try { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java index aa3b895df..0b6de82ef 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java @@ -97,9 +97,6 @@ public class AbstractFlag { @Override public boolean equals(final Object other) { - if (other == null) { - return false; - } if (other == this) { return true; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java new file mode 100644 index 000000000..a8e36a013 --- /dev/null +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java @@ -0,0 +1,8 @@ +package com.intellectualcrafters.plot.flag; + +public class BooleanFlag extends Flag { + + public BooleanFlag(String name) { + super(name); + } +} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java index d2ed6107c..c72720461 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flag.java @@ -25,10 +25,11 @@ import com.intellectualcrafters.plot.util.StringMan; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -public class Flag implements Cloneable { +public class Flag implements Cloneable { private AbstractFlag key; private Object value; - + private String name; + /** * Flag object used to store basic information for a Plot. Flags are a key/value pair. For a flag to be usable by a * player, you need to register it with PlotSquared. @@ -59,6 +60,10 @@ public class Flag implements Cloneable { this.key = key; this.value = value; } + + public Flag(String name) { + this.name = name; + } /** * Get the AbstractFlag used in creating the flag @@ -145,4 +150,8 @@ public class Flag implements Cloneable { } return this; } + + public String getName() { + return name; + } } 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 2737e3b3b..9626ce6d8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -2308,9 +2308,6 @@ public class Plot { connected_cache.add(current); queuecache.remove(current); merged = current.getMerged(); - for (int i = 0; i < 5; i++) { - - } if (merged[0]) { tmp = current.area.getPlotAbs(current.id.getRelative(0)); if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java index 4f151a989..ee7128fe8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java @@ -20,11 +20,12 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.object; -/** +/** + */ public class PlotBlock { - - public static PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0); + + public final static PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0); public final short id; public final byte data; 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 6d43b46fc..2ae2213a8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -21,6 +21,7 @@ import java.util.Iterator; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; public class ExpireManager { @@ -233,8 +234,7 @@ public class ExpireManager { } if ((last = opp.getLastPlayed()) != 0) { dates_cache.put(uuid, last); - } - else { + } else { return false; } } @@ -242,7 +242,7 @@ public class ExpireManager { return false; } final long compared = System.currentTimeMillis() - last; - if (compared >= (86400000l * Settings.AUTO_CLEAR_DAYS)) { + if (compared >= (TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS))) { return true; } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index b6560e0c7..4fc1e3e2c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -13,14 +13,40 @@ import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.SetupObject; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.AbstractTitle; +import com.intellectualcrafters.plot.util.ChatManager; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.EconHandler; +import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.InventoryUtil; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlotQueue; +import com.intellectualcrafters.plot.util.SchematicHandler; +import com.intellectualcrafters.plot.util.SetupUtils; +import com.intellectualcrafters.plot.util.StringMan; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; +import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.sponge.generator.SpongePlotGenerator; import com.plotsquared.sponge.listener.ChunkProcessor; import com.plotsquared.sponge.listener.MainListener; import com.plotsquared.sponge.listener.WorldEvents; -import com.plotsquared.sponge.util.*; +import com.plotsquared.sponge.util.KillRoadMobs; +import com.plotsquared.sponge.util.SpongeChatManager; +import com.plotsquared.sponge.util.SpongeChunkManager; +import com.plotsquared.sponge.util.SpongeCommand; +import com.plotsquared.sponge.util.SpongeEconHandler; +import com.plotsquared.sponge.util.SpongeEventUtil; +import com.plotsquared.sponge.util.SpongeHybridUtils; +import com.plotsquared.sponge.util.SpongeInventoryUtil; +import com.plotsquared.sponge.util.SpongeMetrics; +import com.plotsquared.sponge.util.SpongeSchematicHandler; import com.plotsquared.sponge.util.SpongeSetupUtils; +import com.plotsquared.sponge.util.SpongeTaskManager; +import com.plotsquared.sponge.util.SpongeTitleManager; +import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.block.FastQueue; import com.plotsquared.sponge.util.block.SlowQueue; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; @@ -138,12 +164,11 @@ public class SpongeMain implements IPlotMain { } @Override - public int[] getPluginVersion() { + public String getPluginVersion() { PluginContainer plugin = game.getPluginManager().fromInstance(this).get(); String version = plugin.getVersion().get(); log("Checking plugin version: PlotSquared: "); - final String[] split = version.split("\\."); - return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 }; + return version; } @Override @@ -203,7 +228,7 @@ public class SpongeMain implements IPlotMain { @Override public void registerCommands() { - getGame().getCommandManager().register(THIS, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" }); + getGame().getCommandManager().register(THIS, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2", "2"); } @Override