Package fr.pacdu.pacpackquests.reward
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
ConstructorsConstructorDescriptionCommandReward(String command, String description, int amount) Creates an instance of aCommandRewardrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintamount()Returns the value of theamountrecord component.command()Returns the value of thecommandrecord component.net.minecraft.world.item.ItemStackcreateIconStack(net.minecraft.core.HolderLookup.Provider registries) Generates a visual ItemStack representing this reward for display in tooltips and menus.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.voidgrant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager) Grants the reward to the given server player.final inthashCode()Returns a hash code value for this object.static CommandRewardread(net.minecraft.network.FriendlyByteBuf buf) Reads aCommandRewardfrom the network buffer.final StringtoString()Returns a string representation of this record class.type()Returns the category type of this reward.voidwrite(net.minecraft.network.FriendlyByteBuf buf) Serializes this reward into a network buffer.
-
Constructor Details
-
CommandReward
Creates an instance of aCommandRewardrecord class.- Parameters:
command- the value for thecommandrecord componentdescription- the value for thedescriptionrecord componentamount- the value for theamountrecord component
-
-
Method Details
-
type
Description copied from interface:QuestRewardReturns the category type of this reward.- Specified by:
typein interfaceQuestReward- Returns:
- The
RewardType.
-
grant
public void grant(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.RegistryAccess registryManager) Description copied from interface:QuestRewardGrants the reward to the given server player.- Specified by:
grantin interfaceQuestReward- Parameters:
player- TheServerPlayerclaiming 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:QuestRewardGenerates a visual ItemStack representing this reward for display in tooltips and menus.- Specified by:
createIconStackin interfaceQuestReward- Parameters:
registries- The registry lookup provider.- Returns:
- An
ItemStackfor GUI rendering.
-
write
public void write(net.minecraft.network.FriendlyByteBuf buf) Description copied from interface:QuestRewardSerializes this reward into a network buffer.- Specified by:
writein interfaceQuestReward- Parameters:
buf- TheFriendlyByteBufto write into.
-
read
Reads aCommandRewardfrom the network buffer.- Parameters:
buf- The buffer to read from.- Returns:
- The read
CommandReward.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
command
Returns the value of thecommandrecord component.- Returns:
- the value of the
commandrecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
amount
public int amount()Returns the value of theamountrecord component.- Specified by:
amountin interfaceQuestReward- Returns:
- the value of the
amountrecord component
-