GWorld API - Gilljan/GWorld GitHub Wiki

GWorld API

Manage worlds easily and quickly!

Introduction

In the following article I will explain how you can use the GWorld API easily and quickly.

First steps

//Most important imports for you!
import de.gilljan.gworld.api.GWorldAPI;
//New GWorldAPI for your world
GWorldAPI api = new GWorldAPI("Your world");

Create world
api.create(GWorldAPI.WorldType.NORMAL);
api.create(
        GWorldAPI.WorldType.NORMAL,
        -9874561L /*Seed can also be null*/,
        "your generator" /*generator null if not needed*/
);
//Rebuild the world based on the seed and the generator 
//Recreate the old world.
api.reCreate(saveOldWorld /*boolean*/);
Delete world
api.delete();
Clone world
api.clone("name of new world");
World import
api.importExisting(
GWorldAPI.WorldType.NORMAL, 
"your generator" /*generator null if not needed*/
);
api.importExisting(GWorldAPI.WorldType.NORMAL);

//query if the world is already imported
api.isImported();
Load/Unload world
//load world
api.load();

//unload world
api.unload();

//query whether the world is loaded
api.isLoaded();
Enable/Disable automatic loading of the world
api.setAutoLoad(autoLoad /*boolean*/);

//query whether the world is loaded automatically
api.isAutoLoad();
Flags
Getter
boolean#api.isPvp(); //Get true if PvP is enabled
boolean#api.isMobSpawning(); //Get true if monster spawning is enabled
boolean#api.isAnimalSpawning(); //Returns true if spawning of Animals is active
boolean#api.isDayNightCycle(); //Get true if DayNightCycle is active
boolean#api.isForceGameMode(); //Get true if a certain GameMode is forced on the world
boolean#api.isWeatherCycle(); //Get true if weather change is active on the world
GWorldAPI.WeatherType#api.getDefaultWeather(); //Returns the set weather type of the world
long#api.getDefaultTime(); //Get the set default time of the world
GWorldAPI.Gamemode#api.getDefaultGamemode(); //Get the set GWorld gamemode
GWorldAPI.Difficulty#api.getDifficulty(); //Returns the set GWorld difficulty
Setter
api.setPvp(enablePvp /*boolean*/); //Activate/Disable PvP on a world
api.setMobSpawning(enableMobSpawning /*boolean*/); //Activate/Disable MobSpawning on a world
api.setAnimalSpawning(enableAnimalSpawning /*boolean*/); //Activate/Disable MobSpawning on a world
api.setWeatherCycle(enableWeatherCycle /*boolean*/); //Activate/Disable changing weather on a world
api.setForceGamemode(enableForceGamemode /*boolean*/): //Activate/Disable forcing a GameMode on a world
api.setDayNightCycle(enableDayNightCycle /*boolean*/); //Activate/Disable day and night cycling
api.setDefaultWeather(GWorldAPI.WeatherType.SUN); //Set the normal weather for a world
api.setDefaultTime(defaultTime /*long*/); //Set the normal time on a world
api.setDifficulty(GWorldAPI.Difficulty.EASY); //Set the difficulty on a world

It is important to save the changes. Use

api.save();
Simple Getter
String#api.getName(); //Returns the name of the world
Long#api.getSeed(); //Get the seed of the world
String#api.getGenerator(); //Get the generator of the world
GWorldAPI.WorldType#api.getType(); //Returns the GWorld type
org.bukkit.World#api.getBukkitWorld(); //Returns the bukkit world