mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixes #1504
This commit is contained in:
parent
da51be20a3
commit
c9cee8a4a8
@ -204,13 +204,10 @@ public abstract class HybridUtils {
|
|||||||
HybridUtils.area = area;
|
HybridUtils.area = area;
|
||||||
chunks = new HashSet<>();
|
chunks = new HashSet<>();
|
||||||
final AtomicInteger count = new AtomicInteger(0);
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
final long baseTime = System.currentTimeMillis();
|
|
||||||
final AtomicInteger last = new AtomicInteger();
|
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!UPDATE) {
|
if (!UPDATE) {
|
||||||
last.set(0);
|
|
||||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
ChunkLoc chunk = iter.next();
|
ChunkLoc chunk = iter.next();
|
||||||
@ -232,12 +229,10 @@ public abstract class HybridUtils {
|
|||||||
} else {
|
} else {
|
||||||
final Runnable task = this;
|
final Runnable task = this;
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
|
private long last = System.currentTimeMillis();
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (last.get() == 0) {
|
|
||||||
last.set((int) (System.currentTimeMillis() - baseTime));
|
|
||||||
}
|
|
||||||
if (chunks.size() < 1024) {
|
if (chunks.size() < 1024) {
|
||||||
if (!regions.isEmpty()) {
|
if (!regions.isEmpty()) {
|
||||||
Iterator<ChunkLoc> iterator = regions.iterator();
|
Iterator<ChunkLoc> iterator = regions.iterator();
|
||||||
@ -250,38 +245,18 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!chunks.isEmpty()) {
|
if (!chunks.isEmpty()) {
|
||||||
long diff = System.currentTimeMillis() + 1;
|
while (System.currentTimeMillis() < 10 && !chunks.isEmpty()) {
|
||||||
if (System.currentTimeMillis() - baseTime - last.get() > 2200 && last.get() != 0) {
|
|
||||||
last.set(0);
|
|
||||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
|
||||||
Iterator<ChunkLoc> iterator = chunks.iterator();
|
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||||
final ChunkLoc chunk = iterator.next();
|
final ChunkLoc chunk = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run(Object value) {
|
||||||
regenerateRoad(area, chunk, extend);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// DELAY TASK
|
|
||||||
TaskManager.runTaskLater(task, 600);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
|
|
||||||
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
|
|
||||||
Iterator<ChunkLoc> iterator = chunks.iterator();
|
|
||||||
final ChunkLoc chunk = iterator.next();
|
|
||||||
iterator.remove();
|
|
||||||
TaskManager.runTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
regenerateRoad(area, chunk, extend);
|
regenerateRoad(area, chunk, extend);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last.set((int) (System.currentTimeMillis() - baseTime));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iterator<ChunkLoc> iterator = regions.iterator();
|
Iterator<ChunkLoc> iterator = regions.iterator();
|
||||||
|
Loading…
Reference in New Issue
Block a user