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