Fix legacyComposer not using AsyncChatEvent messages (#5509)

This commit is contained in:
Prof-Bloodstone 2021-04-22 20:28:22 +02:00
parent 23b028a34f
commit 27c8f8cf70

View file

@ -165,13 +165,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ 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..00000000000000000000000000000000
+ // 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..00000000000000000000000000000000
+ 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) {