mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Cleanup of some database methods
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
dfbcecb081
commit
e3d43509cf
@ -47,8 +47,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
} else {
|
} else {
|
||||||
world = worlds.get(0).getName();
|
world = worlds.get(0).getName();
|
||||||
}
|
}
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
|
||||||
PlotSquared.debug(C.PREFIX + "&6Starting player data caching for: " + world);
|
PlotSquared.debug(C.PREFIX + "&6Starting player data caching for: " + world);
|
||||||
File uuidFile = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
|
File uuidFile = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
|
||||||
if (uuidFile.exists()) {
|
if (uuidFile.exists()) {
|
||||||
@ -133,11 +132,11 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
+ " uuids - slowly processing all files");
|
+ " uuids - slowly processing all files");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HashSet<String> worlds = Sets.newHashSet(world, "world");
|
HashSet<String> worlds1 = Sets.newHashSet(world, "world");
|
||||||
HashSet<UUID> uuids = new HashSet<>();
|
HashSet<UUID> uuids = new HashSet<>();
|
||||||
HashSet<String> names = new HashSet<>();
|
HashSet<String> names = new HashSet<>();
|
||||||
File playerDataFolder = null;
|
File playerDataFolder = null;
|
||||||
for (String worldName : worlds) {
|
for (String worldName : worlds1) {
|
||||||
// Getting UUIDs
|
// Getting UUIDs
|
||||||
playerDataFolder =
|
playerDataFolder =
|
||||||
new File(container, worldName + File.separator + "playerdata");
|
new File(container, worldName + File.separator + "playerdata");
|
||||||
@ -234,17 +233,14 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
@Override public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
|
||||||
ifFetch.value = FileUUIDHandler.this.uuidWrapper.getUUID(name);
|
ifFetch.value = FileUUIDHandler.this.uuidWrapper.getUUID(name);
|
||||||
TaskManager.runTask(ifFetch);
|
TaskManager.runTask(ifFetch);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,26 +30,19 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
||||||
final PlotPlayer player) {
|
final PlotPlayer player) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
|
||||||
try {
|
try {
|
||||||
ArrayList<Plot> ps = new ArrayList<>();
|
ArrayList<Plot> ps = new ArrayList<>(plots);
|
||||||
for (Plot p : plots) {
|
|
||||||
ps.add(p);
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(player, "&6Starting...");
|
MainUtil.sendMessage(player, "&6Starting...");
|
||||||
manager.createPlotsAndData(ps, new Runnable() {
|
manager.createPlotsAndData(ps, () -> {
|
||||||
@Override public void run() {
|
|
||||||
MainUtil.sendMessage(player, "&6Database conversion finished!");
|
MainUtil.sendMessage(player, "&6Database conversion finished!");
|
||||||
manager.close();
|
manager.close();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
"Failed to insert plot objects, see stacktrace for info");
|
"Failed to insert plot objects, see stacktrace for info");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,20 +123,13 @@ import java.util.Map.Entry;
|
|||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HashMap<PlotId, Plot> plotmap =
|
HashMap<PlotId, Plot> plotmap = PlotSquared.get().plots_tmp
|
||||||
PlotSquared.get().plots_tmp.get(areaname);
|
.computeIfAbsent(areaname, k -> new HashMap<>());
|
||||||
if (plotmap == null) {
|
|
||||||
plotmap = new HashMap<>();
|
|
||||||
PlotSquared.get().plots_tmp.put(areaname, plotmap);
|
|
||||||
}
|
|
||||||
plotmap.putAll(entry.getValue());
|
plotmap.putAll(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
DBFunc.createPlotsAndData(plots,
|
||||||
@Override public void run() {
|
() -> MainUtil.sendMessage(player, "&6Database conversion finished!"));
|
||||||
MainUtil.sendMessage(player, "&6Database conversion finished!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if (args.length < 6) {
|
if (args.length < 6) {
|
||||||
|
@ -6,7 +6,6 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.config.Storage;
|
import com.github.intellectualsites.plotsquared.plot.config.Storage;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.StringFlag;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
@ -121,8 +120,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
|
||||||
long last = System.currentTimeMillis();
|
long last = System.currentTimeMillis();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (SQLManager.this.closed) {
|
if (SQLManager.this.closed) {
|
||||||
@ -158,7 +156,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +168,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try (PreparedStatement stmt = this.connection.prepareStatement("SELECT 1")) {
|
try (PreparedStatement stmt = this.connection.prepareStatement("SELECT 1")) {
|
||||||
stmt.executeQuery();
|
stmt.execute();
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
return false;
|
return false;
|
||||||
@ -212,7 +209,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void set(PreparedStatement stmt) {
|
@Override public void set(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void addBatch(PreparedStatement statement) {
|
@Override public void addBatch(PreparedStatement statement) {
|
||||||
@ -242,7 +239,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void set(PreparedStatement stmt) {
|
@Override public void set(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void addBatch(PreparedStatement statement) {
|
@Override public void addBatch(PreparedStatement statement) {
|
||||||
@ -269,7 +266,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void set(PreparedStatement stmt) {
|
@Override public void set(PreparedStatement statement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void addBatch(PreparedStatement statement) {
|
@Override public void addBatch(PreparedStatement statement) {
|
||||||
@ -515,12 +512,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void createPlotsAndData(final List<Plot> myList, final Runnable whenDone) {
|
@Override public void createPlotsAndData(final List<Plot> myList, final Runnable whenDone) {
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> {
|
||||||
@Override public void run() {
|
|
||||||
try {
|
try {
|
||||||
// Create the plots
|
// Create the plots
|
||||||
createPlots(myList, new Runnable() {
|
createPlots(myList, () -> {
|
||||||
@Override public void run() {
|
|
||||||
try {
|
try {
|
||||||
// Creating datastructures
|
// Creating datastructures
|
||||||
HashMap<PlotId, Plot> plotMap = new HashMap<>();
|
HashMap<PlotId, Plot> plotMap = new HashMap<>();
|
||||||
@ -591,7 +586,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -602,7 +596,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -929,11 +922,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
stmt.setInt(1, pair.id);
|
stmt.setInt(1, pair.id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> setBulk(myList, mod, whenDone));
|
||||||
@Override public void run() {
|
|
||||||
setBulk(myList, mod, whenDone);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
|
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
|
||||||
@ -977,25 +966,21 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> setBulk(myList, mod, whenDone));
|
||||||
@Override public void run() {
|
|
||||||
setBulk(myList, mod, whenDone);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
||||||
final long timestamp = plot.getTimestamp();
|
final long timestamp = plot.getTimestamp();
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
|
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().x);
|
||||||
stmt.setInt(2, plot.getId().y);
|
statement.setInt(2, plot.getId().y);
|
||||||
stmt.setString(3, plot.owner.toString());
|
statement.setString(3, plot.owner.toString());
|
||||||
stmt.setString(4, plot.getArea().toString());
|
statement.setString(4, plot.getArea().toString());
|
||||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
stmt.setString(6, plot.getArea().toString());
|
statement.setString(6, plot.getArea().toString());
|
||||||
stmt.setInt(7, plot.getId().x);
|
statement.setInt(7, plot.getId().x);
|
||||||
stmt.setInt(8, plot.getId().y);
|
statement.setInt(8, plot.getId().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1015,9 +1000,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
plot.temp = keys.getInt(1);
|
plot.temp = keys.getInt(1);
|
||||||
addPlotTask(plot, new UniqueStatement(
|
addPlotTask(plot, new UniqueStatement(
|
||||||
"createPlotAndSettings_settings_" + plot.hashCode()) {
|
"createPlotAndSettings_settings_" + plot.hashCode()) {
|
||||||
@Override public void set(PreparedStatement stmt)
|
@Override public void set(PreparedStatement statement)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1054,12 +1039,12 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void createPlotAndSettings(final Plot plot, Runnable whenDone) {
|
@Override public void createPlotAndSettings(final Plot plot, Runnable whenDone) {
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
|
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().x);
|
||||||
stmt.setInt(2, plot.getId().y);
|
statement.setInt(2, plot.getId().y);
|
||||||
stmt.setString(3, plot.owner.toString());
|
statement.setString(3, plot.owner.toString());
|
||||||
stmt.setString(4, plot.getArea().toString());
|
statement.setString(4, plot.getArea().toString());
|
||||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1080,8 +1065,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_settings_" + plot.hashCode()) {
|
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_settings_" + plot.hashCode()) {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1248,8 +1233,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void deleteSettings(final Plot plot) {
|
@Override public void deleteSettings(final Plot plot) {
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1265,8 +1250,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_helpers") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_helpers") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1282,8 +1267,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_trusted") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_trusted") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1299,8 +1284,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_denied") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_denied") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1313,9 +1298,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void deleteComments(final Plot plot) {
|
@Override public void deleteComments(final Plot plot) {
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, plot.getArea().toString());
|
statement.setString(1, plot.getArea().toString());
|
||||||
stmt.setInt(2, plot.hashCode());
|
statement.setInt(2, plot.hashCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1331,8 +1316,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot_ratings") {
|
addPlotTask(plot, new UniqueStatement("delete_plot_ratings") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1359,8 +1344,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
deleteComments(plot);
|
deleteComments(plot);
|
||||||
deleteRatings(plot);
|
deleteRatings(plot);
|
||||||
addPlotTask(plot, new UniqueStatement("delete_plot") {
|
addPlotTask(plot, new UniqueStatement("delete_plot") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getId(plot));
|
statement.setInt(1, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1381,8 +1366,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
"Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
"Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
||||||
+ plot.owner + " Index: " + id);
|
+ plot.owner + " Index: " + id);
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1685,8 +1670,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
time = System.currentTimeMillis() + id;
|
time = System.currentTimeMillis() + id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(),
|
Plot p = new Plot(plot_id, user, new HashSet<>(), new HashSet<>(),
|
||||||
new HashSet<UUID>(), "", null, null, null,
|
new HashSet<>(), "", null, null, null,
|
||||||
new boolean[] {false, false, false, false}, time, id);
|
new boolean[] {false, false, false, false}, time, id);
|
||||||
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
@ -1845,7 +1830,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Integer m = resultSet.getInt("merged");
|
int m = resultSet.getInt("merged");
|
||||||
boolean[] merged = new boolean[4];
|
boolean[] merged = new boolean[4];
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
merged[3 - i] = (m & 1 << i) != 0;
|
merged[3 - i] = (m & 1 << i) != 0;
|
||||||
@ -1878,13 +1863,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
if (StringMan
|
if (StringMan
|
||||||
.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
||||||
Flag flag = FlagManager.getOrCreateFlag(element);
|
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||||
if (flag == null) {
|
|
||||||
flag = new StringFlag(element) {
|
|
||||||
@Override public String getValueDescription() {
|
|
||||||
return "Generic Filler Flag";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
flags.put(flag, flag.parseValue(""));
|
flags.put(flag, flag.parseValue(""));
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.debug("INVALID FLAG: " + element);
|
PlotSquared.debug("INVALID FLAG: " + element);
|
||||||
@ -1936,10 +1914,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void setMerged(final Plot plot, final boolean[] merged) {
|
@Override public void setMerged(final Plot plot, final boolean[] merged) {
|
||||||
plot.getSettings().setMerged(merged);
|
plot.getSettings().setMerged(merged);
|
||||||
addPlotTask(plot, new UniqueStatement("setMerged") {
|
addPlotTask(plot, new UniqueStatement("setMerged") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
int hash = MainUtil.hash(merged);
|
int hash = MainUtil.hash(merged);
|
||||||
stmt.setInt(1, hash);
|
statement.setInt(1, hash);
|
||||||
stmt.setInt(2, getId(plot));
|
statement.setInt(2, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1956,10 +1934,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
final PlotId pos1 = plot1.getId();
|
final PlotId pos1 = plot1.getId();
|
||||||
final PlotId pos2 = plot2.getId();
|
final PlotId pos2 = plot2.getId();
|
||||||
addPlotTask(plot1, new UniqueStatement("swapPlots") {
|
addPlotTask(plot1, new UniqueStatement("swapPlots") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, pos2.x);
|
statement.setInt(1, pos2.x);
|
||||||
stmt.setInt(2, pos2.y);
|
statement.setInt(2, pos2.y);
|
||||||
stmt.setInt(3, id1);
|
statement.setInt(3, id1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1969,10 +1947,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
addPlotTask(plot2, new UniqueStatement("swapPlots") {
|
addPlotTask(plot2, new UniqueStatement("swapPlots") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, pos1.x);
|
statement.setInt(1, pos1.x);
|
||||||
stmt.setInt(2, pos1.y);
|
statement.setInt(2, pos1.y);
|
||||||
stmt.setInt(3, id2);
|
statement.setInt(3, id2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -1985,11 +1963,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void movePlot(final Plot original, final Plot newPlot) {
|
@Override public void movePlot(final Plot original, final Plot newPlot) {
|
||||||
addPlotTask(original, new UniqueStatement("movePlot") {
|
addPlotTask(original, new UniqueStatement("movePlot") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, newPlot.getId().x);
|
statement.setInt(1, newPlot.getId().x);
|
||||||
stmt.setInt(2, newPlot.getId().y);
|
statement.setInt(2, newPlot.getId().y);
|
||||||
stmt.setString(3, newPlot.getArea().toString());
|
statement.setString(3, newPlot.getArea().toString());
|
||||||
stmt.setInt(4, getId(original));
|
statement.setInt(4, getId(original));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2004,9 +1982,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void setFlags(final Plot plot, HashMap<Flag<?>, Object> flags) {
|
@Override public void setFlags(final Plot plot, HashMap<Flag<?>, Object> flags) {
|
||||||
final String flag_string = FlagManager.toString(flags);
|
final String flag_string = FlagManager.toString(flags);
|
||||||
addPlotTask(plot, new UniqueStatement("setFlags") {
|
addPlotTask(plot, new UniqueStatement("setFlags") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, flag_string);
|
statement.setString(1, flag_string);
|
||||||
stmt.setInt(2, getId(plot));
|
statement.setInt(2, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2019,9 +1997,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void setAlias(final Plot plot, final String alias) {
|
@Override public void setAlias(final Plot plot, final String alias) {
|
||||||
addPlotTask(plot, new UniqueStatement("setAlias") {
|
addPlotTask(plot, new UniqueStatement("setAlias") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, alias);
|
statement.setString(1, alias);
|
||||||
stmt.setInt(2, getId(plot));
|
statement.setInt(2, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2040,8 +2018,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
if (!uniqueIds.isEmpty()) {
|
if (!uniqueIds.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
ArrayList<Integer> uniqueIdsList = new ArrayList<Integer>(uniqueIds);
|
ArrayList<Integer> uniqueIdsList = new ArrayList<>(uniqueIds);
|
||||||
String stmt_prefix = "";
|
|
||||||
int size = uniqueIdsList.size();
|
int size = uniqueIdsList.size();
|
||||||
int packet = 990;
|
int packet = 990;
|
||||||
int amount = size / packet;
|
int amount = size / packet;
|
||||||
@ -2054,8 +2031,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
if (subList.isEmpty()) {
|
if (subList.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
StringBuilder idstr2 = new StringBuilder("");
|
StringBuilder idstr2 = new StringBuilder();
|
||||||
stmt_prefix = "";
|
String stmt_prefix = "";
|
||||||
for (Integer id : subList) {
|
for (Integer id : subList) {
|
||||||
idstr2.append(stmt_prefix).append(id);
|
idstr2.append(stmt_prefix).append(id);
|
||||||
stmt_prefix = " OR `id` = ";
|
stmt_prefix = " OR `id` = ";
|
||||||
@ -2105,8 +2082,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void purge(final PlotArea area, final Set<PlotId> plots) {
|
@Override public void purge(final PlotArea area, final Set<PlotId> plots) {
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> {
|
||||||
@Override public void run() {
|
|
||||||
try (PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
|
try (PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
|
||||||
"SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + SQLManager.this.prefix
|
"SELECT `id`, `plot_id_x`, `plot_id_z` FROM `" + SQLManager.this.prefix
|
||||||
+ "plot` WHERE `world` = ?")) {
|
+ "plot` WHERE `world` = ?")) {
|
||||||
@ -2133,15 +2109,14 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
PlotId id = new PlotId(plotId.x, plotId.y);
|
PlotId id = new PlotId(plotId.x, plotId.y);
|
||||||
area.removePlot(id);
|
area.removePlot(id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setPosition(final Plot plot, final String position) {
|
@Override public void setPosition(final Plot plot, final String position) {
|
||||||
addPlotTask(plot, new UniqueStatement("setPosition") {
|
addPlotTask(plot, new UniqueStatement("setPosition") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, position == null ? "" : position);
|
statement.setString(1, position == null ? "" : position);
|
||||||
stmt.setInt(2, getId(plot));
|
statement.setInt(2, getId(plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2407,8 +2382,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void delete(PlotCluster cluster) {
|
@Override public void delete(PlotCluster cluster) {
|
||||||
final int id = getClusterId(cluster);
|
final int id = getClusterId(cluster);
|
||||||
addClusterTask(cluster, new UniqueStatement("delete_cluster_settings") {
|
addClusterTask(cluster, new UniqueStatement("delete_cluster_settings") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2418,8 +2393,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
addClusterTask(cluster, new UniqueStatement("delete_cluster_helpers") {
|
addClusterTask(cluster, new UniqueStatement("delete_cluster_helpers") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2429,8 +2404,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
addClusterTask(cluster, new UniqueStatement("delete_cluster_invited") {
|
addClusterTask(cluster, new UniqueStatement("delete_cluster_invited") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2440,8 +2415,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
addClusterTask(cluster, new UniqueStatement("delete_cluster") {
|
addClusterTask(cluster, new UniqueStatement("delete_cluster") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2454,15 +2429,15 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void addPersistentMeta(final UUID uuid, final String key, final byte[] meta,
|
@Override public void addPersistentMeta(final UUID uuid, final String key, final byte[] meta,
|
||||||
final boolean replace) {
|
final boolean replace) {
|
||||||
addPlayerTask(uuid, new UniqueStatement("addPersistentMeta") {
|
addPlayerTask(uuid, new UniqueStatement("addPersistentMeta") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
if (replace) {
|
if (replace) {
|
||||||
stmt.setBytes(1, meta);
|
statement.setBytes(1, meta);
|
||||||
stmt.setString(2, uuid.toString());
|
statement.setString(2, uuid.toString());
|
||||||
stmt.setString(3, key);
|
statement.setString(3, key);
|
||||||
} else {
|
} else {
|
||||||
stmt.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
stmt.setString(2, key);
|
statement.setString(2, key);
|
||||||
stmt.setBytes(3, meta);
|
statement.setBytes(3, meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2482,9 +2457,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void removePersistentMeta(final UUID uuid, final String key) {
|
@Override public void removePersistentMeta(final UUID uuid, final String key) {
|
||||||
addPlayerTask(uuid, new UniqueStatement("removePersistentMeta") {
|
addPlayerTask(uuid, new UniqueStatement("removePersistentMeta") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
stmt.setString(2, key);
|
statement.setString(2, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2498,8 +2473,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override
|
@Override
|
||||||
public void getPersistentMeta(final UUID uuid, final RunnableVal<Map<String, byte[]>> result) {
|
public void getPersistentMeta(final UUID uuid, final RunnableVal<Map<String, byte[]>> result) {
|
||||||
addPlayerTask(uuid, new UniqueStatement("getPersistentMeta") {
|
addPlayerTask(uuid, new UniqueStatement("getPersistentMeta") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2523,11 +2498,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> result.run(metaMap));
|
||||||
@Override public void run() {
|
|
||||||
result.run(metaMap);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -2591,11 +2562,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
}
|
}
|
||||||
cluster = new PlotCluster(null, pos1, pos2, user, id);
|
cluster = new PlotCluster(null, pos1, pos2, user, id);
|
||||||
clusters.put(id, cluster);
|
clusters.put(id, cluster);
|
||||||
Set<PlotCluster> set = newClusters.get(areaid);
|
Set<PlotCluster> set = newClusters.computeIfAbsent(areaid, k -> new HashSet<>());
|
||||||
if (set == null) {
|
|
||||||
set = new HashSet<>();
|
|
||||||
newClusters.put(areaid, set);
|
|
||||||
}
|
|
||||||
set.add(cluster);
|
set.add(cluster);
|
||||||
}
|
}
|
||||||
//Getting helpers
|
//Getting helpers
|
||||||
@ -2693,9 +2660,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void setClusterName(final PlotCluster cluster, final String name) {
|
@Override public void setClusterName(final PlotCluster cluster, final String name) {
|
||||||
addClusterTask(cluster, new UniqueStatement("setClusterName") {
|
addClusterTask(cluster, new UniqueStatement("setClusterName") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, name);
|
statement.setString(1, name);
|
||||||
stmt.setInt(2, getClusterId(cluster));
|
statement.setInt(2, getClusterId(cluster));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2739,13 +2706,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void createCluster(final PlotCluster cluster) {
|
@Override public void createCluster(final PlotCluster cluster) {
|
||||||
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
|
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, cluster.getP1().x);
|
statement.setInt(1, cluster.getP1().x);
|
||||||
stmt.setInt(2, cluster.getP1().y);
|
statement.setInt(2, cluster.getP1().y);
|
||||||
stmt.setInt(3, cluster.getP2().x);
|
statement.setInt(3, cluster.getP2().x);
|
||||||
stmt.setInt(4, cluster.getP2().y);
|
statement.setInt(4, cluster.getP2().y);
|
||||||
stmt.setString(5, cluster.owner.toString());
|
statement.setString(5, cluster.owner.toString());
|
||||||
stmt.setString(6, cluster.area.toString());
|
statement.setString(6, cluster.area.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2767,9 +2734,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
});
|
});
|
||||||
addClusterTask(cluster,
|
addClusterTask(cluster,
|
||||||
new UniqueStatement("createCluster_settings_" + cluster.hashCode()) {
|
new UniqueStatement("createCluster_settings_" + cluster.hashCode()) {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, getClusterId(cluster));
|
statement.setInt(1, getClusterId(cluster));
|
||||||
stmt.setString(2, cluster.settings.getAlias());
|
statement.setString(2, cluster.settings.getAlias());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2787,12 +2754,12 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
current.setP2(max);
|
current.setP2(max);
|
||||||
|
|
||||||
addClusterTask(current, new UniqueStatement("resizeCluster") {
|
addClusterTask(current, new UniqueStatement("resizeCluster") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setInt(1, pos1.x);
|
statement.setInt(1, pos1.x);
|
||||||
stmt.setInt(2, pos1.y);
|
statement.setInt(2, pos1.y);
|
||||||
stmt.setInt(3, pos2.x);
|
statement.setInt(3, pos2.x);
|
||||||
stmt.setInt(4, pos2.y);
|
statement.setInt(4, pos2.y);
|
||||||
stmt.setInt(5, getClusterId(current));
|
statement.setInt(5, getClusterId(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -2805,9 +2772,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override public void setPosition(final PlotCluster cluster, final String position) {
|
@Override public void setPosition(final PlotCluster cluster, final String position) {
|
||||||
addClusterTask(cluster, new UniqueStatement("setPosition") {
|
addClusterTask(cluster, new UniqueStatement("setPosition") {
|
||||||
@Override public void set(PreparedStatement stmt) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
stmt.setString(1, position);
|
statement.setString(1, position);
|
||||||
stmt.setInt(2, getClusterId(cluster));
|
statement.setInt(2, getClusterId(cluster));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public PreparedStatement get() throws SQLException {
|
@Override public PreparedStatement get() throws SQLException {
|
||||||
@ -3008,8 +2975,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override
|
@Override
|
||||||
public void replaceWorld(final String oldWorld, final String newWorld, final PlotId min,
|
public void replaceWorld(final String oldWorld, final String newWorld, final PlotId min,
|
||||||
final PlotId max) {
|
final PlotId max) {
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> {
|
||||||
@Override public void run() {
|
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
try (PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
|
try (PreparedStatement stmt = SQLManager.this.connection.prepareStatement(
|
||||||
"UPDATE `" + SQLManager.this.prefix
|
"UPDATE `" + SQLManager.this.prefix
|
||||||
@ -3057,13 +3023,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void replaceUUID(final UUID old, final UUID now) {
|
@Override public void replaceUUID(final UUID old, final UUID now) {
|
||||||
addGlobalTask(new Runnable() {
|
addGlobalTask(() -> {
|
||||||
@Override public void run() {
|
|
||||||
try (Statement stmt = SQLManager.this.connection.createStatement()) {
|
try (Statement stmt = SQLManager.this.connection.createStatement()) {
|
||||||
stmt.executeUpdate(
|
stmt.executeUpdate(
|
||||||
"UPDATE `" + SQLManager.this.prefix + "cluster` SET `owner` = '" + now
|
"UPDATE `" + SQLManager.this.prefix + "cluster` SET `owner` = '" + now
|
||||||
@ -3089,7 +3053,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3120,7 +3083,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
public abstract PreparedStatement get() throws SQLException;
|
public abstract PreparedStatement get() throws SQLException;
|
||||||
|
|
||||||
public abstract void set(PreparedStatement stmt) throws SQLException;
|
public abstract void set(PreparedStatement statement) throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag Manager Utility.
|
* Flag Manager Utility.
|
||||||
@ -234,13 +235,9 @@ public class FlagManager {
|
|||||||
* @return a list of flags the specified player can use
|
* @return a list of flags the specified player can use
|
||||||
*/
|
*/
|
||||||
public static List<Flag> getFlags(PlotPlayer player) {
|
public static List<Flag> getFlags(PlotPlayer player) {
|
||||||
List<Flag> returnFlags = new ArrayList<>();
|
List<Flag> returnFlags = Flags.getFlags().stream().filter(flag -> Permissions
|
||||||
for (Flag flag : Flags.getFlags()) {
|
.hasPermission(player, "plots.set.flag." + flag.getName().toLowerCase()))
|
||||||
if (Permissions
|
.collect(Collectors.toList());
|
||||||
.hasPermission(player, "plots.set.flag." + flag.getName().toLowerCase())) {
|
|
||||||
returnFlags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnFlags;
|
return returnFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user