mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-01-06 15:51:30 +00:00
Dev code + added maxcpm for lazy gen
This commit is contained in:
@@ -63,6 +63,7 @@ import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.Queue;
|
||||
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -145,6 +145,7 @@ public class IrisSettings {
|
||||
public boolean dynamicPerformanceMode = true;
|
||||
public boolean AggressiveTectonicUnload = false;
|
||||
public int AggressiveTectonicThreshold = -1; // -1 = Disabled and instead uses the tectonicLimit
|
||||
public int LazyPregenMaxCPM = -1; // -1 = no limit
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.core.commands;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||
@@ -78,12 +79,18 @@ public class CommandPregen implements DecreeExecutor {
|
||||
sender().sendMessage(C.RED + "The engine access for this world is null!");
|
||||
sender().sendMessage(C.RED + "Please make sure the world is loaded & the engine is initialized. Generate a new chunk, for example.");
|
||||
}
|
||||
int cpm = 0;
|
||||
if (IrisSettings.get().getPerformance().getLazyPregenMaxCPM() == -1) {
|
||||
cpm = 999999999;
|
||||
} else {
|
||||
cpm = IrisSettings.get().getPerformance().getLazyPregenMaxCPM();
|
||||
}
|
||||
|
||||
LazyPregenerator.LazyPregenJob pregenJob = LazyPregenerator.LazyPregenJob.builder()
|
||||
.world(worldName)
|
||||
.healingPosition(0)
|
||||
.healing(false)
|
||||
.chunksPerMinute(999999999)
|
||||
.chunksPerMinute(cpm)
|
||||
.radiusBlocks(radius)
|
||||
.position(0)
|
||||
.build();
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
@@ -140,9 +141,10 @@ public class LazyPregenerator extends Thread implements Listener {
|
||||
);
|
||||
}
|
||||
|
||||
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
private void tickGenerate(Position2 chunk) {
|
||||
BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(IrisSettings.get().getConcurrency().getParallelism()), lazyTotalChunks.get());
|
||||
burstExecutor.queue(() -> {
|
||||
executorService.submit(() -> {
|
||||
if (PaperLib.isPaper()) {
|
||||
PaperLib.getChunkAtAsync(world, chunk.getX(), chunk.getZ(), true).thenAccept((i) -> Iris.verbose("Generated Async " + chunk));
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.volmit.iris.core.safeguard;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.util.format.C;
|
||||
|
||||
public class IrisSafeguard {
|
||||
public static boolean unstablemode = false;
|
||||
|
||||
@@ -2,40 +2,42 @@ package com.volmit.iris.core.service;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.IrisWorld;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.misc.getHardware;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.scheduling.Looper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import static com.volmit.iris.util.mantle.Mantle.tectonicLimit;
|
||||
|
||||
public class DynamicPerformanceSVC implements IrisService {
|
||||
public class IrisEngineSVC implements IrisService {
|
||||
private JavaPlugin plugin;
|
||||
public Looper ticker;
|
||||
public Mantle mantle;
|
||||
public Engine engine;
|
||||
public final World IrisWorld = Bukkit.getWorld("test");
|
||||
// public Engine engine = IrisToolbelt.access(IrisWorld).getEngine();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.plugin = Iris.instance;
|
||||
if (IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
||||
this.startupPerformance();
|
||||
this.DynamicPerformance();
|
||||
this.IrisEngine();
|
||||
ticker.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void DynamicPerformance(){
|
||||
public void IrisEngine(){
|
||||
ticker = new Looper() {
|
||||
@Override
|
||||
protected long loop() {
|
||||
try {
|
||||
if (engine.getMantle().getTectonicLimit() < engine.getMantle().getLoadedRegionCount()){
|
||||
engine.getMantle().trim(5);
|
||||
return 2000;
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
@@ -57,6 +59,9 @@ public class DynamicPerformanceSVC implements IrisService {
|
||||
tectonicLimit.set(10);
|
||||
}
|
||||
}
|
||||
public void getAllIrisWorlds(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.volmit.iris.core.service;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import static java.lang.System.getLogger;
|
||||
|
||||
public class WorldLoadSFG implements IrisService {
|
||||
private JavaPlugin plugin;
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
World world = event.getWorld();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.plugin = Iris.instance;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user