Record Class QuestDefinition

java.lang.Object
java.lang.Record
fr.pacdu.pacpackquests.QuestDefinition
Record Components:
id - The unique identifier of the quest (used in files, network packets, and save states).
title - The human-readable title displayed in screens and tooltips.
category - The name of the tab/category this quest belongs to.
icon - The ItemStack rendered as the visual icon for the quest node.
displayX - The X coordinate of the quest node on the visual canvas.
displayY - The Y coordinate of the quest node on the visual canvas.
parents - The list of prerequisite quest IDs that must be completed before unlocking this quest.
properties - A key-value map containing arbitrary metadata (such as custom descriptions).
tasks - The list of objectives that must be satisfied to complete this quest.
rewards - The list of rewards granted to the player upon claiming this quest.

public record QuestDefinition(String id, String title, String category, net.minecraft.world.item.ItemStack icon, int displayX, int displayY, List<String> parents, Map<String,String> properties, List<QuestTask> tasks, List<QuestReward> rewards) extends Record
Represents the immutable static configuration and metadata of a quest. A quest is an aggregate holding display metadata, an extensible list of tasks (objectives), an extensible list of rewards, and arbitrary properties/descriptions.
  • Constructor Details

    • QuestDefinition

      public QuestDefinition(String id, String title, String category, net.minecraft.world.item.ItemStack icon, int displayX, int displayY, List<String> parents, Map<String,String> properties, List<QuestTask> tasks, List<QuestReward> rewards)
      Creates an instance of a QuestDefinition record class.
      Parameters:
      id - the value for the id record component
      title - the value for the title record component
      category - the value for the category record component
      icon - the value for the icon record component
      displayX - the value for the displayX record component
      displayY - the value for the displayY record component
      parents - the value for the parents record component
      properties - the value for the properties record component
      tasks - the value for the tasks record component
      rewards - the value for the rewards record component
  • Method Details

    • withPosition

      public QuestDefinition withPosition(int newX, int newY)
      Creates a copy of this quest with updated canvas coordinates.
      Parameters:
      newX - The new X coordinate on the visual canvas.
      newY - The new Y coordinate on the visual canvas.
      Returns:
      A new QuestDefinition with updated position.
    • withIdAndTitle

      public QuestDefinition withIdAndTitle(String newId, String newTitle)
      Creates a copy of this quest with a new ID and title.
      Parameters:
      newId - The new unique identifier.
      newTitle - The new display title.
      Returns:
      A new QuestDefinition with updated ID and title.
    • withCategory

      public QuestDefinition withCategory(String newCategory)
      Creates a copy of this quest moved into a different category.
      Parameters:
      newCategory - The target category name.
      Returns:
      A new QuestDefinition placed in the target category.
    • createReward

      public static QuestReward createReward(RewardType type, String target, int amount, String description)
      Factory helper to create a concrete QuestReward instance based on a type enum.
      Parameters:
      type - The RewardType category.
      target - The target identifier (item ID or command string).
      amount - The reward quantity or count.
      description - A custom description for command rewards.
      Returns:
      A concrete QuestReward instance.
    • primaryTask

      public QuestTask primaryTask()
      Returns the first task of the quest, or a default fallback task if none exist.
      Returns:
      The primary QuestTask.
    • primaryReward

      public QuestReward primaryReward()
      Returns the first reward of the quest, or a default fallback reward if none exist.
      Returns:
      The primary QuestReward.
    • taskType

      public TaskType taskType()
      Returns the task type of the primary task.
      Returns:
      The TaskType.
    • target

      public String target()
      Returns the target string (e.g. block ID, mob ID) of the primary task.
      Returns:
      The target string.
    • requiredAmount

      public int requiredAmount()
      Returns the required amount to fulfill the primary task.
      Returns:
      The required amount integer.
    • rewardType

      public RewardType rewardType()
      Returns the reward type of the primary reward.
      Returns:
      The RewardType.
    • reward

      public String reward()
      Returns the target identifier of the primary reward (item ID or command string).
      Returns:
      The target identifier string.
    • rewardAmount

      public int rewardAmount()
      Returns the numerical amount of the primary reward.
      Returns:
      The reward amount.
    • rewardDescription

      public String rewardDescription()
      Returns the human-readable description of the primary reward if applicable.
      Returns:
      The reward description string.
    • description

      public String description()
      Returns the general description of this quest stored in its properties map.
      Returns:
      The quest description string.
    • 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.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component
    • category

      public String category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • icon

      public net.minecraft.world.item.ItemStack icon()
      Returns the value of the icon record component.
      Returns:
      the value of the icon record component
    • displayX

      public int displayX()
      Returns the value of the displayX record component.
      Returns:
      the value of the displayX record component
    • displayY

      public int displayY()
      Returns the value of the displayY record component.
      Returns:
      the value of the displayY record component
    • parents

      public List<String> parents()
      Returns the value of the parents record component.
      Returns:
      the value of the parents record component
    • properties

      public Map<String,String> properties()
      Returns the value of the properties record component.
      Returns:
      the value of the properties record component
    • tasks

      public List<QuestTask> tasks()
      Returns the value of the tasks record component.
      Returns:
      the value of the tasks record component
    • rewards

      public List<QuestReward> rewards()
      Returns the value of the rewards record component.
      Returns:
      the value of the rewards record component