Paper/patches/server/0521-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch

36 lines
2.7 KiB
Diff
Raw Normal View History

2023-09-22 07:41:27 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alvinn8 <42838560+Alvinn8@users.noreply.github.com>
Date: Fri, 8 Jan 2021 20:31:13 +0100
Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
2024-10-23 20:15:25 +02:00
index 0fe941b0802f2966ad55509baac124f56ecef999..1dcb8a287be7df2a59b5b4c1345be80637a7f679 100644
2023-09-22 07:41:27 +02:00
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
2023-12-06 04:34:04 +01:00
@@ -236,11 +236,21 @@ public class PlayerAdvancements {
2023-09-22 07:41:27 +02:00
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
- this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.toBukkit())); // CraftBukkit
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
2023-12-06 04:34:04 +01:00
+ final net.kyori.adventure.text.Component message = advancement.value().display().flatMap(info -> {
+ return java.util.Optional.ofNullable(
+ info.shouldAnnounceChat() ? io.papermc.paper.adventure.PaperAdventure.asAdventure(info.getType().createAnnouncement(advancement, this.player)) : null
+ );
+ }).orElse(null);
2023-09-22 07:41:27 +02:00
+ final org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.toBukkit(), message);
+ this.player.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
+ // Paper end
advancement.value().rewards().grant(this.player);
advancement.value().display().ifPresent((advancementdisplay) -> {
2024-10-23 20:15:25 +02:00
- if (advancementdisplay.shouldAnnounceChat() && this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
2023-12-06 04:34:04 +01:00
- this.playerList.broadcastSystemMessage(advancementdisplay.getType().createAnnouncement(advancement, this.player), false);
2023-09-22 07:41:27 +02:00
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
2024-10-23 20:15:25 +02:00
+ if (event.message() != null && this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
2023-09-22 07:41:27 +02:00
+ this.playerList.broadcastSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false);
+ // Paper end
}
});