Use implementation-provided legacy serializer for events

This commit is contained in:
Riley Park 2021-03-08 17:11:17 -08:00
parent 246dff9c8b
commit 0eaa2dd444
8 changed files with 88 additions and 62 deletions

View file

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
+ public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage, @Nullable QuitReason quitReason) { + public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage, @Nullable QuitReason quitReason) {
super(who); super(who);
this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper this.quitMessage = quitMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(quitMessage) : null; // Paper
+ this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; + this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason;
} }
// Paper start // Paper start

View file

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -0,0 +0,0 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe @@ -0,0 +0,0 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe
default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message)); this.sendMessage(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(message));
} }
+ +
+ /** + /**

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package org.bukkit.event.command; +package org.bukkit.event.command;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender; +import org.bukkit.command.CommandSender;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Deprecated + @Deprecated
+ public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final String message) { + public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final String message) {
+ this(sender, commandLine, message == null ? null : LegacyComponentSerializer.legacySection().deserialize(message)); + this(sender, commandLine, message == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message));
+ } + }
+ +
+ public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) { + public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) {
@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Nullable + @Nullable
+ @Deprecated + @Deprecated
+ public String getMessage() { + public String getMessage() {
+ return this.message == null ? null : LegacyComponentSerializer.legacySection().serialize(this.message); + return this.message == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message);
+ } + }
+ +
+ /** + /**
@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated + @Deprecated
+ public void setMessage(@Nullable String message) { + public void setMessage(@Nullable String message) {
+ this.message(message == null ? null : LegacyComponentSerializer.legacySection().deserialize(message)); + this.message(message == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message));
+ } + }
+ +
+ /** + /**

View file

@ -15,8 +15,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import org.apache.commons.lang.Validate; +import org.apache.commons.lang.Validate;
+import org.bukkit.Bukkit;
+import org.bukkit.event.Cancellable; +import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
@ -262,7 +262,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull + @NotNull
+ @Deprecated + @Deprecated
+ public String getFailMessage() { + public String getFailMessage() {
+ return LegacyComponentSerializer.legacySection().serialize(this.failMessage()); + return Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.failMessage());
+ } + }
+ +
+ /** + /**
@ -274,7 +274,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated + @Deprecated
+ public void setFailMessage(@NotNull String failMessage) { + public void setFailMessage(@NotNull String failMessage) {
+ Validate.notEmpty(failMessage, "fail message cannot be null or empty"); + Validate.notEmpty(failMessage, "fail message cannot be null or empty");
+ this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage)); + this.failMessage(Bukkit.getUnsafe().legacyComponentSerializer().deserialize(failMessage));
+ } + }
+ +
+ @NotNull + @NotNull

View file

@ -809,6 +809,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -0,0 +0,0 @@ import org.bukkit.plugin.PluginDescriptionFile;
*/
@Deprecated
public interface UnsafeValues {
+ net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer(); // Paper
void reportTimings(); // Paper
Material toLegacy(Material material);
diff --git a/src/main/java/org/bukkit/Warning.java b/src/main/java/org/bukkit/Warning.java diff --git a/src/main/java/org/bukkit/Warning.java b/src/main/java/org/bukkit/Warning.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/Warning.java --- a/src/main/java/org/bukkit/Warning.java
@ -1014,7 +1026,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start + // Paper start
+ @Override + @Override
+ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { + default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) {
+ this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message)); + this.sendMessage(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(message));
+ } + }
+ // Paper end + // Paper end
} }
@ -1485,7 +1497,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start + // Paper start
+ this.adventure$lines = new java.util.ArrayList<>(); + this.adventure$lines = new java.util.ArrayList<>();
+ for (String theLine : theLines) { + for (String theLine : theLines) {
+ this.adventure$lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(theLine)); + this.adventure$lines.add(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(theLine));
+ } + }
+ // Paper end + // Paper end
} }
@ -1541,7 +1553,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String[] getLines() { public String[] getLines() {
- return lines; - return lines;
+ return adventure$lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper + return adventure$lines.stream().map(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer()::serialize).toArray(String[]::new); // Paper
} }
/** /**
@ -1555,7 +1567,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getLine(int index) throws IndexOutOfBoundsException { public String getLine(int index) throws IndexOutOfBoundsException {
- return lines[index]; - return lines[index];
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.adventure$lines.get(index)); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.adventure$lines.get(index)); // Paper
} }
/** /**
@ -1568,7 +1580,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException { public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException {
- lines[index] = line; - lines[index] = line;
+ adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper + adventure$lines.set(index, line != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(line) : null); // Paper
} }
@Override @Override
@ -1621,7 +1633,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.newTotalExp = newTotalExp; this.newTotalExp = newTotalExp;
this.newLevel = newLevel; this.newLevel = newLevel;
this.deathMessage = deathMessage; this.deathMessage = deathMessage;
+ this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.adventure$deathMessage = deathMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper
} }
@NotNull @NotNull
@ -1659,7 +1671,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setDeathMessage(@Nullable String deathMessage) { public void setDeathMessage(@Nullable String deathMessage) {
this.deathMessage = deathMessage; this.deathMessage = deathMessage;
+ this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.adventure$deathMessage = deathMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper
} }
/** /**
@ -1677,7 +1689,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- -
+ // Paper start //TODO: add translation API to drop String deathMessage in favor of just Adventure + // Paper start //TODO: add translation API to drop String deathMessage in favor of just Adventure
+ private static String getDeathMessageString(net.kyori.adventure.text.Component component) { + private static String getDeathMessageString(net.kyori.adventure.text.Component component) {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(component); + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(component);
+ } + }
+ // Paper end + // Paper end
/** /**
@ -1822,7 +1834,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull + @NotNull
+ @Deprecated // Paper + @Deprecated // Paper
+ public String getKickMessage() { + public String getKickMessage() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper
+ } + }
+ +
+ /** + /**
@ -1833,7 +1845,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated // Paper + @Deprecated // Paper
+ public void setKickMessage(@NotNull final String message) { + public void setKickMessage(@NotNull final String message) {
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
+ } + }
+ +
/** /**
@ -1856,7 +1868,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void disallow(@NotNull final Result result, @NotNull final String message) { public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result; this.result = result;
- this.message = message; - this.message = message;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
} }
/** /**
@ -1865,7 +1877,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final String message) { public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final String message) {
this.result = result == null ? null : Result.valueOf(result.name()); this.result = result == null ? null : Result.valueOf(result.name());
- this.message = message; - this.message = message;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
} }
/** /**
@ -1913,7 +1925,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper end + @Deprecated // Paper end
public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) { public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) {
super(playerJoined); super(playerJoined);
+ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper end + this.joinMessage = joinMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(joinMessage) : null; // Paper end
+ } + }
+ +
+ // Paper start + // Paper start
@ -1946,7 +1958,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getJoinMessage() { public String getJoinMessage() {
- return joinMessage; - return joinMessage;
+ return this.joinMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.joinMessage); // Paper + return this.joinMessage == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.joinMessage); // Paper
} }
/** /**
@ -1958,7 +1970,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setJoinMessage(@Nullable String joinMessage) { public void setJoinMessage(@Nullable String joinMessage) {
- this.joinMessage = joinMessage; - this.joinMessage = joinMessage;
+ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper + this.joinMessage = joinMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(joinMessage) : null; // Paper
} }
@NotNull @NotNull
@ -1979,8 +1991,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) { public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) {
+ super(playerKicked); + super(playerKicked);
+ this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper + this.kickReason = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickReason); // Paper
+ this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper + this.leaveMessage = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(leaveMessage); // Paper
+ this.cancel = false; + this.cancel = false;
+ } + }
+ // Paper start + // Paper start
@ -2038,7 +2050,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getReason() { public String getReason() {
- return kickReason; - return kickReason;
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.kickReason); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.kickReason); // Paper
} }
/** /**
@ -2051,7 +2063,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getLeaveMessage() { public String getLeaveMessage() {
- return leaveMessage; - return leaveMessage;
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.leaveMessage); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.leaveMessage); // Paper
} }
@Override @Override
@ -2064,7 +2076,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setReason(@NotNull String kickReason) { public void setReason(@NotNull String kickReason) {
- this.kickReason = kickReason; - this.kickReason = kickReason;
+ this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper + this.kickReason = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickReason); // Paper
} }
/** /**
@ -2076,7 +2088,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setLeaveMessage(@NotNull String leaveMessage) { public void setLeaveMessage(@NotNull String leaveMessage) {
- this.leaveMessage = leaveMessage; - this.leaveMessage = leaveMessage;
+ this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper + this.leaveMessage = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(leaveMessage); // Paper
} }
@NotNull @NotNull
@ -2140,7 +2152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message, @NotNull final InetAddress realAddress) { // Spigot public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message, @NotNull final InetAddress realAddress) { // Spigot
this(player, hostname, address, realAddress); // Spigot this(player, hostname, address, realAddress); // Spigot
this.result = result; this.result = result;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
+ } + }
+ +
+ // Paper start + // Paper start
@ -2193,7 +2205,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getKickMessage() { public String getKickMessage() {
- return message; - return message;
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper
} }
/** /**
@ -2205,7 +2217,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setKickMessage(@NotNull final String message) { public void setKickMessage(@NotNull final String message) {
- this.message = message; - this.message = message;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
} }
/** /**
@ -2227,7 +2239,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper start + @Deprecated // Paper start
public void disallow(@NotNull final Result result, @NotNull final String message) { public void disallow(@NotNull final Result result, @NotNull final String message) {
+ this.result = result; + this.result = result;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message);
+ } + }
+ /** + /**
+ * Disallows the player from logging in, with the given reason + * Disallows the player from logging in, with the given reason
@ -2309,7 +2321,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
+ @NotNull + @NotNull
+ public String getKickMessage() { + public String getKickMessage() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper
+ } + }
+ +
+ /** + /**
@ -2320,7 +2332,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated // Paper + @Deprecated // Paper
+ public void setKickMessage(@NotNull final String message) { + public void setKickMessage(@NotNull final String message) {
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
+ } + }
+ +
/** /**
@ -2343,7 +2355,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void disallow(@NotNull final Result result, @NotNull final String message) { public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result; this.result = result;
- this.message = message; - this.message = message;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
} }
/** /**
@ -2361,7 +2373,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) { public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) {
super(who); super(who);
+ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper + this.quitMessage = quitMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(quitMessage) : null; // Paper
+ } + }
+ // Paper start + // Paper start
+ public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) { + public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) {
@ -2398,7 +2410,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getQuitMessage() { public String getQuitMessage() {
- return quitMessage; - return quitMessage;
+ return this.quitMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.quitMessage); // Paper + return this.quitMessage == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.quitMessage); // Paper
} }
/** /**
@ -2410,7 +2422,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setQuitMessage(@Nullable String quitMessage) { public void setQuitMessage(@Nullable String quitMessage) {
- this.quitMessage = quitMessage; - this.quitMessage = quitMessage;
+ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper + this.quitMessage = quitMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(quitMessage) : null; // Paper
} }
@NotNull @NotNull
@ -2435,7 +2447,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set<CommandSender> recipients) { public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set<CommandSender> recipients) {
+ // Paper start + // Paper start
+ super(isAsync); + super(isAsync);
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message);
+ this.recipients = recipients; + this.recipients = recipients;
+ } + }
+ +
@ -2480,7 +2492,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getMessage() { public String getMessage() {
- return message; - return message;
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper
} }
/** /**
@ -2492,7 +2504,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setMessage(@NotNull String message) { public void setMessage(@NotNull String message) {
- this.message = message; - this.message = message;
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper
} }
/** /**
@ -2500,11 +2512,7 @@ diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/sr
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java --- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
+++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; @@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
* checked and removed by {@link #iterator() iterating} over this event.
*/
public class ServerListPingEvent extends ServerEvent implements Iterable<Player> {
+ private static final net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer LEGACY_SECTION_SERIALIZER = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.builder().useUnusualXRepeatedCharacterHexFormat().build(); // Paper
private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE; private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE;
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final InetAddress address; private final InetAddress address;
@ -2519,7 +2527,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
this.address = address; this.address = address;
- this.motd = motd; - this.motd = motd;
+ this.motd = LEGACY_SECTION_SERIALIZER.deserialize(motd); // Paper + this.motd = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(motd); // Paper
this.numPlayers = numPlayers; this.numPlayers = numPlayers;
this.maxPlayers = maxPlayers; this.maxPlayers = maxPlayers;
} }
@ -2534,7 +2542,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ super(true); + super(true);
+ this.numPlayers = MAGIC_PLAYER_COUNT; + this.numPlayers = MAGIC_PLAYER_COUNT;
+ this.address = address; + this.address = address;
+ this.motd = LEGACY_SECTION_SERIALIZER.deserialize(motd); // Paper + this.motd = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(motd); // Paper
+ this.maxPlayers = maxPlayers; + this.maxPlayers = maxPlayers;
+ } + }
+ // Paper start + // Paper start
@ -2592,7 +2600,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getMotd() { public String getMotd() {
- return motd; - return motd;
+ return LEGACY_SECTION_SERIALIZER.serialize(this.motd); // Paper + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.motd); // Paper
} }
/** /**
@ -2604,7 +2612,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setMotd(@NotNull String motd) { public void setMotd(@NotNull String motd) {
- this.motd = motd; - this.motd = motd;
+ this.motd = LEGACY_SECTION_SERIALIZER.deserialize(motd); // Paper + this.motd = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(motd); // Paper
} }
/** /**
@ -2624,7 +2632,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
*/ */
@NotNull @NotNull
+ public /*abstract*/ net.kyori.adventure.text.Component title() { + public /*abstract*/ net.kyori.adventure.text.Component title() {
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.getTitle()); + return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(this.getTitle());
+ } + }
+ // Paper end + // Paper end
+ +
@ -3071,7 +3079,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
setRawType(type); setRawType(type);
this.visible = visible; this.visible = visible;
- this.caption = caption; - this.caption = caption;
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper + this.caption = caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(caption); // Paper
} }
+ // Paper start + // Paper start
+ /** + /**
@ -3115,7 +3123,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
setType(type); setType(type);
this.visible = visible; this.visible = visible;
- this.caption = caption; - this.caption = caption;
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper + this.caption = caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(caption); // Paper
} }
/** /**
@ -3151,7 +3159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getCaption() { public String getCaption() {
- return caption; - return caption;
+ return this.caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.caption); // Paper + return this.caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.caption); // Paper
} }
/** /**
@ -3163,7 +3171,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setCaption(@Nullable String caption) { public void setCaption(@Nullable String caption) {
- this.caption = caption; - this.caption = caption;
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper + this.caption = caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(caption); // Paper
} }
/** /**

View file

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this(player, drops, droppedExp, 0, deathMessage); this(player, drops, droppedExp, 0, deathMessage);
} }
@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { @@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent {
this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper this.adventure$deathMessage = deathMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper
} }
+ @Deprecated // Paper + @Deprecated // Paper

View file

@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+import com.destroystokyo.paper.profile.PlayerProfile; +import com.destroystokyo.paper.profile.PlayerProfile;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList; +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
@ -62,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Deprecated + @Deprecated
+ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) { + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) {
+ this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); + this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickMessage));
+ } + }
+ +
+ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) { + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) {
@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated + @Deprecated
+ @Nullable + @Nullable
+ public String getKickMessage() { + public String getKickMessage() {
+ return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(kickMessage); + return this.kickMessage == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().serialize(kickMessage);
+ } + }
+ +
+ /** + /**
@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */ + */
+ @Deprecated + @Deprecated
+ public void setKickMessage(@Nullable String kickMessage) { + public void setKickMessage(@Nullable String kickMessage) {
+ this.kickMessage(kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); + this.kickMessage(kickMessage == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickMessage));
+ } + }
+ +
+ /** + /**

View file

@ -3116,3 +3116,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
StringBuilder out = new StringBuilder(); StringBuilder out = new StringBuilder();
boolean hadFormat = false; boolean hadFormat = false;
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
private CraftMagicNumbers() {}
+ // Paper start
+ @Override
+ public net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer() {
+ return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC;
+ }
+ // Paper end
+
public static IBlockData getBlock(MaterialData material) {
return getBlock(material.getItemType(), material.getData());
}