13
0
geforkt von Mirrors/Paper

Provide ComponentSerializer services (#7527)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-05-26 12:12:14 -07:00 committet von GitHub
Ursprung 182a609b85
Commit b6a6544ad1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
21 geänderte Dateien mit 505 neuen und 311 gelöschten Zeilen

Datei anzeigen

@ -358,10 +358,10 @@ index 0000000000000000000000000000000000000000..eb179aae1e1d2ce842442e49fe275827
+} +}
diff --git a/src/main/java/io/papermc/paper/text/PaperComponents.java b/src/main/java/io/papermc/paper/text/PaperComponents.java diff --git a/src/main/java/io/papermc/paper/text/PaperComponents.java b/src/main/java/io/papermc/paper/text/PaperComponents.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..15ecb12fd2fefcac96edbaef7cdd487a1d2c5641 index 0000000000000000000000000000000000000000..bff9a6295db367c6b89d69fb55459a40828265ea
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/text/PaperComponents.java +++ b/src/main/java/io/papermc/paper/text/PaperComponents.java
@@ -0,0 +1,104 @@ @@ -0,0 +1,112 @@
+package io.papermc.paper.text; +package io.papermc.paper.text;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
@ -398,10 +398,10 @@ index 0000000000000000000000000000000000000000..15ecb12fd2fefcac96edbaef7cdd487a
+ * <p>Implementations may provide a serializer capable of processing any + * <p>Implementations may provide a serializer capable of processing any
+ * information that requires access to implementation details.</p> + * information that requires access to implementation details.</p>
+ * + *
+ * @deprecated will be removed in adventure 5.0.0, use {@link #plainTextSerializer()}
+ * @return a serializer to plain text + * @return a serializer to plain text
+ * @deprecated will be removed in adventure 5.0.0, use {@link PlainTextComponentSerializer#plainText()}
+ */ + */
+ @Deprecated + @Deprecated(forRemoval = true)
+ public static @NotNull PlainComponentSerializer plainSerializer() { + public static @NotNull PlainComponentSerializer plainSerializer() {
+ return Bukkit.getUnsafe().plainComponentSerializer(); + return Bukkit.getUnsafe().plainComponentSerializer();
+ } + }
@ -414,7 +414,9 @@ index 0000000000000000000000000000000000000000..15ecb12fd2fefcac96edbaef7cdd487a
+ * information that requires access to implementation details.</p> + * information that requires access to implementation details.</p>
+ * + *
+ * @return a serializer to plain text + * @return a serializer to plain text
+ * @deprecated use {@link PlainTextComponentSerializer#plainText()}
+ */ + */
+ @Deprecated(forRemoval = true)
+ public static @NotNull PlainTextComponentSerializer plainTextSerializer() { + public static @NotNull PlainTextComponentSerializer plainTextSerializer() {
+ return Bukkit.getUnsafe().plainTextSerializer(); + return Bukkit.getUnsafe().plainTextSerializer();
+ } + }
@ -428,7 +430,9 @@ index 0000000000000000000000000000000000000000..15ecb12fd2fefcac96edbaef7cdd487a
+ * (pre-1.16) hover events.</p> + * (pre-1.16) hover events.</p>
+ * + *
+ * @return a json component serializer + * @return a json component serializer
+ * @deprecated use {@link GsonComponentSerializer#gson()}
+ */ + */
+ @Deprecated(forRemoval = true)
+ public static @NotNull GsonComponentSerializer gsonSerializer() { + public static @NotNull GsonComponentSerializer gsonSerializer() {
+ return Bukkit.getUnsafe().gsonComponentSerializer(); + return Bukkit.getUnsafe().gsonComponentSerializer();
+ } + }
@ -443,7 +447,9 @@ index 0000000000000000000000000000000000000000..15ecb12fd2fefcac96edbaef7cdd487a
+ * (pre-1.16) hover events.</p> + * (pre-1.16) hover events.</p>
+ * + *
+ * @return a json component serializer + * @return a json component serializer
+ * @deprecated use {@link GsonComponentSerializer#colorDownsamplingGson()}
+ */ + */
+ @Deprecated(forRemoval = true)
+ public static @NotNull GsonComponentSerializer colorDownsamplingGsonSerializer() { + public static @NotNull GsonComponentSerializer colorDownsamplingGsonSerializer() {
+ return Bukkit.getUnsafe().colorDownsamplingGsonComponentSerializer(); + return Bukkit.getUnsafe().colorDownsamplingGsonComponentSerializer();
+ } + }
@ -461,7 +467,9 @@ index 0000000000000000000000000000000000000000..15ecb12fd2fefcac96edbaef7cdd487a
+ * information that requires access to implementation details.</p> + * information that requires access to implementation details.</p>
+ * + *
+ * @return a section serializer + * @return a section serializer
+ * @deprecated use {@link LegacyComponentSerializer#legacySection()}
+ */ + */
+ @Deprecated(forRemoval = true)
+ public static @NotNull LegacyComponentSerializer legacySectionSerializer() { + public static @NotNull LegacyComponentSerializer legacySectionSerializer() {
+ return Bukkit.getUnsafe().legacyComponentSerializer(); + return Bukkit.getUnsafe().legacyComponentSerializer();
+ } + }
@ -1100,7 +1108,7 @@ index ac5e263d737973af077e3406a84a84baca4370db..2d91924b7f5ef16a91d40cdc1bfc3d68
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 01e11f882abb6c631f810584aa23646042688435..f43ad19a44f3b7368a1a110cc55247277f4d3751 100644 index 01e11f882abb6c631f810584aa23646042688435..fa28b5bb0efd9d400277cd8969f38e039e6ea8ac 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java --- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -22,6 +22,14 @@ import org.bukkit.plugin.PluginDescriptionFile; @@ -22,6 +22,14 @@ import org.bukkit.plugin.PluginDescriptionFile;
@ -1109,11 +1117,11 @@ index 01e11f882abb6c631f810584aa23646042688435..f43ad19a44f3b7368a1a110cc5524727
public interface UnsafeValues { public interface UnsafeValues {
+ // Paper start + // Paper start
+ net.kyori.adventure.text.flattener.ComponentFlattener componentFlattener(); + net.kyori.adventure.text.flattener.ComponentFlattener componentFlattener();
+ @Deprecated net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer(); + @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer();
+ net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer(); + @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer();
+ net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer(); + @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer();
+ net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer(); + @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer();
+ net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer(); + @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer();
+ // Paper end + // Paper end
Material toLegacy(Material material); Material toLegacy(Material material);
@ -1276,7 +1284,7 @@ index ab6b0ec328e94bf65a0dafd0403e5ee3b870296c..c8d37184d8e882a4084a1bfef85faa33
/** /**
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..50e6d45ec9349b56d20e2ffc664eca15ba936cc6 100644 index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..8edd78adb042013bf702027f59455045d3b3e14f 100644
--- a/src/main/java/org/bukkit/command/Command.java --- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java
@@ -32,8 +32,7 @@ public abstract class Command { @@ -32,8 +32,7 @@ public abstract class Command {
@ -1314,7 +1322,7 @@ index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..50e6d45ec9349b56d20e2ffc664eca15
+ @Deprecated // Paper + @Deprecated // Paper
public String getPermissionMessage() { public String getPermissionMessage() {
- return permissionMessage; - return permissionMessage;
+ return io.papermc.paper.text.PaperComponents.legacySectionSerializer().serializeOrNull(permissionMessage); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serializeOrNull(permissionMessage); // Paper
} }
/** /**
@ -1328,7 +1336,7 @@ index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..50e6d45ec9349b56d20e2ffc664eca15
+ @Deprecated // Paper + @Deprecated // Paper
public Command setPermissionMessage(@Nullable String permissionMessage) { public Command setPermissionMessage(@Nullable String permissionMessage) {
- this.permissionMessage = permissionMessage; - this.permissionMessage = permissionMessage;
+ this.permissionMessage = io.papermc.paper.text.PaperComponents.legacySectionSerializer().deserializeOrNull(permissionMessage); // Paper + this.permissionMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(permissionMessage); // Paper
return this; return this;
} }
@ -1359,7 +1367,7 @@ index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..50e6d45ec9349b56d20e2ffc664eca15
public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message) { public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message) {
broadcastCommandMessage(source, message, true); broadcastCommandMessage(source, message, true);
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
index 284be63a125624a8ae43d2c164aede810ce6bfe5..f98d46fa45bb7c842d791b09f082a0968ae537fb 100644 index 284be63a125624a8ae43d2c164aede810ce6bfe5..22b654efdcc49d6dc6d52c9d6afa1c9dc7978e35 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java --- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java +++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -6,12 +6,13 @@ import org.bukkit.permissions.Permissible; @@ -6,12 +6,13 @@ import org.bukkit.permissions.Permissible;
@ -1456,12 +1464,12 @@ index 284be63a125624a8ae43d2c164aede810ce6bfe5..f98d46fa45bb7c842d791b09f082a096
+ +
+ @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(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(message)); + this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
+ } + }
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java diff --git a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
index a542c4bb3c973bbe4b976642feccde6a4d90cb7b..614cba22c0997dbb45576f800675db4053a9831c 100644 index a542c4bb3c973bbe4b976642feccde6a4d90cb7b..ef870b864c1e36032b54b31f3f85707edc06d764 100644
--- a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java --- a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
+++ b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java +++ b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
@@ -67,7 +67,7 @@ public class PluginCommandYamlParser { @@ -67,7 +67,7 @@ public class PluginCommandYamlParser {
@ -1469,7 +1477,7 @@ index a542c4bb3c973bbe4b976642feccde6a4d90cb7b..614cba22c0997dbb45576f800675db40
if (permissionMessage != null) { if (permissionMessage != null) {
- newCmd.setPermissionMessage(permissionMessage.toString()); - newCmd.setPermissionMessage(permissionMessage.toString());
+ newCmd.permissionMessage(io.papermc.paper.text.PaperComponents.legacySectionSerializer().deserialize(permissionMessage.toString())); // Paper + newCmd.permissionMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(permissionMessage.toString())); // Paper
} }
pluginCmds.add(newCmd); pluginCmds.add(newCmd);
@ -2133,7 +2141,7 @@ index 63c80b4ee1f7adc8a9efc3b607993104b1991f90..91cab8b13d5bba34007f124838b32a1d
} }
diff --git a/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/src/main/java/org/bukkit/event/block/SignChangeEvent.java diff --git a/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/src/main/java/org/bukkit/event/block/SignChangeEvent.java
index 7190db11eff7d48df8a99f405a9dbaefdfa76e3d..1f79f704abf339150df08900b8ea7da4cefef258 100644 index 7190db11eff7d48df8a99f405a9dbaefdfa76e3d..1268066e30ddb0cd3792ea4b3de894eb04196669 100644
--- a/src/main/java/org/bukkit/event/block/SignChangeEvent.java --- a/src/main/java/org/bukkit/event/block/SignChangeEvent.java
+++ b/src/main/java/org/bukkit/event/block/SignChangeEvent.java +++ b/src/main/java/org/bukkit/event/block/SignChangeEvent.java
@@ -16,12 +16,25 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { @@ -16,12 +16,25 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
@ -2158,7 +2166,7 @@ index 7190db11eff7d48df8a99f405a9dbaefdfa76e3d..1f79f704abf339150df08900b8ea7da4
+ // 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(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(theLine)); + this.adventure$lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(theLine));
+ } + }
+ // Paper end + // Paper end
} }
@ -2214,7 +2222,7 @@ index 7190db11eff7d48df8a99f405a9dbaefdfa76e3d..1f79f704abf339150df08900b8ea7da4
+ @Deprecated // Paper + @Deprecated // Paper
public String[] getLines() { public String[] getLines() {
- return lines; - return lines;
+ return adventure$lines.stream().map(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer()::serialize).toArray(String[]::new); // Paper + return adventure$lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper
} }
/** /**
@ -2228,7 +2236,7 @@ index 7190db11eff7d48df8a99f405a9dbaefdfa76e3d..1f79f704abf339150df08900b8ea7da4
+ @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 org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.adventure$lines.get(index)); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.adventure$lines.get(index)); // Paper
} }
/** /**
@ -2241,12 +2249,12 @@ index 7190db11eff7d48df8a99f405a9dbaefdfa76e3d..1f79f704abf339150df08900b8ea7da4
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(line) : null); // Paper + adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper
} }
@Override @Override
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
index 3c2ea8fec3a748cab7f5ad9100d12bd8213ec6c9..a01d4c21bedc7f1a54f5a330bb4c2909ce3a18e4 100644 index 3c2ea8fec3a748cab7f5ad9100d12bd8213ec6c9..7941c60b0e1840785ba2b250071591bd75bc6e35 100644
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java --- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -12,25 +12,48 @@ import org.jetbrains.annotations.Nullable; @@ -12,25 +12,48 @@ import org.jetbrains.annotations.Nullable;
@ -2294,7 +2302,7 @@ index 3c2ea8fec3a748cab7f5ad9100d12bd8213ec6c9..a01d4c21bedc7f1a54f5a330bb4c2909
this.newTotalExp = newTotalExp; this.newTotalExp = newTotalExp;
this.newLevel = newLevel; this.newLevel = newLevel;
this.deathMessage = deathMessage; this.deathMessage = deathMessage;
+ this.adventure$deathMessage = deathMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper
} }
@NotNull @NotNull
@ -2332,7 +2340,7 @@ index 3c2ea8fec3a748cab7f5ad9100d12bd8213ec6c9..a01d4c21bedc7f1a54f5a330bb4c2909
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper
} }
/** /**
@ -2350,7 +2358,7 @@ index 3c2ea8fec3a748cab7f5ad9100d12bd8213ec6c9..a01d4c21bedc7f1a54f5a330bb4c2909
- -
+ // 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 org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(component); + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(component);
+ } + }
+ // Paper end + // Paper end
/** /**
@ -2412,7 +2420,7 @@ index 9c68c3f2d61500479f48b80264f625aaae2f3204..399afcd19fcb6acd24857ed6ab48cf0d
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private boolean cancel = false; private boolean cancel = false;
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
index 9866c07c999f46cb585709804aaad710c3031d5a..31f6f781a0403bf6388d668f0effaed5aae94468 100644 index 9866c07c999f46cb585709804aaad710c3031d5a..c7c45e2de8cca1bf8b8e12752e08db62403efa6a 100644
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java --- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
@ -2495,7 +2503,7 @@ index 9866c07c999f46cb585709804aaad710c3031d5a..31f6f781a0403bf6388d668f0effaed5
+ @NotNull + @NotNull
+ @Deprecated // Paper + @Deprecated // Paper
+ public String getKickMessage() { + public String getKickMessage() {
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
+ } + }
+ +
+ /** + /**
@ -2506,7 +2514,7 @@ index 9866c07c999f46cb585709804aaad710c3031d5a..31f6f781a0403bf6388d668f0effaed5
+ */ + */
+ @Deprecated // Paper + @Deprecated // Paper
+ public void setKickMessage(@NotNull final String message) { + public void setKickMessage(@NotNull final String message) {
+ this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
+ } + }
+ +
/** /**
@ -2529,7 +2537,7 @@ index 9866c07c999f46cb585709804aaad710c3031d5a..31f6f781a0403bf6388d668f0effaed5
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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
} }
/** /**
@ -2538,7 +2546,7 @@ index 9866c07c999f46cb585709804aaad710c3031d5a..31f6f781a0403bf6388d668f0effaed5
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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
} }
/** /**
@ -2568,7 +2576,7 @@ index 793b661b6d2d05de3d7f4fc26a4c018a2af58e62..f6d3b817de3001f04ea4554c7c39a129
player = who; player = who;
diff --git a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
index d06684aba7688ce06777dbd837a46856a9d7767f..851a189d42e271679abc78f95049d8badf7a2b64 100644 index d06684aba7688ce06777dbd837a46856a9d7767f..4af1d064fcb57773dfa8f6ad40d6482973f8e1a8 100644
--- a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
@@ -10,30 +10,60 @@ import org.jetbrains.annotations.Nullable; @@ -10,30 +10,60 @@ import org.jetbrains.annotations.Nullable;
@ -2586,7 +2594,7 @@ index d06684aba7688ce06777dbd837a46856a9d7767f..851a189d42e271679abc78f95049d8ba
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(joinMessage) : null; // Paper end + this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper end
+ } + }
+ +
+ // Paper start + // Paper start
@ -2619,7 +2627,7 @@ index d06684aba7688ce06777dbd837a46856a9d7767f..851a189d42e271679abc78f95049d8ba
+ @Deprecated // Paper + @Deprecated // Paper
public String getJoinMessage() { public String getJoinMessage() {
- return joinMessage; - return joinMessage;
+ return this.joinMessage == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.joinMessage); // Paper + return this.joinMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.joinMessage); // Paper
} }
/** /**
@ -2631,12 +2639,12 @@ index d06684aba7688ce06777dbd837a46856a9d7767f..851a189d42e271679abc78f95049d8ba
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(joinMessage) : null; // Paper + this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper
} }
@NotNull @NotNull
diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
index 14c337f15fc804f52e52cb0a185aad38d89303a8..5c0efe74237dbe6803ce023fde99682ff70d1a92 100644 index 14c337f15fc804f52e52cb0a185aad38d89303a8..2b3f57d1a1c79923a2173f52d9cf61da1f75b7fc 100644
--- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
@@ -10,35 +10,84 @@ import org.jetbrains.annotations.NotNull; @@ -10,35 +10,84 @@ import org.jetbrains.annotations.NotNull;
@ -2652,8 +2660,8 @@ index 14c337f15fc804f52e52cb0a185aad38d89303a8..5c0efe74237dbe6803ce023fde99682f
+ @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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickReason); // Paper + this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper
+ this.leaveMessage = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(leaveMessage); // Paper + this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper
+ this.cancel = false; + this.cancel = false;
+ } + }
+ // Paper start + // Paper start
@ -2711,7 +2719,7 @@ index 14c337f15fc804f52e52cb0a185aad38d89303a8..5c0efe74237dbe6803ce023fde99682f
+ @Deprecated // Paper + @Deprecated // Paper
public String getReason() { public String getReason() {
- return kickReason; - return kickReason;
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.kickReason); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.kickReason); // Paper
} }
/** /**
@ -2724,7 +2732,7 @@ index 14c337f15fc804f52e52cb0a185aad38d89303a8..5c0efe74237dbe6803ce023fde99682f
+ @Deprecated // Paper + @Deprecated // Paper
public String getLeaveMessage() { public String getLeaveMessage() {
- return leaveMessage; - return leaveMessage;
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.leaveMessage); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.leaveMessage); // Paper
} }
@Override @Override
@ -2737,7 +2745,7 @@ index 14c337f15fc804f52e52cb0a185aad38d89303a8..5c0efe74237dbe6803ce023fde99682f
+ @Deprecated // Paper + @Deprecated // Paper
public void setReason(@NotNull String kickReason) { public void setReason(@NotNull String kickReason) {
- this.kickReason = kickReason; - this.kickReason = kickReason;
+ this.kickReason = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickReason); // Paper + this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper
} }
/** /**
@ -2749,7 +2757,7 @@ index 14c337f15fc804f52e52cb0a185aad38d89303a8..5c0efe74237dbe6803ce023fde99682f
+ @Deprecated // Paper + @Deprecated // Paper
public void setLeaveMessage(@NotNull String leaveMessage) { public void setLeaveMessage(@NotNull String leaveMessage) {
- this.leaveMessage = leaveMessage; - this.leaveMessage = leaveMessage;
+ this.leaveMessage = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(leaveMessage); // Paper + this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper
} }
@NotNull @NotNull
@ -2790,7 +2798,7 @@ index 36b436e145a7215682b692a87ab894df25752c1d..ebd499c1a2d11ea068e8c374edbc3967
return locale; return locale;
} }
diff --git a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..75cc54739ef841cd90568d74927d6002d4cfa7e0 100644 index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..95c53d934f928d25f7b20cfbf2e5faa3df31ddc4 100644
--- a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
@@ -17,7 +17,7 @@ public class PlayerLoginEvent extends PlayerEvent { @@ -17,7 +17,7 @@ public class PlayerLoginEvent extends PlayerEvent {
@ -2812,7 +2820,7 @@ index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..75cc54739ef841cd90568d74927d6002
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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
+ } + }
+ +
+ // Paper start + // Paper start
@ -2865,7 +2873,7 @@ index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..75cc54739ef841cd90568d74927d6002
+ @Deprecated // Paper + @Deprecated // Paper
public String getKickMessage() { public String getKickMessage() {
- return message; - return message;
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
} }
/** /**
@ -2877,7 +2885,7 @@ index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..75cc54739ef841cd90568d74927d6002
+ @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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
} }
/** /**
@ -2899,7 +2907,7 @@ index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..75cc54739ef841cd90568d74927d6002
+ @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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message);
+ } + }
+ /** + /**
+ * Disallows the player from logging in, with the given reason + * Disallows the player from logging in, with the given reason
@ -2913,7 +2921,7 @@ index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..75cc54739ef841cd90568d74927d6002
this.message = message; this.message = message;
} }
diff --git a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
index fb066251f793ec3b41bfc075b9478901b15ee549..123979ed64939d615b061f91c19c630e1e1db8c7 100644 index fb066251f793ec3b41bfc075b9478901b15ee549..6800132c6288b4588fd02b08d26f016c38f27129 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
@ -2981,7 +2989,7 @@ index fb066251f793ec3b41bfc075b9478901b15ee549..123979ed64939d615b061f91c19c630e
+ @Deprecated // Paper + @Deprecated // Paper
+ @NotNull + @NotNull
+ public String getKickMessage() { + public String getKickMessage() {
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
+ } + }
+ +
+ /** + /**
@ -2992,7 +3000,7 @@ index fb066251f793ec3b41bfc075b9478901b15ee549..123979ed64939d615b061f91c19c630e
+ */ + */
+ @Deprecated // Paper + @Deprecated // Paper
+ public void setKickMessage(@NotNull final String message) { + public void setKickMessage(@NotNull final String message) {
+ this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
+ } + }
+ +
/** /**
@ -3015,12 +3023,12 @@ index fb066251f793ec3b41bfc075b9478901b15ee549..123979ed64939d615b061f91c19c630e
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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
} }
/** /**
diff --git a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
index d70c25f404e994766a9ebce89a917c8d0719777c..849e8f10dd77e9fb46aab17752b8f1ff79e9d42e 100644 index d70c25f404e994766a9ebce89a917c8d0719777c..0395ca85a466f6356259078d3bad48b2ce6e57b7 100644
--- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
@@ -10,30 +10,59 @@ import org.jetbrains.annotations.Nullable; @@ -10,30 +10,59 @@ import org.jetbrains.annotations.Nullable;
@ -3033,7 +3041,7 @@ index d70c25f404e994766a9ebce89a917c8d0719777c..849e8f10dd77e9fb46aab17752b8f1ff
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(quitMessage) : null; // Paper + this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().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) {
@ -3070,7 +3078,7 @@ index d70c25f404e994766a9ebce89a917c8d0719777c..849e8f10dd77e9fb46aab17752b8f1ff
+ @Deprecated // Paper + @Deprecated // Paper
public String getQuitMessage() { public String getQuitMessage() {
- return quitMessage; - return quitMessage;
+ return this.quitMessage == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.quitMessage); // Paper + return this.quitMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.quitMessage); // Paper
} }
/** /**
@ -3082,12 +3090,12 @@ index d70c25f404e994766a9ebce89a917c8d0719777c..849e8f10dd77e9fb46aab17752b8f1ff
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(quitMessage) : null; // Paper + this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
} }
@NotNull @NotNull
diff --git a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java diff --git a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java
index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..4f8c85222c7bd33217c7db0ff5f47bf397f8f3e5 100644 index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..943d324435350d3f16fad3e21cb472a01a3ff60b 100644
--- a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java --- a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java
+++ b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java +++ b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull; @@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
@ -3107,7 +3115,7 @@ index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..4f8c85222c7bd33217c7db0ff5f47bf3
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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message);
+ this.recipients = recipients; + this.recipients = recipients;
+ } + }
+ +
@ -3152,7 +3160,7 @@ index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..4f8c85222c7bd33217c7db0ff5f47bf3
+ @Deprecated // Paper + @Deprecated // Paper
public String getMessage() { public String getMessage() {
- return message; - return message;
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
} }
/** /**
@ -3164,12 +3172,12 @@ index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..4f8c85222c7bd33217c7db0ff5f47bf3
+ @Deprecated // Paper + @Deprecated // Paper
public void setMessage(@NotNull String message) { public void setMessage(@NotNull String message) {
- this.message = message; - this.message = message;
+ this.message = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message); // Paper + this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
} }
/** /**
diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
index cc5e2fef75736e56420df4cf4f83152fa97926df..fd4db14bef92b893ddaf5424e14ee71da22dcf84 100644 index cc5e2fef75736e56420df4cf4f83152fa97926df..172697ac5dc0ea3551a61b5589416ac68f372cd1 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
@@ -21,15 +21,16 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player> @@ -21,15 +21,16 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
@ -3187,7 +3195,7 @@ index cc5e2fef75736e56420df4cf4f83152fa97926df..fd4db14bef92b893ddaf5424e14ee71d
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 = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(motd); // Paper + this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
this.numPlayers = numPlayers; this.numPlayers = numPlayers;
this.maxPlayers = maxPlayers; this.maxPlayers = maxPlayers;
} }
@ -3202,7 +3210,7 @@ index cc5e2fef75736e56420df4cf4f83152fa97926df..fd4db14bef92b893ddaf5424e14ee71d
+ super(true); + super(true);
+ this.numPlayers = MAGIC_PLAYER_COUNT; + this.numPlayers = MAGIC_PLAYER_COUNT;
+ this.address = address; + this.address = address;
+ this.motd = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(motd); // Paper + this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
+ this.maxPlayers = maxPlayers; + this.maxPlayers = maxPlayers;
+ } + }
+ // Paper start + // Paper start
@ -3260,7 +3268,7 @@ index cc5e2fef75736e56420df4cf4f83152fa97926df..fd4db14bef92b893ddaf5424e14ee71d
+ @Deprecated // Paper + @Deprecated // Paper
public String getMotd() { public String getMotd() {
- return motd; - return motd;
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.motd); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.motd); // Paper
} }
/** /**
@ -3272,12 +3280,12 @@ index cc5e2fef75736e56420df4cf4f83152fa97926df..fd4db14bef92b893ddaf5424e14ee71d
+ @Deprecated // Paper + @Deprecated // Paper
public void setMotd(@NotNull String motd) { public void setMotd(@NotNull String motd) {
- this.motd = motd; - this.motd = motd;
+ this.motd = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(motd); // Paper + this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
} }
/** /**
diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java
index 14346d83bc99581b18e53d19af03708c0bf22cf7..664de64b020cf9090a2fbee0afe2bfaf150adc3c 100644 index 14346d83bc99581b18e53d19af03708c0bf22cf7..a4e3d526db2d17dc923cbe82e53d3c902d61e1f3 100644
--- a/src/main/java/org/bukkit/inventory/InventoryView.java --- a/src/main/java/org/bukkit/inventory/InventoryView.java
+++ b/src/main/java/org/bukkit/inventory/InventoryView.java +++ b/src/main/java/org/bukkit/inventory/InventoryView.java
@@ -446,11 +446,25 @@ public abstract class InventoryView { @@ -446,11 +446,25 @@ public abstract class InventoryView {
@ -3292,7 +3300,7 @@ index 14346d83bc99581b18e53d19af03708c0bf22cf7..664de64b020cf9090a2fbee0afe2bfaf
*/ */
@NotNull @NotNull
+ public /*abstract*/ net.kyori.adventure.text.Component title() { + public /*abstract*/ net.kyori.adventure.text.Component title() {
+ return org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(this.getTitle()); + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.getTitle());
+ } + }
+ // Paper end + // Paper end
+ +
@ -3720,7 +3728,7 @@ index 91eee1470f0969e9eef0753c0c700ae5354f1acc..69f68ca2d62c2cfe07a193776054c14c
/** /**
diff --git a/src/main/java/org/bukkit/map/MapCursor.java b/src/main/java/org/bukkit/map/MapCursor.java diff --git a/src/main/java/org/bukkit/map/MapCursor.java b/src/main/java/org/bukkit/map/MapCursor.java
index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..ed0bc2024a0bb85837e25f75ae89d1fe257b2e60 100644 index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..ca763b231749f108b6773040a5c6109378b21b31 100644
--- a/src/main/java/org/bukkit/map/MapCursor.java --- a/src/main/java/org/bukkit/map/MapCursor.java
+++ b/src/main/java/org/bukkit/map/MapCursor.java +++ b/src/main/java/org/bukkit/map/MapCursor.java
@@ -10,7 +10,7 @@ public final class MapCursor { @@ -10,7 +10,7 @@ public final class MapCursor {
@ -3764,7 +3772,7 @@ index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..ed0bc2024a0bb85837e25f75ae89d1fe
setRawType(type); setRawType(type);
this.visible = visible; this.visible = visible;
- this.caption = caption; - this.caption = caption;
+ this.caption = caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(caption); // Paper + this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
} }
+ // Paper start + // Paper start
+ /** + /**
@ -3808,7 +3816,7 @@ index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..ed0bc2024a0bb85837e25f75ae89d1fe
setType(type); setType(type);
this.visible = visible; this.visible = visible;
- this.caption = caption; - this.caption = caption;
+ this.caption = caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(caption); // Paper + this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
} }
/** /**
@ -3844,7 +3852,7 @@ index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..ed0bc2024a0bb85837e25f75ae89d1fe
+ @Deprecated // Paper + @Deprecated // Paper
public String getCaption() { public String getCaption() {
- return caption; - return caption;
+ return this.caption == null ? null : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.caption); // Paper + return this.caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.caption); // Paper
} }
/** /**
@ -3856,7 +3864,7 @@ index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..ed0bc2024a0bb85837e25f75ae89d1fe
+ @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 : org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(caption); // Paper + this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
} }
/** /**

Datei anzeigen

@ -2835,11 +2835,11 @@ index 14b078e8fa4347dd0e186e5847693904e4ceb9df..bbb4eb3c4e46ade7dd939c2b0e443616
* Sends the component to the player * Sends the component to the player
* *
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index f43ad19a44f3b7368a1a110cc55247277f4d3751..ce5794d684a1126ec9acbf4af17f5d6fa783f551 100644 index fa28b5bb0efd9d400277cd8969f38e039e6ea8ac..c9ecd5b1908e05a1b39dadcded27241672adcddf 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java --- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -31,6 +31,7 @@ public interface UnsafeValues { @@ -31,6 +31,7 @@ public interface UnsafeValues {
net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer(); @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer();
// Paper end // Paper end
+ void reportTimings(); // Paper + void reportTimings(); // Paper
@ -2887,7 +2887,7 @@ index 0000000000000000000000000000000000000000..f9a00aecca5ec41b460bf41dfe1c6969
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index 50e6d45ec9349b56d20e2ffc664eca15ba936cc6..c4dcafac892169a7bfcc065701fffb43c6cfdf44 100644 index 8edd78adb042013bf702027f59455045d3b3e14f..53f9262f7c61985eeef1f418098bd764522d3c9a 100644
--- a/src/main/java/org/bukkit/command/Command.java --- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java
@@ -33,6 +33,8 @@ public abstract class Command { @@ -33,6 +33,8 @@ public abstract class Command {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add BaseComponent sendMessage methods to CommandSender
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
index f98d46fa45bb7c842d791b09f082a0968ae537fb..e330a0d2be7a73ff84ec18499de6aecbceb5166c 100644 index 22b654efdcc49d6dc6d52c9d6afa1c9dc7978e35..daab4d13556150d4a4875f0273795e2c4cb82d63 100644
--- a/src/main/java/org/bukkit/command/CommandSender.java --- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java +++ b/src/main/java/org/bukkit/command/CommandSender.java
@@ -1,6 +1,9 @@ @@ -1,6 +1,9 @@
@ -20,7 +20,7 @@ index f98d46fa45bb7c842d791b09f082a0968ae537fb..e330a0d2be7a73ff84ec18499de6aecb
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -124,5 +127,33 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe @@ -124,5 +127,33 @@ 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(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(message)); this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
} }
+ +
+ /** + /**

Datei anzeigen

@ -7,7 +7,7 @@ Subject: [PATCH] Add handshake event to allow plugins to handle client
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..a077962fa786a3291849abfa823c7f0ec4664fce index 0000000000000000000000000000000000000000..a79aa4834e700f845a625e9ab15760690726e81c
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java
@@ -0,0 +1,277 @@ @@ -0,0 +1,277 @@
@ -15,16 +15,16 @@ index 0000000000000000000000000000000000000000..a077962fa786a3291849abfa823c7f0e
+ +
+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;
+
+import java.util.UUID;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
+import java.util.UUID;
+
+/** +/**
+ * This event is fired during a player handshake. + * This event is fired during a player handshake.
+ * + *
@ -262,7 +262,7 @@ index 0000000000000000000000000000000000000000..a077962fa786a3291849abfa823c7f0e
+ @NotNull + @NotNull
+ @Deprecated + @Deprecated
+ public String getFailMessage() { + public String getFailMessage() {
+ return Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.failMessage()); + return LegacyComponentSerializer.legacySection().serialize(this.failMessage());
+ } + }
+ +
+ /** + /**
@ -274,7 +274,7 @@ index 0000000000000000000000000000000000000000..a077962fa786a3291849abfa823c7f0e
+ @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(Bukkit.getUnsafe().legacyComponentSerializer().deserialize(failMessage)); + this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage));
+ } + }
+ +
+ @NotNull + @NotNull

Datei anzeigen

@ -6,18 +6,17 @@ Subject: [PATCH] Add UnknownCommandEvent
diff --git a/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java diff --git a/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..d5632d352590dec6982a372b285a8d4a332fa589 index 0000000000000000000000000000000000000000..57128c780bc73e39d2733cceeb21dc06c2422c3c
--- /dev/null --- /dev/null
+++ b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java +++ b/src/main/java/org/bukkit/event/command/UnknownCommandEvent.java
@@ -0,0 +1,114 @@ @@ -0,0 +1,113 @@
+package org.bukkit.event.command; +package org.bukkit.event.command;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import org.bukkit.Bukkit; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import org.bukkit.command.CommandSender; +import org.bukkit.command.CommandSender;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.Event; +import org.bukkit.event.Event;
+ +import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Nullable;
+ +
@ -32,7 +31,7 @@ index 0000000000000000000000000000000000000000..d5632d352590dec6982a372b285a8d4a
+ +
+ @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 : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message)); + this(sender, commandLine, message == null ? null : LegacyComponentSerializer.legacySection().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 +73,7 @@ index 0000000000000000000000000000000000000000..d5632d352590dec6982a372b285a8d4a
+ @Nullable + @Nullable
+ @Deprecated + @Deprecated
+ public String getMessage() { + public String getMessage() {
+ return this.message == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.message); + return this.message == null ? null : LegacyComponentSerializer.legacySection().serialize(this.message);
+ } + }
+ +
+ /** + /**
@ -87,7 +86,7 @@ index 0000000000000000000000000000000000000000..d5632d352590dec6982a372b285a8d4a
+ */ + */
+ @Deprecated + @Deprecated
+ public void setMessage(@Nullable String message) { + public void setMessage(@Nullable String message) {
+ this.message(message == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(message)); + this.message(message == null ? null : LegacyComponentSerializer.legacySection().deserialize(message));
+ } + }
+ +
+ /** + /**

Datei anzeigen

@ -9,7 +9,7 @@ Allows you to do dynamic whitelisting and change of kick message
diff --git a/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java diff --git a/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8a259ab49ea79673b6da9e4e2aaecec67469994e index 0000000000000000000000000000000000000000..c6f5e2b5459368ad1e4db9929ca14568a25793fa
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/profile/ProfileWhitelistVerifyEvent.java
@@ -0,0 +1,142 @@ @@ -0,0 +1,142 @@
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..8a259ab49ea79673b6da9e4e2aaecec6
+ +
+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 org.bukkit.Bukkit; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+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..8a259ab49ea79673b6da9e4e2aaecec6
+ +
+ @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 : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickMessage)); + this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : LegacyComponentSerializer.legacySection().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..8a259ab49ea79673b6da9e4e2aaecec6
+ @Deprecated + @Deprecated
+ @Nullable + @Nullable
+ public String getKickMessage() { + public String getKickMessage() {
+ return this.kickMessage == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().serialize(kickMessage); + return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(kickMessage);
+ } + }
+ +
+ /** + /**
@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..8a259ab49ea79673b6da9e4e2aaecec6
+ */ + */
+ @Deprecated + @Deprecated
+ public void setKickMessage(@Nullable String kickMessage) { + public void setKickMessage(@Nullable String kickMessage) {
+ this.kickMessage(kickMessage == null ? null : Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickMessage)); + this.kickMessage(kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage));
+ } + }
+ +
+ /** + /**

Datei anzeigen

@ -43,7 +43,7 @@ index 2042f4963c53d5a903f0de1fec6a9af3a7b2bba4..b8ed8d5d48cb4f1b2f598e2c48e4423a
* Creates a PlayerProfile for the specified uuid, with name as null. * Creates a PlayerProfile for the specified uuid, with name as null.
* *
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
index b1152f4dede61383232cc6713d448840612eac13..95847fcb1ac2e430ee192f4f7ac94e981151c5db 100644 index d039f722ab9f08bc485b581832b50830c7145c2d..97dc60444746c37c44ff5c8056f4fed04a944714 100644
--- a/src/main/java/org/bukkit/command/Command.java --- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java
@@ -184,10 +184,9 @@ public abstract class Command { @@ -184,10 +184,9 @@ public abstract class Command {
@ -54,7 +54,7 @@ index b1152f4dede61383232cc6713d448840612eac13..95847fcb1ac2e430ee192f4f7ac94e98
- target.sendMessage(ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is a mistake."); - target.sendMessage(ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is a mistake.");
// Paper start - use components for permissionMessage // Paper start - use components for permissionMessage
- } else if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) { - } else if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
+ net.kyori.adventure.text.Component permissionMessage = this.permissionMessage != null ? this.permissionMessage : io.papermc.paper.text.PaperComponents.legacySectionSerializer().deserialize(Bukkit.getPermissionMessage()); + net.kyori.adventure.text.Component permissionMessage = this.permissionMessage != null ? this.permissionMessage : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(Bukkit.getPermissionMessage());
+ if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) { + if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
target.sendMessage(permissionMessage.replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<permission>").replacement(permission).build())); target.sendMessage(permissionMessage.replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<permission>").replacement(permission).build()));
// Paper end // Paper end

Datei anzeigen

@ -8,7 +8,7 @@ Exposes a mutable array on items a player should keep on death
Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4 Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
index 48f272747b8d5ab43f79a9d474713aca79f121b7..61d12cb8f0a924abf696b6da7258f34dbb7b51b6 100644 index a871eddf73f918c0e3d2554ef8d9cfd0f830fcaa..5f7d0d08be8bca06c9aa89659b7865a7b5a547f8 100644
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java --- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -36,7 +36,6 @@ public class PlayerDeathEvent extends EntityDeathEvent { @@ -36,7 +36,6 @@ public class PlayerDeathEvent extends EntityDeathEvent {
@ -20,7 +20,7 @@ index 48f272747b8d5ab43f79a9d474713aca79f121b7..61d12cb8f0a924abf696b6da7258f34d
this(player, drops, droppedExp, 0, deathMessage); this(player, drops, droppedExp, 0, deathMessage);
} }
@@ -56,6 +55,41 @@ public class PlayerDeathEvent extends EntityDeathEvent { @@ -56,6 +55,41 @@ public class PlayerDeathEvent extends EntityDeathEvent {
this.adventure$deathMessage = deathMessage != null ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper
} }
+ @Deprecated // Paper + @Deprecated // Paper

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add API for quit reason
diff --git a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
index 849e8f10dd77e9fb46aab17752b8f1ff79e9d42e..b6016aa1e91863efc252eecab69ade6f54c89f27 100644 index 0395ca85a466f6356259078d3bad48b2ce6e57b7..6e9205024ca9d3000a371bd0eb723dcd6c662bce 100644
--- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
@@ -11,16 +11,28 @@ import org.jetbrains.annotations.Nullable; @@ -11,16 +11,28 @@ import org.jetbrains.annotations.Nullable;
@ -22,7 +22,7 @@ index 849e8f10dd77e9fb46aab17752b8f1ff79e9d42e..b6016aa1e91863efc252eecab69ade6f
+ @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 ? org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(quitMessage) : null; // Paper this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
+ this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; + this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason;
} }
// Paper start // Paper start

Datei anzeigen

@ -24,7 +24,7 @@ index 8b37b895b7de99a0be6b54c2aedfc0faddb06435..826faf48f9e2f7441a0cb5434dd1b337
/** /**
diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
index 5c0efe74237dbe6803ce023fde99682ff70d1a92..05ecfd8c133e72d198faeeded8c757c231c871cc 100644 index 2b3f57d1a1c79923a2173f52d9cf61da1f75b7fc..45235379b7b54f1ca36dff3bf02c496cef2f3254 100644
--- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java --- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
@@ -12,6 +12,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { @@ -12,6 +12,7 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
@ -37,8 +37,8 @@ index 5c0efe74237dbe6803ce023fde99682ff70d1a92..05ecfd8c133e72d198faeeded8c757c2
@Deprecated // Paper @Deprecated // Paper
@@ -19,14 +20,25 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { @@ -19,14 +20,25 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable {
super(playerKicked); super(playerKicked);
this.kickReason = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(kickReason); // Paper this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper
this.leaveMessage = org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().deserialize(leaveMessage); // Paper this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper
+ this.cause = Cause.UNKNOWN; // Paper + this.cause = Cause.UNKNOWN; // Paper
this.cancel = false; this.cancel = false;
} }

Datei anzeigen

@ -26,10 +26,10 @@ index 80a3d5890aab91e6a48d5734140187851106bde3..c1eb4201ecb0541c606ef0d05b828ae9
} }
diff --git a/src/main/java/io/papermc/paper/adventure/AdventureComponent.java b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java diff --git a/src/main/java/io/papermc/paper/adventure/AdventureComponent.java b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..85546e1ac1d1ed7f70c3c0a1bf49937f865ad091 index 0000000000000000000000000000000000000000..1c820b01c65f69b4b158a5d2134419b52e77f5ee
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java +++ b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java
@@ -0,0 +1,82 @@ @@ -0,0 +1,84 @@
+package io.papermc.paper.adventure; +package io.papermc.paper.adventure;
+ +
+import com.google.gson.JsonElement; +import com.google.gson.JsonElement;
@ -39,6 +39,8 @@ index 0000000000000000000000000000000000000000..85546e1ac1d1ed7f70c3c0a1bf49937f
+import java.util.List; +import java.util.List;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.TextComponent;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
+import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.MutableComponent;
+import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.Style;
+import net.minecraft.util.FormattedCharSequence; +import net.minecraft.util.FormattedCharSequence;
@ -82,7 +84,7 @@ index 0000000000000000000000000000000000000000..85546e1ac1d1ed7f70c3c0a1bf49937f
+ +
+ @Override + @Override
+ public String getString() { + public String getString() {
+ return PaperAdventure.PLAIN.serialize(this.adventure); + return PlainTextComponentSerializer.plainText().serialize(this.adventure);
+ } + }
+ +
+ @Override + @Override
@ -108,16 +110,16 @@ index 0000000000000000000000000000000000000000..85546e1ac1d1ed7f70c3c0a1bf49937f
+ public static class Serializer implements JsonSerializer<AdventureComponent> { + public static class Serializer implements JsonSerializer<AdventureComponent> {
+ @Override + @Override
+ public JsonElement serialize(final AdventureComponent src, final Type type, final JsonSerializationContext context) { + public JsonElement serialize(final AdventureComponent src, final Type type, final JsonSerializationContext context) {
+ return PaperAdventure.GSON.serializer().toJsonTree(src.adventure, Component.class); + return GsonComponentSerializer.gson().serializer().toJsonTree(src.adventure, Component.class);
+ } + }
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java 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 new file mode 100644
index 0000000000000000000000000000000000000000..65b6e260464b2003d6bd172610adb5b8651df169 index 0000000000000000000000000000000000000000..3526bc0b6ad590776124966ea907fe2467cbbf5f
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
@@ -0,0 +1,192 @@ @@ -0,0 +1,193 @@
+package io.papermc.paper.adventure; +package io.papermc.paper.adventure;
+ +
+import io.papermc.paper.chat.ChatRenderer; +import io.papermc.paper.chat.ChatRenderer;
@ -133,6 +135,7 @@ index 0000000000000000000000000000000000000000..65b6e260464b2003d6bd172610adb5b8
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextReplacementConfig; +import net.kyori.adventure.text.TextReplacementConfig;
+import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.event.ClickEvent;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerPlayer;
+import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.entity.CraftPlayer;
@ -195,14 +198,14 @@ index 0000000000000000000000000000000000000000..65b6e260464b2003d6bd172610adb5b8
+ this.processModern( + this.processModern(
+ legacyRenderer(se.getFormat()), + legacyRenderer(se.getFormat()),
+ this.viewersFromLegacy(se.getRecipients()), + this.viewersFromLegacy(se.getRecipients()),
+ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(se.getMessage()), + LegacyComponentSerializer.legacySection().deserialize(se.getMessage()),
+ se.isCancelled() + se.isCancelled()
+ ); + );
+ } else { + } else {
+ this.processModern( + this.processModern(
+ legacyRenderer(ae.getFormat()), + legacyRenderer(ae.getFormat()),
+ this.viewersFromLegacy(ae.getRecipients()), + this.viewersFromLegacy(ae.getRecipients()),
+ PaperAdventure.LEGACY_SECTION_UXRC.deserialize(ae.getMessage()), + LegacyComponentSerializer.legacySection().deserialize(ae.getMessage()),
+ ae.isCancelled() + ae.isCancelled()
+ ); + );
+ } + }
@ -284,7 +287,7 @@ index 0000000000000000000000000000000000000000..65b6e260464b2003d6bd172610adb5b8
+ if (DEFAULT_LEGACY_FORMAT.equals(format)) { + if (DEFAULT_LEGACY_FORMAT.equals(format)) {
+ return ChatRenderer.defaultRenderer(); + return ChatRenderer.defaultRenderer();
+ } + }
+ return ChatRenderer.viewerUnaware((player, displayName, message) -> PaperAdventure.LEGACY_SECTION_UXRC.deserialize(String.format(format, legacyDisplayName((CraftPlayer) player), PaperAdventure.LEGACY_SECTION_UXRC.serialize(message))).replaceText(URL_REPLACEMENT_CONFIG)); + return ChatRenderer.viewerUnaware((player, displayName, message) -> LegacyComponentSerializer.legacySection().deserialize(String.format(format, legacyDisplayName((CraftPlayer) player), LegacyComponentSerializer.legacySection().serialize(message))).replaceText(URL_REPLACEMENT_CONFIG));
+ } + }
+ +
+ private void queueIfAsyncOrRunImmediately(final Waitable<Void> waitable) { + private void queueIfAsyncOrRunImmediately(final Waitable<Void> waitable) {
@ -312,12 +315,13 @@ index 0000000000000000000000000000000000000000..65b6e260464b2003d6bd172610adb5b8
+} +}
diff --git a/src/main/java/io/papermc/paper/adventure/DisplayNames.java b/src/main/java/io/papermc/paper/adventure/DisplayNames.java diff --git a/src/main/java/io/papermc/paper/adventure/DisplayNames.java b/src/main/java/io/papermc/paper/adventure/DisplayNames.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..fb23f5b733093384fefc331cd3bef7cf16f09293 index 0000000000000000000000000000000000000000..3957f68182e8f7a773613a687f1d9a0cfa4f066c
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/DisplayNames.java +++ b/src/main/java/io/papermc/paper/adventure/DisplayNames.java
@@ -0,0 +1,23 @@ @@ -0,0 +1,24 @@
+package io.papermc.paper.adventure; +package io.papermc.paper.adventure;
+ +
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.ServerPlayer;
+import org.bukkit.ChatColor; +import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.entity.CraftPlayer;
@ -334,9 +338,9 @@ index 0000000000000000000000000000000000000000..fb23f5b733093384fefc331cd3bef7cf
+ final String legacy = player.displayName; + final String legacy = player.displayName;
+ if (legacy != null) { + if (legacy != null) {
+ // thank you for being worse than wet socks, Bukkit + // thank you for being worse than wet socks, Bukkit
+ return PaperAdventure.LEGACY_SECTION_UXRC.serialize(player.adventure$displayName) + ChatColor.getLastColors(player.displayName); + return LegacyComponentSerializer.legacySection().serialize(player.adventure$displayName) + ChatColor.getLastColors(player.displayName);
+ } + }
+ return PaperAdventure.LEGACY_SECTION_UXRC.serialize(player.adventure$displayName); + return LegacyComponentSerializer.legacySection().serialize(player.adventure$displayName);
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/adventure/LazyChatAudienceSet.java b/src/main/java/io/papermc/paper/adventure/LazyChatAudienceSet.java diff --git a/src/main/java/io/papermc/paper/adventure/LazyChatAudienceSet.java b/src/main/java/io/papermc/paper/adventure/LazyChatAudienceSet.java
@ -371,106 +375,12 @@ index 0000000000000000000000000000000000000000..2fd6c3e65354071af71c7d8ebb97b559
+ return audiences; + return audiences;
+ } + }
+} +}
diff --git a/src/main/java/io/papermc/paper/adventure/NBTLegacyHoverEventSerializer.java b/src/main/java/io/papermc/paper/adventure/NBTLegacyHoverEventSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..eeedc30a45d9637d68f04f185b3dd90dd711b9e0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/NBTLegacyHoverEventSerializer.java
@@ -0,0 +1,88 @@
+package io.papermc.paper.adventure;
+
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+import java.io.IOException;
+import java.util.UUID;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.nbt.api.BinaryTagHolder;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.event.HoverEvent;
+import net.kyori.adventure.text.serializer.gson.LegacyHoverEventSerializer;
+import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
+import net.kyori.adventure.util.Codec;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.Tag;
+import net.minecraft.nbt.TagParser;
+
+final class NBTLegacyHoverEventSerializer implements LegacyHoverEventSerializer {
+ public static final NBTLegacyHoverEventSerializer INSTANCE = new NBTLegacyHoverEventSerializer();
+ private static final Codec<CompoundTag, String, CommandSyntaxException, RuntimeException> SNBT_CODEC = Codec.of(TagParser::parseTag, Tag::toString);
+
+ static final String ITEM_TYPE = "id";
+ static final String ITEM_COUNT = "Count";
+ static final String ITEM_TAG = "tag";
+
+ static final String ENTITY_NAME = "name";
+ static final String ENTITY_TYPE = "type";
+ static final String ENTITY_ID = "id";
+
+ NBTLegacyHoverEventSerializer() {
+ }
+
+ @Override
+ public HoverEvent.ShowItem deserializeShowItem(final Component input) throws IOException {
+ final String raw = PlainComponentSerializer.plain().serialize(input);
+ try {
+ final CompoundTag contents = SNBT_CODEC.decode(raw);
+ final CompoundTag tag = contents.getCompound(ITEM_TAG);
+ return HoverEvent.ShowItem.of(
+ Key.key(contents.getString(ITEM_TYPE)),
+ contents.contains(ITEM_COUNT) ? contents.getByte(ITEM_COUNT) : 1,
+ tag.isEmpty() ? null : BinaryTagHolder.encode(tag, SNBT_CODEC)
+ );
+ } catch (final CommandSyntaxException ex) {
+ throw new IOException(ex);
+ }
+ }
+
+ @Override
+ public HoverEvent.ShowEntity deserializeShowEntity(final Component input, final Codec.Decoder<Component, String, ? extends RuntimeException> componentCodec) throws IOException {
+ final String raw = PlainComponentSerializer.plain().serialize(input);
+ try {
+ final CompoundTag contents = SNBT_CODEC.decode(raw);
+ return HoverEvent.ShowEntity.of(
+ Key.key(contents.getString(ENTITY_TYPE)),
+ UUID.fromString(contents.getString(ENTITY_ID)),
+ componentCodec.decode(contents.getString(ENTITY_NAME))
+ );
+ } catch (final CommandSyntaxException ex) {
+ throw new IOException(ex);
+ }
+ }
+
+ @Override
+ public Component serializeShowItem(final HoverEvent.ShowItem input) throws IOException {
+ final CompoundTag tag = new CompoundTag();
+ tag.putString(ITEM_TYPE, input.item().asString());
+ tag.putByte(ITEM_COUNT, (byte) input.count());
+ if (input.nbt() != null) {
+ try {
+ tag.put(ITEM_TAG, input.nbt().get(SNBT_CODEC));
+ } catch (final CommandSyntaxException ex) {
+ throw new IOException(ex);
+ }
+ }
+ return Component.text(SNBT_CODEC.encode(tag));
+ }
+
+ @Override
+ public Component serializeShowEntity(final HoverEvent.ShowEntity input, final Codec.Encoder<Component, String, ? extends RuntimeException> componentCodec) throws IOException {
+ final CompoundTag tag = new CompoundTag();
+ tag.putString(ENTITY_ID, input.id().toString());
+ tag.putString(ENTITY_TYPE, input.type().asString());
+ if (input.name() != null) {
+ tag.putString(ENTITY_NAME, componentCodec.encode(input.name()));
+ }
+ return Component.text(SNBT_CODEC.encode(tag));
+ }
+}
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..85c9056f92711b985e251f0f06ed551d03deb562 index 0000000000000000000000000000000000000000..3f25a9b1a74cfa0c9a4d0379ecda109d99f33db3
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
@@ -0,0 +1,341 @@ @@ -0,0 +1,331 @@
+package io.papermc.paper.adventure; +package io.papermc.paper.adventure;
+ +
+import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.CommandSyntaxException;
@ -564,17 +474,7 @@ index 0000000000000000000000000000000000000000..85c9056f92711b985e251f0f06ed551d
+ } + }
+ }) + })
+ .build(); + .build();
+ public static final LegacyComponentSerializer LEGACY_SECTION_UXRC = LegacyComponentSerializer.builder().flattener(FLATTENER).hexColors().useUnusualXRepeatedCharacterHexFormat().build(); + @Deprecated public static final PlainComponentSerializer PLAIN = PlainComponentSerializer.builder().flattener(FLATTENER).build();
+ @Deprecated
+ public static final PlainComponentSerializer PLAIN_COMPONENT = PlainComponentSerializer.builder().flattener(FLATTENER).build();
+ public static final PlainTextComponentSerializer PLAIN = PlainTextComponentSerializer.builder().flattener(FLATTENER).build();
+ public static final GsonComponentSerializer GSON = GsonComponentSerializer.builder()
+ .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE)
+ .build();
+ public static final GsonComponentSerializer COLOR_DOWNSAMPLING_GSON = GsonComponentSerializer.builder()
+ .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE)
+ .downsampleColors()
+ .build();
+ private static final Codec<CompoundTag, String, IOException, IOException> NBT_CODEC = new Codec<CompoundTag, String, IOException, IOException>() { + private static final Codec<CompoundTag, String, IOException, IOException> NBT_CODEC = new Codec<CompoundTag, String, IOException, IOException>() {
+ @Override + @Override
+ public @NotNull CompoundTag decode(final @NotNull String encoded) throws IOException { + public @NotNull CompoundTag decode(final @NotNull String encoded) throws IOException {
@ -611,7 +511,7 @@ index 0000000000000000000000000000000000000000..85c9056f92711b985e251f0f06ed551d
+ // Component + // Component
+ +
+ public static Component asAdventure(final net.minecraft.network.chat.Component component) { + public static Component asAdventure(final net.minecraft.network.chat.Component component) {
+ return component == null ? Component.empty() : GSON.serializer().fromJson(net.minecraft.network.chat.Component.Serializer.toJsonTree(component), Component.class); + return component == null ? Component.empty() : GsonComponentSerializer.gson().serializer().fromJson(net.minecraft.network.chat.Component.Serializer.toJsonTree(component), Component.class);
+ } + }
+ +
+ public static ArrayList<Component> asAdventure(final List<net.minecraft.network.chat.Component> vanillas) { + public static ArrayList<Component> asAdventure(final List<net.minecraft.network.chat.Component> vanillas) {
@ -641,7 +541,7 @@ index 0000000000000000000000000000000000000000..85c9056f92711b985e251f0f06ed551d
+ public static net.minecraft.network.chat.Component asVanilla(final Component component) { + public static net.minecraft.network.chat.Component asVanilla(final Component component) {
+ if (component == null) return null; + if (component == null) return null;
+ if (true) return new AdventureComponent(component); + if (true) return new AdventureComponent(component);
+ return net.minecraft.network.chat.Component.Serializer.fromJson(GSON.serializer().toJsonTree(component)); + return net.minecraft.network.chat.Component.Serializer.fromJson(GsonComponentSerializer.gson().serializer().toJsonTree(component));
+ } + }
+ +
+ public static List<net.minecraft.network.chat.Component> asVanilla(final List<Component> adventures) { + public static List<net.minecraft.network.chat.Component> asVanilla(final List<Component> adventures) {
@ -653,7 +553,7 @@ index 0000000000000000000000000000000000000000..85c9056f92711b985e251f0f06ed551d
+ } + }
+ +
+ public static String asJsonString(final Component component, final Locale locale) { + public static String asJsonString(final Component component, final Locale locale) {
+ return GSON.serialize(translated(component, locale)); + return GsonComponentSerializer.gson().serialize(translated(component, locale));
+ } + }
+ +
+ public static String asJsonString(final net.minecraft.network.chat.Component component, final Locale locale) { + public static String asJsonString(final net.minecraft.network.chat.Component component, final Locale locale) {
@ -664,7 +564,7 @@ index 0000000000000000000000000000000000000000..85c9056f92711b985e251f0f06ed551d
+ } + }
+ +
+ public static String asPlain(final Component component, final Locale locale) { + public static String asPlain(final Component component, final Locale locale) {
+ return PLAIN.serialize(translated(component, locale)); + return PlainTextComponentSerializer.plainText().serialize(translated(component, locale));
+ } + }
+ +
+ private static Component translated(final Component component, final Locale locale) { + private static Component translated(final Component component, final Locale locale) {
@ -864,14 +764,15 @@ index 0000000000000000000000000000000000000000..7493efba31403cbe7f26e493f165f1b8
+} +}
diff --git a/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java diff --git a/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..76be058996599dd798d26a166d1a5139ee72761a index 0000000000000000000000000000000000000000..2a08e0461db4e699b7e6a1558a4419c848fc7f4f
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java +++ b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java
@@ -0,0 +1,19 @@ @@ -0,0 +1,20 @@
+package io.papermc.paper.adventure; +package io.papermc.paper.adventure;
+ +
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.ComponentSerializer; +import net.kyori.adventure.text.serializer.ComponentSerializer;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+ +
+final class WrapperAwareSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> { +final class WrapperAwareSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> {
+ @Override + @Override
@ -879,12 +780,240 @@ index 0000000000000000000000000000000000000000..76be058996599dd798d26a166d1a5139
+ if (input instanceof AdventureComponent) { + if (input instanceof AdventureComponent) {
+ return ((AdventureComponent) input).adventure; + return ((AdventureComponent) input).adventure;
+ } + }
+ return PaperAdventure.GSON.serializer().fromJson(net.minecraft.network.chat.Component.Serializer.toJsonTree(input), Component.class); + return GsonComponentSerializer.gson().serializer().fromJson(net.minecraft.network.chat.Component.Serializer.toJsonTree(input), Component.class);
+ } + }
+ +
+ @Override + @Override
+ public net.minecraft.network.chat.Component serialize(final Component component) { + public net.minecraft.network.chat.Component serialize(final Component component) {
+ return net.minecraft.network.chat.Component.Serializer.fromJson(PaperAdventure.GSON.serializer().toJsonTree(component)); + return net.minecraft.network.chat.Component.Serializer.fromJson(GsonComponentSerializer.gson().serializer().toJsonTree(component));
+ }
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c620d5aa2b0208b769dbe9563f0e99edc9a91047
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/GsonComponentSerializerProviderImpl.java
@@ -0,0 +1,30 @@
+package io.papermc.paper.adventure.providers;
+
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.function.Consumer;
+
+@SuppressWarnings("UnstableApiUsage") // permitted provider
+public class GsonComponentSerializerProviderImpl implements GsonComponentSerializer.Provider {
+
+ @Override
+ public @NotNull GsonComponentSerializer gson() {
+ return GsonComponentSerializer.builder()
+ .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE)
+ .build();
+ }
+
+ @Override
+ public @NotNull GsonComponentSerializer gsonLegacy() {
+ return GsonComponentSerializer.builder()
+ .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE)
+ .downsampleColors()
+ .build();
+ }
+
+ @Override
+ public @NotNull Consumer<GsonComponentSerializer.Builder> builder() {
+ return builder -> builder.legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/LegacyComponentSerializerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/LegacyComponentSerializerProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..03723dbe32b7eb95253e8ff6e72dbf8d2300a059
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/LegacyComponentSerializerProviderImpl.java
@@ -0,0 +1,36 @@
+package io.papermc.paper.adventure.providers;
+
+import io.papermc.paper.adventure.PaperAdventure;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.function.Consumer;
+
+@SuppressWarnings("UnstableApiUsage") // permitted provider
+public class LegacyComponentSerializerProviderImpl implements LegacyComponentSerializer.Provider {
+
+ @Override
+ public @NotNull LegacyComponentSerializer legacyAmpersand() {
+ return LegacyComponentSerializer.builder()
+ .flattener(PaperAdventure.FLATTENER)
+ .character(LegacyComponentSerializer.AMPERSAND_CHAR)
+ .hexColors()
+ .useUnusualXRepeatedCharacterHexFormat()
+ .build();
+ }
+
+ @Override
+ public @NotNull LegacyComponentSerializer legacySection() {
+ return LegacyComponentSerializer.builder()
+ .flattener(PaperAdventure.FLATTENER)
+ .character(LegacyComponentSerializer.SECTION_CHAR)
+ .hexColors()
+ .useUnusualXRepeatedCharacterHexFormat()
+ .build();
+ }
+
+ @Override
+ public @NotNull Consumer<LegacyComponentSerializer.Builder> legacy() {
+ return builder -> builder.flattener(PaperAdventure.FLATTENER);
+ }
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..25fd6992c869c841b1b1b3240f4d524948487614
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java
@@ -0,0 +1,20 @@
+package io.papermc.paper.adventure.providers;
+
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.function.Consumer;
+
+@SuppressWarnings("UnstableApiUsage") // permitted provider
+public class MiniMessageProviderImpl implements MiniMessage.Provider {
+
+ @Override
+ public @NotNull MiniMessage miniMessage() {
+ return MiniMessage.builder().build();
+ }
+
+ @Override
+ public @NotNull Consumer<MiniMessage.Builder> builder() {
+ return builder -> {};
+ }
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/NBTLegacyHoverEventSerializer.java b/src/main/java/io/papermc/paper/adventure/providers/NBTLegacyHoverEventSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..b3514a3e415f3444a235f1a45f0c53741264e516
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/NBTLegacyHoverEventSerializer.java
@@ -0,0 +1,89 @@
+package io.papermc.paper.adventure.providers;
+
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+import net.kyori.adventure.key.Key;
+import net.kyori.adventure.nbt.api.BinaryTagHolder;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.event.HoverEvent;
+import net.kyori.adventure.text.serializer.gson.LegacyHoverEventSerializer;
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
+import net.kyori.adventure.util.Codec;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.Tag;
+import net.minecraft.nbt.TagParser;
+
+import java.io.IOException;
+import java.util.UUID;
+
+final class NBTLegacyHoverEventSerializer implements LegacyHoverEventSerializer {
+ public static final NBTLegacyHoverEventSerializer INSTANCE = new NBTLegacyHoverEventSerializer();
+ private static final Codec<CompoundTag, String, CommandSyntaxException, RuntimeException> SNBT_CODEC = Codec.codec(TagParser::parseTag, Tag::toString);
+
+ static final String ITEM_TYPE = "id";
+ static final String ITEM_COUNT = "Count";
+ static final String ITEM_TAG = "tag";
+
+ static final String ENTITY_NAME = "name";
+ static final String ENTITY_TYPE = "type";
+ static final String ENTITY_ID = "id";
+
+ NBTLegacyHoverEventSerializer() {
+ }
+
+ @Override
+ public HoverEvent.ShowItem deserializeShowItem(final Component input) throws IOException {
+ final String raw = PlainTextComponentSerializer.plainText().serialize(input);
+ try {
+ final CompoundTag contents = SNBT_CODEC.decode(raw);
+ final CompoundTag tag = contents.getCompound(ITEM_TAG);
+ return HoverEvent.ShowItem.of(
+ Key.key(contents.getString(ITEM_TYPE)),
+ contents.contains(ITEM_COUNT) ? contents.getByte(ITEM_COUNT) : 1,
+ tag.isEmpty() ? null : BinaryTagHolder.encode(tag, SNBT_CODEC)
+ );
+ } catch (final CommandSyntaxException ex) {
+ throw new IOException(ex);
+ }
+ }
+
+ @Override
+ public HoverEvent.ShowEntity deserializeShowEntity(final Component input, final Codec.Decoder<Component, String, ? extends RuntimeException> componentCodec) throws IOException {
+ final String raw = PlainTextComponentSerializer.plainText().serialize(input);
+ try {
+ final CompoundTag contents = SNBT_CODEC.decode(raw);
+ return HoverEvent.ShowEntity.of(
+ Key.key(contents.getString(ENTITY_TYPE)),
+ UUID.fromString(contents.getString(ENTITY_ID)),
+ componentCodec.decode(contents.getString(ENTITY_NAME))
+ );
+ } catch (final CommandSyntaxException ex) {
+ throw new IOException(ex);
+ }
+ }
+
+ @Override
+ public Component serializeShowItem(final HoverEvent.ShowItem input) throws IOException {
+ final CompoundTag tag = new CompoundTag();
+ tag.putString(ITEM_TYPE, input.item().asString());
+ tag.putByte(ITEM_COUNT, (byte) input.count());
+ if (input.nbt() != null) {
+ try {
+ tag.put(ITEM_TAG, input.nbt().get(SNBT_CODEC));
+ } catch (final CommandSyntaxException ex) {
+ throw new IOException(ex);
+ }
+ }
+ return Component.text(SNBT_CODEC.encode(tag));
+ }
+
+ @Override
+ public Component serializeShowEntity(final HoverEvent.ShowEntity input, final Codec.Encoder<Component, String, ? extends RuntimeException> componentCodec) throws IOException {
+ final CompoundTag tag = new CompoundTag();
+ tag.putString(ENTITY_ID, input.id().toString());
+ tag.putString(ENTITY_TYPE, input.type().asString());
+ if (input.name() != null) {
+ tag.putString(ENTITY_NAME, componentCodec.encode(input.name()));
+ }
+ return Component.text(SNBT_CODEC.encode(tag));
+ }
+}
diff --git a/src/main/java/io/papermc/paper/adventure/providers/PlainTextComponentSerializerProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/PlainTextComponentSerializerProviderImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0701d4f93a4d77a8177d2dd8d5076f9f781873d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/adventure/providers/PlainTextComponentSerializerProviderImpl.java
@@ -0,0 +1,23 @@
+package io.papermc.paper.adventure.providers;
+
+import io.papermc.paper.adventure.PaperAdventure;
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.function.Consumer;
+
+@SuppressWarnings("UnstableApiUsage") // permitted provider
+public class PlainTextComponentSerializerProviderImpl implements PlainTextComponentSerializer.Provider {
+
+ @Override
+ public @NotNull PlainTextComponentSerializer plainTextSimple() {
+ return PlainTextComponentSerializer.builder()
+ .flattener(PaperAdventure.FLATTENER)
+ .build();
+ }
+
+ @Override
+ public @NotNull Consumer<PlainTextComponentSerializer.Builder> plainText() {
+ return builder -> builder.flattener(PaperAdventure.FLATTENER);
+ } + }
+} +}
diff --git a/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java b/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java diff --git a/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java b/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java
@ -1259,7 +1388,7 @@ index 0753fdff0fe7b660af8bc09ad98a95701b1aaa01..91c1447c9e365345e02b9162e3b9e721
- this.disconnect(CraftChatMessage.fromComponent(reason)); - this.disconnect(CraftChatMessage.fromComponent(reason));
+ public void disconnect(String s) { + public void disconnect(String s) {
+ // Paper start + // Paper start
+ this.disconnect(PaperAdventure.LEGACY_SECTION_UXRC.deserialize(s)); + this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s));
} }
- // CraftBukkit end - // CraftBukkit end
@ -1491,7 +1620,7 @@ index 60b4044e3d914ff83a4f37499e278fbcbc65e5c1..be9a29f01d59584a1492d925248f0947
} else if (!this.isWhiteListed(gameprofile)) { } else if (!this.isWhiteListed(gameprofile)) {
chatmessage = new TranslatableComponent("multiplayer.disconnect.not_whitelisted"); chatmessage = new TranslatableComponent("multiplayer.disconnect.not_whitelisted");
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot - event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure
} else if (this.getIpBans().isBanned(socketaddress) && !this.getIpBans().get(socketaddress).hasExpired()) { } else if (this.getIpBans().isBanned(socketaddress) && !this.getIpBans().get(socketaddress).hasExpired()) {
IpBanListEntry ipbanentry = this.ipBans.get(socketaddress); IpBanListEntry ipbanentry = this.ipBans.get(socketaddress);
@ -1505,7 +1634,7 @@ index 60b4044e3d914ff83a4f37499e278fbcbc65e5c1..be9a29f01d59584a1492d925248f0947
// return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) { if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
- event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot - event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure + event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
} }
} }
@ -1657,7 +1786,7 @@ index d29c6d0536619fab5a48fbb52115dac09e7d7ca3..75871f74a25ee34db89a431de584b998
@Override @Override
+ public net.kyori.adventure.text.Component shutdownMessage() { + public net.kyori.adventure.text.Component shutdownMessage() {
+ String msg = getShutdownMessage(); + String msg = getShutdownMessage();
+ return msg != null ? io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(msg) : null; + return msg != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(msg) : null;
+ } + }
+ // Paper end + // Paper end
+ @Override + @Override
@ -1672,7 +1801,7 @@ index d29c6d0536619fab5a48fbb52115dac09e7d7ca3..75871f74a25ee34db89a431de584b998
+ @Deprecated // Paper + @Deprecated // Paper
public int broadcast(String message, String permission) { public int broadcast(String message, String permission) {
+ // Paper start - Adventure + // Paper start - Adventure
+ return this.broadcast(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(message), permission); + return this.broadcast(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message), permission);
+ } + }
+ +
+ @Override + @Override
@ -1918,7 +2047,7 @@ index 0beb96dc896f63003e1b1ae458b73902bdbe648a..102eb86bad3000f258775ac06ecd1a6d
public String getCustomName() { public String getCustomName() {
EnchantmentTableBlockEntity enchant = this.getSnapshot(); EnchantmentTableBlockEntity enchant = this.getSnapshot();
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
index 9e68893b189ad05e4d2a5e8788e93e10670ac824..9d513b3a1a50e67284ee7ebdc5607e4f44bd0a4b 100644 index 9e68893b189ad05e4d2a5e8788e93e10670ac824..26f21754b5ec3d1cbd455c4d9d04af299fc10b1b 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
@@ -14,34 +14,60 @@ import org.bukkit.entity.Player; @@ -14,34 +14,60 @@ import org.bukkit.entity.Player;
@ -1977,21 +2106,21 @@ index 9e68893b189ad05e4d2a5e8788e93e10670ac824..9d513b3a1a50e67284ee7ebdc5607e4f
+ @Override + @Override
+ public String[] getLines() { + public String[] getLines() {
+ this.loadLines(); + this.loadLines();
+ return this.lines.stream().map(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC::serialize).toArray(String[]::new); // Paper + return this.lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper
+ } + }
+ +
@Override @Override
public String getLine(int index) throws IndexOutOfBoundsException { public String getLine(int index) throws IndexOutOfBoundsException {
- return this.getLines()[index]; - return this.getLines()[index];
+ this.loadLines(); + this.loadLines();
+ return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(this.lines.get(index)); // Paper + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.lines.get(index)); // Paper
} }
@Override @Override
public void setLine(int index, String line) throws IndexOutOfBoundsException { public void setLine(int index, String line) throws IndexOutOfBoundsException {
- this.getLines()[index] = line; - this.getLines()[index] = line;
+ this.loadLines(); + this.loadLines();
+ this.lines.set(index, line != null ? io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(line) : net.kyori.adventure.text.Component.empty()); // Paper + this.lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : net.kyori.adventure.text.Component.empty()); // Paper
} }
@Override @Override
@ -2056,7 +2185,7 @@ index 83efca7144b4ce9cf7bd6bbbbf9c4426d2472315..bf4c5c83c3c6d710c9c40257087a2c74
public boolean isOp() { public boolean isOp() {
return true; return true;
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
index f3cb4102ab223f379f60dac317df7da1fab812a8..269738c499c6aab6f8c39ba4ffd12fa09f0d79dc 100644 index f3cb4102ab223f379f60dac317df7da1fab812a8..324e6d1a4fadd3e557e4ba05f04e6a5891cc54df 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
@@ -46,6 +46,13 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co @@ -46,6 +46,13 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
@ -2081,7 +2210,7 @@ index f3cb4102ab223f379f60dac317df7da1fab812a8..269738c499c6aab6f8c39ba4ffd12fa0
+ // Paper start + // Paper start
+ @Override + @Override
+ public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { + public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) {
+ this.sendRawMessage(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(message)); + this.sendRawMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
+ } + }
+ // Paper end + // Paper end
} }
@ -2233,7 +2362,7 @@ index a4907dee676e9e9cc2725a3312831198a0db7b10..4b7ed15279bbdd116d993f190094f80c
@Override @Override
public boolean isPermissionSet(String name) { public boolean isPermissionSet(String name) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index b4d3f6358b8a762d44586fbded8844ba5485f2d0..ebd5372fdd7aa3e5e67a8b3b916176eeb6ff54bf 100644 index b4d3f6358b8a762d44586fbded8844ba5485f2d0..ea952e82078acc2256757b599d1d4ca457f951b5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -317,9 +317,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -317,9 +317,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@ -2243,7 +2372,7 @@ index b4d3f6358b8a762d44586fbded8844ba5485f2d0..ebd5372fdd7aa3e5e67a8b3b916176ee
- String title = container.getBukkitView().getTitle(); - String title = container.getBukkitView().getTitle();
+ //String title = container.getBukkitView().getTitle(); // Paper - comment + //String title = container.getBukkitView().getTitle(); // Paper - comment
+ net.kyori.adventure.text.Component adventure$title = container.getBukkitView().title(); // Paper + net.kyori.adventure.text.Component adventure$title = container.getBukkitView().title(); // Paper
+ if (adventure$title == null) adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(container.getBukkitView().getTitle()); // Paper + if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper
- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); - player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0]));
+ //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment + //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment
@ -2260,7 +2389,7 @@ index b4d3f6358b8a762d44586fbded8844ba5485f2d0..ebd5372fdd7aa3e5e67a8b3b916176ee
+ +
+ //String title = inventory.getTitle(); // Paper - comment + //String title = inventory.getTitle(); // Paper - comment
+ net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper + net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper
+ if (adventure$title == null) adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(inventory.getTitle()); // Paper + if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper
+ //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment + //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
+ player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper + player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
player.containerMenu = container; player.containerMenu = container;
@ -2298,7 +2427,7 @@ index 2577a135bb88adc9000ab67477846c6466d973e7..7ff1fcfdc87bcd299da46fe8a7e090c1
@Override @Override
public void setDisplayName(final String name) { public void setDisplayName(final String name) {
+ this.getHandle().adventure$displayName = name != null ? io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(name) : net.kyori.adventure.text.Component.text(this.getName()); // Paper + this.getHandle().adventure$displayName = name != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(name) : net.kyori.adventure.text.Component.text(this.getName()); // Paper
this.getHandle().displayName = name == null ? getName() : name; this.getHandle().displayName = name == null ? getName() : name;
} }
@ -2340,26 +2469,26 @@ index 2577a135bb88adc9000ab67477846c6466d973e7..7ff1fcfdc87bcd299da46fe8a7e090c1
@Override @Override
public String getPlayerListHeader() { public String getPlayerListHeader() {
- return (this.playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader); - return (this.playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader);
+ return (this.playerListHeader == null) ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(playerListHeader); + return (this.playerListHeader == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(playerListHeader);
} }
@Override @Override
public String getPlayerListFooter() { public String getPlayerListFooter() {
- return (this.playerListFooter == null) ? null : CraftChatMessage.fromComponent(playerListFooter); - return (this.playerListFooter == null) ? null : CraftChatMessage.fromComponent(playerListFooter);
+ return (this.playerListFooter == null) ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(playerListFooter); // Paper - Adventure + return (this.playerListFooter == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(playerListFooter); // Paper - Adventure
} }
@Override @Override
public void setPlayerListHeader(String header) { public void setPlayerListHeader(String header) {
- this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); - this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true);
+ this.playerListHeader = header == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(header); // Paper - Adventure + this.playerListHeader = header == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(header); // Paper - Adventure
this.updatePlayerListHeaderFooter(); this.updatePlayerListHeaderFooter();
} }
@Override @Override
public void setPlayerListFooter(String footer) { public void setPlayerListFooter(String footer) {
- this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); - this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true);
+ this.playerListFooter = footer == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(footer); // Paper - Adventure + this.playerListFooter = footer == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(footer); // Paper - Adventure
this.updatePlayerListHeaderFooter(); this.updatePlayerListHeaderFooter();
} }
@ -2367,8 +2496,8 @@ index 2577a135bb88adc9000ab67477846c6466d973e7..7ff1fcfdc87bcd299da46fe8a7e090c1
public void setPlayerListHeaderFooter(String header, String footer) { public void setPlayerListHeaderFooter(String header, String footer) {
- this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); - this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true);
- this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); - this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true);
+ this.playerListHeader = header == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(header); // Paper - Adventure + this.playerListHeader = header == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(header); // Paper - Adventure
+ this.playerListFooter = footer == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(footer); // Paper - Adventure + this.playerListFooter = footer == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(footer); // Paper - Adventure
this.updatePlayerListHeaderFooter(); this.updatePlayerListHeaderFooter();
} }
@ -2744,7 +2873,7 @@ index af9facfaa8bba614e37bd604ca0656a852d0325b..60fa587ce17e138d2baf8959c26e25ed
public String getTitle() { public String getTitle() {
return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle(); return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index 6486a76466691f958349a4706d7c9caff9cb8f64..08fc05836b26f5f93ae74324705d5f593b57315a 100644 index 6486a76466691f958349a4706d7c9caff9cb8f64..f3ebaefd949ae73afad3dcb69b8d9c632cc782f7 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -19,6 +19,12 @@ public class CraftInventoryCustom extends CraftInventory { @@ -19,6 +19,12 @@ public class CraftInventoryCustom extends CraftInventory {
@ -2795,7 +2924,7 @@ index 6486a76466691f958349a4706d7c9caff9cb8f64..08fc05836b26f5f93ae74324705d5f59
Validate.notNull(title, "Title cannot be null"); Validate.notNull(title, "Title cannot be null");
this.items = NonNullList.withSize(size, ItemStack.EMPTY); this.items = NonNullList.withSize(size, ItemStack.EMPTY);
this.title = title; this.title = title;
+ this.adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(title); + this.adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(title);
this.viewers = new ArrayList<HumanEntity>(); this.viewers = new ArrayList<HumanEntity>();
this.owner = owner; this.owner = owner;
this.type = InventoryType.CHEST; this.type = InventoryType.CHEST;
@ -2805,7 +2934,7 @@ index 6486a76466691f958349a4706d7c9caff9cb8f64..08fc05836b26f5f93ae74324705d5f59
+ public MinecraftInventory(final InventoryHolder owner, final int size, final net.kyori.adventure.text.Component title) { + public MinecraftInventory(final InventoryHolder owner, final int size, final net.kyori.adventure.text.Component title) {
+ Validate.notNull(title, "Title cannot be null"); + Validate.notNull(title, "Title cannot be null");
+ this.items = NonNullList.withSize(size, ItemStack.EMPTY); + this.items = NonNullList.withSize(size, ItemStack.EMPTY);
+ this.title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(title); + this.title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title);
+ this.adventure$title = title; + this.adventure$title = title;
+ this.viewers = new ArrayList<HumanEntity>(); + this.viewers = new ArrayList<HumanEntity>();
+ this.owner = owner; + this.owner = owner;
@ -2910,7 +3039,7 @@ index 059c84a4e50b043f2ac2a033d5d3cbf3cba3b3f9..552851cff3678d605428866999951fef
@Override @Override
public CraftMerchant getCraftMerchant() { public CraftMerchant getCraftMerchant() {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
index ca359cb1ac5f48d4f75d33946fcddedb270407c2..0f753f4868141ecc383877ea3a666a383f2e3339 100644 index ca359cb1ac5f48d4f75d33946fcddedb270407c2..fefa4d83c5699be0b55794cd28d13d27b66ef108 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
@@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
@ -2943,30 +3072,30 @@ index ca359cb1ac5f48d4f75d33946fcddedb270407c2..0f753f4868141ecc383877ea3a666a38
+ // Paper start + // Paper start
+ @Override + @Override
+ public net.kyori.adventure.text.Component title() { + public net.kyori.adventure.text.Component title() {
+ return this.title == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(this.title); + return this.title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.title);
+ } + }
+ +
+ @Override + @Override
+ public org.bukkit.inventory.meta.BookMeta title(net.kyori.adventure.text.Component title) { + public org.bukkit.inventory.meta.BookMeta title(net.kyori.adventure.text.Component title) {
+ this.setTitle(title == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(title)); + this.setTitle(title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title));
+ return this; + return this;
+ } + }
+ +
+ @Override + @Override
+ public net.kyori.adventure.text.Component author() { + public net.kyori.adventure.text.Component author() {
+ return this.author == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(this.author); + return this.author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.author);
+ } + }
+ +
+ @Override + @Override
+ public org.bukkit.inventory.meta.BookMeta author(net.kyori.adventure.text.Component author) { + public org.bukkit.inventory.meta.BookMeta author(net.kyori.adventure.text.Component author) {
+ this.setAuthor(author == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(author)); + this.setAuthor(author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author));
+ return this; + return this;
+ } + }
+ +
+ @Override + @Override
+ public net.kyori.adventure.text.Component page(final int page) { + public net.kyori.adventure.text.Component page(final int page) {
+ Validate.isTrue(isValidPage(page), "Invalid page number"); + Validate.isTrue(isValidPage(page), "Invalid page number");
+ return this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(pages.get(page - 1)) : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(pages.get(page - 1)); + return this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(pages.get(page - 1)) : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(pages.get(page - 1));
+ } + }
+ +
+ @Override + @Override
@ -2977,7 +3106,7 @@ index ca359cb1ac5f48d4f75d33946fcddedb270407c2..0f753f4868141ecc383877ea3a666a38
+ if (data == null) { + if (data == null) {
+ data = net.kyori.adventure.text.Component.empty(); + data = net.kyori.adventure.text.Component.empty();
+ } + }
+ pages.set(page - 1, this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(data) : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(data)); + pages.set(page - 1, this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(data) : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(data));
+ } + }
+ +
+ @Override + @Override
@ -2986,7 +3115,7 @@ index ca359cb1ac5f48d4f75d33946fcddedb270407c2..0f753f4868141ecc383877ea3a666a38
+ if (this instanceof CraftMetaBookSigned) + if (this instanceof CraftMetaBookSigned)
+ return pages.stream().map(net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson()::deserialize).collect(ImmutableList.toImmutableList()); + return pages.stream().map(net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson()::deserialize).collect(ImmutableList.toImmutableList());
+ else + else
+ return pages.stream().map(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC::deserialize).collect(ImmutableList.toImmutableList()); + return pages.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::deserialize).collect(ImmutableList.toImmutableList());
+ } + }
+ +
+ @Override + @Override
@ -3017,15 +3146,15 @@ index ca359cb1ac5f48d4f75d33946fcddedb270407c2..0f753f4868141ecc383877ea3a666a38
+ page = net.kyori.adventure.text.Component.empty(); + page = net.kyori.adventure.text.Component.empty();
+ } + }
+ +
+ this.pages.add(this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(page) : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(page)); + this.pages.add(this instanceof CraftMetaBookSigned ? net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(page) : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(page));
+ } + }
+ } + }
+ +
+ private CraftMetaBook(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, List<net.kyori.adventure.text.Component> pages) { + private CraftMetaBook(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, List<net.kyori.adventure.text.Component> pages) {
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK)); + super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK));
+ this.title = title == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(title); + this.title = title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title);
+ this.author = author == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(author); + this.author = author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author);
+ this.pages = pages.subList(0, Math.min(MAX_PAGES, pages.size())).stream().map(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC::serialize).collect(java.util.stream.Collectors.toList()); + this.pages = pages.subList(0, Math.min(MAX_PAGES, pages.size())).stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).collect(java.util.stream.Collectors.toList());
+ } + }
+ +
+ static class CraftMetaBookBuilder implements BookMetaBuilder { + static class CraftMetaBookBuilder implements BookMetaBuilder {
@ -3092,7 +3221,7 @@ index ca359cb1ac5f48d4f75d33946fcddedb270407c2..0f753f4868141ecc383877ea3a666a38
if (this.hasTitle()) { if (this.hasTitle()) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
index 00445fc7373c70f4cecc4114f9bcfb4b6f27c0e8..b132c151e4fb6c64b633a0712100c3ae5adb81a9 100644 index 00445fc7373c70f4cecc4114f9bcfb4b6f27c0e8..67a198fe1ba930836b82fcc22ab25eb1810be0cf 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java
@@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
@ -3116,8 +3245,8 @@ index 00445fc7373c70f4cecc4114f9bcfb4b6f27c0e8..b132c151e4fb6c64b633a0712100c3ae
+ // Paper start - adventure + // Paper start - adventure
+ private CraftMetaBookSigned(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List<net.kyori.adventure.text.Component> pages) { + private CraftMetaBookSigned(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, java.util.List<net.kyori.adventure.text.Component> pages) {
+ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(Material.WRITABLE_BOOK)); + super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(Material.WRITABLE_BOOK));
+ this.title = title == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(title); + this.title = title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title);
+ this.author = author == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(author); + this.author = author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author);
+ this.pages = io.papermc.paper.adventure.PaperAdventure.asJson(pages.subList(0, Math.min(MAX_PAGES, pages.size()))); + this.pages = io.papermc.paper.adventure.PaperAdventure.asJson(pages.subList(0, Math.min(MAX_PAGES, pages.size())));
+ } + }
+ +
@ -3382,7 +3511,7 @@ index afc059755ae3e7b1c0a4cf3c6b8f32ce13cc458d..5f2af880619e01a03e05258ae1f9fa58
+ CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); + CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
+ ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); + ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
+ return new CraftObjective(this, objective);*/ // Paper + return new CraftObjective(this, objective);*/ // Paper
+ return registerNewObjective(name, criteria, io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(displayName), renderType); // Paper + return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName), renderType); // Paper
} }
@Override @Override
@ -3482,27 +3611,27 @@ index 6e990ab85b1510a952de931a0ae4f5b6356da13f..5e5904e24bb9e4992567190cf6b40fe8
+ +
+ @Override + @Override
+ public net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer() { + public net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer() {
+ return io.papermc.paper.adventure.PaperAdventure.COLOR_DOWNSAMPLING_GSON; + return net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.colorDownsamplingGson();
+ } + }
+ +
+ @Override + @Override
+ public net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer() { + public net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer() {
+ return io.papermc.paper.adventure.PaperAdventure.GSON; + return net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson();
+ } + }
+ +
+ @Override + @Override
+ public net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer() { + public net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer() {
+ return io.papermc.paper.adventure.PaperAdventure.PLAIN_COMPONENT;
+ }
+
+ @Override
+ public net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer() {
+ return io.papermc.paper.adventure.PaperAdventure.PLAIN; + return io.papermc.paper.adventure.PaperAdventure.PLAIN;
+ } + }
+ +
+ @Override + @Override
+ public net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer() {
+ return net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText();
+ }
+
+ @Override
+ public net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer() { + public net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer() {
+ return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC; + return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection();
+ } + }
+ // Paper end + // Paper end
+ +
@ -3545,3 +3674,60 @@ index 838d5b877c01be3ef353f434d98e27b46c0a3fb4..5c4c0ba05f10d2d83b22d3e86805cfa8
HashSet<Player> reference = new HashSet<Player>(players.size()); HashSet<Player> reference = new HashSet<Player>(players.size());
for (ServerPlayer player : players) { for (ServerPlayer player : players) {
reference.add(player.getBukkitEntity()); reference.add(player.getBukkitEntity());
diff --git a/src/main/resources/META-INF/services/net.kyori.adventure.text.minimessage.MiniMessage$Provider b/src/main/resources/META-INF/services/net.kyori.adventure.text.minimessage.MiniMessage$Provider
new file mode 100644
index 0000000000000000000000000000000000000000..6ce632b6c9dc5e4b3b978331df51c0ffd1526471
--- /dev/null
+++ b/src/main/resources/META-INF/services/net.kyori.adventure.text.minimessage.MiniMessage$Provider
@@ -0,0 +1 @@
+io.papermc.paper.adventure.providers.MiniMessageProviderImpl
diff --git a/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.gson.GsonComponentSerializer$Provider b/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.gson.GsonComponentSerializer$Provider
new file mode 100644
index 0000000000000000000000000000000000000000..bc9f7398a0fe158af05b562a8ded9e74a22eae9b
--- /dev/null
+++ b/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.gson.GsonComponentSerializer$Provider
@@ -0,0 +1 @@
+io.papermc.paper.adventure.providers.GsonComponentSerializerProviderImpl
diff --git a/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer$Provider b/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer$Provider
new file mode 100644
index 0000000000000000000000000000000000000000..820f381981a91754b7f0c5106f93b773d885e321
--- /dev/null
+++ b/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer$Provider
@@ -0,0 +1 @@
+io.papermc.paper.adventure.providers.LegacyComponentSerializerProviderImpl
diff --git a/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer$Provider b/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer$Provider
new file mode 100644
index 0000000000000000000000000000000000000000..28d777610b52ba74f808bf3245d73b8333d01fa7
--- /dev/null
+++ b/src/main/resources/META-INF/services/net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer$Provider
@@ -0,0 +1 @@
+io.papermc.paper.adventure.providers.PlainTextComponentSerializerProviderImpl
diff --git a/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java b/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6c4f8e2d375396a0ef3300a8bc324d77f23a768
--- /dev/null
+++ b/src/test/java/io/papermc/paper/adventure/ComponentServicesTest.java
@@ -0,0 +1,23 @@
+package io.papermc.paper.adventure;
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ComponentServicesTest {
+
+ @Test
+ public void testPlainTextComponentSerializerProvider() {
+ assertEquals("Done", PlainTextComponentSerializer.plainText().serialize(Component.translatable("narrator.loading.done")));
+ }
+
+ @Test
+ public void testLegacyComponentSerializerProvider() {
+ assertEquals("§cDone", LegacyComponentSerializer.legacySection().serialize(Component.translatable("narrator.loading.done", NamedTextColor.RED)));
+ assertEquals("&cDone", LegacyComponentSerializer.legacyAmpersand().serialize(Component.translatable("narrator.loading.done", NamedTextColor.RED)));
+ }
+}

Datei anzeigen

@ -26,11 +26,11 @@ index 1496ad80007b93255d105942fef19f4f1a069206..f0be60905effc3489ec0050cc456ae88
+ } + }
} }
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
index 65b6e260464b2003d6bd172610adb5b8651df169..55276e9679dcdc38c6716533e9218f81fc146592 100644 index 3526bc0b6ad590776124966ea907fe2467cbbf5f..65005e9818ef603724ff8f8041f617f1e602a868 100644
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
@@ -15,6 +15,8 @@ import net.kyori.adventure.text.TextReplacementConfig; @@ -16,6 +16,8 @@ import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
+import org.bukkit.ChatColor; +import org.bukkit.ChatColor;
@ -38,12 +38,12 @@ index 65b6e260464b2003d6bd172610adb5b8651df169..55276e9679dcdc38c6716533e9218f81
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.util.LazyPlayerSet; import org.bukkit.craftbukkit.util.LazyPlayerSet;
import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.craftbukkit.util.Waitable;
@@ -153,10 +155,16 @@ public final class ChatProcessor { @@ -154,10 +156,16 @@ public final class ChatProcessor {
} }
private static String legacyDisplayName(final CraftPlayer player) { private static String legacyDisplayName(final CraftPlayer player) {
+ if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) { + if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) {
+ return PaperAdventure.LEGACY_SECTION_UXRC.serialize(player.teamDisplayName()) + ChatColor.RESET; + return LegacyComponentSerializer.legacySection().serialize(player.teamDisplayName()) + ChatColor.RESET;
+ } + }
return player.getDisplayName(); return player.getDisplayName();
} }

