Record Class MaskedIdentity

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.identity.MaskedIdentity
Record Components:
alias - the name every other client sees; 1-16 characters of [A-Za-z0-9_]
skinValue - the base64 textures property value, or null for the default skin
skinSignature - the signature Mojang issued for skinValue, or null when unsigned

public record MaskedIdentity(@NotNull String alias, @Nullable String skinValue, @Nullable String skinSignature) extends Record
The face a player wears while they are masked: a name and, optionally, a skin.

An identity is presentation only. It never replaces the player's real profile, UUID, name, statistics or anything Zentrix stores about them — it is what other clients are told, and nothing more. That is what makes a mask safe to drop at any moment and impossible to persist by accident.

The skin is supplied the way Mojang serves it: a base64 textures property value and the signature that came with it. Leaving both out yields a nameless-skin mask, where the client falls back to the default Steve/Alex model derived from the alias.

Since:
1.6.0
  • Field Details

    • MAXIMUM_ALIAS_LENGTH

      public static final int MAXIMUM_ALIAS_LENGTH
      The longest name a vanilla client accepts in a player-info entry.
      See Also:
  • Constructor Details

    • MaskedIdentity

      public MaskedIdentity(@NotNull @NotNull String alias, @Nullable @Nullable String skinValue, @Nullable @Nullable String skinSignature)
      Creates an instance of a MaskedIdentity record class.
      Parameters:
      alias - the value for the alias record component
      skinValue - the value for the skinValue record component
      skinSignature - the value for the skinSignature record component
  • Method Details

    • ofAlias

      @NotNull public static @NotNull MaskedIdentity ofAlias(@NotNull @NotNull String alias)
      A mask that only changes the name, leaving the client to derive a default skin.
    • of

      @NotNull public static @NotNull MaskedIdentity of(@NotNull @NotNull String alias, @Nullable @Nullable String skinValue)
      A mask with an unsigned skin, which clients accept in offline and proxied setups.
    • hasSkin

      public boolean hasSkin()
      Whether this identity carries a skin of its own.
    • skin

      @NotNull public @NotNull Optional<String> skin()
    • signature

      @NotNull public @NotNull Optional<String> signature()
    • normalizedAlias

      @NotNull public @NotNull String normalizedAlias()
      The alias in the form aliases are compared by, which is case-insensitively.
    • withAlias

      @NotNull public @NotNull MaskedIdentity withAlias(@NotNull @NotNull String newAlias)
      The same identity under a different name, keeping the skin.
    • withSkin

      @NotNull public @NotNull MaskedIdentity withSkin(@Nullable @Nullable String value, @Nullable @Nullable String signature)
      The same alias wearing a different skin.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • alias

      @NotNull public @NotNull String alias()
      Returns the value of the alias record component.
      Returns:
      the value of the alias record component
    • skinValue

      @Nullable public @Nullable String skinValue()
      Returns the value of the skinValue record component.
      Returns:
      the value of the skinValue record component
    • skinSignature

      @Nullable public @Nullable String skinSignature()
      Returns the value of the skinSignature record component.
      Returns:
      the value of the skinSignature record component