diff --git a/Spigot-Server-Patches/Adventure.patch b/Spigot-Server-Patches/Adventure.patch index 563aa8480e..2e08077092 100644 --- a/Spigot-Server-Patches/Adventure.patch +++ b/Spigot-Server-Patches/Adventure.patch @@ -123,8 +123,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextReplacementConfig; +import net.kyori.adventure.text.event.ClickEvent; -+import net.kyori.adventure.text.format.Style; -+import net.kyori.adventure.text.format.TextDecoration; +import net.minecraft.server.EntityPlayer; +import net.minecraft.server.IChatBaseComponent; +import net.minecraft.server.MinecraftServer; @@ -165,66 +163,80 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.async = async; + } + -+ @SuppressWarnings("deprecation") ++ @SuppressWarnings("CodeBlock2Expr") + public void process() { -+ final boolean listenersOnSyncEvent = anyListeners(ChatEvent.getHandlerList()); -+ -+ this.processLegacy( ++ this.processingLegacyFirst( + // continuing from AsyncPlayerChatEvent (without PlayerChatEvent) + event -> { -+ final AsyncChatEvent ae = this.createAsync( ++ this.processModern( + legacyFormatter(event.getFormat(), legacyDisplayName((CraftPlayer) event.getPlayer()), event.getMessage()), + event.getRecipients(), -+ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getMessage()) ++ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getMessage()), ++ event.isCancelled() + ); -+ ae.setCancelled(event.isCancelled()); // propagate cancelled state -+ post(ae); -+ if (listenersOnSyncEvent) { -+ this.continueWithSyncFromWhereAsyncLeftOff(ae); -+ } else { -+ this.complete(ae); -+ } + }, + // continuing from AsyncPlayerChatEvent and PlayerChatEvent + event -> { -+ this.queueIfAsyncOrRunImmediately(new Waitable() { -+ @Override -+ protected Void evaluate() { -+ final ChatEvent se = ChatProcessor.this.createSync( -+ legacyFormatter(event.getFormat(), legacyDisplayName((CraftPlayer) event.getPlayer()), event.getMessage()), -+ event.getRecipients(), -+ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getMessage()) -+ ); -+ se.setCancelled(event.isCancelled()); // propagate cancelled state -+ post(se); -+ ChatProcessor.this.complete(se); -+ return null; -+ } -+ }); ++ this.processModern( ++ legacyFormatter(event.getFormat(), legacyDisplayName((CraftPlayer) event.getPlayer()), event.getMessage()), ++ event.getRecipients(), ++ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getMessage()), ++ event.isCancelled() ++ ); + }, + // no legacy events called, all nice and fresh! + () -> { -+ final AsyncChatEvent ae = this.createAsync(ChatFormatter.DEFAULT, new LazyPlayerSet(this.server), Component.text(this.message).replaceText(URL_REPLACEMENT_CONFIG)); -+ post(ae); -+ if (listenersOnSyncEvent) { -+ this.continueWithSyncFromWhereAsyncLeftOff(ae); -+ } else { -+ this.complete(ae); -+ } ++ this.processModern( ++ ChatFormatter.DEFAULT, ++ new LazyPlayerSet(this.server), ++ Component.text(this.message).replaceText(URL_REPLACEMENT_CONFIG), ++ false ++ ); + } + ); + } + -+ private static String legacyDisplayName(final CraftPlayer player) { -+ return player.getDisplayName(); ++ @SuppressWarnings("deprecation") ++ private void processingLegacyFirst( ++ final Consumer continueAfterAsync, ++ final Consumer continueAfterAsyncAndSync, ++ final Runnable modernOnly ++ ) { ++ final boolean listenersOnAsyncEvent = anyListeners(AsyncPlayerChatEvent.getHandlerList()); ++ final boolean listenersOnSyncEvent = anyListeners(PlayerChatEvent.getHandlerList()); ++ if (listenersOnAsyncEvent || listenersOnSyncEvent) { ++ final CraftPlayer player = this.player.getBukkitEntity(); ++ final AsyncPlayerChatEvent ae = new AsyncPlayerChatEvent(this.async, player, this.message, new LazyPlayerSet(this.server)); ++ post(ae); ++ if (listenersOnSyncEvent) { ++ final PlayerChatEvent se = new PlayerChatEvent(player, ae.getMessage(), ae.getFormat(), ae.getRecipients()); ++ se.setCancelled(ae.isCancelled()); // propagate cancelled state ++ this.queueIfAsyncOrRunImmediately(new Waitable() { ++ @Override ++ protected Void evaluate() { ++ post(se); ++ return null; ++ } ++ }); ++ continueAfterAsyncAndSync.accept(se); ++ } else if (!ae.isCancelled()) { ++ continueAfterAsync.accept(ae); ++ } ++ } else { ++ modernOnly.run(); ++ } + } + -+ private static Component displayName(final CraftPlayer player) { -+ return player.displayName(); -+ } -+ -+ private static ChatFormatter legacyFormatter(final String format, final String legacyDisplayName, final String legacyMessage) { -+ return (displayName, message) -> PaperAdventure.LEGACY_SECTION_UXRC.deserialize(String.format(format, legacyDisplayName, legacyMessage)).replaceText(URL_REPLACEMENT_CONFIG); ++ private void processModern(final ChatFormatter formatter, final Set recipients, final Component message, final boolean cancelled) { ++ final AsyncChatEvent ae = this.createAsync(formatter, recipients, message); ++ ae.setCancelled(cancelled); // propagate cancelled state ++ post(ae); ++ final boolean listenersOnSyncEvent = anyListeners(ChatEvent.getHandlerList()); ++ if (listenersOnSyncEvent) { ++ this.continueWithSyncFromWhereAsyncLeftOff(ae); ++ } else { ++ this.complete(ae); ++ } + } + + private void continueWithSyncFromWhereAsyncLeftOff(final AsyncChatEvent ae) { @@ -274,35 +286,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return new ChatEvent(this.player.getBukkitEntity(), recipients, formatter, message); + } + -+ @SuppressWarnings("deprecation") -+ public void processLegacy( -+ final Consumer continueAfterAsync, -+ final Consumer continueAfterAsyncAndSync, -+ final Runnable modernOnly -+ ) { -+ final boolean listenersOnAsyncEvent = anyListeners(AsyncPlayerChatEvent.getHandlerList()); -+ final boolean listenersOnSyncEvent = anyListeners(PlayerChatEvent.getHandlerList()); -+ if (listenersOnAsyncEvent || listenersOnSyncEvent) { -+ final CraftPlayer player = this.player.getBukkitEntity(); -+ final AsyncPlayerChatEvent ae = new AsyncPlayerChatEvent(this.async, player, this.message, new LazyPlayerSet(this.server)); -+ post(ae); -+ if (listenersOnSyncEvent) { -+ final PlayerChatEvent se = new PlayerChatEvent(player, ae.getMessage(), ae.getFormat(), ae.getRecipients()); -+ se.setCancelled(ae.isCancelled()); // propagate cancelled state -+ this.queueIfAsyncOrRunImmediately(new Waitable() { -+ @Override -+ protected Void evaluate() { -+ post(se); -+ return null; -+ } -+ }); -+ continueAfterAsyncAndSync.accept(se); -+ } else if (!ae.isCancelled()) { -+ continueAfterAsync.accept(ae); -+ } -+ } else { -+ modernOnly.run(); -+ } ++ private static String legacyDisplayName(final CraftPlayer player) { ++ return player.getDisplayName(); ++ } ++ ++ private static Component displayName(final CraftPlayer player) { ++ return player.displayName(); ++ } ++ ++ private static ChatFormatter legacyFormatter(final String format, final String legacyDisplayName, final String legacyMessage) { ++ return (displayName, message) -> PaperAdventure.LEGACY_SECTION_UXRC.deserialize(String.format(format, legacyDisplayName, legacyMessage)).replaceText(URL_REPLACEMENT_CONFIG); + } + + private void queueIfAsyncOrRunImmediately(final Waitable waitable) { diff --git a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch index a7d9c298d7..6f17c24836 100644 --- a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch +++ b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch @@ -29,12 +29,7 @@ diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -@@ -0,0 +0,0 @@ import java.util.regex.Pattern; - import net.kyori.adventure.text.Component; - import net.kyori.adventure.text.TextReplacementConfig; - import net.kyori.adventure.text.event.ClickEvent; --import net.kyori.adventure.text.format.Style; --import net.kyori.adventure.text.format.TextDecoration; +@@ -0,0 +0,0 @@ import net.kyori.adventure.text.event.ClickEvent; import net.minecraft.server.EntityPlayer; import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.MinecraftServer;