From 8ee512d806d3db9d3d4a0baacd0b23cb9c62bd97 Mon Sep 17 00:00:00 2001 From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com> Date: Fri, 8 Jan 2021 20:29:58 +0100 Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent --- .../player/PlayerAdvancementDoneEvent.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java index 21ff095afb..6f618bb140 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java @@ -4,6 +4,10 @@ import org.bukkit.advancement.Advancement; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +// Paper start +import org.jetbrains.annotations.Nullable; +import net.kyori.adventure.text.Component; +// Paper end /** * Called when a player has completed all criteria in an advancement. @@ -13,10 +17,17 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); // private final Advancement advancement; + private Component message; // Paper - Add Adventure message public PlayerAdvancementDoneEvent(@NotNull Player who, @NotNull Advancement advancement) { + // Paper start - Add Adventure message + this(who, advancement, null); + } + public PlayerAdvancementDoneEvent(@NotNull Player who, @NotNull Advancement advancement, @Nullable Component message) { + // Paper end super(who); this.advancement = advancement; + this.message = message; // Paper - Add Adventure message } /** @@ -29,6 +40,31 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent { return advancement; } + // Paper start - Add Adventure message + /** + * Gets the message to send to all online players. + *
+ * Will be null if the advancement does not announce to chat, for example if + * it is a recipe unlock or a root advancement. + * + * @return The announcement message, or null + */ + @Nullable + public Component message() { + return this.message; + } + + /** + * Sets the message to send to all online players. + *
+ * If set to null the message will not be sent. + * + * @param message The new message + */ + public void message(@Nullable Component message) { + this.message = message; + } + // Paper end @NotNull @Override public HandlerList getHandlers() {