Class PlayerBadge

java.lang.Object
io.github.thecsdev.tcdcommons.api.badge.PlayerBadge
Direct Known Subclasses:
ClientPlayerBadge, SimplePlayerBadge

public abstract class PlayerBadge extends Object
Represents a badge that can be assigned to a player.
A PlayerBadge is similar to an advancement in that it signifies an achievement or status. However, unlike advancements, badges can be temporary and are typically used to denote special or unique accomplishments.

Each badge has a constant name and description, which can be retrieved using the getName() and getDescription() methods. Whether or not a badge should be saved with the player's data is determined by the shouldSave() method.
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract net.minecraft.text.Text
    Returns the description of the badge.
    The returned description should be constant, meaning it should not change over the lifetime of a badge instance.

    Must be constant.
    final Optional<net.minecraft.util.Identifier>
    Returns the Identifier of this PlayerBadge in accordance with the TRegistries.PLAYER_BADGE registry.
    abstract net.minecraft.text.Text
    Returns the display name of the badge.
    The returned name should be constant, meaning it should not change over the lifetime of a badge instance.

    Must be constant.
    abstract boolean
    Determines if the badge assigned to a player should persist in the player's save data.
    When this method returns true, the badge is stored with the player's save data, ensuring its persistence across sessions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlayerBadge

      protected PlayerBadge()
  • Method Details

    • getId

      public final Optional<net.minecraft.util.Identifier> getId()
      Returns the Identifier of this PlayerBadge in accordance with the TRegistries.PLAYER_BADGE registry.
    • getName

      public abstract net.minecraft.text.Text getName()
      Returns the display name of the badge.
      The returned name should be constant, meaning it should not change over the lifetime of a badge instance.

      Must be constant.
    • getDescription

      public abstract net.minecraft.text.Text getDescription()
      Returns the description of the badge.
      The returned description should be constant, meaning it should not change over the lifetime of a badge instance.

      Must be constant.
    • shouldSave

      public abstract boolean shouldSave()
      Determines if the badge assigned to a player should persist in the player's save data.
      When this method returns true, the badge is stored with the player's save data, ensuring its persistence across sessions. If this method returns false, the badge is considered temporary and will not be saved.
      The result of this method should be constant for a given badge, as changing the result can lead to inconsistent saving behavior.

      Must be constant.