Record Class InputPattern

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.api.dialogue.InputPattern
Record Components:
pattern - The regex pattern.
errorMessage - The error message to display when the input is invalid.
errorDuration - The duration in milliseconds that the error message will display in the display box.

public record InputPattern(Pattern pattern, net.minecraft.network.chat.Component errorMessage, long errorDuration) extends Record
Represents a pattern that the user's input must match.
This is checked against the user's input when they press a button to submit their input.
  • Constructor Details

    • InputPattern

      public InputPattern(Pattern pattern, net.minecraft.network.chat.Component errorMessage, long errorDuration)
      Creates an instance of a InputPattern record class.
      Parameters:
      pattern - the value for the pattern record component
      errorMessage - the value for the errorMessage record component
      errorDuration - the value for the errorDuration record component
  • Method Details

    • encode

      @Internal public void encode(net.minecraft.network.FriendlyByteBuf buffer)
      Encodes the InputPattern into the given FriendlyByteBuf.
      Parameters:
      buffer - The buffer.
    • decode

      @Internal public static InputPattern decode(net.minecraft.network.FriendlyByteBuf buffer)
      Reads an InputPattern from the given FriendlyByteBuf.
      Parameters:
      buffer - The buffer.
      Returns:
      The InputPattern.
    • of

      public static InputPattern of(Pattern pattern, net.minecraft.network.chat.Component errorMessage, long errorDuration)
      Creates a new InputPattern with the given pattern, error message, and error duration.
      Parameters:
      pattern - The pattern.
      errorMessage - The error message.
      errorDuration - The duration in milliseconds that the error message will display in the display box.
      Returns:
      The InputPattern.
    • of

      public static InputPattern of(Pattern pattern, net.minecraft.network.chat.Component errorMessage)
      Creates a new InputPattern with the given pattern and error message.
      Parameters:
      pattern - The pattern.
      errorMessage - The error message.
      Returns:
      The InputPattern.
    • of

      public static InputPattern of(String pattern, net.minecraft.network.chat.Component errorMessage)
      Creates a new InputPattern with the given pattern and error message.
      Parameters:
      pattern - The pattern.
      errorMessage - The error message.
      Returns:
      The InputPattern.
    • builder

      public static InputPattern.Builder builder()
      Creates a new InputPattern builder.
      Returns:
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • pattern

      public Pattern pattern()
      Returns the value of the pattern record component.
      Returns:
      the value of the pattern record component
    • errorMessage

      public net.minecraft.network.chat.Component errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • errorDuration

      public long errorDuration()
      Returns the value of the errorDuration record component.
      Returns:
      the value of the errorDuration record component