3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00

Fix legacyComposer not using AsyncChatEvent messages (#5509)

Dieser Commit ist enthalten in:
Prof-Bloodstone 2021-04-22 20:28:22 +02:00 committet von GitHub
Ursprung 053bd82cc2
Commit d94882043d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -105,7 +105,7 @@ index 0000000000000000000000000000000000000000..89597b4a3064c3c6001c7e927a848ee7
+}
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
new file mode 100644
index 0000000000000000000000000000000000000000..84dcca67ccd2e52881b4a97de0f061b396ab5f35
index 0000000000000000000000000000000000000000..50253e8dfffc84e26f02c6a470a5a8b078d90e12
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
@@ -0,0 +1,215 @@
@ -165,13 +165,13 @@ index 0000000000000000000000000000000000000000..84dcca67ccd2e52881b4a97de0f061b3
+ this.async = async;
+ }
+
+ @SuppressWarnings("CodeBlock2Expr")
+ @SuppressWarnings({"CodeBlock2Expr", "deprecated"})
+ public void process() {
+ this.processingLegacyFirst(
+ // continuing from AsyncPlayerChatEvent (without PlayerChatEvent)
+ event -> {
+ this.processModern(
+ legacyComposer(event.getFormat(), legacyDisplayName((CraftPlayer) event.getPlayer()), event.getMessage()),
+ legacyComposer(event.getFormat()),
+ event.getRecipients(),
+ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getMessage()),
+ event.isCancelled()
@ -180,7 +180,7 @@ index 0000000000000000000000000000000000000000..84dcca67ccd2e52881b4a97de0f061b3
+ // continuing from AsyncPlayerChatEvent and PlayerChatEvent
+ event -> {
+ this.processModern(
+ legacyComposer(event.getFormat(), legacyDisplayName((CraftPlayer) event.getPlayer()), event.getMessage()),
+ legacyComposer(event.getFormat()),
+ event.getRecipients(),
+ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getMessage()),
+ event.isCancelled()
@ -297,8 +297,8 @@ index 0000000000000000000000000000000000000000..84dcca67ccd2e52881b4a97de0f061b3
+ return player.displayName();
+ }
+
+ private static ChatComposer legacyComposer(final String format, final String legacyDisplayName, final String legacyMessage) {
+ return (player, displayName, message) -> PaperAdventure.LEGACY_SECTION_UXRC.deserialize(String.format(format, legacyDisplayName, legacyMessage)).replaceText(URL_REPLACEMENT_CONFIG);
+ private static ChatComposer legacyComposer(final String format) {
+ return (player, displayName, message) -> PaperAdventure.LEGACY_SECTION_UXRC.deserialize(String.format(format, legacyDisplayName((CraftPlayer) player), PaperAdventure.LEGACY_SECTION_UXRC.serialize(message))).replaceText(URL_REPLACEMENT_CONFIG);
+ }
+
+ private void queueIfAsyncOrRunImmediately(final Waitable<Void> waitable) {