aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0621-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0621-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch')
-rw-r--r--patches/server/0621-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch32
1 files changed, 32 insertions, 0 deletions
diff --git a/patches/server/0621-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch b/patches/server/0621-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
new file mode 100644
index 0000000000..4169ad0754
--- /dev/null
+++ b/patches/server/0621-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch
@@ -0,0 +1,32 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alvinn8 <[email protected]>
+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
+index e7ec5e1144c1596b035f97fb1fb86d18e61be3c9..a0c19503aabab5378d672a30163d35a5ba05b6c1 100644
+--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
++++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
+@@ -287,10 +287,18 @@ public class PlayerAdvancements {
+ 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.bukkit)); // CraftBukkit
++ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
++ boolean announceToChat = advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat();
++ net.kyori.adventure.text.Component message = announceToChat ? io.papermc.paper.adventure.PaperAdventure.asAdventure(Component.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent())) : null;
++ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message);
++ this.player.level.getCraftServer().getPluginManager().callEvent(event);
++ message = event.message();
++ // Paper end
+ advancement.getRewards().grant(this.player);
+- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
+- this.playerList.broadcastSystemMessage(Component.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent()), false);
++ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
++ if (message != null && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
++ this.playerList.broadcastSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), false);
++ // Paper end
+ }
+ }
+ }