mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 23:01:07 +00:00
MVC Fixes
This commit is contained in:
@@ -104,6 +104,7 @@ public class IrisSettings {
|
|||||||
public boolean verbose = false;
|
public boolean verbose = false;
|
||||||
public boolean ignoreWorldEdit = false;
|
public boolean ignoreWorldEdit = false;
|
||||||
public boolean disableNMS = false;
|
public boolean disableNMS = false;
|
||||||
|
public boolean keepProductionOnReload = false;
|
||||||
public boolean pluginMetrics = true;
|
public boolean pluginMetrics = true;
|
||||||
public boolean splashLogoStartup = true;
|
public boolean splashLogoStartup = true;
|
||||||
public String forceMainWorld = "";
|
public String forceMainWorld = "";
|
||||||
|
|||||||
@@ -73,15 +73,27 @@ public class StudioSVC implements IrisService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (IrisSettings.get().isStudio()) {
|
|
||||||
Iris.debug("Studio Mode Active: Closing Projects");
|
Iris.debug("Studio Mode Active: Closing Projects");
|
||||||
|
|
||||||
for (World i : Bukkit.getWorlds()) {
|
for (World i : Bukkit.getWorlds()) {
|
||||||
if (IrisToolbelt.isIrisWorld(i)) {
|
if (IrisToolbelt.isIrisWorld(i)) {
|
||||||
|
if(IrisToolbelt.isStudio(i))
|
||||||
|
{
|
||||||
IrisToolbelt.evacuate(i);
|
IrisToolbelt.evacuate(i);
|
||||||
Iris.debug("Closing Platform Generator " + i.getName());
|
|
||||||
IrisToolbelt.access(i).close();
|
IrisToolbelt.access(i).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!IrisSettings.get().getGeneral().isKeepProductionOnReload())
|
||||||
|
{
|
||||||
|
IrisToolbelt.evacuate(i);
|
||||||
|
IrisToolbelt.access(i).close();
|
||||||
|
Iris.error("You cannot reload Iris while production worlds are active!");
|
||||||
|
Iris.error("To prevent corrupted chunks, Iris is shutting the server down now!");
|
||||||
|
Bukkit.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,4 +189,12 @@ public class IrisToolbelt {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isStudio(World i) {
|
||||||
|
return isIrisWorld(i) && access(i).isStudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHeadless(World i) {
|
||||||
|
return isIrisWorld(i) && access(i).isHeadless();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.management.RuntimeErrorException;
|
import javax.management.RuntimeErrorException;
|
||||||
|
import javax.swing.text.TableView;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -58,7 +59,7 @@ import java.util.concurrent.Semaphore;
|
|||||||
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator {
|
public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChunkGenerator {
|
||||||
private static final int LOAD_LOCKS = 1_000_000;
|
private static final int LOAD_LOCKS = 1_000_000;
|
||||||
private final Semaphore loadLock;
|
private final Semaphore loadLock;
|
||||||
private final Engine engine;
|
private Engine engine;
|
||||||
private final IrisWorld world;
|
private final IrisWorld world;
|
||||||
private final File dataLocation;
|
private final File dataLocation;
|
||||||
private final String dimensionKey;
|
private final String dimensionKey;
|
||||||
@@ -67,9 +68,11 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
private final ChronoLatch hotloadChecker;
|
private final ChronoLatch hotloadChecker;
|
||||||
private final Looper hotloader;
|
private final Looper hotloader;
|
||||||
private final boolean studio;
|
private final boolean studio;
|
||||||
|
private long lastSeed;
|
||||||
|
|
||||||
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
||||||
populators = new KList<>();
|
populators = new KList<>();
|
||||||
|
lastSeed = world.seed();
|
||||||
loadLock = new Semaphore(LOAD_LOCKS);
|
loadLock = new Semaphore(LOAD_LOCKS);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.hotloadChecker = new ChronoLatch(1000, false);
|
this.hotloadChecker = new ChronoLatch(1000, false);
|
||||||
@@ -77,6 +80,23 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
this.dataLocation = dataLocation;
|
this.dataLocation = dataLocation;
|
||||||
this.dimensionKey = dimensionKey;
|
this.dimensionKey = dimensionKey;
|
||||||
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
|
this.folder = new ReactiveFolder(dataLocation, (_a, _b, _c) -> hotload());
|
||||||
|
setupEngine();
|
||||||
|
this.hotloader = new Looper() {
|
||||||
|
@Override
|
||||||
|
protected long loop() {
|
||||||
|
if (hotloadChecker.flip()) {
|
||||||
|
folder.check();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 250;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
hotloader.setPriority(Thread.MIN_PRIORITY);
|
||||||
|
hotloader.start();
|
||||||
|
hotloader.setName(getTarget().getWorld().name() + " Hotloader");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupEngine() {
|
||||||
IrisData data = IrisData.get(dataLocation);
|
IrisData data = IrisData.get(dataLocation);
|
||||||
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
|
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
|
||||||
|
|
||||||
@@ -114,21 +134,9 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
||||||
|
populators.clear();
|
||||||
populators.add((BlockPopulator) engine);
|
populators.add((BlockPopulator) engine);
|
||||||
this.hotloader = new Looper() {
|
|
||||||
@Override
|
|
||||||
protected long loop() {
|
|
||||||
if (hotloadChecker.flip()) {
|
|
||||||
folder.check();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 250;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
hotloader.setPriority(Thread.MIN_PRIORITY);
|
|
||||||
hotloader.start();
|
|
||||||
hotloader.setName(getTarget().getWorld().name() + " Hotloader");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -170,6 +178,15 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
||||||
try {
|
try {
|
||||||
|
if(lastSeed != world.getSeed())
|
||||||
|
{
|
||||||
|
Iris.warn("Seed for engine " + lastSeed + " does not match world seed if " + world.getSeed());
|
||||||
|
lastSeed = world.getSeed();
|
||||||
|
engine.getTarget().getWorld().seed(lastSeed);
|
||||||
|
engine.hotload();
|
||||||
|
Iris.success("Updated Engine seed to " + lastSeed);
|
||||||
|
}
|
||||||
|
|
||||||
loadLock.acquire();
|
loadLock.acquire();
|
||||||
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
||||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||||
@@ -183,6 +200,26 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch (WrongEngineBroException e)
|
||||||
|
{
|
||||||
|
Iris.warn("Trying to generate with a shut-down engine! Did you reload? Attempting to resolve this...");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
setupEngine();
|
||||||
|
Iris.success("Resolved! Should generate now!");
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable fe)
|
||||||
|
{
|
||||||
|
Iris.error("FATAL! Iris cannot generate in this world since it was reloaded! This will cause a crash, with missing chunks, so we're crashing right now!");
|
||||||
|
Bukkit.shutdown();
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return generateChunkData(world, ignored, x, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
loadLock.release();
|
loadLock.release();
|
||||||
Iris.error("======================================");
|
Iris.error("======================================");
|
||||||
|
|||||||
Reference in New Issue
Block a user