From 98f6ab9a04d3fb8bc8e8e226bd4d7e13ad220abd Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot <noreply+git-bukkit@papermc.io> Date: Sat, 23 Nov 2024 21:25:09 +1100 Subject: [PATCH] #1067: Add method to get Advancement requirements By: Nothixal <nothixal@gmail.com> --- .../org/bukkit/advancement/Advancement.java | 8 ++++++ .../advancement/AdvancementRequirement.java | 23 ++++++++++++++++ .../advancement/AdvancementRequirements.java | 26 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirement.java create mode 100644 paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirements.java diff --git a/paper-api/src/main/java/org/bukkit/advancement/Advancement.java b/paper-api/src/main/java/org/bukkit/advancement/Advancement.java index 17527c2f7b..e683af5eb1 100644 --- a/paper-api/src/main/java/org/bukkit/advancement/Advancement.java +++ b/paper-api/src/main/java/org/bukkit/advancement/Advancement.java @@ -19,6 +19,14 @@ public interface Advancement extends Keyed { @NotNull Collection<String> getCriteria(); + /** + * Returns the requirements for this advancement. + * + * @return an AdvancementRequirements object. + */ + @NotNull + AdvancementRequirements getRequirements(); + /** * Returns the display information for this advancement. * diff --git a/paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirement.java b/paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirement.java new file mode 100644 index 0000000000..ec591d28dc --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirement.java @@ -0,0 +1,23 @@ +package org.bukkit.advancement; + +import java.util.List; +import org.jetbrains.annotations.NotNull; + +public interface AdvancementRequirement { + + /** + * Get all required criteria. + * + * @return the list of required criteria for this requirement. + */ + @NotNull + List<String> getRequiredCriteria(); + + /** + * Check if the requirement is strict. + * + * @return true if requirement list contains one criteria, false if + * multiple. + */ + boolean isStrict(); +} diff --git a/paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirements.java b/paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirements.java new file mode 100644 index 0000000000..4bb79dd52f --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/advancement/AdvancementRequirements.java @@ -0,0 +1,26 @@ +package org.bukkit.advancement; + +import java.util.List; +import org.jetbrains.annotations.NotNull; + +/** + * The list of requirements for the advancement. + * + * Requirements are complimentary to criteria. They are just lists that contain + * more lists, which in turn contains strings that equal the names of the + * criteria. Ultimately defining the logic around how criteria are completed in + * order to grant the advancement. + * + * @see <a href=https://minecraft.wiki/w/Advancement_definition>Advancement Definition</a> + * @see <a href=https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2809368-1-12-custom-advancements-aka-achievements#Requirements>Advancement Requirements</a> + */ +public interface AdvancementRequirements { + + /** + * Get all the requirements present in this advancement. + * + * @return an unmodifiable copy of all requirements. + */ + @NotNull + List<AdvancementRequirement> getRequirements(); +}