From 4dd10489948da62110596003cda04e0e2fcb1678 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Tue, 22 Nov 2016 22:54:36 -0500 Subject: [PATCH] Created methods that load and unload chunks --- .../ChunkLoaderAPI.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/iieLoadSaveEntireWorld/ChunkLoaderAPI.java b/src/iieLoadSaveEntireWorld/ChunkLoaderAPI.java index e47b37c..0a0fd58 100644 --- a/src/iieLoadSaveEntireWorld/ChunkLoaderAPI.java +++ b/src/iieLoadSaveEntireWorld/ChunkLoaderAPI.java @@ -1,5 +1,31 @@ package iieLoadSaveEntireWorld; +import org.bukkit.Location; + public class ChunkLoaderAPI { + /**This method loads a chunk if the chunk isn't loaded already. + * @param locationToLoad + * @return True if chunk was already loaded, False if chunk wasn't already loaded + */ + public static boolean loadChunk(Location locationToLoad){ + if(!(locationToLoad.getBlock().getChunk().isLoaded())){ + locationToLoad.getBlock().getChunk().load(); + return true; + } + return false; + } + + + /**This method loads a chunk if the chunk isn't loaded already. + * @param locationToLoad + * @return True if chunk was already unloaded, False if chunk wasn't already unloaded + */ + public static boolean unloadChunk(Location locationToUnload){ + if (locationToUnload.getBlock().getChunk().isLoaded()){ + locationToUnload.getBlock().getChunk().unload(); + return false; + } + return true; + } }