Package dev.majek.hexnicks.storage
Class JsonStorage
java.lang.Object
dev.majek.hexnicks.storage.JsonStorage
- All Implemented Interfaces:
StorageMethod
Handles Json storage for nicknames.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCompletableFuture<net.kyori.adventure.text.Component>
Get the nickname stored for a specific unique id.Check if there is a nickname stored for the provided unique id.nicknameExists
(@NotNull net.kyori.adventure.text.Component nickname, boolean strict, @NotNull org.bukkit.entity.Player player) Check if a nickname is already taken by a player.void
removeNick
(@NotNull UUID uuid) Remove a nickname from storage.void
saveNick
(@NotNull org.bukkit.entity.Player player, @NotNull net.kyori.adventure.text.Component nickname) Save a nickname in storage.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.majek.hexnicks.storage.StorageMethod
updateNicks
-
Constructor Details
-
JsonStorage
public JsonStorage()
-
-
Method Details
-
hasNick
Description copied from interface:StorageMethod
Check if there is a nickname stored for the provided unique id.- Specified by:
hasNick
in interfaceStorageMethod
- Parameters:
uuid
- The unique id to check.- Returns:
- True if nickname stored.
-
getNick
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 interfaceStorageMethod
- Parameters:
uuid
- The unique id to fetch.- Returns:
- Nickname.
-
removeNick
Description copied from interface:StorageMethod
Remove a nickname from storage.- Specified by:
removeNick
in interfaceStorageMethod
- 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 interfaceStorageMethod
- 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 interfaceStorageMethod
- Parameters:
nickname
- the nickname to checkstrict
- whether the same names with different colors should be consideredplayer
- the player creating a nickname - we want to exclude them so their name doesn't count against them- Returns:
- whether it's taken
-