Record Class CommandReward

java.lang.Object
java.lang.Record
fr.pacdu.pacpackquests.reward.CommandReward
Record Components:
command - The command string to execute (e.g. "/effect give @s speed 60 1").
description - An optional friendly description explaining what the command does.
amount - The number of times the command should be run (or repeat count).
All Implemented Interfaces:
QuestReward

public record CommandReward(String command, String description, int amount) extends Record implements QuestReward
A quest reward that executes a server command on behalf of or targeting the player upon claiming.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CommandReward(String command, String description, int amount)
    Creates an instance of a CommandReward record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the amount record component.
    Returns the value of the command record component.
    net.minecraft.world.item.ItemStack
    createIconStack(net.minecraft.core.HolderLookup.Provider registries)
    Generates a visual ItemStack representing this reward for display in tooltips and menus.
    Returns the value of the description record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    void
    grant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager)
    Grants the reward to the given server player.
    final int
    Returns a hash code value for this object.
    read(net.minecraft.network.FriendlyByteBuf buf)
    Reads a CommandReward from the network buffer.
    final String
    Returns a string representation of this record class.
    Returns the category type of this reward.
    void
    write(net.minecraft.network.FriendlyByteBuf buf)
    Serializes this reward into a network buffer.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CommandReward

      public CommandReward(String command, String description, int amount)
      Creates an instance of a CommandReward record class.
      Parameters:
      command - the value for the command record component
      description - the value for the description record component
      amount - the value for the amount record component
  • Method Details

    • type

      public RewardType type()
      Description copied from interface: QuestReward
      Returns the category type of this reward.
      Specified by:
      type in interface QuestReward
      Returns:
      The RewardType.
    • grant

      public void grant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager)
      Description copied from interface: QuestReward
      Grants the reward to the given server player.
      Specified by:
      grant in interface QuestReward
      Parameters:
      player - The ServerPlayer claiming the quest.
      registryManager - The server registry access.
    • createIconStack

      public net.minecraft.world.item.ItemStack createIconStack(net.minecraft.core.HolderLookup.Provider registries)
      Description copied from interface: QuestReward
      Generates a visual ItemStack representing this reward for display in tooltips and menus.
      Specified by:
      createIconStack in interface QuestReward
      Parameters:
      registries - The registry lookup provider.
      Returns:
      An ItemStack for GUI rendering.
    • write

      public void write(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: QuestReward
      Serializes this reward into a network buffer.
      Specified by:
      write in interface QuestReward
      Parameters:
      buf - The FriendlyByteBuf to write into.
    • read

      public static CommandReward read(net.minecraft.network.FriendlyByteBuf buf)
      Reads a CommandReward from the network buffer.
      Parameters:
      buf - The buffer to read from.
      Returns:
      The read CommandReward.
    • 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.
    • command

      public String command()
      Returns the value of the command record component.
      Returns:
      the value of the command record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • amount

      public int amount()
      Returns the value of the amount record component.
      Specified by:
      amount in interface QuestReward
      Returns:
      the value of the amount record component