Add displayName methods for advancements (#8584)

This commit is contained in:
Jake Potrebic
2022-11-24 23:05:48 -08:00
parent 26993f7801
commit 06be0d0b4d
2 changed files with 72 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ From: syldium <syldium@mailo.com>
Date: Fri, 9 Jul 2021 18:49:40 +0200
Subject: [PATCH] Add more advancement API
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/io/papermc/paper/advancement/AdvancementDisplay.java b/src/main/java/io/papermc/paper/advancement/AdvancementDisplay.java
new file mode 100644
@@ -107,6 +108,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ NamespacedKey backgroundPath();
+
+ /**
+ * Gets the formatted display name for this display. This
+ * is a part of the component that would be shown in chat when a player
+ * completes the advancement.
+ *
+ * @return the display name
+ * @see org.bukkit.advancement.Advancement#displayName()
+ */
+ @NotNull Component displayName();
+
+ /**
+ * Defines how the {@link #icon()} appears in the advancements screen and
+ * the color used with the {@link #title() advancement name}.
+ */
@@ -189,6 +200,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ io.papermc.paper.advancement.AdvancementDisplay getDisplay();
+
+ /**
+ * Gets the formatted display name for this display. This
+ * is part of the component that would be shown in chat when a player
+ * completes the advancement. Will return the same as
+ * {@link io.papermc.paper.advancement.AdvancementDisplay#displayName()} when an
+ * {@link io.papermc.paper.advancement.AdvancementDisplay} is present.
*
- * @return a AdvancementDisplay object, or null if not set.
+ * @return the display name
+ * @see io.papermc.paper.advancement.AdvancementDisplay#displayName()
*/
- @Nullable
- AdvancementDisplay getDisplay();
+ @NotNull net.kyori.adventure.text.Component displayName();
+
+ /**
+ * Gets the parent advancement, if any.
+ *
+ * @return the parent advancement
@@ -198,12 +224,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ /**
+ * Gets all the direct children advancements.
*
- * @return a AdvancementDisplay object, or null if not set.
+ *
+ * @return the children advancements
*/
- @Nullable
- AdvancementDisplay getDisplay();
+ */
+ @NotNull
+ @org.jetbrains.annotations.Unmodifiable
+ Collection<Advancement> getChildren();