mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-12 10:24:07 +01:00
Should be stable now
This commit is contained in:
parent
3487d7d4c4
commit
7143da0ebf
@ -1224,6 +1224,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
// Setup configuration
|
// Setup configuration
|
||||||
configs();
|
configs();
|
||||||
|
defaultFlags();
|
||||||
// Setup metrics
|
// Setup metrics
|
||||||
if (Settings.METRICS) {
|
if (Settings.METRICS) {
|
||||||
try {
|
try {
|
||||||
@ -1244,12 +1245,18 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
if (C.ENABLED.s().length() > 0) {
|
if (C.ENABLED.s().length() > 0) {
|
||||||
sendConsoleSenderMessage(C.ENABLED);
|
sendConsoleSenderMessage(C.ENABLED);
|
||||||
}
|
}
|
||||||
|
final String[] tables;
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
MainCommand.subCommands.add(new Cluster());
|
MainCommand.subCommands.add(new Cluster());
|
||||||
|
tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments", "cluster"};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add tables to this one, if we create more :D
|
// Add tables to this one, if we create more :D
|
||||||
final String[] tables = new String[]{"plot_trusted", "plot_ratings", "plot_comments"};
|
|
||||||
|
|
||||||
|
|
||||||
// Use mysql?
|
// Use mysql?
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
@ -1356,7 +1363,6 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
// Forcefield listener
|
// Forcefield listener
|
||||||
getServer().getPluginManager().registerEvents(new ForceFieldListener(this), this);
|
getServer().getPluginManager().registerEvents(new ForceFieldListener(this), this);
|
||||||
// Default flags
|
// Default flags
|
||||||
defaultFlags();
|
|
||||||
|
|
||||||
if (getServer().getPluginManager().getPlugin("BarAPI") != null) {
|
if (getServer().getPluginManager().getPlugin("BarAPI") != null) {
|
||||||
barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI");
|
barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI");
|
||||||
|
@ -50,9 +50,6 @@ public class Cluster extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
if (!ClusterManager.clusters.containsKey(plr.getWorld().getName())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
@ -75,17 +72,15 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + "");
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_HEADING, clusters.size() + "");
|
||||||
for (PlotCluster cluster : clusters) {
|
for (PlotCluster cluster : clusters) {
|
||||||
// Ignore unmanaged clusters
|
// Ignore unmanaged clusters
|
||||||
if (cluster.settings.getAlias().equals("")) {
|
String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (UUIDHandler.getUUID(plr).equals(cluster.owner)) {
|
if (UUIDHandler.getUUID(plr).equals(cluster.owner)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + cluster.toString());
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||||
}
|
}
|
||||||
else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) {
|
else if (cluster.helpers.contains(UUIDHandler.getUUID(plr))) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + cluster.toString());
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&3" + name);
|
||||||
}
|
}
|
||||||
else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) {
|
else if (cluster.invited.contains(UUIDHandler.getUUID(plr))) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + cluster.toString());
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, "&9" + name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
||||||
@ -129,11 +124,14 @@ public class Cluster extends SubCommand {
|
|||||||
PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr));
|
PlotCluster cluster = new PlotCluster(world, pos1, pos2, UUIDHandler.getUUID(plr));
|
||||||
cluster.settings.setAlias(name);
|
cluster.settings.setAlias(name);
|
||||||
DBFunc.createCluster(world, cluster);
|
DBFunc.createCluster(world, cluster);
|
||||||
|
if (!ClusterManager.clusters.containsKey(world)) {
|
||||||
|
ClusterManager.clusters.put(world, new HashSet<PlotCluster>());
|
||||||
|
}
|
||||||
ClusterManager.clusters.get(world).add(cluster);
|
ClusterManager.clusters.get(world).add(cluster);
|
||||||
// Add any existing plots to the current cluster
|
// Add any existing plots to the current cluster
|
||||||
for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) {
|
for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) {
|
||||||
PlotCluster current = ClusterManager.getCluster(plot);
|
PlotCluster current = ClusterManager.getCluster(plot);
|
||||||
if (cluster.equals(current)) {
|
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) {
|
||||||
cluster.invited.add(plot.owner);
|
cluster.invited.add(plot.owner);
|
||||||
DBFunc.setInvited(world, cluster, plot.owner);
|
DBFunc.setInvited(world, cluster, plot.owner);
|
||||||
}
|
}
|
||||||
@ -146,16 +144,30 @@ public class Cluster extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length != 1) {
|
if (args.length != 1 && args.length != 2) {
|
||||||
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete");
|
PlayerFunctions.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotCluster toDelete = ClusterManager.getCluster(plr.getLocation());
|
PlotCluster cluster;
|
||||||
if (toDelete == null) {
|
if (args.length == 2) {
|
||||||
|
cluster = ClusterManager.getCluster(plr.getWorld().getName(), args[1]);
|
||||||
|
if (cluster == null) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.INVALID_CLUSTER, args[1]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cluster = ClusterManager.getCluster(plr.getLocation());
|
||||||
|
if (cluster == null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!toDelete.owner.equals(UUIDHandler.getUUID(plr))) {
|
}
|
||||||
|
if (cluster == null) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NOT_IN_CLUSTER);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!cluster.owner.equals(UUIDHandler.getUUID(plr))) {
|
||||||
if (!PlotMain.hasPermission(plr, "plots.cluster.delete.other")) {
|
if (!PlotMain.hasPermission(plr, "plots.cluster.delete.other")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete.other");
|
||||||
return false;
|
return false;
|
||||||
@ -164,16 +176,16 @@ public class Cluster extends SubCommand {
|
|||||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||||
if (plotworld.REQUIRE_CLUSTER) {
|
if (plotworld.REQUIRE_CLUSTER) {
|
||||||
for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) {
|
for (Plot plot : PlotMain.getPlots(plr.getWorld()).values()) {
|
||||||
PlotCluster cluster = ClusterManager.getCluster(plot);
|
PlotCluster other = ClusterManager.getCluster(plot);
|
||||||
if (toDelete.equals(cluster)) {
|
if (cluster.equals(other)) {
|
||||||
String world = plr.getWorld().getName();
|
String world = plr.getWorld().getName();
|
||||||
DBFunc.delete(world, plot);
|
DBFunc.delete(world, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String world_delete = plr.getWorld().getName();
|
String world_delete = plr.getWorld().getName();
|
||||||
ClusterManager.clusters.get(world_delete).remove(toDelete);
|
ClusterManager.clusters.get(world_delete).remove(cluster);
|
||||||
DBFunc.delete(toDelete);
|
DBFunc.delete(cluster);
|
||||||
PlayerFunctions.sendMessage(plr, C.CLUSTER_DELETED);
|
PlayerFunctions.sendMessage(plr, C.CLUSTER_DELETED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public enum Command {
|
|||||||
// (Rating system) (ratings can be stored as the average, and number of
|
// (Rating system) (ratings can be stored as the average, and number of
|
||||||
// ratings)
|
// ratings)
|
||||||
// - /plot rate <number out of 10>
|
// - /plot rate <number out of 10>
|
||||||
CLUSTER("cluster", "cl"),
|
CLUSTER("cluster", "clusters"),
|
||||||
BUY("buy","b"),
|
BUY("buy","b"),
|
||||||
CREATEROADSCHEMATIC("createroadschematic"),
|
CREATEROADSCHEMATIC("createroadschematic"),
|
||||||
DEBUGROADREGEN("debugroadregen"),
|
DEBUGROADREGEN("debugroadregen"),
|
||||||
|
@ -58,7 +58,7 @@ public enum C {
|
|||||||
CLUSTER_ADDED_HELPER("&6Successfully added a helper to the cluster"),
|
CLUSTER_ADDED_HELPER("&6Successfully added a helper to the cluster"),
|
||||||
CLUSTER_REMOVED_HELPER("&6Successfully removed a helper to the cluster"),
|
CLUSTER_REMOVED_HELPER("&6Successfully removed a helper to the cluster"),
|
||||||
CLUSTER_TELEPORTING("&6Teleporting..."),
|
CLUSTER_TELEPORTING("&6Teleporting..."),
|
||||||
CLUSTER_INFO("&6Current cluster: %id%\nName: %name%\nOwner: %owner%\nSize: %size%\nRights: %rights%"),
|
CLUSTER_INFO("&6Current cluster: &7%id%\n&6Name: &7%name%\n&6Owner: &7%owner%\n&6Size: &7%size%\n&6Rights: &7%rights%"),
|
||||||
/*
|
/*
|
||||||
* Border
|
* Border
|
||||||
*/
|
*/
|
||||||
|
@ -372,7 +372,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
final boolean mysql = database.equals("mysql");
|
final boolean mysql = database.equals("mysql");
|
||||||
final Statement stmt = this.connection.createStatement();
|
final Statement stmt = this.connection.createStatement();
|
||||||
if (mysql) {
|
if (mysql) {
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`plot_plot_id` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`tier` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
@ -382,9 +382,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (add_constraint) {
|
if (add_constraint) {
|
||||||
stmt.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD CONSTRAINT `" + this.prefix + "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `" + this.prefix + "plot` (`id`) ON DELETE CASCADE");
|
stmt.addBatch("ALTER TABLE `" + this.prefix + "plot_settings` ADD CONSTRAINT `" + this.prefix + "plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `" + this.prefix + "plot` (`id`) ON DELETE CASCADE");
|
||||||
}
|
}
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + "`tier` INT(11) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + "`tier` INT(11) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -396,7 +396,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))");
|
||||||
|
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster` (" + "`id` INTEGER PRIMARY KEY AUTOINCREMENT," + "`pos1_x` INT(11) NOT NULL," + "`pos1_z` INT(11) NOT NULL," + "`pos2_x` INT(11) NOT NULL," + "`pos2_z` INT(11) NOT NULL," + "`owner` VARCHAR(40) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_helpers` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_invited` (" + "`cluster_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ")");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "cluster_settings` (" + " `cluster_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`cluster_id`)" + ")");
|
||||||
@ -1270,11 +1270,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
public int getClusterId(String world, PlotClusterId id) {
|
public int getClusterId(String world, PlotClusterId id) {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
stmt = this.connection.prepareStatement("SELECT `id` FROM `" + this.prefix + "cluster` WHERE `pos1_x` = ? AND `pos1_z` = ? AND `pos2_x` = ? AND `pos2_z` = ? AND `world` = ? ORDER BY `timestamp` ASC");
|
||||||
stmt.setInt(1, id.pos1.x);
|
stmt.setInt(1, id.pos1.x);
|
||||||
stmt.setInt(2, id.pos1.y);
|
stmt.setInt(2, id.pos1.y);
|
||||||
stmt.setInt(3, id.pos1.x);
|
stmt.setInt(3, id.pos2.x);
|
||||||
stmt.setInt(3, id.pos2.y);
|
stmt.setInt(4, id.pos2.y);
|
||||||
stmt.setString(5, world);
|
stmt.setString(5, world);
|
||||||
final ResultSet r = stmt.executeQuery();
|
final ResultSet r = stmt.executeQuery();
|
||||||
int c_id = Integer.MAX_VALUE;
|
int c_id = Integer.MAX_VALUE;
|
||||||
@ -1342,7 +1342,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
|
r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("cluster_id");
|
||||||
owner = r.getString("user_uuid");
|
owner = r.getString("user_uuid");
|
||||||
user = uuids.get(owner);
|
user = uuids.get(owner);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@ -1361,7 +1361,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
|
r = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("cluster_id");
|
||||||
owner = r.getString("user_uuid");
|
owner = r.getString("user_uuid");
|
||||||
user = uuids.get(owner);
|
user = uuids.get(owner);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@ -1377,7 +1377,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`");
|
r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`");
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
id = r.getInt("plot_plot_id");
|
id = r.getInt("cluster_id");
|
||||||
cluster = clusters.get(id);
|
cluster = clusters.get(id);
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
final String b = r.getString("biome");
|
final String b = r.getString("biome");
|
||||||
@ -1393,6 +1393,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (alias != null) {
|
if (alias != null) {
|
||||||
cluster.settings.setAlias(alias);
|
cluster.settings.setAlias(alias);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
System.out.print("ALIAS IS NULL!!!");
|
||||||
|
}
|
||||||
|
|
||||||
final String pos = r.getString("position");
|
final String pos = r.getString("position");
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ package com.intellectualcrafters.plot.flag;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
public class Flag {
|
public class Flag {
|
||||||
private final AbstractFlag key;
|
private AbstractFlag key;
|
||||||
private final Object value;
|
private Object value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -55,6 +55,13 @@ public class Flag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setKey(AbstractFlag key) {
|
||||||
|
this.key = key;
|
||||||
|
if (this.value instanceof String) {
|
||||||
|
this.value = key.parseValueRaw((String) this.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning: Unchecked
|
* Warning: Unchecked
|
||||||
*/
|
*/
|
||||||
|
@ -31,6 +31,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
|
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
||||||
@ -61,8 +62,19 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
*
|
*
|
||||||
* @return success?
|
* @return success?
|
||||||
*/
|
*/
|
||||||
public static boolean addFlag(final AbstractFlag flag) {
|
public static boolean addFlag(final AbstractFlag af) {
|
||||||
return (getFlag(flag.getKey()) == null) && flags.add(flag);
|
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
||||||
|
String key = af.getKey();
|
||||||
|
if (PlotMain.getAllPlotsRaw() != null) {
|
||||||
|
for (Plot plot : PlotMain.getPlots()) {
|
||||||
|
for (Flag flag : plot.settings.flags) {
|
||||||
|
if (flag.getAbstractFlag().getKey().equals(af)) {
|
||||||
|
flag.setKey(af);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (getFlag(af.getKey()) == null) && flags.add(af);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Flag getSettingFlag(String world, PlotSettings settings, String flag) {
|
public static Flag getSettingFlag(String world, PlotSettings settings, String flag) {
|
||||||
|
@ -108,7 +108,7 @@ public class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<PlotCluster> getIntersects(String world, PlotClusterId id) {
|
public static HashSet<PlotCluster> getIntersects(String world, PlotClusterId id) {
|
||||||
if (clusters.containsKey(world)) {
|
if (!clusters.containsKey(world)) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}
|
}
|
||||||
HashSet<PlotCluster> list = new HashSet<PlotCluster>();
|
HashSet<PlotCluster> list = new HashSet<PlotCluster>();
|
||||||
|
Loading…
Reference in New Issue
Block a user