Beginning rewrite of Flags and various cleanups

This commit is contained in:
Matt 2016-03-16 10:15:38 -04:00
parent 3fb64d9811
commit 65ddb12701
13 changed files with 135 additions and 111 deletions

View File

@ -163,9 +163,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} }
@Override @Override
public int[] getPluginVersion() { public String getPluginVersion() {
final String[] split = getDescription().getVersion().split("\\."); return getDescription().getVersion();
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
} }
@Override @Override

View File

@ -32,10 +32,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
@Override @Override
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) { public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
this.plugin = plugin.toLowerCase(); this.plugin = plugin.toLowerCase();
prefix = plotConfig.getString("mySQLprefix"); prefix = plotConfig.getString("mySQLprefix", plugin.toLowerCase());
if (prefix == null) {
prefix = plugin.toLowerCase();
}
try { try {
if (plotConfig.getBoolean("usemySQL")) { if (plotConfig.getBoolean("usemySQL")) {
final String user = plotConfig.getString("mySQLuname"); final String user = plotConfig.getString("mySQLuname");

View File

@ -1,8 +1,5 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import java.io.File;
import java.util.List;
import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; 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.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import java.io.File;
import java.util.List;
public interface IPlotMain { public interface IPlotMain {
/** /**
@ -57,7 +57,7 @@ public interface IPlotMain {
* Get the version of the PlotSquared being used * Get the version of the PlotSquared being used
* @return * @return
*/ */
int[] getPluginVersion(); String getPluginVersion();
/** /**
* Get the version of Minecraft that is running * Get the version of Minecraft that is running

View File

@ -126,7 +126,7 @@ public class PS {
// private: // private:
private File storageFile; private File storageFile;
private File FILE = null; // This file private File FILE = null; // This file
private int[] VERSION = null; private String VERSION = null;
private String PLATFORM = null; private String PLATFORM = null;
private String LAST_VERSION; private String LAST_VERSION;
private Database database; private Database database;
@ -278,8 +278,8 @@ public class PS {
final URL url = Updater.getUpdate(); final URL url = Updater.getUpdate();
if (url != null) { if (url != null) {
update = url; update = url;
} else if ((LAST_VERSION != null) && !StringMan.join(VERSION, ".").equals(LAST_VERSION)) { } else if ((LAST_VERSION != null) && !VERSION.equals(LAST_VERSION)) {
log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, ".")); log("&aThanks for updating from: " + LAST_VERSION + " to " + VERSION);
} }
} }
}); });
@ -383,7 +383,7 @@ public class PS {
* Get the current PlotSquared version * Get the current PlotSquared version
* @return current version in config or null * @return current version in config or null
*/ */
public int[] getVersion() { public String getVersion() {
return VERSION; return VERSION;
} }
@ -2037,7 +2037,7 @@ public class PS {
*/ */
public void setupConfig() { public void setupConfig() {
LAST_VERSION = config.getString("version"); LAST_VERSION = config.getString("version");
config.set("version", StringMan.join(VERSION, ".")); config.set("version", VERSION);
config.set("platform", PLATFORM); config.set("platform", PLATFORM);
final Map<String, Object> options = new HashMap<>(); final Map<String, Object> options = new HashMap<>();
@ -2362,7 +2362,7 @@ public class PS {
* Setup the storage file (load + save missing nodes) * Setup the storage file (load + save missing nodes)
*/ */
private void setupStorage() { private void setupStorage() {
storage.set("version", StringMan.join(VERSION, ".")); storage.set("version", VERSION);
final Map<String, Object> options = new HashMap<>(9); final Map<String, Object> options = new HashMap<>(9);
options.put("mysql.use", false); options.put("mysql.use", false);
options.put("sqlite.use", true); options.put("sqlite.use", true);
@ -2414,7 +2414,7 @@ public class PS {
* Setup the style.yml file * Setup the style.yml file
*/ */
private void setupStyle() { private void setupStyle() {
style.set("version", StringMan.join(VERSION, ".")); style.set("version", VERSION);
final Map<String, Object> o = new HashMap<>(); final Map<String, Object> o = new HashMap<>();
o.put("color.1", "6"); o.put("color.1", "6");
o.put("color.2", "7"); o.put("color.2", "7");

View File

@ -23,18 +23,18 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class plugin extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { 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&lAuthors$2: $1Citymonstret $2& $1Empire92");
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"); 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; return true;
} }
} }

View File

@ -180,11 +180,11 @@ public class SQLManager implements AbstractDB {
public synchronized Queue<Runnable> getGlobalTasks() { public synchronized Queue<Runnable> getGlobalTasks() {
return globalTasks; return globalTasks;
} }
public synchronized Queue<Runnable> getNotifyTasks() { public synchronized Queue<Runnable> getNotifyTasks() {
return notifyTasks; return notifyTasks;
} }
public synchronized void addPlotTask(Plot plot, UniqueStatement task) { public synchronized void addPlotTask(Plot plot, UniqueStatement task) {
if (plot == null) { if (plot == null) {
plot = new Plot(null, new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE)); plot = new Plot(null, new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE));
@ -274,17 +274,17 @@ public class SQLManager implements AbstractDB {
} }
tasks.add(task); tasks.add(task);
} }
public synchronized void addGlobalTask(final Runnable task) { public synchronized void addGlobalTask(final Runnable task) {
getGlobalTasks().add(task); getGlobalTasks().add(task);
} }
public synchronized void addNotifyTask(final Runnable task) { public synchronized void addNotifyTask(final Runnable task) {
if (task != null) { if (task != null) {
getNotifyTasks().add(task); getNotifyTasks().add(task);
} }
} }
public boolean sendBatch() { public boolean sendBatch() {
try { try {
if (!getGlobalTasks().isEmpty()) { if (!getGlobalTasks().isEmpty()) {
@ -426,11 +426,11 @@ public class SQLManager implements AbstractDB {
} }
return false; return false;
} }
public Connection getConnection() { public Connection getConnection() {
return connection; return connection;
} }
/** /**
* Set Plot owner * Set Plot owner
* *
@ -454,7 +454,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void createPlotsAndData(final ArrayList<Plot> myList, final Runnable whenDone) { public void createPlotsAndData(final ArrayList<Plot> myList, final Runnable whenDone) {
addGlobalTask(new Runnable() { addGlobalTask(new Runnable() {
@ -549,7 +549,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
/** /**
* Create a plot * Create a plot
* *
@ -592,7 +592,7 @@ public class SQLManager implements AbstractDB {
}; };
setBulk(myList, mod, whenDone); setBulk(myList, mod, whenDone);
} }
/** /**
* Create a plot * Create a plot
* *
@ -655,7 +655,7 @@ public class SQLManager implements AbstractDB {
}; };
setBulk(myList, mod, whenDone); setBulk(myList, mod, whenDone);
} }
public <T> void setBulk(final ArrayList<T> objList, final StmtMod<T> mod, final Runnable whenDone) { public <T> void setBulk(final ArrayList<T> objList, final StmtMod<T> mod, final Runnable whenDone) {
final int size = objList.size(); final int size = objList.size();
if (size == 0) { if (size == 0) {
@ -774,7 +774,7 @@ public class SQLManager implements AbstractDB {
whenDone.run(); whenDone.run();
} }
} }
public void createSettings(final ArrayList<SettingsPair> myList, final Runnable whenDone) { public void createSettings(final ArrayList<SettingsPair> myList, final Runnable whenDone) {
final StmtMod<SettingsPair> mod = new StmtMod<SettingsPair>() { final StmtMod<SettingsPair> mod = new StmtMod<SettingsPair>() {
@Override @Override
@ -885,7 +885,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) { public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
final StmtMod<Integer> mod = new StmtMod<Integer>() { final StmtMod<Integer> mod = new StmtMod<Integer>() {
@Override @Override
@ -939,7 +939,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
/** /**
* Create a plot * Create a plot
* *
@ -963,7 +963,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
public void commit() { public void commit() {
try { try {
if (CLOSED) { if (CLOSED) {
@ -977,7 +977,7 @@ public class SQLManager implements AbstractDB {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override @Override
public void createPlotAndSettings(final Plot plot, final Runnable whenDone) { public void createPlotAndSettings(final Plot plot, final Runnable whenDone) {
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) { addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
@ -1022,7 +1022,7 @@ public class SQLManager implements AbstractDB {
}); });
addNotifyTask(whenDone); addNotifyTask(whenDone);
} }
/** /**
* Create tables * Create tables
* *
@ -1243,7 +1243,7 @@ public class SQLManager implements AbstractDB {
stmt.clearBatch(); stmt.clearBatch();
stmt.close(); stmt.close();
} }
@Override @Override
public void deleteSettings(final Plot plot) { public void deleteSettings(final Plot plot) {
addPlotTask(plot, new UniqueStatement("delete_plot_settings") { addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
@ -1258,7 +1258,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void deleteHelpers(final Plot plot) { public void deleteHelpers(final Plot plot) {
if (plot.getTrusted().isEmpty()) { if (plot.getTrusted().isEmpty()) {
@ -1276,7 +1276,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void deleteTrusted(final Plot plot) { public void deleteTrusted(final Plot plot) {
if (plot.getMembers().isEmpty()) { if (plot.getMembers().isEmpty()) {
@ -1294,7 +1294,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void deleteDenied(final Plot plot) { public void deleteDenied(final Plot plot) {
if (plot.getDenied().isEmpty()) { if (plot.getDenied().isEmpty()) {
@ -1312,7 +1312,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void deleteComments(final Plot plot) { public void deleteComments(final Plot plot) {
addPlotTask(plot, new UniqueStatement("delete_plot_comments") { addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
@ -1328,7 +1328,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void deleteRatings(final Plot plot) { public void deleteRatings(final Plot plot) {
if (Settings.CACHE_RATINGS && plot.getSettings().getRatings().isEmpty()) { if (Settings.CACHE_RATINGS && plot.getSettings().getRatings().isEmpty()) {
@ -1393,7 +1393,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public int getClusterId(final PlotCluster cluster) { public int getClusterId(final PlotCluster cluster) {
if (cluster.temp > 0) { if (cluster.temp > 0) {
@ -1553,7 +1553,7 @@ public class SQLManager implements AbstractDB {
} }
} }
public void deleteRows(final ArrayList<Integer> rowIds, final String table, final String column) { public void deleteRows(final ArrayList<Integer> rowIds, final String table, final String column) {
setBulk(rowIds, new StmtMod<Integer>() { setBulk(rowIds, new StmtMod<Integer>() {
@ -1891,7 +1891,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void swapPlots(final Plot p1, final Plot p2) { public void swapPlots(final Plot p1, final Plot p2) {
final int id1 = getId(p1); final int id1 = getId(p1);
@ -1925,7 +1925,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void movePlot(final Plot original, final Plot newPlot) { public void movePlot(final Plot original, final Plot newPlot) {
addPlotTask(original, new UniqueStatement("movePlot") { addPlotTask(original, new UniqueStatement("movePlot") {
@ -1944,7 +1944,7 @@ public class SQLManager implements AbstractDB {
}); });
addPlotTask(newPlot, null); addPlotTask(newPlot, null);
} }
@Override @Override
public void setFlags(final Plot plot, final Collection<Flag> flags) { public void setFlags(final Plot plot, final Collection<Flag> flags) {
final String flag_string = FlagManager.toString(flags); final String flag_string = FlagManager.toString(flags);
@ -1961,7 +1961,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setAlias(final Plot plot, final String alias) { public void setAlias(final Plot plot, final String alias) {
addPlotTask(plot, new UniqueStatement("setAlias") { addPlotTask(plot, new UniqueStatement("setAlias") {
@ -1977,7 +1977,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
/** /**
* Purge all plots with the following database IDs * Purge all plots with the following database IDs
*/ */
@ -2025,7 +2025,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void purge(final PlotArea area, final Set<PlotId> plots) { public void purge(final PlotArea area, final Set<PlotId> plots) {
addGlobalTask(new Runnable() { addGlobalTask(new Runnable() {
@ -2058,7 +2058,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setPosition(final Plot plot, final String position) { public void setPosition(final Plot plot, final String position) {
addPlotTask(plot, new UniqueStatement("setPosition") { addPlotTask(plot, new UniqueStatement("setPosition") {
@ -2074,7 +2074,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void removeComment(final Plot plot, final PlotComment comment) { public void removeComment(final Plot plot, final PlotComment comment) {
addPlotTask(plot, new UniqueStatement("removeComment") { addPlotTask(plot, new UniqueStatement("removeComment") {
@ -2102,7 +2102,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void clearInbox(final Plot plot, final String inbox) { public void clearInbox(final Plot plot, final String inbox) {
addPlotTask(plot, new UniqueStatement("clearInbox") { addPlotTask(plot, new UniqueStatement("clearInbox") {
@ -2126,7 +2126,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void getComments(final Plot plot, final String inbox, final RunnableVal<List<PlotComment>> whenDone) { public void getComments(final Plot plot, final String inbox, final RunnableVal<List<PlotComment>> whenDone) {
addPlotTask(plot, new UniqueStatement("getComments_" + plot) { addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
@ -2177,7 +2177,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setComment(final Plot plot, final PlotComment comment) { public void setComment(final Plot plot, final PlotComment comment) {
addPlotTask(plot, new UniqueStatement("setComment") { addPlotTask(plot, new UniqueStatement("setComment") {
@ -2197,7 +2197,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void removeTrusted(final Plot plot, final UUID uuid) { public void removeTrusted(final Plot plot, final UUID uuid) {
addPlotTask(plot, new UniqueStatement("removeTrusted") { addPlotTask(plot, new UniqueStatement("removeTrusted") {
@ -2213,7 +2213,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void removeMember(final Plot plot, final UUID uuid) { public void removeMember(final Plot plot, final UUID uuid) {
addPlotTask(plot, new UniqueStatement("removeMember") { addPlotTask(plot, new UniqueStatement("removeMember") {
@ -2229,7 +2229,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setTrusted(final Plot plot, final UUID uuid) { public void setTrusted(final Plot plot, final UUID uuid) {
addPlotTask(plot, new UniqueStatement("setTrusted") { addPlotTask(plot, new UniqueStatement("setTrusted") {
@ -2245,7 +2245,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setMember(final Plot plot, final UUID uuid) { public void setMember(final Plot plot, final UUID uuid) {
addPlotTask(plot, new UniqueStatement("setMember") { addPlotTask(plot, new UniqueStatement("setMember") {
@ -2261,7 +2261,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void removeDenied(final Plot plot, final UUID uuid) { public void removeDenied(final Plot plot, final UUID uuid) {
addPlotTask(plot, new UniqueStatement("removeDenied") { addPlotTask(plot, new UniqueStatement("removeDenied") {
@ -2277,7 +2277,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setDenied(final Plot plot, final UUID uuid) { public void setDenied(final Plot plot, final UUID uuid) {
addPlotTask(plot, new UniqueStatement("setDenied") { addPlotTask(plot, new UniqueStatement("setDenied") {
@ -2293,7 +2293,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public HashMap<UUID, Integer> getRatings(final Plot plot) { public HashMap<UUID, Integer> getRatings(final Plot plot) {
final HashMap<UUID, Integer> map = new HashMap<>(); final HashMap<UUID, Integer> map = new HashMap<>();
@ -2313,7 +2313,7 @@ public class SQLManager implements AbstractDB {
} }
return map; return map;
} }
@Override @Override
public void setRating(final Plot plot, final UUID rater, final int value) { public void setRating(final Plot plot, final UUID rater, final int value) {
addPlotTask(plot, new UniqueStatement("setRating") { addPlotTask(plot, new UniqueStatement("setRating") {
@ -2330,7 +2330,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void delete(final PlotCluster cluster) { public void delete(final PlotCluster cluster) {
final int id = getClusterId(cluster); final int id = getClusterId(cluster);
@ -2666,7 +2666,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setClusterName(final PlotCluster cluster, final String name) { public void setClusterName(final PlotCluster cluster, final String name) {
addClusterTask(cluster, new UniqueStatement("setClusterName") { addClusterTask(cluster, new UniqueStatement("setClusterName") {
@ -2683,7 +2683,7 @@ public class SQLManager implements AbstractDB {
}); });
cluster.settings.setAlias(name); cluster.settings.setAlias(name);
} }
@Override @Override
public void removeHelper(final PlotCluster cluster, final UUID uuid) { public void removeHelper(final PlotCluster cluster, final UUID uuid) {
addClusterTask(cluster, new UniqueStatement("removeHelper") { addClusterTask(cluster, new UniqueStatement("removeHelper") {
@ -2699,7 +2699,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setHelper(final PlotCluster cluster, final UUID uuid) { public void setHelper(final PlotCluster cluster, final UUID uuid) {
addClusterTask(cluster, new UniqueStatement("setHelper") { addClusterTask(cluster, new UniqueStatement("setHelper") {
@ -2715,7 +2715,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void createCluster(final PlotCluster cluster) { public void createCluster(final PlotCluster cluster) {
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) { addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
@ -2761,7 +2761,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) { public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) {
final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y); final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y);
@ -2785,7 +2785,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setPosition(final PlotCluster cluster, final String position) { public void setPosition(final PlotCluster cluster, final String position) {
addClusterTask(cluster, new UniqueStatement("setPosition") { addClusterTask(cluster, new UniqueStatement("setPosition") {
@ -2801,7 +2801,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void removeInvited(final PlotCluster cluster, final UUID uuid) { public void removeInvited(final PlotCluster cluster, final UUID uuid) {
addClusterTask(cluster, new UniqueStatement("removeInvited") { addClusterTask(cluster, new UniqueStatement("removeInvited") {
@ -2817,7 +2817,7 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public void setInvited(final PlotCluster cluster, final UUID uuid) { public void setInvited(final PlotCluster cluster, final UUID uuid) {
addClusterTask(cluster, new UniqueStatement("setInvited") { addClusterTask(cluster, new UniqueStatement("setInvited") {
@ -2833,14 +2833,14 @@ public class SQLManager implements AbstractDB {
} }
}); });
} }
@Override @Override
public boolean deleteTables() { public boolean deleteTables() {
try { try (Statement stmt = connection.createStatement();
PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`")) {
close(); close();
CLOSED = false; CLOSED = false;
SQLManager.this.connection = database.forceConnection(); SQLManager.this.connection = database.forceConnection();
final Statement stmt = connection.createStatement();
stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`");
stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`");
stmt.addBatch("DROP TABLE `" + prefix + "cluster`"); stmt.addBatch("DROP TABLE `" + prefix + "cluster`");
@ -2852,9 +2852,6 @@ public class SQLManager implements AbstractDB {
stmt.addBatch("DROP TABLE `" + prefix + "plot_denied`"); stmt.addBatch("DROP TABLE `" + prefix + "plot_denied`");
stmt.executeBatch(); stmt.executeBatch();
stmt.clearBatch(); stmt.clearBatch();
stmt.close();
final PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`");
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
@ -2862,7 +2859,7 @@ public class SQLManager implements AbstractDB {
} }
return true; return true;
} }
@Override @Override
public void validateAllPlots(final Set<Plot> toValidate) { public void validateAllPlots(final Set<Plot> toValidate) {
try { try {
@ -2990,7 +2987,7 @@ public class SQLManager implements AbstractDB {
} }
commit(); commit();
} }
@Override @Override
public void replaceWorld(final String oldWorld, final String newWorld, final PlotId min, final PlotId max) { public void replaceWorld(final String oldWorld, final String newWorld, final PlotId min, final PlotId max) {
addGlobalTask(new Runnable() { addGlobalTask(new Runnable() {
@ -3001,7 +2998,6 @@ public class SQLManager implements AbstractDB {
stmt.setString(1, newWorld); stmt.setString(1, newWorld);
stmt.setString(2, oldWorld); stmt.setString(2, oldWorld);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -3009,14 +3005,12 @@ public class SQLManager implements AbstractDB {
stmt.setString(1, newWorld); stmt.setString(1, newWorld);
stmt.setString(2, oldWorld); stmt.setString(2, oldWorld);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
try (PreparedStatement stmt = connection.prepareStatement("UPDATE `" try (PreparedStatement stmt = connection.prepareStatement("UPDATE `"
+ prefix + prefix + "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
+ "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
stmt.setString(1, newWorld); stmt.setString(1, newWorld);
stmt.setString(2, oldWorld); stmt.setString(2, oldWorld);
stmt.setInt(3, min.x); stmt.setInt(3, min.x);
@ -3024,7 +3018,6 @@ public class SQLManager implements AbstractDB {
stmt.setInt(5, min.y); stmt.setInt(5, min.y);
stmt.setInt(6, max.y); stmt.setInt(6, max.y);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -3038,7 +3031,6 @@ public class SQLManager implements AbstractDB {
stmt.setInt(5, min.x); stmt.setInt(5, min.x);
stmt.setInt(6, min.y); stmt.setInt(6, min.y);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -3071,14 +3063,13 @@ public class SQLManager implements AbstractDB {
stmt.executeUpdate( stmt.executeUpdate(
"UPDATE `" + prefix + "plot_trusted` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '" + old.toString() "UPDATE `" + prefix + "plot_trusted` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '" + old.toString()
+ "'"); + "'");
stmt.close();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}); });
} }
@Override @Override
public void close() { public void close() {
try { try {

View File

@ -97,9 +97,6 @@ public class AbstractFlag {
@Override @Override
public boolean equals(final Object other) { public boolean equals(final Object other) {
if (other == null) {
return false;
}
if (other == this) { if (other == this) {
return true; return true;
} }

View File

@ -0,0 +1,8 @@
package com.intellectualcrafters.plot.flag;
public class BooleanFlag extends Flag<Boolean> {
public BooleanFlag(String name) {
super(name);
}
}

View File

@ -25,10 +25,11 @@ import com.intellectualcrafters.plot.util.StringMan;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class Flag implements Cloneable { public class Flag<T> implements Cloneable {
private AbstractFlag key; private AbstractFlag key;
private Object value; 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 * 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. * player, you need to register it with PlotSquared.
@ -59,6 +60,10 @@ public class Flag implements Cloneable {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
public Flag(String name) {
this.name = name;
}
/** /**
* Get the AbstractFlag used in creating the flag * Get the AbstractFlag used in creating the flag
@ -145,4 +150,8 @@ public class Flag implements Cloneable {
} }
return this; return this;
} }
public String getName() {
return name;
}
} }

View File

@ -2308,9 +2308,6 @@ public class Plot {
connected_cache.add(current); connected_cache.add(current);
queuecache.remove(current); queuecache.remove(current);
merged = current.getMerged(); merged = current.getMerged();
for (int i = 0; i < 5; i++) {
}
if (merged[0]) { if (merged[0]) {
tmp = current.area.getPlotAbs(current.id.getRelative(0)); tmp = current.area.getPlotAbs(current.id.getRelative(0));
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) { if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {

View File

@ -20,11 +20,12 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
/** /**
*/ */
public class PlotBlock { 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 short id;
public final byte data; public final byte data;

View File

@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class ExpireManager { public class ExpireManager {
@ -233,8 +234,7 @@ public class ExpireManager {
} }
if ((last = opp.getLastPlayed()) != 0) { if ((last = opp.getLastPlayed()) != 0) {
dates_cache.put(uuid, last); dates_cache.put(uuid, last);
} } else {
else {
return false; return false;
} }
} }
@ -242,7 +242,7 @@ public class ExpireManager {
return false; return false;
} }
final long compared = System.currentTimeMillis() - last; final long compared = System.currentTimeMillis() - last;
if (compared >= (86400000l * Settings.AUTO_CLEAR_DAYS)) { if (compared >= (TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS))) {
return true; return true;
} }
} }

View File

@ -13,14 +13,40 @@ import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.SetupObject; 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.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.sponge.generator.SpongePlotGenerator; import com.plotsquared.sponge.generator.SpongePlotGenerator;
import com.plotsquared.sponge.listener.ChunkProcessor; import com.plotsquared.sponge.listener.ChunkProcessor;
import com.plotsquared.sponge.listener.MainListener; import com.plotsquared.sponge.listener.MainListener;
import com.plotsquared.sponge.listener.WorldEvents; 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.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.FastQueue;
import com.plotsquared.sponge.util.block.SlowQueue; import com.plotsquared.sponge.util.block.SlowQueue;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
@ -138,12 +164,11 @@ public class SpongeMain implements IPlotMain {
} }
@Override @Override
public int[] getPluginVersion() { public String getPluginVersion() {
PluginContainer plugin = game.getPluginManager().fromInstance(this).get(); PluginContainer plugin = game.getPluginManager().fromInstance(this).get();
String version = plugin.getVersion().get(); String version = plugin.getVersion().get();
log("Checking plugin version: PlotSquared: "); log("Checking plugin version: PlotSquared: ");
final String[] split = version.split("\\."); return version;
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
} }
@Override @Override
@ -203,7 +228,7 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public void registerCommands() { 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 @Override