Created methods that load and unload chunks

This commit is contained in:
alisolarflare 2016-11-22 22:54:36 -05:00
parent ddb27a4752
commit 4dd1048994

View file

@ -1,5 +1,31 @@
package iieLoadSaveEntireWorld; package iieLoadSaveEntireWorld;
import org.bukkit.Location;
public class ChunkLoaderAPI { 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;
}
} }