Interface ArenaPersistentStorage
- All Superinterfaces:
PersistentStorage
,StringMapSerializationHelper
It also may be synchronized between arenas. Access it using RemoteArena.getPersistentStorage()
.
For local arenas, you may use Arena.getPersistentStorage()
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.marcely.bedwars.tools.PersistentStorage
PersistentStorage.Holder
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deserialize
(Reader reader) Deserializes the JSON object string fromserialize(Writer)
.Gets the value of the key.getArena()
Gets the RemoteArena to which this instance matches.getKeys()
Gets all the keys that exist within this storage.boolean
Get whether the key-value pair shall be synchronized between servers.boolean
Removes everything we know about a given key-value pair.void
Serializes this every entry of this instance into a JsonObject String.void
Sets the value for the key.void
setSynchronizedFlag
(String key, boolean synchronize) Define whether a certain key-value pair shall be synchronized between servers.Methods inherited from interface de.marcely.bedwars.tools.PersistentStorage
saveAsync
Methods inherited from interface de.marcely.bedwars.tools.StringMapSerializationHelper
getBoolean, getDouble, getInt, getItemStack, getLong, set, set, set
-
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
Gets all the keys that exist within this storage.Note that this may not include all of them if the
RemoteArena.isLocal()
ofgetArena()
returns false. Reason being, that it is possible to disable the synchronization usingsetSynchronizedFlag(String, boolean)
.- Specified by:
getKeys
in interfacePersistentStorage
- Returns:
- All known keys
-
get
Gets the value of the key.Note that this may return an empty result if the
RemoteArena.isLocal()
ofgetArena()
returns false, even if the key exists on the server that handles the arena. Reason being, that it is possible to disable the synchronization usingsetSynchronizedFlag(String, boolean)
.- Specified by:
get
in interfaceStringMapSerializationHelper
- 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
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 interfacePersistentStorage
- Specified by:
set
in interfaceStringMapSerializationHelper
- Parameters:
key
- The key of the value with which you may identify the value later onvalue
- The value that you want to store- Throws:
IllegalArgumentException
- If the limitations aren't met
-
remove
Removes everything we know about a given key-value pair.- Specified by:
remove
in interfacePersistentStorage
- Parameters:
key
- The key that we want to remove- Returns:
true
if it has been found and removed
-
setSynchronizedFlag
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 pairsynchronize
- 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
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
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
Deserializes the JSON object string fromserialize(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 formatUnsupportedOperationException
- If you are trying to access this for arenas that are remote
-