mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-17 06:11:06 +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.Queue;
|
||||||
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ public class IrisSettings {
|
|||||||
public boolean dynamicPerformanceMode = true;
|
public boolean dynamicPerformanceMode = true;
|
||||||
public boolean AggressiveTectonicUnload = false;
|
public boolean AggressiveTectonicUnload = false;
|
||||||
public int AggressiveTectonicThreshold = -1; // -1 = Disabled and instead uses the tectonicLimit
|
public int AggressiveTectonicThreshold = -1; // -1 = Disabled and instead uses the tectonicLimit
|
||||||
|
public int LazyPregenMaxCPM = -1; // -1 = no limit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package com.volmit.iris.core.commands;
|
package com.volmit.iris.core.commands;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||||
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
import com.volmit.iris.core.pregenerator.LazyPregenerator;
|
||||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
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 + "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.");
|
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()
|
LazyPregenerator.LazyPregenJob pregenJob = LazyPregenerator.LazyPregenJob.builder()
|
||||||
.world(worldName)
|
.world(worldName)
|
||||||
.healingPosition(0)
|
.healingPosition(0)
|
||||||
.healing(false)
|
.healing(false)
|
||||||
.chunksPerMinute(999999999)
|
.chunksPerMinute(cpm)
|
||||||
.radiusBlocks(radius)
|
.radiusBlocks(radius)
|
||||||
.position(0)
|
.position(0)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
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) {
|
private void tickGenerate(Position2 chunk) {
|
||||||
BurstExecutor burstExecutor = new BurstExecutor(Executors.newFixedThreadPool(IrisSettings.get().getConcurrency().getParallelism()), lazyTotalChunks.get());
|
executorService.submit(() -> {
|
||||||
burstExecutor.queue(() -> {
|
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
PaperLib.getChunkAtAsync(world, chunk.getX(), chunk.getZ(), true).thenAccept((i) -> Iris.verbose("Generated Async " + chunk));
|
PaperLib.getChunkAtAsync(world, chunk.getX(), chunk.getZ(), true).thenAccept((i) -> Iris.verbose("Generated Async " + chunk));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.volmit.iris.core.safeguard;
|
package com.volmit.iris.core.safeguard;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
|
||||||
import com.volmit.iris.util.format.C;
|
|
||||||
|
|
||||||
public class IrisSafeguard {
|
public class IrisSafeguard {
|
||||||
public static boolean unstablemode = false;
|
public static boolean unstablemode = false;
|
||||||
|
|||||||
+13
-8
@@ -2,40 +2,42 @@ package com.volmit.iris.core.service;
|
|||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
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.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.object.IrisWorld;
|
||||||
import com.volmit.iris.util.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
import com.volmit.iris.util.misc.getHardware;
|
import com.volmit.iris.util.misc.getHardware;
|
||||||
import com.volmit.iris.util.plugin.IrisService;
|
import com.volmit.iris.util.plugin.IrisService;
|
||||||
import com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import static com.volmit.iris.util.mantle.Mantle.tectonicLimit;
|
import static com.volmit.iris.util.mantle.Mantle.tectonicLimit;
|
||||||
|
|
||||||
public class DynamicPerformanceSVC implements IrisService {
|
public class IrisEngineSVC implements IrisService {
|
||||||
private JavaPlugin plugin;
|
private JavaPlugin plugin;
|
||||||
public Looper ticker;
|
public Looper ticker;
|
||||||
public Mantle mantle;
|
public Mantle mantle;
|
||||||
public Engine engine;
|
public final World IrisWorld = Bukkit.getWorld("test");
|
||||||
|
// public Engine engine = IrisToolbelt.access(IrisWorld).getEngine();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.plugin = Iris.instance;
|
this.plugin = Iris.instance;
|
||||||
if (IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
if (IrisSettings.get().getPerformance().dynamicPerformanceMode) {
|
||||||
this.startupPerformance();
|
this.startupPerformance();
|
||||||
this.DynamicPerformance();
|
this.IrisEngine();
|
||||||
ticker.start();
|
ticker.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DynamicPerformance(){
|
public void IrisEngine(){
|
||||||
ticker = new Looper() {
|
ticker = new Looper() {
|
||||||
@Override
|
@Override
|
||||||
protected long loop() {
|
protected long loop() {
|
||||||
try {
|
try {
|
||||||
if (engine.getMantle().getTectonicLimit() < engine.getMantle().getLoadedRegionCount()){
|
|
||||||
engine.getMantle().trim(5);
|
|
||||||
return 2000;
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -57,6 +59,9 @@ public class DynamicPerformanceSVC implements IrisService {
|
|||||||
tectonicLimit.set(10);
|
tectonicLimit.set(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void getAllIrisWorlds(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
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