Is there an easy way to prevent chunks from unloading? I've tried cancelling the ChunkUnloadEvent but that does nothing. If there is no easy way to do this is there a working plugin for 1.8 that does it? Cheers.
Here is what I do, Code: // force load all of our chunks for (int x = -68; x <= -56; x++) { for (int z = 55; z <= 68; z++) { Main.world.loadChunk(x, z, true); Main.world.getChunkAt(x, z).setForceLoaded(true); } } Everyone says its dangerous though because it will lag the server quite a bit. My server is just a small minigame server though so it doesn't matter much for me.
@Coopah From reading the javadocs, it seems the ChunkUnloadEvent is called after the chunk is unloaded, so try this: Code:Java @EventHandlerprivate void onUnload(ChunkUnloadEvent event) { Chunk chunk = event.getChunk(); chunk.setForceLoaded(true); // I'm not sure if this is needed // First try without it, then if it doesn't work, try with it //chunk.load();}
@Yeowza @KarimAKL There is no method for setForceLoaded ? I am using 1.8.9 and all I get is chunk.load(); not chunk.setForceLoaded();
@Coopah Ah, my bad, i didn't check the docs for 1.8. Try the code i sent, but with "chunk.load()" instead of "chunk.setForceLoaded(true)".
@Coopah Ah, that's too bad. Try looking into some of the NMS source to see if you can find any way to do it in 1.8. I'd recommend first looking at some NMS where the setForceLoaded(boolean) method is there, see how it works, and then see if it's possible to do it in NMS 1.8. I checked a little for 1.14.4, it seems the setForceLoaded method is in the "WorldServer" class, and it seems to use the following classes to do it: - "ForcedChunk" - "WorldPersistentData" - "ChunkProviderServer"