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.
  • 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-z0-9/._-]+$") String statusId)
      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-z0-9/._-]+$".

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

    • getKey

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