mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-09-07 01:08:40 +02:00
Fix plot automerging
This commit is contained in:
parent
f2d56ec231
commit
3bc3b51a27
@ -83,6 +83,11 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
public volatile Queue<Runnable> globalTasks;
|
||||
|
||||
/**
|
||||
* Notify tasks
|
||||
*/
|
||||
public volatile Queue<Runnable> notifyTasks;
|
||||
|
||||
/**
|
||||
* plot
|
||||
* plot_denied
|
||||
@ -107,6 +112,10 @@ public class SQLManager implements AbstractDB {
|
||||
return globalTasks;
|
||||
}
|
||||
|
||||
public synchronized Queue<Runnable> getNotifyTasks() {
|
||||
return notifyTasks;
|
||||
}
|
||||
|
||||
public synchronized void addPlotTask(Plot plot, UniqueStatement task) {
|
||||
if (plot == null) {
|
||||
plot = new Plot("", new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE), null);
|
||||
@ -151,6 +160,12 @@ public class SQLManager implements AbstractDB {
|
||||
getGlobalTasks().add(task);
|
||||
}
|
||||
|
||||
public synchronized void addNotifyTask(Runnable task) {
|
||||
if (task != null) {
|
||||
getNotifyTasks().add(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -166,6 +181,7 @@ public class SQLManager implements AbstractDB {
|
||||
this.connection = database.openConnection();
|
||||
this.MYSQL = (database instanceof MySQL);
|
||||
globalTasks = new ConcurrentLinkedQueue<>();
|
||||
notifyTasks = new ConcurrentLinkedQueue<>();
|
||||
plotTasks = new ConcurrentHashMap<>();
|
||||
clusterTasks = new ConcurrentHashMap<>();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@ -189,6 +205,12 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
if (!sendBatch()) {
|
||||
try {
|
||||
if (getNotifyTasks().size() > 0) {
|
||||
for (Runnable task : getNotifyTasks()) {
|
||||
TaskManager.runTask(task);
|
||||
}
|
||||
getNotifyTasks().clear();
|
||||
}
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
@ -936,6 +958,7 @@ public class SQLManager implements AbstractDB {
|
||||
return SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
||||
}
|
||||
});
|
||||
addNotifyTask(whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -859,6 +859,7 @@ public class MainUtil {
|
||||
if (count > 16) {
|
||||
break;
|
||||
}
|
||||
merge = false;
|
||||
count++;
|
||||
final PlotId bot = getBottomPlot(plot).id;
|
||||
final PlotId top = getTopPlot(plot).id;
|
||||
@ -898,10 +899,8 @@ public class MainUtil {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
merge = false;
|
||||
}
|
||||
for (PlotId id : toUpdate) {
|
||||
Plot update = getPlot(plot.world, id);
|
||||
DBFunc.setMerged(plot, plot.getSettings().getMerged());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user