Interface ArenaPersistentStorage

All Superinterfaces:
PersistentStorage, StringMapSerializationHelper

public interface ArenaPersistentStorage extends PersistentStorage
Represents the persistent storage of an arena.

It also may be synchronized between arenas. Access it using RemoteArena.getPersistentStorage(). For local arenas, you may use Arena.getPersistentStorage().

  • Method Details

    • getArena

      RemoteArena getArena()
      Gets the RemoteArena to which this instance matches.

      You may use RemoteArena.getLocal() to access the local instance, if this instance matches a local arena.

      Returns:
      The matching arena
    • getKeys

      Set<String> getKeys()
      Gets all the keys that exist within this storage.

      Note that this may not include all of them if the RemoteArena.isLocal() of getArena() returns false. Reason being, that it is possible to disable the synchronization using setSynchronizedFlag(String, boolean).

      Specified by:
      getKeys in interface PersistentStorage
      Returns:
      All known keys
    • get

      Optional<String> get(String key)
      Gets the value of the key.

      Note that this may return an empty result if the RemoteArena.isLocal() of getArena() returns false, even if the key exists on the server that handles the arena. Reason being, that it is possible to disable the synchronization using setSynchronizedFlag(String, boolean).

      Specified by:
      get in interface StringMapSerializationHelper
      Parameters:
      key - The key that contains to the value
      Returns:
      The value that matches the key. May be empty if there's no value
    • set

      void set(String key, String value)
      Sets the value for the key.

      Note that you should set setSynchronizedFlag(String, boolean) before you set the value. Without specified, the key is being synchronized between servers by default.

      Following limitations exist:
      - Key may not be longer than 255 characters
      - Key must only persist of the following characters: a-Z 0-9 ?!_-'#:@
      - Value may not be longer than 65534 characters

      Specified by:
      set in interface PersistentStorage
      Specified by:
      set in interface StringMapSerializationHelper
      Parameters:
      key - The key of the value with which you may identify the value later on
      value - The value that you want to store
      Throws:
      IllegalArgumentException - If the limitations aren't met
    • remove

      boolean remove(String key)
      Removes everything we know about a given key-value pair.
      Specified by:
      remove in interface PersistentStorage
      Parameters:
      key - The key that we want to remove
      Returns:
      true if it has been found and removed
    • setSynchronizedFlag

      void setSynchronizedFlag(String key, boolean synchronize)
      Define whether a certain key-value pair shall be synchronized between servers.

      This is only interesting for servers that actually make use of the Enhanced ProxySync addon.

      By default, it is enabled for all arenas. However, you may disable it for certain key-value pairs to reduce traffic. You should, however, set this before you actually set the value.

      Parameters:
      key - The key of the key-value pair
      synchronize - Whether synchronization accross servers shall be disabled or enabled for the key
      Throws:
      UnsupportedOperationException - If you are trying to access this for arenas that are remote
    • getSynchronizedFlag

      boolean getSynchronizedFlag(String key)
      Get whether the key-value pair shall be synchronized between servers.

      This is only interesting for servers that actually make use of the Enhanced ProxySync addon.

      By default, it is enabled for all arenas. However, you may disable it for certain key-value pairs to reduce traffic. You should, however, set this before you actually set the value.

      Parameters:
      key - The key of the key-value pair
      Returns:
      true if they are being synchronized between servers
    • serialize

      void serialize(Writer writer)
      Serializes this every entry of this instance into a JsonObject String.

      Mainly used for internal purposes.

      Parameters:
      writer - The writer to which the JSON string will be written into
      Throws:
      UnsupportedOperationException - If you are trying to access this for arenas that are remote
    • deserialize

      void deserialize(Reader reader) throws Exception
      Deserializes the JSON object string from serialize(Writer).

      Mainly used for internal purposes.

      Parameters:
      reader - The reader that holds the JsonObject that we want to deserialize
      Throws:
      Exception - JsonObject has an invalid format
      UnsupportedOperationException - If you are trying to access this for arenas that are remote