Datei anzeigen

@ -166,7 +166,7 @@ index aa02ab4ea7890d9a477be55ce6c0be0a2a0d4b52..f846d9163ca97901ac1508ef8a476dab
@Override @Override
public void sendMessage(Component message, UUID sender) { public void sendMessage(Component message, UUID sender) {
- MinecraftServer.LOGGER.info(message.getString()); - MinecraftServer.LOGGER.info(message.getString());
+ MinecraftServer.LOGGER.info(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors + MinecraftServer.LOGGER.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors
} }
public KeyPair getKeyPair() { public KeyPair getKeyPair() {
@ -222,7 +222,7 @@ index b99c1b62ce01700d5c374a1801e8323d5906255c..39a24292f215920bc3121f4ac903040d
System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream()); System.setOut(IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream()); System.setErr(IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 5b1dcf148d24bbd61728d8c2af611b7c4f8dd166..03fc0bca0c1a11db43d315236ca05dfea137ddb3 100644 index 17afebfc2091392c5ec9aa9f6734ff71d67c9dac..caf92576ed2023f721810b7dd09dd194b1cb3d8c 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -155,8 +155,7 @@ public abstract class PlayerList { @@ -155,8 +155,7 @@ public abstract class PlayerList {

Datei anzeigen

@ -14,7 +14,7 @@ index 03fc0bca0c1a11db43d315236ca05dfea137ddb3..a1ca0c0c08f6793ce3440733f802a40f
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure
- } else if (!this.isWhiteListed(gameprofile)) { - } else if (!this.isWhiteListed(gameprofile)) {
- chatmessage = new TranslatableComponent("multiplayer.disconnect.not_whitelisted"); - chatmessage = new TranslatableComponent("multiplayer.disconnect.not_whitelisted");
- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure - event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure
+ } else if (!this.isWhitelisted(gameprofile, event)) { // Paper + } else if (!this.isWhitelisted(gameprofile, event)) { // Paper
+ //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper + //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper
+ //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted + //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted
@ -38,7 +38,7 @@ index 03fc0bca0c1a11db43d315236ca05dfea137ddb3..a1ca0c0c08f6793ce3440733f802a40f
+ event.callEvent(); + event.callEvent();
+ if (!event.isWhitelisted()) { + if (!event.isWhitelisted()) {
+ if (loginEvent != null) { + if (loginEvent != null) {
+ loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(event.getKickMessage() == null ? org.spigotmc.SpigotConfig.whitelistMessage : event.getKickMessage())); + loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(event.getKickMessage() == null ? org.spigotmc.SpigotConfig.whitelistMessage : event.getKickMessage()));
+ } + }
+ return false; + return false;
+ } + }

Datei anzeigen

@ -11,14 +11,15 @@ outside of custom inventories.
diff --git a/src/main/java/io/papermc/paper/inventory/PaperInventoryCustomHolderContainer.java b/src/main/java/io/papermc/paper/inventory/PaperInventoryCustomHolderContainer.java diff --git a/src/main/java/io/papermc/paper/inventory/PaperInventoryCustomHolderContainer.java b/src/main/java/io/papermc/paper/inventory/PaperInventoryCustomHolderContainer.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..8e02633b2f8676095ca5c5326c88499a8f36c842 index 0000000000000000000000000000000000000000..224d4b2cc45b0d02230a76caee9c88573a448b4c
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/inventory/PaperInventoryCustomHolderContainer.java +++ b/src/main/java/io/papermc/paper/inventory/PaperInventoryCustomHolderContainer.java
@@ -0,0 +1,140 @@ @@ -0,0 +1,141 @@
+package io.papermc.paper.inventory; +package io.papermc.paper.inventory;
+ +
+import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.adventure.PaperAdventure;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import net.minecraft.world.Container; +import net.minecraft.world.Container;
+import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ItemStack;
@ -55,7 +56,7 @@ index 0000000000000000000000000000000000000000..8e02633b2f8676095ca5c5326c88499a
+ adventure$title = type.defaultTitle(); + adventure$title = type.defaultTitle();
+ } + }
+ this.adventure$title = adventure$title; + this.adventure$title = adventure$title;
+ this.title = PaperAdventure.LEGACY_SECTION_UXRC.serialize(this.adventure$title); + this.title = LegacyComponentSerializer.legacySection().serialize(this.adventure$title);
+ } + }
+ +
+ public Component title() { + public Component title() {
@ -202,7 +203,7 @@ index 6ca8e76d1569f3f631275fea187e7110f09fc69e..3796f8b122ad981b6faacd2afcaf3696
return InventoryType.ENDER_CHEST; return InventoryType.ENDER_CHEST;
} else if (this.inventory instanceof MerchantContainer) { } else if (this.inventory instanceof MerchantContainer) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index 08fc05836b26f5f93ae74324705d5f593b57315a..fdde2b3f2320393ab4acf450d08ab6744c5408ea 100644 index f3ebaefd949ae73afad3dcb69b8d9c632cc782f7..08f8ea0716ef8fa850f1f2f7b8a6e636f57ae872 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -15,6 +15,11 @@ import org.bukkit.event.inventory.InventoryType; @@ -15,6 +15,11 @@ import org.bukkit.event.inventory.InventoryType;

Datei anzeigen

@ -31,7 +31,7 @@ index adfbc156b4c4a8591609f385adaa6b04f984a64f..709bab9ac4eb453caeb0f565b6a0d6d0
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -322,7 +322,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -322,7 +322,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
if (adventure$title == null) adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(container.getBukkitView().getTitle()); // Paper if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper
//player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment
- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
@ -41,7 +41,7 @@ index adfbc156b4c4a8591609f385adaa6b04f984a64f..709bab9ac4eb453caeb0f565b6a0d6d0
} }
@@ -396,7 +396,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -396,7 +396,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper
if (adventure$title == null) adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(inventory.getTitle()); // Paper if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper
//player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
+ if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper + if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper

