Class StatusInstance

java.lang.Object
net.mathias2246.buildmc.api.status.StatusInstance
All Implemented Interfaces:
net.kyori.adventure.key.Keyed, org.bukkit.configuration.serialization.ConfigurationSerializable, org.bukkit.Keyed

public class StatusInstance extends Object implements org.bukkit.configuration.serialization.ConfigurationSerializable, org.bukkit.Keyed
The instance of a status that shows up inside the '/status set ...' command when registered.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    A simple enum to show if a player is allowed to use a StatusInstance, or if he doesn't fulfill all requirements.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StatusInstance(@NotNull @MatchesRegex("^[a-z0-9_.-]+$") String statusId, @Nullable Set<org.bukkit.permissions.Permission> permissions, @Nullable Set<org.bukkit.scoreboard.Team> teams, @Nullable net.kyori.adventure.text.Component display)
    Constructs a new StatusInstance with optional Teams and Permission requirements.
  • Method Summary

    Modifier and Type
    Method
    Description
    allowPlayer(org.bukkit.entity.Player player)
    Checks if the given player can have this status.
    deserialize(@NotNull Map<String,Object> map, @NotNull @MatchesRegex("^[A-Za-z0-9_.-]+$") String statusId)
    Deserializes a StatusInstance that is represented using a Map.
    @NotNull net.kyori.adventure.text.Component
     
    @NotNull org.bukkit.NamespacedKey
     
    @Nullable Set<org.bukkit.permissions.Permission>
    Gets an optional set of Permissions, of which at least one is required to set this status.
    @NotNull String
     
    @Nullable Set<org.bukkit.scoreboard.Team>
    Gets an optional set of Teams, of which at least one is required to set this status.
    @NotNull Map<String,Object>
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.bukkit.Keyed

    key
  • Constructor Details

    • StatusInstance

      public StatusInstance(@NotNull @NotNull @MatchesRegex("^[a-z0-9_.-]+$") String statusId, @Nullable @Nullable Set<org.bukkit.permissions.Permission> permissions, @Nullable @Nullable Set<org.bukkit.scoreboard.Team> teams, @Nullable @Nullable net.kyori.adventure.text.Component display)
      Constructs a new StatusInstance with optional Teams and Permission requirements.
      Parameters:
      statusId - The id of the status. The key of a NamespacedKey that has to match this pattern "^[a-z0-9_.-]+$".

      NOTE: You only need the key because the namespace will always be "buildmc:" when using statuses

      permissions - The Permissions required to use this status, or null if no permissions should be required.
      teams - The Teams required to use this status. A player needs to be in at least one of the teams. Use null if no teams should be required
      display - The display Component of the Status that is shown before the players name.

      When set to null the status will just display "null" before the players name.

  • Method Details

    • getDisplay

      @Contract(pure=true) @NotNull public @NotNull net.kyori.adventure.text.Component getDisplay()
      Returns:
      The Text-Component that is displayed as a prefix before the players name.
    • getStatusId

      @Contract(pure=true) @NotNull public @NotNull String getStatusId()
      Returns:
      The id of this status.

      This is also displayed as the tab completion inside the '/status set ...' command.

    • getPermissions

      @Nullable public @Nullable Set<org.bukkit.permissions.Permission> getPermissions()
      Gets an optional set of Permissions, of which at least one is required to set this status.
      Returns:
      The list of permissions, or null if not required.
    • getTeams

      @Nullable public @Nullable Set<org.bukkit.scoreboard.Team> getTeams()
      Gets an optional set of Teams, of which at least one is required to set this status.
      Returns:
      The list of teams, or null if not required.
    • allowPlayer

      @Contract(pure=true) public StatusInstance.AllowStatus allowPlayer(org.bukkit.entity.Player player)
      Checks if the given player can have this status.
      Returns:
      True if, the player has the optional permissions and or team and is not null.
    • serialize

      @Contract(pure=true) @NotNull public @NotNull Map<String,Object> serialize()
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
    • deserialize

      @Contract("_, _ -> new") public static StatusInstance deserialize(@NotNull @NotNull Map<String,Object> map, @NotNull @NotNull @MatchesRegex("^[A-Za-z0-9_.-]+$") String statusId) throws InvalidStringException
      Deserializes a StatusInstance that is represented using a Map.
      Parameters:
      map - The serialized representation of a StatusInstance.

      You can serialize a Status using serialize()

      statusId - The key of a NamespacedKey that has to match this pattern "^[A-Za-z0-9_.-]+$".

      NOTE: You only need the key because the namespace will always be "buildmc:" when using statuses

      Throws:
      InvalidStringException
    • getKey

      @Contract(pure=true) @NotNull public @NotNull org.bukkit.NamespacedKey getKey()
      Specified by:
      getKey in interface org.bukkit.Keyed