Package com.infernalsuite.aswm.api
Interface AdvancedSlimePaperAPI
public interface AdvancedSlimePaperAPI
Main class of the SWM API. From here, you can load
worlds and add them to the server's world list.
All methods are allowed to be called asynchronously unless specifically stated in the javadoc
All methods are allowed to be called asynchronously unless specifically stated in the javadoc
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateEmptyWorld
(String worldName, boolean readOnly, SlimePropertyMap propertyMap, @Nullable SlimeLoader loader) Creates an empty world.getLoadedWorld
(String worldName) Gets a world which has already been loaded by ASWM.Gets a list of worlds which have been loaded by ASWM.static AdvancedSlimePaperAPI
instance()
Gets the instance of the AdvancedSlimePaper API.loadWorld
(SlimeWorld world, boolean callWorldLoadEvent) Generates a Minecraft World from aSlimeWorld
and adds it to the server's world list.void
migrateWorld
(String worldName, SlimeLoader currentLoader, SlimeLoader newLoader) Migrates aSlimeWorld
to another datasource.readVanillaWorld
(File worldDir, String worldName, @Nullable SlimeLoader loader) Reads a vanilla world and converts it to SRF.readWorld
(SlimeLoader loader, String worldName, boolean readOnly, SlimePropertyMap propertyMap) Reads a world using a specifiedSlimeLoader
.void
saveWorld
(SlimeWorld world) Saves aSlimeWorld
into theSlimeLoader
obtained fromSlimeWorld.getLoader()
It is suggested to use this instead ofWorld.save()
, as this method will block the current thread until the world is savedboolean
worldLoaded
(SlimeWorld world) Checks if aSlimeWorld
is loaded on the server.
-
Method Details
-
readWorld
SlimeWorld readWorld(SlimeLoader loader, String worldName, boolean readOnly, SlimePropertyMap propertyMap) throws UnknownWorldException, IOException, CorruptedWorldException, NewerFormatException Reads a world using a specifiedSlimeLoader
. This world won't be loaded into the server's world list.- Parameters:
loader
-SlimeLoader
used to retrieve the world.worldName
- Name of the world.readOnly
- Whether read-only mode is enabled.propertyMap
- ASlimePropertyMap
object containing all the properties of the world.- Returns:
- A
SlimeWorld
, which is the in-memory representation of the world. - Throws:
UnknownWorldException
- if the world cannot be found.IOException
- if the world cannot be obtained from the specified data source.CorruptedWorldException
- if the world retrieved cannot be parsed into aSlimeWorld
object.NewerFormatException
- if the world uses a newer version of the SRF.
-
getLoadedWorld
Gets a world which has already been loaded by ASWM.- Parameters:
worldName
- the name of the world to get- Returns:
- the loaded world, or
null
if no loaded world matches the given name
-
getLoadedWorlds
List<SlimeWorld> getLoadedWorlds()Gets a list of worlds which have been loaded by ASWM. Note: The returned list is immutable, and encompasses a view of the loaded worlds at the time of the method call.- Returns:
- a list of worlds
-
loadWorld
Generates a Minecraft World from aSlimeWorld
and adds it to the server's world list.
This method must be called in sync with the Server Thread- Parameters:
world
-SlimeWorld
world to be added to the server's world listcallWorldLoadEvent
- Whether to callWorldLoadEvent
- Returns:
- Returns a slime world representing a live minecraft world
- Throws:
IllegalArgumentException
- if the world is already loaded
-
worldLoaded
Checks if aSlimeWorld
is loaded on the server.- Parameters:
world
- TheSlimeWorld
to check.- Returns:
true
if the world is loaded,false
otherwise.
-
saveWorld
Saves aSlimeWorld
into theSlimeLoader
obtained fromSlimeWorld.getLoader()
It is suggested to use this instead ofWorld.save()
, as this method will block the current thread until the world is saved- Parameters:
world
- TheSlimeWorld
to save.- Throws:
IOException
- if the world could not be saved.
-
migrateWorld
void migrateWorld(String worldName, SlimeLoader currentLoader, SlimeLoader newLoader) throws IOException, WorldAlreadyExistsException, UnknownWorldException Migrates aSlimeWorld
to another datasource.- Parameters:
worldName
- The name of the world to be migrated.currentLoader
- TheSlimeLoader
of the data source where the world is currently stored in.newLoader
- TheSlimeLoader
of the data source where the world will be moved to.- Throws:
IOException
- if the world could not be migrated.WorldAlreadyExistsException
- if a world with the same name already exists inside the new data source.UnknownWorldException
- if the world has been removed from the old data source.
-
createEmptyWorld
SlimeWorld createEmptyWorld(String worldName, boolean readOnly, SlimePropertyMap propertyMap, @Nullable @Nullable SlimeLoader loader) Creates an empty world.
This method does not load the world, nor save it to a datasource. UseloadWorld(SlimeWorld, boolean)
, andsaveWorld(SlimeWorld)
for that.- Parameters:
worldName
- Name of the world.readOnly
- Whether read-only mode is enabled.propertyMap
- ASlimePropertyMap
object containing all the properties of the world.loader
- TheSlimeLoader
used to store the world when it gets loaded, ornull
if the world is temporary.- Returns:
- A
SlimeWorld
, which is the in-memory representation of the world.
-
readVanillaWorld
SlimeWorld readVanillaWorld(File worldDir, String worldName, @Nullable @Nullable SlimeLoader loader) throws InvalidWorldException, WorldLoadedException, WorldTooBigException, IOException, WorldAlreadyExistsException Reads a vanilla world and converts it to SRF.
This method does not load the world, nor save it to a datasource. UseloadWorld(SlimeWorld, boolean)
, andsaveWorld(SlimeWorld)
for that.- Parameters:
worldDir
- The directory where the world is.worldName
- The name of the world.loader
- TheSlimeLoader
used to store the world when it gets loaded, ornull
if the world is temporary.- Returns:
- SlimeWorld to import
- Throws:
InvalidWorldException
- if the provided directory does not contain a valid world.WorldLoadedException
- if the world is loaded on the server.WorldTooBigException
- if the world is too big to be imported into the SRF.IOException
- if the world could not be read or stored.WorldAlreadyExistsException
-
instance
Gets the instance of the AdvancedSlimePaper API.- Returns:
- the instance of the AdvancedSlimePaper API
-