Interface SlimeLoader


public interface SlimeLoader
SlimeLoaders are in charge of loading worlds from a data source, and also locking and deleting them.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    acquireLock(String worldName)
    Attempts to lock the world.
    void
    deleteWorld(String worldName)
    Deletes a world from the data source.
    boolean
    isWorldLocked(String worldName)
    Checks whether or not a world is locked.
    Returns the current saved world names.
    byte[]
    loadWorld(String worldName)
    Load a world's data file.
    void
    saveWorld(String worldName, byte[] serializedWorld)
    Saves the world's data file.
    void
    unlockWorld(String worldName)
    Attempts to unlock the world.
    boolean
    worldExists(String worldName)
    Checks whether or not a world exists inside the data source.
  • Method Details

    • loadWorld

      byte[] loadWorld(String worldName) throws UnknownWorldException, IOException
      Load a world's data file.
      Parameters:
      worldName - The name of the world.
      Returns:
      The world's data file, contained inside a byte array.
      Throws:
      UnknownWorldException - if the world cannot be found.
      IOException - if the world could not be obtained.
    • worldExists

      boolean worldExists(String worldName) throws IOException
      Checks whether or not a world exists inside the data source.
      Parameters:
      worldName - The name of the world.
      Returns:
      true if the world exists inside the data source, false otherwhise.
      Throws:
      IOException - if the world could not be obtained.
    • listWorlds

      List<String> listWorlds() throws IOException
      Returns the current saved world names.
      Returns:
      a list containing all the world names
      Throws:
      IOException - if the list could not be obtained
    • saveWorld

      void saveWorld(String worldName, byte[] serializedWorld) throws IOException
      Saves the world's data file. This method will also lock the world, in case it's not locked already.
      Parameters:
      worldName - The name of the world.
      serializedWorld - The world's data file, contained inside a byte array.
      Throws:
      IOException - if the world could not be saved.
    • deleteWorld

      void deleteWorld(String worldName) throws UnknownWorldException, IOException
      Deletes a world from the data source.
      Parameters:
      worldName - name of the world
      Throws:
      UnknownWorldException - if the world could not be found.
      IOException - if the world could not be deleted.
    • acquireLock

      void acquireLock(String worldName) throws UnknownWorldException, WorldLockedException, IOException
      Attempts to lock the world.
      Parameters:
      worldName - name of the world
      Throws:
      UnknownWorldException - If the world could not be found
      WorldLockedException - If the world is already locked
      IOException - If the world could not be locked
    • isWorldLocked

      boolean isWorldLocked(String worldName) throws UnknownWorldException, IOException
      Checks whether or not a world is locked.
      Parameters:
      worldName - The name of the world.
      Returns:
      true if the world is locked, false otherwhise.
      Throws:
      UnknownWorldException - if the world could not be found.
      IOException - if the world could not be obtained.
    • unlockWorld

      void unlockWorld(String worldName) throws UnknownWorldException, IOException
      Attempts to unlock the world.
      Parameters:
      worldName - name of the world
      Throws:
      UnknownWorldException - If the world could not be found
      IOException - If the world could not be unlocked