13
0
geforkt von Mirrors/Paper
Paper/patches/unapplied/server/0596-Add-Adventure-message-to-PlayerAdvancementDoneEvent.patch

33 Zeilen
2.7 KiB
Diff

2021-06-15 04:59:31 +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
2023-06-08 03:13:54 +02:00
index 9034faaf7b169788abad01d3da9c65ad5ddc4b8b..acc49f66bf34e2507d0ee6fec0a56b11bfc68f46 100644
2021-06-15 04:59:31 +02:00
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
2023-03-14 21:25:13 +01:00
@@ -239,10 +239,18 @@ public class PlayerAdvancements {
2021-06-15 04:59:31 +02:00
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
2023-06-08 03:13:54 +02:00
- this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
2021-06-15 04:59:31 +02:00
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
+ boolean announceToChat = advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat();
2022-06-08 10:00:56 +02:00
+ 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;
2021-06-15 04:59:31 +02:00
+ org.bukkit.event.player.PlayerAdvancementDoneEvent event = new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit, message);
2023-06-08 03:13:54 +02:00
+ this.player.level().getCraftServer().getPluginManager().callEvent(event);
2021-06-15 04:59:31 +02:00
+ message = event.message();
+ // Paper end
advancement.getRewards().grant(this.player);
2023-06-08 03:13:54 +02:00
- if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
2022-07-27 22:55:55 +02:00
- this.playerList.broadcastSystemMessage(Component.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent()), false);
2021-06-15 04:59:31 +02:00
+ // Paper start - Add Adventure message to PlayerAdvancementDoneEvent
2023-06-08 03:13:54 +02:00
+ if (message != null && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
2022-07-27 22:55:55 +02:00
+ this.playerList.broadcastSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), false);
2021-06-15 04:59:31 +02:00
+ // Paper end
}
}
}