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 ClassesModifier and TypeClassDescriptionstatic enumA simple enum to show if a player is allowed to use aStatusInstance, or if he doesn't fulfill all requirements. -
Constructor Summary
ConstructorsConstructorDescriptionStatusInstance(@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) -
Method Summary
Modifier and TypeMethodDescriptionallowPlayer(org.bukkit.entity.Player player) Checks if the given player can have this status.static StatusInstancedeserialize(@NotNull Map<String, Object> map, @NotNull @MatchesRegex("[a-z0-9/._-]+$") String statusId) Deserializes aStatusInstancethat is represented using a Map.@NotNull net.kyori.adventure.text.Component@NotNull org.bukkit.NamespacedKeygetKey()@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> getTeams()Gets an optional set of Teams, of which at least one is required to set this status.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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) - Parameters:
statusId- The id of the status. The key of aNamespacedKeythat 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- ThePermissions required to use this status, ornullif no permissions should be required.teams- TheTeams required to use this status. A player needs to be in at least one of the teams. Usenullif no teams should be requireddisplay- The displayComponentof the Status that is shown before the players name.When set to
nullthe 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
- Returns:
- The id of this status.
This is also displayed as the tab completion inside the '/status set ...' command.
-
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
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
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
-
deserialize
@Contract("_, _ -> new") public static StatusInstance deserialize(@NotNull @NotNull Map<String, Object> map, @NotNull @NotNull @MatchesRegex("[a-z0-9/._-]+$") String statusId) Deserializes aStatusInstancethat is represented using a Map.- Parameters:
map- The serialized representation of aStatusInstance.You can serialize a Status using
serialize()statusId- The key of aNamespacedKeythat 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:
getKeyin interfaceorg.bukkit.Keyed
-