mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-21 23:50:13 +00:00
Headless pregen!
This commit is contained in:
@@ -19,9 +19,16 @@
|
|||||||
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.PregenTask;
|
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.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.DecreeExecutor;
|
||||||
import com.volmit.iris.util.decree.annotations.Decree;
|
import com.volmit.iris.util.decree.annotations.Decree;
|
||||||
import com.volmit.iris.util.decree.annotations.Param;
|
import com.volmit.iris.util.decree.annotations.Param;
|
||||||
@@ -42,6 +49,8 @@ public class CommandPregen implements DecreeExecutor {
|
|||||||
World world,
|
World world,
|
||||||
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
|
@Param(aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
|
||||||
Vector center,
|
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")
|
@Param(aliases = "gui", description = "Enable or disable the Iris GUI.", defaultValue = "true")
|
||||||
boolean gui,
|
boolean gui,
|
||||||
@Param(aliases = "resetCache", description = "If it should reset the generated region cache", defaultValue = "false")
|
@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);
|
radius = Math.max(radius, 1024);
|
||||||
int w = (radius >> 9 + 1) * 2;
|
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
|
IrisToolbelt.pregenerate(PregenTask
|
||||||
.builder()
|
.builder()
|
||||||
.resetCache(resetCache)
|
.resetCache(resetCache)
|
||||||
@@ -62,7 +78,9 @@ public class CommandPregen implements DecreeExecutor {
|
|||||||
.gui(!GraphicsEnvironment.isHeadless() && gui)
|
.gui(!GraphicsEnvironment.isHeadless() && gui)
|
||||||
.width(w)
|
.width(w)
|
||||||
.height(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();
|
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);
|
sender().sendMessage(msg);
|
||||||
Iris.info(msg);
|
Iris.info(msg);
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ import com.volmit.iris.util.scheduling.J;
|
|||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Synchronized;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@@ -93,6 +95,7 @@ public class IrisEngine implements Engine {
|
|||||||
private final ChronoLatch perSecondBudLatch;
|
private final ChronoLatch perSecondBudLatch;
|
||||||
private final EngineMetrics metrics;
|
private final EngineMetrics metrics;
|
||||||
private final boolean studio;
|
private final boolean studio;
|
||||||
|
private boolean headless;
|
||||||
private final AtomicRollingSequence wallClock;
|
private final AtomicRollingSequence wallClock;
|
||||||
private final int art;
|
private final int art;
|
||||||
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
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
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if (headless) return;
|
||||||
PregeneratorJob.shutdownInstance();
|
PregeneratorJob.shutdownInstance();
|
||||||
closed = true;
|
closed = true;
|
||||||
J.car(art);
|
J.car(art);
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
saveEngineData();
|
saveEngineData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean setEngineHeadless();
|
||||||
|
|
||||||
SeedManager getSeedManager();
|
SeedManager getSeedManager();
|
||||||
|
|
||||||
void saveEngineData();
|
void saveEngineData();
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ public class EngineMobHandlerSVC extends IrisEngineService implements IrisMobDat
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable(boolean hotload) {
|
public void onDisable(boolean hotload) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Ticker extends Looper {
|
private class Ticker extends Looper {
|
||||||
|
|||||||
Reference in New Issue
Block a user