Class JsonStorage

java.lang.Object
dev.majek.hexnicks.storage.JsonStorage
All Implemented Interfaces:
StorageMethod

public class JsonStorage extends Object implements StorageMethod
Handles Json storage for nicknames.
  • Constructor Details

    • JsonStorage

      public JsonStorage()
  • Method Details

    • hasNick

      public CompletableFuture<Boolean> hasNick(@NotNull @NotNull UUID uuid)
      Description copied from interface: StorageMethod
      Check if there is a nickname stored for the provided unique id.
      Specified by:
      hasNick in interface StorageMethod
      Parameters:
      uuid - The unique id to check.
      Returns:
      True if nickname stored.
    • getNick

      public CompletableFuture<net.kyori.adventure.text.Component> getNick(@NotNull @NotNull UUID uuid)
      Description copied from interface: StorageMethod
      Get the nickname stored for a specific unique id. StorageMethod.hasNick(UUID) should be checked first.
      Specified by:
      getNick in interface StorageMethod
      Parameters:
      uuid - The unique id to fetch.
      Returns:
      Nickname.
    • removeNick

      public void removeNick(@NotNull @NotNull UUID uuid)
      Description copied from interface: StorageMethod
      Remove a nickname from storage.
      Specified by:
      removeNick in interface StorageMethod
      Parameters:
      uuid - The unique id the nickname is tied to.
    • saveNick

      public void saveNick(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull net.kyori.adventure.text.Component nickname)
      Description copied from interface: StorageMethod
      Save a nickname in storage. This can be used to put it there initially or to update it.
      Specified by:
      saveNick in interface StorageMethod
      Parameters:
      player - The player whose nickname to save.
      nickname - the nickname to save
    • nicknameExists

      public CompletableFuture<Boolean> nicknameExists(@NotNull @NotNull net.kyori.adventure.text.Component nickname, boolean strict, @NotNull @NotNull org.bukkit.entity.Player player)
      Description copied from interface: StorageMethod
      Check if a nickname is already taken by a player.
      Specified by:
      nicknameExists in interface StorageMethod
      Parameters:
      nickname - the nickname to check
      strict - whether the same names with different colors should be considered
      player - the player creating a nickname - we want to exclude them so their name doesn't count against them
      Returns:
      whether it's taken