Interface PlayerProperties

All Superinterfaces:
StringMapSerializationHelper

public interface PlayerProperties extends StringMapSerializationHelper
Basically a key/value (key and value being a String) Map that persists of various general-purpose information of a player.
  • Method Details

    • getPlayerUUID

      UUID getPlayerUUID()
      Returns the uuid of the player behind these properties.
      Returns:
      The UUID of the player who owns the properties
    • get

      Optional<String> get(String key)
      Will look for the property with that key.

      Ignores whether the key is uppercase or undercase.

      Specified by:
      get in interface StringMapSerializationHelper
      Parameters:
      key - The key/id of the property
      Returns:
      The optional value of the property
    • getStoredKeys

      Collection<String> getStoredKeys()
      Returns all keys/ids of the properties that are currently stored in this object.
      Returns:
      All keys/ids set
    • set

      default void set(String key, String value)
      Will set the value of the property with that key.

      Ignores whether the key is uppercase or undercase.

      You may only use the following chars for the key: a-z, 0-9, :, _

      It's safe to use UTF8 for the value. Values are limited to 8192 bytes, otherwise an exception will be thrown.

      Keep in mind that the PlayerPropertyChangeEvent is likely being dispatched with this.

      Specified by:
      set in interface StringMapSerializationHelper
      Parameters:
      key - The key/id of the property
      value - The new value
      Throws:
      IllegalArgumentException - When key or value don't fit the format
    • set

      void set(String key, String value, AttributeChangeCause cause)
      Will set the value of the property with that key
      Ignores whether the key is uppercase or undercase
      You may only use the following chars for the key: a-z, 0-9, :, _
      It's safe to use UTF8 for the value.
      Values are limited to 8192 bytes, otherwise an exception will be thrown
      Parameters:
      key - The key/id of the property
      value - The new value
      cause - The technical cause for setting this
      Throws:
      IllegalArgumentException - When key or value don't fit the format
    • replace

      default Optional<String> replace(String key, String value)
      Parameters:
      key - The key/id of the property
      value - The new value
      Returns:
      The previous value
      Throws:
      IllegalArgumentException - When key or value don't fit the format
    • replace

      Optional<String> replace(String key, String value, AttributeChangeCause cause)
      Parameters:
      key - The key/id of the property
      value - The new valuevalue
      cause - The technical cause for setting this
      Returns:
      The previous value
      Throws:
      IllegalArgumentException - When key or value don't fit the format
    • remove

      default Optional<String> remove(String key)
      Removes the property from the internal storage.

      Keep in mind that the PlayerPropertyChangeEvent is likely being dispatched with this.

      Parameters:
      key - The key/id of the property
      Returns:
      The value of the removed property
    • remove

      Removes the property from the internal storage.
      Parameters:
      key - The key/id of the propertyvalue
      cause - The technical cause for setting this
      Returns:
      The value of the removed property
    • isReadOnly

      boolean isReadOnly()
      Any changes made to this instance will not be saved, even if tried.

      While it is possible to change the values, MBedwars' auto-saving and save() will not actually do anything and any changes will be lost with the next loading.

      Reasons for read-only are:

      • We failed to load it fully (due to an error). Reasons for that may include e.g. a disconnection to the storage server.
      • The player might be online on another server and we don't want to intercept with whatever the other server is doing. Although cross-server support can be obtained using the ProxySync addon and making sure that player-data-syncing is enabled within it, in which case this instance won't be set as read-only.
      Returns:
      Whether this instance is read-only and changes won't be saved
    • save

      default void save()
      Asynchronously saves these achievements.

      It's usually not needed to call this method when the player is currently on the server as the plugin will already handle it.

    • save

      void save(@Nullable @Nullable Runnable callback)
      Asynchronously saves these achievements.

      It's usually not needed to call this method when the player is currently on the server as the plugin will already handle it.

      Important: The callback doesn't get synced to the main thread.

      Parameters:
      callback - Gets called when the operation was finished
    • getShopHypixelV2QuickBuyItems

      ShopItem[] getShopHypixelV2QuickBuyItems()
      Parses the entry DefaultPlayerProperty.SHOPDESIGN_HYPIXELV2_QUICKBUY and returns all the items stored in the quick buy.

      In case the entry does not exist (he has never opened the HyPixelV2 shop layout before), or the data got corrupted, a new random set of items is being generated given by the currently configured pages.

      Entries in the array may be null. Those represent air.

      Returns:
      All the items stored in the HyPixelV2 quick buy
      See Also:
    • setShopHypixelV2QuickBuyItems

      void setShopHypixelV2QuickBuyItems(ShopItem[] items)
      Serializes and sets the entry DefaultPlayerProperty.SHOPDESIGN_HYPIXELV2_QUICKBUY for all the items that are stored in the quick buy.

      You may not pass null. To reset the items, simply remove the property key using remove(String).

      It is legt for entries to be null. Those represent air

      Note that those changes (likely) do not apply in case the shop is currently open.

      Parameters:
      items - All the items stored in the HyPixelV2 quick buy
      See Also: