Package com.infernalsuite.aswm.api
Interface SlimePlugin
public interface SlimePlugin
Main class of the SWM API. From here, you can load
worlds and add them to the server's world list, and
also add your own implementations of the
SlimeLoader
interface, to load and store worlds from other data sources.-
Method Summary
Modifier and TypeMethodDescriptioncreateEmptyWorld
(SlimeLoader loader, String worldName, boolean readOnly, SlimePropertyMap propertyMap) Creates an empty world and stores it using a specifiedSlimeLoader
.Gets a list of worlds which have been loaded by ASWM.Returns theSlimeLoader
that is able to read and store worlds from a specified data source.Gets a world which has already been loaded by ASWM.importVanillaWorld
(File worldDir, String worldName, SlimeLoader loader) Imports a world into the SRF and saves it in a data source.void
importWorld
(File worldDir, String worldName, SlimeLoader loader) Imports a world into the SRF and saves it in a data source.loadWorld
(SlimeLoader loader, String worldName, boolean readOnly, SlimePropertyMap propertyMap) Loads a world using a specificiedSlimeLoader
.default SlimeWorld
loadWorld
(SlimeWorld world) Generates a Minecraft World from aSlimeWorld
and adds it to the server's world list.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.void
registerLoader
(String dataSource, SlimeLoader loader) Registers a customSlimeLoader
.
-
Method Details
-
loadWorld
SlimeWorld loadWorld(SlimeLoader loader, String worldName, boolean readOnly, SlimePropertyMap propertyMap) throws UnknownWorldException, IOException, CorruptedWorldException, NewerFormatException, WorldLockedException Loads a world using a specificiedSlimeLoader
. This world can then be added to the server's world list by using theloadWorld(SlimeWorld)
method.- Parameters:
loader
-SlimeLoader
used to retrieve the world.worldName
- Name of the world.readOnly
- Whether or not 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 speficied data source.CorruptedWorldException
- if the world retrieved cannot be parsed into aSlimeWorld
object.NewerFormatException
- if the world uses a newer version of the SRF.WorldLockedException
- if the world is already being used on another server when trying to open it without read-only mode enabled.
-
getWorld
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
-
createEmptyWorld
SlimeWorld createEmptyWorld(SlimeLoader loader, String worldName, boolean readOnly, SlimePropertyMap propertyMap) throws WorldAlreadyExistsException, IOException Creates an empty world and stores it using a specifiedSlimeLoader
. This world can then be added to the server's world list by using theloadWorld(SlimeWorld)
method.- Parameters:
loader
-SlimeLoader
used to store the world.worldName
- Name of the world.readOnly
- Whether or not 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:
WorldAlreadyExistsException
- if the provided data source already contains a world with the same name.IOException
- if the world could not be stored.
-
loadWorld
default SlimeWorld loadWorld(SlimeWorld world) throws UnknownWorldException, WorldLockedException, IOException Generates a Minecraft World from aSlimeWorld
and adds it to the server's world list.- Parameters:
world
-SlimeWorld
world to be added to the server's world list- Returns:
- Returns a slime world representing a live minecraft world
- Throws:
UnknownWorldException
WorldLockedException
IOException
-
loadWorld
SlimeWorld loadWorld(SlimeWorld world, boolean callWorldLoadEvent) throws UnknownWorldException, WorldLockedException, IOException Generates a Minecraft World from aSlimeWorld
and adds it to the server's world list.- Parameters:
world
-SlimeWorld
world to be added to the server's world listcallWorldLoadEvent
- Whether or not to callWorldLoadEvent
- Returns:
- Returns a slime world representing a live minecraft world
- Throws:
UnknownWorldException
WorldLockedException
IOException
-
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.
-
getLoader
Returns theSlimeLoader
that is able to read and store worlds from a specified data source.- Parameters:
dataSource
-String
containing the data source.- Returns:
- The
SlimeLoader
capable of reading and writing to the data source.
-
registerLoader
Registers a customSlimeLoader
. This loader can then be used by Slime World Manager to load and store worlds.- Parameters:
dataSource
- The data source this loader is capable of reading and writing to.loader
- TheSlimeLoader
that is going to be registered.
-
importWorld
void importWorld(File worldDir, String worldName, SlimeLoader loader) throws WorldAlreadyExistsException, InvalidWorldException, WorldLoadedException, WorldTooBigException, IOException Imports a world into the SRF and saves it in a data source.- Parameters:
worldDir
- The directory where the world is.worldName
- The name of the world.loader
- TheSlimeLoader
that will be used to store the world.- Throws:
WorldAlreadyExistsException
- if the data source already contains a world with the same name.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.
-
importVanillaWorld
SlimeWorld importVanillaWorld(File worldDir, String worldName, SlimeLoader loader) throws WorldAlreadyExistsException, InvalidWorldException, WorldLoadedException, WorldTooBigException, IOException Imports a world into the SRF and saves it in a data source.- Parameters:
worldDir
- The directory where the world is.worldName
- The name of the world.loader
- TheSlimeLoader
that will be used to store the world.- Returns:
- SlimeWorld to import
- Throws:
WorldAlreadyExistsException
- if the data source already contains a world with the same name.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.
-