mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Make plot clears/sets less crashy.
There's still the issue of Spigot's (or paper's) terrible GC that does nothing and stores everything in PS old gen memory so the server just numpties itself though.
This commit is contained in:
parent
d5d18a60fb
commit
7aba70ea65
@ -31,6 +31,7 @@ import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.queue.BasicLocalBlockQueue;
|
||||
import com.plotsquared.core.util.BlockUtil;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -50,7 +51,6 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.BlockInventoryHolder;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
@ -117,9 +117,6 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
||||
@Override public final void setComponents(LocalChunk lc)
|
||||
throws ExecutionException, InterruptedException {
|
||||
setBaseBlocks(lc);
|
||||
if (setBiome() && lc.biomes != null) {
|
||||
setBiomes(lc);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBaseBlocks(LocalChunk localChunk) {
|
||||
@ -165,6 +162,22 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (setBiome() && localChunk.biomes != null) {
|
||||
for (int x = 0; x < localChunk.biomes.length; x++) {
|
||||
BiomeType[] biomeZ = localChunk.biomes[x];
|
||||
if (biomeZ != null) {
|
||||
for (int z = 0; z < biomeZ.length; z++) {
|
||||
if (biomeZ[z] != null) {
|
||||
BiomeType biomeType = biomeZ[z];
|
||||
|
||||
Biome biome = BukkitAdapter.adapt(biomeType);
|
||||
worldObj.setBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z,
|
||||
biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (isForceSync()) {
|
||||
chunkConsumer.accept(getChunk(worldObj, localChunk));
|
||||
|
@ -270,7 +270,7 @@ public class PlotSquared {
|
||||
// create setup util class
|
||||
SetupUtils.manager = this.IMP.initSetupUtils();
|
||||
// Set block
|
||||
GlobalBlockQueue.IMP = new GlobalBlockQueue(IMP.initBlockQueue(), 1);
|
||||
GlobalBlockQueue.IMP = new GlobalBlockQueue(IMP.initBlockQueue(), 1, Settings.QUEUE.TARGET_TIME);
|
||||
GlobalBlockQueue.IMP.runTask();
|
||||
// Set chunk
|
||||
ChunkManager.manager = this.IMP.initChunkManager();
|
||||
|
@ -489,6 +489,13 @@ public class Settings extends Config {
|
||||
public static boolean TILE_ENTITY_CHECK = true;
|
||||
}
|
||||
|
||||
@Comment("Settings relating to PlotSquared's GlobalBlockQueue")
|
||||
public static final class QUEUE {
|
||||
@Comment({"Average time per tick spent completing chunk tasks in ms. Target average TPS = 20 * 50 / TARGET_TIME.",
|
||||
"Waits (chunk task time / target_time) ticks before completely the next task."})
|
||||
public static int TARGET_TIME = 65;
|
||||
}
|
||||
|
||||
|
||||
@Comment({"Enable or disable parts of the plugin",
|
||||
"Note: A cache will use some memory if enabled"})
|
||||
|
@ -44,8 +44,8 @@ public class GlobalBlockQueue {
|
||||
private final ConcurrentLinkedDeque<LocalBlockQueue> inactiveQueues;
|
||||
private final ConcurrentLinkedDeque<Runnable> runnables;
|
||||
private final AtomicBoolean running;
|
||||
private final int targetTime;
|
||||
private QueueProvider provider;
|
||||
|
||||
/**
|
||||
* Used to calculate elapsed time in milliseconds and ensure block placement doesn't lag the
|
||||
* server
|
||||
@ -53,6 +53,7 @@ public class GlobalBlockQueue {
|
||||
private long last;
|
||||
private long secondLast;
|
||||
private long lastSuccess;
|
||||
private double lastPeriod = 0;
|
||||
private final RunnableVal2<Long, LocalBlockQueue> SET_TASK =
|
||||
new RunnableVal2<Long, LocalBlockQueue>() {
|
||||
@Override public void run(Long free, LocalBlockQueue queue) {
|
||||
@ -65,17 +66,19 @@ public class GlobalBlockQueue {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} while (((GlobalBlockQueue.this.secondLast = System.currentTimeMillis())
|
||||
- GlobalBlockQueue.this.last) < free);
|
||||
} while ((lastPeriod =
|
||||
((GlobalBlockQueue.this.secondLast = System.currentTimeMillis())
|
||||
- GlobalBlockQueue.this.last)) < free);
|
||||
}
|
||||
};
|
||||
|
||||
public GlobalBlockQueue(QueueProvider provider, int threads) {
|
||||
public GlobalBlockQueue(QueueProvider provider, int threads, int targetTime) {
|
||||
this.provider = provider;
|
||||
this.activeQueues = new ConcurrentLinkedDeque<>();
|
||||
this.inactiveQueues = new ConcurrentLinkedDeque<>();
|
||||
this.runnables = new ConcurrentLinkedDeque<>();
|
||||
this.running = new AtomicBoolean();
|
||||
this.targetTime = targetTime;
|
||||
this.PARALLEL_THREADS = threads;
|
||||
}
|
||||
|
||||
@ -112,9 +115,15 @@ public class GlobalBlockQueue {
|
||||
@Override public void run() {
|
||||
if (inactiveQueues.isEmpty() && activeQueues.isEmpty()) {
|
||||
lastSuccess = System.currentTimeMillis();
|
||||
lastPeriod = 0;
|
||||
GlobalBlockQueue.this.runEmptyTasks();
|
||||
return;
|
||||
}
|
||||
// Server laggy? Skip.
|
||||
if (lastPeriod > targetTime) {
|
||||
lastPeriod -= targetTime;
|
||||
return;
|
||||
}
|
||||
SET_TASK.value1 = 50 + Math.min(
|
||||
(50 + GlobalBlockQueue.this.last) - (GlobalBlockQueue.this.last =
|
||||
System.currentTimeMillis()),
|
||||
|
Loading…
Reference in New Issue
Block a user