Use original user input instead of legacy event result for AbstractChatEvent#originalMessage (#5770)

This commit is contained in:
Josh Taylor 2021-06-02 23:57:54 +01:00
parent 2614cde313
commit 887b02a2ad
2 changed files with 63 additions and 10 deletions

View File

@ -292,6 +292,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Component originalMessage; + private final Component originalMessage;
+ private Component message; + private Component message;
+ +
+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) {
+ super(player, async);
+ this.viewers = viewers;
+ this.recipients = new HashSet<>(Bukkit.getOnlinePlayers());
+ this.renderer = renderer;
+ this.message = message;
+ this.originalMessage = originalMessage;
+ }
+
+ /**
+ * @deprecated for removal with 1.17
+ */
+ @Deprecated
+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) { + AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) {
+ super(player, async); + super(player, async);
+ this.viewers = viewers; + this.viewers = viewers;
@ -305,6 +318,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @deprecated for removal with 1.17 + * @deprecated for removal with 1.17
+ */ + */
+ @Deprecated + @Deprecated
+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) {
+ super(player, async);
+ this.recipients = recipients;
+ this.viewers = viewers;
+ this.renderer = renderer;
+ this.message = message;
+ this.originalMessage = originalMessage;
+ }
+
+ /**
+ * @deprecated for removal with 1.17
+ */
+ @Deprecated
+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) { + AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) {
+ super(player, async); + super(player, async);
+ this.recipients = recipients; + this.recipients = recipients;
@ -556,12 +582,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+public final class AsyncChatEvent extends AbstractChatEvent { +public final class AsyncChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList(); + private static final HandlerList HANDLERS = new HandlerList();
+ +
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) {
+ super(async, player, viewers, renderer, message, originalMessage);
+ }
+
+ /**
+ * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component, Component)}
+ */
+ @Deprecated
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) { + public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) {
+ super(async, player, viewers, renderer, message); + super(async, player, viewers, renderer, message);
+ } + }
+ +
+ /** + /**
+ * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component)} + * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component, Component)}
+ */
+ @Deprecated
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) {
+ super(async, player, recipients, viewers, renderer, message, originalMessage);
+ }
+
+ /**
+ * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component, Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) { + public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) {
@ -569,7 +611,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ /** + /**
+ * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component)} + * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component, Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatComposer composer, final @NotNull Component message) { + public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatComposer composer, final @NotNull Component message) {
@ -577,7 +619,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ /** + /**
+ * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component)} + * @deprecated for removal with 1.17, use {@link #AsyncChatEvent(boolean, Player, Set, ChatRenderer, Component, Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatFormatter formatter, final @NotNull Component message) { + public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatFormatter formatter, final @NotNull Component message) {
@ -624,19 +666,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+public final class ChatEvent extends AbstractChatEvent { +public final class ChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList(); + private static final HandlerList HANDLERS = new HandlerList();
+ +
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) {
+ super(false, player, viewers, renderer, message, originalMessage);
+ }
+
+ /**
+ * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component, Component)}
+ */
+ @Deprecated
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) { + public ChatEvent(final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) {
+ super(false, player, viewers, renderer, message); + super(false, player, viewers, renderer, message);
+ } + }
+ +
+ /** + /**
+ * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component)} + * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component, Component)}
+ */ + */
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message) { + @Deprecated
+ super(false, player, recipients, viewers, renderer, message); + public ChatEvent(final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage) {
+ super(false, player, recipients, viewers, renderer, message, originalMessage);
+ } + }
+ +
+ /** + /**
+ * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component)} + * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component, Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatComposer composer, final @NotNull Component message) { + public ChatEvent(final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatComposer composer, final @NotNull Component message) {
@ -644,7 +695,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ /** + /**
+ * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component)} + * @deprecated for removal with 1.17, use {@link #ChatEvent(Player, Set, ChatRenderer, Component, Component)}
+ */ + */
+ @Deprecated + @Deprecated
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatFormatter formatter, final @NotNull Component message) { + public ChatEvent(final @NotNull Player player, final @NotNull Set<Player> recipients, final @NotNull ChatFormatter formatter, final @NotNull Component message) {

View File

@ -157,12 +157,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final EntityPlayer player; + final EntityPlayer player;
+ final String message; + final String message;
+ final boolean async; + final boolean async;
+ final Component originalMessage;
+ +
+ public ChatProcessor(final MinecraftServer server, final EntityPlayer player, final String message, final boolean async) { + public ChatProcessor(final MinecraftServer server, final EntityPlayer player, final String message, final boolean async) {
+ this.server = server; + this.server = server;
+ this.player = player; + this.player = player;
+ this.message = message; + this.message = message;
+ this.async = async; + this.async = async;
+ this.originalMessage = Component.text(message);
+ } + }
+ +
+ @SuppressWarnings({"CodeBlock2Expr", "deprecated"}) + @SuppressWarnings({"CodeBlock2Expr", "deprecated"})
@ -280,11 +282,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ +
+ private AsyncChatEvent createAsync(final ChatRenderer renderer, final Set<Player> recipients, final Set<Audience> viewers, final Component message) { + private AsyncChatEvent createAsync(final ChatRenderer renderer, final Set<Player> recipients, final Set<Audience> viewers, final Component message) {
+ return new AsyncChatEvent(this.async, this.player.getBukkitEntity(), recipients, viewers, renderer, message); + return new AsyncChatEvent(this.async, this.player.getBukkitEntity(), recipients, viewers, renderer, message, this.originalMessage);
+ } + }
+ +
+ private ChatEvent createSync(final ChatRenderer renderer, final Set<Player> recipients, final Set<Audience> viewers, final Component message) { + private ChatEvent createSync(final ChatRenderer renderer, final Set<Player> recipients, final Set<Audience> viewers, final Component message) {
+ return new ChatEvent(this.player.getBukkitEntity(), recipients, viewers, renderer, message); + return new ChatEvent(this.player.getBukkitEntity(), recipients, viewers, renderer, message, this.originalMessage);
+ } + }
+ +
+ private static String legacyDisplayName(final CraftPlayer player) { + private static String legacyDisplayName(final CraftPlayer player) {