mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
add the shutdown hook on plugin enable instead of disable to prevent issues
This commit is contained in:
@@ -96,6 +96,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
public static IrisCompat compat;
|
||||
public static FileWatcher configWatcher;
|
||||
private static VolmitSender sender;
|
||||
private static Thread shutdownHook;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -453,6 +454,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||
services.values().forEach(IrisService::onEnable);
|
||||
services.values().forEach(this::registerListener);
|
||||
addShutdownHook();
|
||||
J.s(() -> {
|
||||
J.a(IrisSafeguard::suggestPaper);
|
||||
J.a(() -> IO.delete(getTemp()));
|
||||
@@ -471,6 +473,23 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
public void addShutdownHook() {
|
||||
if (shutdownHook != null) {
|
||||
Runtime.getRuntime().removeShutdownHook(shutdownHook);
|
||||
}
|
||||
shutdownHook = new Thread(() -> {
|
||||
Bukkit.getWorlds()
|
||||
.stream()
|
||||
.map(IrisToolbelt::access)
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(PlatformChunkGenerator::close);
|
||||
|
||||
MultiBurst.burst.close();
|
||||
services.clear();
|
||||
});
|
||||
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
||||
}
|
||||
|
||||
public void checkForBukkitWorlds(Predicate<String> filter) {
|
||||
try {
|
||||
IrisWorlds.readBukkitWorlds().forEach((s, generator) -> {
|
||||
@@ -548,16 +567,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
super.onDisable();
|
||||
|
||||
J.attempt(new JarScanner(instance.getJarFile(), "", false)::scan);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
Bukkit.getWorlds()
|
||||
.stream()
|
||||
.map(IrisToolbelt::access)
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(PlatformChunkGenerator::close);
|
||||
|
||||
MultiBurst.burst.close();
|
||||
services.clear();
|
||||
}));
|
||||
}
|
||||
|
||||
private void setupPapi() {
|
||||
|
||||
@@ -244,7 +244,12 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
return;
|
||||
}
|
||||
|
||||
getMantle().iterateChunk(x, z, t, blocks::set);
|
||||
var chunk = getMantle().getChunk(x, z).use();
|
||||
try {
|
||||
chunk.iterate(t, blocks::set);
|
||||
} finally {
|
||||
chunk.release();
|
||||
}
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
|
||||
Reference in New Issue
Block a user