9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-31 04:46:40 +00:00

Added setting option for ChunkHandler.java and no more random freezes.

This commit is contained in:
RePixelatedMC
2023-11-02 13:03:09 +01:00
parent d5b9a074e6
commit c22ccf71a7
3 changed files with 7 additions and 3 deletions

View File

@@ -459,7 +459,10 @@ public class Iris extends VolmitPlugin implements Listener {
configWatcher = new FileWatcher(getDataFile("settings.json"));
services.values().forEach(IrisService::onEnable);
services.values().forEach(this::registerListener);
chunkHandler = new ChunkHandler(this);
if(IrisSettings.get().getGeneral().useIntegratedChunkHandler) {
chunkHandler = new ChunkHandler(this);
Iris.info("Started Intergrated ChunkHandler");
}
J.s(() -> {
J.a(() -> PaperLib.suggestPaper(this));
J.a(() -> IO.delete(getTemp()));

View File

@@ -23,6 +23,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class ChunkHandler implements Listener {
// Idk how it works but it works lol
private final JavaPlugin plugin;
private static BukkitTask task;
private final Map<World, ChunkUnloader> worlds = new ConcurrentHashMap<>();
@@ -153,10 +154,9 @@ public class ChunkHandler implements Listener {
private void unloadChunk(Chunk chunk) {
try {
System.out.printf("%s > Unloading Chunk [x=%s, z=%s]%n", world.getName(), chunk.getX(), chunk.getZ());
// System.out.printf("%s > Unloading Chunk [x=%s, z=%s]%n", world.getName(), chunk.getX(), chunk.getZ());
Bukkit.getScheduler().runTask(plugin, () -> chunk.unload(true));
} catch (Exception e) {
// Log the error message
System.out.println("Error unloading chunk: " + e.getMessage());
}
}

View File

@@ -146,6 +146,7 @@ public class IrisSettings {
@Data
public static class IrisSettingsGeneral {
public boolean bootUnstable = false;
public boolean useIntegratedChunkHandler = false;
public boolean commandSounds = true;
public boolean debug = false;
public boolean disableNMS = false;