Datei anzeigen

@ -19,12 +19,12 @@ index 045a49da7c17e48534b3bd5b7aa3968963681e6c..5dc7e897fdb2a572b800eb34c40961cd
+ } + }
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
index 269738c499c6aab6f8c39ba4ffd12fa09f0d79dc..dbff1eda25b02b16ec123515338d470489f3b3c4 100644 index 324e6d1a4fadd3e557e4ba05f04e6a5891cc54df..db77cdee224d14ec91e8d530dd65da51f3661a9c 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
@@ -93,5 +93,15 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co @@ -93,5 +93,15 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) {
this.sendRawMessage(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(message)); this.sendRawMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
} }
+ +
+ @Override + @Override

Datei anzeigen

@ -66,7 +66,7 @@ index 5f2af880619e01a03e05258ae1f9fa58110f7f2a..944080939ceaf2db8bcd7d3c01f4b974
+ // Paper end + // Paper end
ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
return new CraftObjective(this, objective);*/ // Paper return new CraftObjective(this, objective);*/ // Paper
return registerNewObjective(name, criteria, io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(displayName), renderType); // Paper return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName), renderType); // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
index ff090edcc85713083449cebb22bd1490123bc1ee..8ccfe9488db44d7d2cf4040a5b4cead33da1d5f4 100644 index ff090edcc85713083449cebb22bd1490123bc1ee..8ccfe9488db44d7d2cf4040a5b4cead33da1d5f4 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Add support for hex color codes in console
Converts upstream's hex color code legacy format into actual hex color codes in the console. Converts upstream's hex color code legacy format into actual hex color codes in the console.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index a0a3cec47c8f9e379a5bc1d43eeda5eb9d81f814..23d849872109e43d6e22a953d3a4298565d4621d 100644 index 1adbceadd5df96e17796561a40eb7b760493440e..c07257314e070d4423c4f53f58cb0962e3ead131 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -454,8 +454,10 @@ public class PaperConfig { @@ -454,8 +454,10 @@ public class PaperConfig {
@ -21,17 +21,17 @@ index a0a3cec47c8f9e379a5bc1d43eeda5eb9d81f814..23d849872109e43d6e22a953d3a42985
public static boolean allowBlockPermanentBreakingExploits = false; public static boolean allowBlockPermanentBreakingExploits = false;
diff --git a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java diff --git a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
index 685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869..84243e10c115104cadfe84c4f152f53c1b5f7c6f 100644 index 685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869..709f2a420ceaffe0101c676ec23e949e8d684465 100644
--- a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java --- a/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
+++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java +++ b/src/main/java/com/destroystokyo/paper/console/TerminalConsoleCommandSender.java
@@ -1,5 +1,10 @@ @@ -1,5 +1,10 @@
package com.destroystokyo.paper.console; package com.destroystokyo.paper.console;
+import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.console.HexFormattingConverter; +import io.papermc.paper.console.HexFormattingConverter;
+import net.kyori.adventure.audience.MessageType; +import net.kyori.adventure.audience.MessageType;
+import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.identity.Identity;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.bukkit.craftbukkit.command.CraftConsoleCommandSender; import org.bukkit.craftbukkit.command.CraftConsoleCommandSender;
@ -41,7 +41,7 @@ index 685deaa0e5d1ddc13e3a7c0471b1cfcf1710c869..84243e10c115104cadfe84c4f152f53c
public void sendRawMessage(String message) { public void sendRawMessage(String message) {
- // TerminalConsoleAppender supports color codes directly in log messages - // TerminalConsoleAppender supports color codes directly in log messages
- LOGGER.info(message); - LOGGER.info(message);
+ final Component msg = PaperAdventure.LEGACY_SECTION_UXRC.deserialize(message); + final Component msg = LegacyComponentSerializer.legacySection().deserialize(message);
+ this.sendMessage(Identity.nil(), msg, MessageType.SYSTEM); + this.sendMessage(Identity.nil(), msg, MessageType.SYSTEM);
+ } + }
+ +
@ -270,14 +270,14 @@ index 0000000000000000000000000000000000000000..ea83ee8762c126c449993a7497257b0b
+ +
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 445efad6a35b819dcb845524a28055a90da6e7f6..2914355be3f6c45b2dbd7ceb0ea65c7f22255a6d 100644 index 3a73d834c3c8481ff3af3eee7634309f7abe60ab..2914355be3f6c45b2dbd7ceb0ea65c7f22255a6d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1712,7 +1712,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1712,7 +1712,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@Override @Override
public void sendMessage(Component message, UUID sender) { public void sendMessage(Component message, UUID sender) {
- MinecraftServer.LOGGER.info(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors - MinecraftServer.LOGGER.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors
+ MinecraftServer.LOGGER.info(io.papermc.paper.console.HexFormattingConverter.SERIALIZER.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors + MinecraftServer.LOGGER.info(io.papermc.paper.console.HexFormattingConverter.SERIALIZER.serialize(io.papermc.paper.adventure.PaperAdventure.asAdventure(message))); // Paper - Log message with colors
} }

Datei anzeigen

@ -100,12 +100,12 @@ index 50797b32b71b2c8a73f34313021457b27fc90660..7ad1b8b836d692b1168609e96e4eb72e
public void disconnect(String s) { public void disconnect(String s) {
// Paper start // Paper start
- this.disconnect(PaperAdventure.LEGACY_SECTION_UXRC.deserialize(s)); - this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s));
+ this.disconnect(PaperAdventure.LEGACY_SECTION_UXRC.deserialize(s), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); + this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
+ } + }
+ +
+ public void disconnect(String s, PlayerKickEvent.Cause cause) { + public void disconnect(String s, PlayerKickEvent.Cause cause) {
+ this.disconnect(PaperAdventure.LEGACY_SECTION_UXRC.deserialize(s), cause); + this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), cause);
} }
public void disconnect(final Component reason) { public void disconnect(final Component reason) {

Datei anzeigen

@ -6,19 +6,19 @@ Subject: [PATCH] API for creating command sender which forwards feedback
diff --git a/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java b/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java diff --git a/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java b/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..f7c86155ce0cfd9b4bf8a2b79d77a656d795c95f index 0000000000000000000000000000000000000000..ed3d488c6581df5eac425d9cccb8e741a52e91d5
--- /dev/null --- /dev/null
+++ b/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java +++ b/src/main/java/io/papermc/paper/commands/FeedbackForwardingSender.java
@@ -0,0 +1,112 @@ @@ -0,0 +1,112 @@
+package io.papermc.paper.commands; +package io.papermc.paper.commands;
+ +
+import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.text.PaperComponents;
+import java.util.UUID; +import java.util.UUID;
+import java.util.function.Consumer; +import java.util.function.Consumer;
+import net.kyori.adventure.audience.MessageType; +import net.kyori.adventure.audience.MessageType;
+import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.identity.Identity;
+import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
+import net.minecraft.commands.CommandSource; +import net.minecraft.commands.CommandSource;
+import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.CommandSourceStack;
+import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TextComponent;
@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..f7c86155ce0cfd9b4bf8a2b79d77a656
+ +
+ @Override + @Override
+ public void sendMessage(final String message) { + public void sendMessage(final String message) {
+ this.sendMessage(PaperComponents.legacySectionSerializer().deserialize(message)); + this.sendMessage(LegacyComponentSerializer.legacySection().deserialize(message));
+ } + }
+ +
+ @Override + @Override
@ -123,7 +123,7 @@ index 0000000000000000000000000000000000000000..f7c86155ce0cfd9b4bf8a2b79d77a656
+ } + }
+} +}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7dc79e7c552d7ebc2dea9248c2d5647b5a6895e0..66d931bf247cfc07c40ef4721ab24e163e6038ea 100644 index 168893fe1790edac8fee884b1fae4e6b7a1bd5c6..231a7935950d40683c8538bfcfc8adea236ad37a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1988,6 +1988,13 @@ public final class CraftServer implements Server { @@ -1988,6 +1988,13 @@ public final class CraftServer implements Server {