mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 11:39:07 +00:00
Headless pregen!
This commit is contained in:
@@ -19,9 +19,16 @@
|
||||
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.PregenTask;
|
||||
import com.volmit.iris.core.pregenerator.methods.HeadlessPregenMethod;
|
||||
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.object.IrisWorld;
|
||||
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||
import com.volmit.iris.util.decree.annotations.Decree;
|
||||
import com.volmit.iris.util.decree.annotations.Param;
|
||||
@@ -42,6 +49,8 @@ public class CommandPregen implements DecreeExecutor {
|
||||
World world,
|
||||
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
|
||||
Vector center,
|
||||
@Param(aliases = "headless", description = "Toggle headless pregeneration", defaultValue = "true")
|
||||
boolean headless,
|
||||
@Param(aliases = "gui", description = "Enable or disable the Iris GUI.", defaultValue = "true")
|
||||
boolean gui,
|
||||
@Param(aliases = "resetCache", description = "If it should reset the generated region cache", defaultValue = "false")
|
||||
@@ -55,6 +64,13 @@ public class CommandPregen implements DecreeExecutor {
|
||||
}
|
||||
radius = Math.max(radius, 1024);
|
||||
int w = (radius >> 9 + 1) * 2;
|
||||
|
||||
Engine engine = IrisToolbelt.access(world).getEngine();
|
||||
if(!engine.setEngineHeadless()) {
|
||||
Iris.error("Failed to enable headless engine!");
|
||||
return;
|
||||
}
|
||||
|
||||
IrisToolbelt.pregenerate(PregenTask
|
||||
.builder()
|
||||
.resetCache(resetCache)
|
||||
@@ -62,7 +78,9 @@ public class CommandPregen implements DecreeExecutor {
|
||||
.gui(!GraphicsEnvironment.isHeadless() && gui)
|
||||
.width(w)
|
||||
.height(w)
|
||||
.build(), world);
|
||||
.build(), headless ? new HeadlessPregenMethod(engine) : new HybridPregenMethod(engine.getWorld().realWorld(),
|
||||
IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getParallelism())), engine);
|
||||
if (headless) sender().sendMessage("Using the headless Pregenerator.");
|
||||
String msg = C.GREEN + "Pregen started in " + C.GOLD + world.getName() + C.GREEN + " of " + C.GOLD + (radius * 2) + C.GREEN + " by " + C.GOLD + (radius * 2) + C.GREEN + " blocks from " + C.GOLD + center.getX() + "," + center.getZ();
|
||||
sender().sendMessage(msg);
|
||||
Iris.info(msg);
|
||||
|
||||
@@ -53,7 +53,9 @@ import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Synchronized;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -93,6 +95,7 @@ public class IrisEngine implements Engine {
|
||||
private final ChronoLatch perSecondBudLatch;
|
||||
private final EngineMetrics metrics;
|
||||
private final boolean studio;
|
||||
private boolean headless;
|
||||
private final AtomicRollingSequence wallClock;
|
||||
private final int art;
|
||||
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
||||
@@ -487,8 +490,19 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
public boolean setEngineHeadless() {
|
||||
if(null != this.getWorld().realWorld()) {
|
||||
J.s(() -> Bukkit.unloadWorld(getWorld().realWorld().getName(), true));
|
||||
headless = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (headless) return;
|
||||
PregeneratorJob.shutdownInstance();
|
||||
closed = true;
|
||||
J.car(art);
|
||||
|
||||
@@ -160,6 +160,8 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
saveEngineData();
|
||||
}
|
||||
|
||||
boolean setEngineHeadless();
|
||||
|
||||
SeedManager getSeedManager();
|
||||
|
||||
void saveEngineData();
|
||||
|
||||
@@ -113,6 +113,8 @@ public class EngineMobHandlerSVC extends IrisEngineService implements IrisMobDat
|
||||
@Override
|
||||
public void onDisable(boolean hotload) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private class Ticker extends Looper {
|
||||
|
||||
Reference in New Issue
Block a user