mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
parent
6e9be620e0
commit
9246aa2bcc
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.12.0</version>
|
<version>2.12.4</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -224,7 +224,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
try {
|
try {
|
||||||
unloadRecursively(this);
|
unloadRecursively(this);
|
||||||
}
|
}
|
||||||
catch (Exception e) {};
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
};
|
||||||
THIS = null;
|
THIS = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ public class PS {
|
|||||||
private File storageFile;
|
private File storageFile;
|
||||||
private File FILE = null; // This file
|
private File FILE = null; // This file
|
||||||
private String VERSION = null;
|
private String VERSION = null;
|
||||||
|
private String LAST_VERSION;
|
||||||
private boolean LOADING_WORLD = false;
|
private boolean LOADING_WORLD = false;
|
||||||
private LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
private LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||||
private Database database;
|
private Database database;
|
||||||
@ -200,6 +201,9 @@ public class PS {
|
|||||||
log("&8 - &3Use: &7/plot update");
|
log("&8 - &3Use: &7/plot update");
|
||||||
log("&8 - &3Or: &7" + url);
|
log("&8 - &3Or: &7" + url);
|
||||||
}
|
}
|
||||||
|
else if (LAST_VERSION != null && !VERSION.equals(LAST_VERSION)) {
|
||||||
|
log("&aThanks for updating from: " + LAST_VERSION + " to " + VERSION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -240,6 +244,22 @@ public class PS {
|
|||||||
public static PS get() {
|
public static PS get() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last PlotSquared version
|
||||||
|
* @return last version in config or null
|
||||||
|
*/
|
||||||
|
public String getLastVersion() {
|
||||||
|
return LAST_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current PlotSquared version
|
||||||
|
* @return current version in config or null
|
||||||
|
*/
|
||||||
|
public String getVersion() {
|
||||||
|
return VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message to the IPlotMain logger
|
* Log a message to the IPlotMain logger
|
||||||
@ -1179,6 +1199,7 @@ public class PS {
|
|||||||
* Setup the default configuration (settings.yml)
|
* Setup the default configuration (settings.yml)
|
||||||
*/
|
*/
|
||||||
public void setupConfig() {
|
public void setupConfig() {
|
||||||
|
LAST_VERSION = config.getString("version");
|
||||||
config.set("version", VERSION);
|
config.set("version", VERSION);
|
||||||
|
|
||||||
final Map<String, Object> options = new HashMap<>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
|
@ -92,7 +92,7 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
case "remove-flag": {
|
case "remove-flag": {
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec reset-flat <flag>");
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec remove-flag <flag>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String flag = args[1];
|
String flag = args[1];
|
||||||
|
@ -5,6 +5,7 @@ import java.net.URL;
|
|||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
@ -19,6 +20,10 @@ public class Download extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, String... args) {
|
public boolean execute(final PlotPlayer plr, String... args) {
|
||||||
|
if (!Settings.METRICS) {
|
||||||
|
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final String world = plr.getLocation().getWorld();
|
final String world = plr.getLocation().getWorld();
|
||||||
if (!PS.get().isPlotWorld(world)) {
|
if (!PS.get().isPlotWorld(world)) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||||
|
@ -25,6 +25,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -240,10 +241,6 @@ public class Set extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NEED_BLOCK);
|
MainUtil.sendMessage(plr, C.NEED_BLOCK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if (!Configuration.BLOCKLIST.validateValue(args[1])) {
|
|
||||||
// MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, args[1]);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
String[] split = args[1].split(",");
|
String[] split = args[1].split(",");
|
||||||
blocks = Configuration.BLOCKLIST.parseString(args[1]);
|
blocks = Configuration.BLOCKLIST.parseString(args[1]);
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
|
@ -144,55 +144,100 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
// Create the plots
|
// Create the plots
|
||||||
createPlots(myList);
|
createPlots(myList, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
// Creating datastructures
|
||||||
|
HashMap<PlotId, Plot> plotMap = new HashMap<>();
|
||||||
|
for (Plot plot : myList) {
|
||||||
|
plotMap.put(plot.id, plot);
|
||||||
|
}
|
||||||
|
final ArrayList<SettingsPair> settings = new ArrayList<>();
|
||||||
|
final ArrayList<UUIDPair> helpers = new ArrayList<>();
|
||||||
|
final ArrayList<UUIDPair> trusted = new ArrayList<>();
|
||||||
|
final ArrayList<UUIDPair> denied = new ArrayList<>();
|
||||||
|
|
||||||
// Creating datastructures
|
// Populating structures
|
||||||
HashMap<PlotId, Plot> plotMap = new HashMap<>();
|
final PreparedStatement stmt = connection.prepareStatement(GET_ALL_PLOTS);
|
||||||
for (Plot plot : myList) {
|
final ResultSet result = stmt.executeQuery();
|
||||||
plotMap.put(plot.id, plot);
|
while (result.next()) {
|
||||||
}
|
final int id = result.getInt("id");
|
||||||
ArrayList<SettingsPair> settings = new ArrayList<>();
|
int x = result.getInt("plot_id_x");
|
||||||
ArrayList<UUIDPair> helpers = new ArrayList<>();
|
int y = result.getInt("plot_id_z");
|
||||||
ArrayList<UUIDPair> trusted = new ArrayList<>();
|
PlotId plotId = new PlotId(x, y);
|
||||||
ArrayList<UUIDPair> denied = new ArrayList<>();
|
Plot plot = plotMap.get(plotId);
|
||||||
|
if (plot != null) {
|
||||||
// Populating structures
|
settings.add(new SettingsPair(id, plot.settings));
|
||||||
final PreparedStatement stmt = connection.prepareStatement(GET_ALL_PLOTS);
|
if (plot.denied != null) {
|
||||||
final ResultSet result = stmt.executeQuery();
|
for (UUID uuid : plot.denied) {
|
||||||
while (result.next()) {
|
denied.add(new UUIDPair(id, uuid));
|
||||||
final int id = result.getInt("id");
|
}
|
||||||
int x = result.getInt("plot_id_x");
|
}
|
||||||
int y = result.getInt("plot_id_z");
|
if (plot.members != null) {
|
||||||
PlotId plotId = new PlotId(x, y);
|
for (UUID uuid : plot.members) {
|
||||||
Plot plot = plotMap.get(plotId);
|
trusted.add(new UUIDPair(id, uuid));
|
||||||
if (plot != null) {
|
}
|
||||||
settings.add(new SettingsPair(id, plot.settings));
|
}
|
||||||
if (plot.denied != null) {
|
if (plot.trusted != null) {
|
||||||
for (UUID uuid : plot.denied) {
|
for (UUID uuid : plot.trusted) {
|
||||||
denied.add(new UUIDPair(id, uuid));
|
helpers.add(new UUIDPair(id, uuid));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plot.members != null) {
|
createSettings(settings, new Runnable() {
|
||||||
for (UUID uuid : plot.members) {
|
@Override
|
||||||
trusted.add(new UUIDPair(id, uuid));
|
public void run() {
|
||||||
|
createTiers(helpers, "helpers", new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
createTiers(trusted, "trusted", new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
createTiers(denied, "denied", new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
connection.commit();
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (whenDone != null) whenDone.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (plot.trusted != null) {
|
catch (SQLException e) {
|
||||||
for (UUID uuid : plot.trusted) {
|
e.printStackTrace();
|
||||||
helpers.add(new UUIDPair(id, uuid));
|
PS.log("&7[WARN] " + "Failed to set all helpers for plots");
|
||||||
|
try {
|
||||||
|
connection.commit();
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
} catch (SQLException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
createSettings(settings);
|
|
||||||
createTiers(helpers, "helpers");
|
|
||||||
createTiers(trusted, "trusted");
|
|
||||||
createTiers(denied, "denied");
|
|
||||||
TaskManager.runTaskLater(whenDone, 60);
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.log("&7[WARN] " + "Failed to set all helpers for plots");
|
PS.log("&7[WARN] " + "Failed to set all helpers for plots");
|
||||||
|
try {
|
||||||
|
connection.commit();
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
} catch (SQLException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -203,7 +248,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param myList list of plots to be created
|
* @param myList list of plots to be created
|
||||||
*/
|
*/
|
||||||
public void createTiers(final ArrayList<UUIDPair> myList, final String tier) {
|
public void createTiers(final ArrayList<UUIDPair> myList, final String tier, final Runnable whenDone) {
|
||||||
final StmtMod<UUIDPair> mod = new StmtMod<UUIDPair>() {
|
final StmtMod<UUIDPair> mod = new StmtMod<UUIDPair>() {
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
@ -239,7 +284,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.setString(2, pair.uuid.toString());
|
stmt.setString(2, pair.uuid.toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setBulk(myList, mod);
|
setBulk(myList, mod, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +292,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param myList list of plots to be created
|
* @param myList list of plots to be created
|
||||||
*/
|
*/
|
||||||
public void createPlots(final ArrayList<Plot> myList) {
|
public void createPlots(final ArrayList<Plot> myList, final Runnable whenDone) {
|
||||||
final StmtMod<Plot> mod = new StmtMod<Plot>() {
|
final StmtMod<Plot> mod = new StmtMod<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
@ -298,12 +343,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.setString(4, plot.world);
|
stmt.setString(4, plot.world);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setBulk(myList, mod);
|
setBulk(myList, mod, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void setBulk(ArrayList<T> objList, StmtMod<T> mod) {
|
public <T> void setBulk(ArrayList<T> objList, StmtMod<T> mod, Runnable whenDone) {
|
||||||
final int size = objList.size();
|
final int size = objList.size();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
|
if (whenDone != null) whenDone.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int packet;
|
int packet;
|
||||||
@ -313,7 +359,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
packet = Math.min(size, 50);
|
packet = Math.min(size, 50);
|
||||||
}
|
}
|
||||||
final int amount = size / packet;
|
final int amount = size / packet;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
PreparedStatement preparedStmt = null;
|
PreparedStatement preparedStmt = null;
|
||||||
@ -347,6 +392,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
preparedStmt.clearParameters();
|
preparedStmt.clearParameters();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
|
if (whenDone != null) whenDone.run();
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
@ -371,8 +417,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
if (subList.size() != last || (count % 5000 == 0 && count > 0)) {
|
if (subList.size() != last || (count % 5000 == 0 && count > 0)) {
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
preparedStmt.close();
|
preparedStmt.clearParameters();
|
||||||
|
|
||||||
statement = mod.getCreateSQLite(subList.size());
|
statement = mod.getCreateSQLite(subList.size());
|
||||||
preparedStmt = this.connection.prepareStatement(statement.toString());
|
preparedStmt = this.connection.prepareStatement(statement.toString());
|
||||||
}
|
}
|
||||||
@ -388,35 +433,34 @@ public class SQLManager implements AbstractDB {
|
|||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
preparedStmt.clearParameters();
|
preparedStmt.clearParameters();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
return;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.log("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName());
|
PS.log("&cERROR 2: " + " | " + objList.get(0).getClass().getCanonicalName());
|
||||||
}
|
PS.log("&6[WARN] " + "Could not bulk save!");
|
||||||
|
try {
|
||||||
PS.log("&6[WARN] " + "Could not bulk save!");
|
PreparedStatement preparedStmt = null;
|
||||||
try {
|
String nonBulk = mod.getCreateSQL();
|
||||||
PreparedStatement preparedStmt = null;
|
preparedStmt = this.connection.prepareStatement(nonBulk.toString());
|
||||||
String nonBulk = mod.getCreateSQL();
|
for (final T obj : objList) {
|
||||||
preparedStmt = this.connection.prepareStatement(nonBulk.toString());
|
try {
|
||||||
for (final T obj : objList) {
|
mod.setSQL(preparedStmt, obj);
|
||||||
try {
|
preparedStmt.addBatch();
|
||||||
mod.setSQL(preparedStmt, obj);
|
} catch (final Exception e3) {
|
||||||
preparedStmt.addBatch();
|
PS.log("&c[ERROR] " + "Failed to save " + obj + "!");
|
||||||
} catch (final Exception e3) {
|
}
|
||||||
PS.log("&c[ERROR] " + "Failed to save " + obj + "!");
|
|
||||||
}
|
}
|
||||||
|
PS.log("&aBatch 3");
|
||||||
|
preparedStmt.executeBatch();
|
||||||
|
preparedStmt.close();
|
||||||
|
} catch (Exception e3) {
|
||||||
|
e3.printStackTrace();
|
||||||
|
PS.log("&c[ERROR] " + "Failed to save all!");
|
||||||
}
|
}
|
||||||
PS.log("&aBatch 3");
|
|
||||||
preparedStmt.executeBatch();
|
|
||||||
preparedStmt.close();
|
|
||||||
} catch (Exception e3) {
|
|
||||||
e3.printStackTrace();
|
|
||||||
PS.log("&c[ERROR] " + "Failed to save all!");
|
|
||||||
}
|
}
|
||||||
|
if (whenDone != null) whenDone.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createSettings(final ArrayList<SettingsPair> myList) {
|
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
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
@ -527,12 +571,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
setBulk(myList, mod);
|
setBulk(myList, mod, whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createEmptySettings(final ArrayList<Integer> myList) {
|
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
|
||||||
public String getCreateMySQL(int size) {
|
public String getCreateMySQL(int size) {
|
||||||
@ -576,7 +620,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
setBulk(myList, mod);
|
setBulk(myList, mod, whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -648,6 +692,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
} else {
|
} else {
|
||||||
tables = new String[]{"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings"};
|
tables = new String[]{"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings"};
|
||||||
}
|
}
|
||||||
|
final boolean mysql = database.equals("mysql");
|
||||||
final DatabaseMetaData meta = connection.getMetaData();
|
final DatabaseMetaData meta = connection.getMetaData();
|
||||||
int create = 0;
|
int create = 0;
|
||||||
for (final String s : tables) {
|
for (final String s : tables) {
|
||||||
@ -663,7 +708,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
boolean add_constraint;
|
boolean add_constraint;
|
||||||
add_constraint = create == tables.length;
|
add_constraint = create == tables.length;
|
||||||
PS.log("Creating tables");
|
PS.log("Creating tables");
|
||||||
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(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` (" + "`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");
|
||||||
@ -791,6 +835,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateTables() {
|
public void updateTables() {
|
||||||
|
if (PS.get().getVersion().equals(PS.get().getLastVersion()) || PS.get().getLastVersion() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
final DatabaseMetaData data = this.connection.getMetaData();
|
final DatabaseMetaData data = this.connection.getMetaData();
|
||||||
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id");
|
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id");
|
||||||
@ -820,9 +867,28 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
} catch (SQLException e) {
|
try (Statement statement = connection.createStatement();) {
|
||||||
|
for (String table : new String[]{"plot_denied", "plot_helpers", "plot_trusted"} ) {
|
||||||
|
ResultSet result = statement.executeQuery("SELECT plot_plot_id, user_uuid, COUNT(*) FROM " + this.prefix + table + " GROUP BY plot_plot_id, user_uuid HAVING COUNT(*) > 1");
|
||||||
|
if (result.next()) {
|
||||||
|
PS.log("BACKING UP: " + table);
|
||||||
|
result.close();
|
||||||
|
statement.executeUpdate("CREATE TABLE " + table + "_tmp AS SELECT * FROM " + this.prefix + table + " GROUP BY plot_plot_id, user_uuid");
|
||||||
|
statement.executeUpdate("DROP TABLE " + this.prefix + table);
|
||||||
|
statement.executeUpdate("CREATE TABLE " + this.prefix + table + " AS SELECT * FROM " + table + "_tmp");
|
||||||
|
statement.executeUpdate("DROP TABLE " + this.prefix + table + "_tmp");
|
||||||
|
PS.log("RESTORING: " + table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e2) {
|
||||||
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -906,7 +972,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
final Plot plot = plots.get(id);
|
final Plot plot = plots.get(id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
plot.addTrusted(user);
|
plot.trusted.add(user);
|
||||||
} else {
|
} else {
|
||||||
PS.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry.");
|
PS.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry.");
|
||||||
}
|
}
|
||||||
@ -926,7 +992,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
final Plot plot = plots.get(id);
|
final Plot plot = plots.get(id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
plot.addMember(user);
|
plot.members.add(user);
|
||||||
} else {
|
} else {
|
||||||
PS.log("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry.");
|
PS.log("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry.");
|
||||||
}
|
}
|
||||||
@ -946,7 +1012,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
final Plot plot = plots.get(id);
|
final Plot plot = plots.get(id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
plot.addDenied(user);
|
plot.denied.add(user);
|
||||||
} else {
|
} else {
|
||||||
PS.log("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry.");
|
PS.log("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry.");
|
||||||
}
|
}
|
||||||
@ -1045,7 +1111,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
stmt.close();
|
stmt.close();
|
||||||
r.close();
|
r.close();
|
||||||
if (plots.keySet().size() > 0) {
|
if (plots.keySet().size() > 0) {
|
||||||
createEmptySettings(new ArrayList<Integer>(plots.keySet()));
|
createEmptySettings(new ArrayList<Integer>(plots.keySet()), null);
|
||||||
}
|
}
|
||||||
boolean invalidPlot = false;
|
boolean invalidPlot = false;
|
||||||
for (final String worldname : noExist.keySet()) {
|
for (final String worldname : noExist.keySet()) {
|
||||||
|
@ -843,12 +843,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
|
|
||||||
PlayerBlockEventType eventType = null;
|
PlayerBlockEventType eventType = null;
|
||||||
|
|
||||||
|
|
||||||
BukkitLazyBlock lb;
|
BukkitLazyBlock lb;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PHYSICAL: {
|
case PHYSICAL: {
|
||||||
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
||||||
@ -925,6 +921,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO calls both:
|
// TODO calls both:
|
||||||
// redstone ore
|
// redstone ore
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.BREAK_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.BREAK_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case BREAK_HANGING:
|
case BREAK_HANGING:
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -135,6 +136,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case PLACE_BLOCK: {
|
case PLACE_BLOCK: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -148,6 +150,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.BUILD_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.BUILD_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case TRIGGER_PHYSICAL: {
|
case TRIGGER_PHYSICAL: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -164,6 +167,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case INTERACT_HANGING: {
|
case INTERACT_HANGING: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -180,6 +184,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case INTERACT_MISC: {
|
case INTERACT_MISC: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -196,6 +201,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case INTERACT_VEHICLE: {
|
case INTERACT_VEHICLE: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -212,6 +218,7 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case SPAWN_MOB: {
|
case SPAWN_MOB: {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -229,13 +236,62 @@ public abstract class EventUtil {
|
|||||||
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case PLACE_HANGING: {
|
||||||
|
// if (plot == null) {
|
||||||
|
// return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
|
// }
|
||||||
|
// if (!plot.hasOwner()) {
|
||||||
|
// return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||||
|
// HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||||
|
// if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
|
// return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case PLACE_MISC: {
|
||||||
|
if (plot == null) {
|
||||||
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
|
}
|
||||||
|
if (!plot.hasOwner()) {
|
||||||
|
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||||
|
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||||
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case PLACE_VEHICLE: {
|
||||||
|
if (plot == null) {
|
||||||
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
|
}
|
||||||
|
if (!plot.hasOwner()) {
|
||||||
|
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Flag flag = FlagManager.getPlotFlag(plot, "place");
|
||||||
|
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||||
|
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||||
|
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case PLACE_HANGING:
|
|
||||||
break;
|
|
||||||
case PLACE_MISC:
|
|
||||||
break;
|
|
||||||
case PLACE_VEHICLE:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -326,8 +326,16 @@ public class BukkitUtil extends BlockManager {
|
|||||||
Material material = Material.getMaterial(block.id);
|
Material material = Material.getMaterial(block.id);
|
||||||
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
|
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
|
||||||
Class<? extends MaterialData> data = material.getData();
|
Class<? extends MaterialData> data = material.getData();
|
||||||
if (data.equals(MaterialData.class) || data.equals(Tree.class) || data.equals(Sandstone.class) || data.equals(Wool.class) || data.equals(Step.class)) {
|
if ((data.equals(MaterialData.class) && !material.isTransparent() && material.isOccluding()) || data.equals(Tree.class) || data.equals(Sandstone.class) || data.equals(Wool.class) || data.equals(Step.class)) {
|
||||||
return true;
|
System.out.print((data.equals(MaterialData.class) && !material.isTransparent() && material.isOccluding()) + " | " + data.getCanonicalName());
|
||||||
|
switch (material) {
|
||||||
|
case NOTE_BLOCK:
|
||||||
|
case MOB_SPAWNER: {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user