From a9f38a878987c33dd4fcee2ead82c4b7eed927b5 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 11 Jun 2021 12:23:46 -0700 Subject: [PATCH] fix adventure patch --- .../0006-Adventure.patch} | 0 patches/removed/1.17/0012-Adventure.patch | 23 + .../0010-Adventure.patch} | 748 ++++++++---------- 3 files changed, 360 insertions(+), 411 deletions(-) rename patches/{api-unmapped/0005-Adventure.patch => api/0006-Adventure.patch} (100%) create mode 100644 patches/removed/1.17/0012-Adventure.patch rename patches/{server-remapped/0012-Adventure.patch => server/0010-Adventure.patch} (82%) diff --git a/patches/api-unmapped/0005-Adventure.patch b/patches/api/0006-Adventure.patch similarity index 100% rename from patches/api-unmapped/0005-Adventure.patch rename to patches/api/0006-Adventure.patch diff --git a/patches/removed/1.17/0012-Adventure.patch b/patches/removed/1.17/0012-Adventure.patch new file mode 100644 index 0000000000..d0d6c9d6b6 --- /dev/null +++ b/patches/removed/1.17/0012-Adventure.patch @@ -0,0 +1,23 @@ +diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java +index 915120cc505c70153f7b70f07d8d42c13eb77ea7..69ff8df7340e60c476803256750a48f0b43414d3 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java +@@ -10,6 +10,7 @@ public class ClientboundSetTitlesPacket implements Packet { -+ final @NonNull String translated = LocaleLanguage.a().a(translatable.key()); ++ final @NonNull String translated = net.minecraft.locale.Language.getInstance().getOrDefault(translatable.key()); + + final Matcher matcher = LOCALIZATION_PATTERN.matcher(translated); + final List args = translatable.args(); @@ -934,19 +934,19 @@ index 0000000000000000000000000000000000000000..2dc92d8d2764d3e9b621d5c7d5e30c30 + } +} diff --git a/src/main/java/net/minecraft/ChatFormatting.java b/src/main/java/net/minecraft/ChatFormatting.java -index e888a90226c30757b190a3b89a56c1a312f32850..1720eba650c959810c6e4a3522979e75e10a1bb8 100644 +index b82b218be1bd849fa280ea1fe0336e279bebfc18..77e35e18754bd2380e1d5f93c62e1d47d21a0a18 100644 --- a/src/main/java/net/minecraft/ChatFormatting.java +++ b/src/main/java/net/minecraft/ChatFormatting.java -@@ -61,6 +61,7 @@ public enum ChatFormatting { - return !this.isFormat && this != ChatFormatting.RESET; +@@ -86,6 +86,7 @@ public enum ChatFormatting { + return !this.isFormat && this != RESET; } + @Nullable public Integer getHexValue() { return this.getColor(); } // Paper - OBFHELPER @Nullable public Integer getColor() { return this.color; -@@ -84,6 +85,18 @@ public enum ChatFormatting { - return name == null ? null : (ChatFormatting) ChatFormatting.FORMATTING_BY_NAME.get(cleanName(name)); +@@ -110,6 +111,18 @@ public enum ChatFormatting { + return name == null ? null : FORMATTING_BY_NAME.get(cleanName(name)); } + // Paper start @@ -964,8 +964,20 @@ index e888a90226c30757b190a3b89a56c1a312f32850..1720eba650c959810c6e4a3522979e75 @Nullable public static ChatFormatting getById(int colorIndex) { if (colorIndex < 0) { +diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java +index 4760fc27b1d4938a248c05af17fc93ab37084c00..750df4ab2fbfdcf759f4d3451340e66b6764391d 100644 +--- a/src/main/java/net/minecraft/nbt/CompoundTag.java ++++ b/src/main/java/net/minecraft/nbt/CompoundTag.java +@@ -128,7 +128,6 @@ public class CompoundTag implements Tag { + /** + * You must use {@link #hasUUID(String)} before or else it will throw an NPE. + */ +- public UUID getUUID(String prefix) { return getUUID(prefix); } // Paper - OBFHELPER + public UUID getUUID(String key) { + return NbtUtils.loadUUID(this.get(key)); + } diff --git a/src/main/java/net/minecraft/nbt/StringTag.java b/src/main/java/net/minecraft/nbt/StringTag.java -index 620e10b5ba9e57ff4d0d7967bf4240fafadb2be7..dab8983fa65b97ecf0fe20fdc06cc8ec60d8fe95 100644 +index ad1c1fbb15cbd744afe54e1c3b533e51021a89eb..b15cfb9374402d4b42d163bf8e3ec838f19004bc 100644 --- a/src/main/java/net/minecraft/nbt/StringTag.java +++ b/src/main/java/net/minecraft/nbt/StringTag.java @@ -43,6 +43,7 @@ public class StringTag implements Tag { @@ -974,29 +986,29 @@ index 620e10b5ba9e57ff4d0d7967bf4240fafadb2be7..dab8983fa65b97ecf0fe20fdc06cc8ec + public static StringTag create(final String value) { return valueOf(value); } // Paper - OBFHELPER public static StringTag valueOf(String value) { - return value.isEmpty() ? StringTag.EMPTY : new StringTag(value); + return value.isEmpty() ? EMPTY : new StringTag(value); } diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index 50f14acb062c2f90266279dbd1945a3297396f0b..59788eaef0dae5ee01ceba1bf45e85cb07f88e53 100644 +index 3b8207046d38d3d14719ff6761a22e60a93628b7..c15860c77c7c24b1946c22f140f1b5c12b052ade 100644 --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java +++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -10,6 +10,7 @@ import io.netty.buffer.ByteBufOutputStream; - import io.netty.handler.codec.DecoderException; - import io.netty.handler.codec.EncoderException; +@@ -14,6 +14,7 @@ import io.netty.handler.codec.EncoderException; import io.netty.util.ByteProcessor; + import it.unimi.dsi.fastutil.ints.IntArrayList; + import it.unimi.dsi.fastutil.ints.IntList; +import io.papermc.paper.adventure.PaperAdventure; // Paper import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -@@ -43,6 +44,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit - public class FriendlyByteBuf extends ByteBuf { - +@@ -61,6 +62,7 @@ public class FriendlyByteBuf extends ByteBuf { + private static final int MAX_VARLONG_SIZE = 10; + private static final int DEFAULT_NBT_QUOTA = 2097152; private final ByteBuf source; + public java.util.Locale adventure$locale; // Paper + public static final short MAX_STRING_LENGTH = 32767; + public static final int MAX_COMPONENT_STRING_LENGTH = 262144; - public FriendlyByteBuf(ByteBuf bytebuf) { - this.source = bytebuf; -@@ -164,8 +166,15 @@ public class FriendlyByteBuf extends ByteBuf { +@@ -327,8 +329,15 @@ public class FriendlyByteBuf extends ByteBuf { return Component.Serializer.fromJson(this.readUtf(262144)); } @@ -1012,17 +1024,9 @@ index 50f14acb062c2f90266279dbd1945a3297396f0b..59788eaef0dae5ee01ceba1bf45e85cb + return this.writeUtf(PaperAdventure.asJsonString(text, this.adventure$locale), 262144); // Paper } - public > T readEnum(Class oclass) { -@@ -348,6 +357,7 @@ public class FriendlyByteBuf extends ByteBuf { - return this.writeUtf(s, 32767); - } - -+ public FriendlyByteBuf writeUtf(final String string, final int maxLength) { return this.writeUtf(string, maxLength); } // Paper - OBFHELPER - public FriendlyByteBuf writeUtf(String s, int i) { - byte[] abyte = s.getBytes(StandardCharsets.UTF_8); - + public > T readEnum(Class enumClass) { diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index 14fa1371e52b9af5a7550a9aa144fa406b754046..d36d0424bcd4811af892f5f76fdcefda2af1ad33 100644 +index 02d253243eb66c30d4f7f6b0e7361518516eefec..847c59dd1b4673f4a03d77717468e07e99fc80a4 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java @@ -3,6 +3,7 @@ package net.minecraft.network; @@ -1033,26 +1037,36 @@ index 14fa1371e52b9af5a7550a9aa144fa406b754046..d36d0424bcd4811af892f5f76fdcefda import java.io.IOException; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; -@@ -37,6 +38,7 @@ public class PacketEncoder extends MessageToByteEncoder> { - throw new IOException("Can't serialize unregistered packet"); +@@ -36,6 +37,7 @@ public class PacketEncoder extends MessageToByteEncoder> { } else { - FriendlyByteBuf packetdataserializer = new FriendlyByteBuf(bytebuf); -+ packetdataserializer.adventure$locale = channelhandlercontext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper - - packetdataserializer.writeVarInt(integer); + FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf); + friendlyByteBuf.writeVarInt(integer); ++ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper + try { + int i = friendlyByteBuf.writerIndex(); +@@ -46,7 +48,7 @@ public class PacketEncoder extends MessageToByteEncoder> { + } + } catch (Throwable var9) { + LOGGER.error(var9); +- throwable.printStackTrace(); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE? ++ var9.printStackTrace(); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE? + if (packet.isSkippable()) { + throw new SkipPacketException(var9); + } else { diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java -index 819ea90ea116dea396c225539fc0fbebd6176ba5..54d186a195aca6d0a4c412ed609d8c86dcc76072 100644 +index d9aac575213f3bda9c44ea2b3b6d1969ff82f09d..02d19fa4abdee0c8331734932a83e64694356030 100644 --- a/src/main/java/net/minecraft/network/chat/Component.java +++ b/src/main/java/net/minecraft/network/chat/Component.java -@@ -1,5 +1,6 @@ +@@ -1,6 +1,7 @@ package net.minecraft.network.chat; + import com.google.common.collect.Lists; +import io.papermc.paper.adventure.AdventureComponent; // Paper import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; -@@ -110,6 +111,7 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -161,6 +162,7 @@ public interface Component extends Message, FormattedText, Iterable { GsonBuilder gsonbuilder = new GsonBuilder(); gsonbuilder.disableHtmlEscaping(); @@ -1060,7 +1074,7 @@ index 819ea90ea116dea396c225539fc0fbebd6176ba5..54d186a195aca6d0a4c412ed609d8c86 gsonbuilder.registerTypeHierarchyAdapter(Component.class, new Component.Serializer()); gsonbuilder.registerTypeHierarchyAdapter(Style.class, new Style.Serializer()); gsonbuilder.registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory()); -@@ -262,6 +264,7 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -320,6 +322,7 @@ public interface Component extends Message, FormattedText, Iterable { } public JsonElement serialize(Component ichatbasecomponent, Type type, JsonSerializationContext jsonserializationcontext) { @@ -1068,20 +1082,15 @@ index 819ea90ea116dea396c225539fc0fbebd6176ba5..54d186a195aca6d0a4c412ed609d8c86 JsonObject jsonobject = new JsonObject(); if (!ichatbasecomponent.getStyle().isEmpty()) { -@@ -350,10 +353,12 @@ public interface Component extends Message, FormattedText, Iterable { - return jsonobject; +@@ -416,6 +419,7 @@ public interface Component extends Message, FormattedText, Iterable { + }); } + public static String componentToJson(final Component component) { return toJson(component); } // Paper - OBFHELPER public static String toJson(Component text) { return Component.Serializer.GSON.toJson(text); } - -+ public static JsonElement toJsonTree(final Component component) { return toJsonTree(component); } // Paper - OBFHELPER - public static JsonElement toJsonTree(Component text) { - return Component.Serializer.GSON.toJsonTree(text); - } -@@ -363,6 +368,7 @@ public interface Component extends Message, FormattedText, Iterable { +@@ -429,6 +433,7 @@ public interface Component extends Message, FormattedText, Iterable { return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false); } @@ -1090,72 +1099,48 @@ index 819ea90ea116dea396c225539fc0fbebd6176ba5..54d186a195aca6d0a4c412ed609d8c86 public static MutableComponent fromJson(JsonElement json) { return (MutableComponent) Component.Serializer.GSON.fromJson(json, MutableComponent.class); diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java -index ce64931b5c363352f03baddbc747246469d56a84..e47102cadb40ed8a9c011386445f15fd30de7596 100644 +index d63a712126973fd1bea547d30c7d116c622669ee..1f5050e6c1d932aa196ab9524f7f1f9bd1b45fce 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundChatPacket.java -@@ -11,6 +11,7 @@ import net.minecraft.network.protocol.Packet; +@@ -10,6 +10,7 @@ import net.minecraft.network.protocol.Packet; public class ClientboundChatPacket implements Packet { - private Component message; + private final Component message; + public net.kyori.adventure.text.Component adventure$message; // Paper public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot - private ChatType type; - private UUID sender; -@@ -32,6 +33,11 @@ public class ClientboundChatPacket implements Packet { + private final ChatType type; + private final UUID sender; +@@ -28,6 +29,11 @@ public class ClientboundChatPacket implements Packet { @Override - public void write(FriendlyByteBuf buf) throws IOException { + public void write(FriendlyByteBuf buf) { + // Paper start + if (this.adventure$message != null) { + buf.writeComponent(this.adventure$message); + } else + // Paper end // Spigot start - if (components != null) { - buf.writeByteArray(net.md_5.bungee.chat.ComponentSerializer.toString(components)); -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java -index 915120cc505c70153f7b70f07d8d42c13eb77ea7..69ff8df7340e60c476803256750a48f0b43414d3 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java -@@ -10,6 +10,7 @@ public class ClientboundSetTitlesPacket implements Packet { + public final Component header; + public final Component footer; + // Paper start + public net.kyori.adventure.text.Component adventure$header; + public net.kyori.adventure.text.Component adventure$footer; + // Paper end - public ClientboundTabListPacket() {} - + public ClientboundTabListPacket(Component header, Component footer) { + this.header = header; @@ -20,6 +24,13 @@ public class ClientboundTabListPacket implements Packet { + this.connection.send((Packet) (new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent)), (future) -> { if (!future.isSuccess()) { -@@ -1666,6 +1663,7 @@ public class ServerPlayer extends Player implements ContainerListener { - this.sendMessage(message, ChatType.SYSTEM, senderUuid); - } - -+ public void sendMessage(final Component message, final ChatType type, final UUID sender) { this.sendMessage(message, type, sender); } // Paper - OBFHELPER - public void sendMessage(Component message, ChatType type, UUID senderUuid) { - this.connection.send((Packet) (new ClientboundChatPacket(message, type, senderUuid)), (future) -> { - if (!future.isSuccess() && (type == ChatType.GAME_INFO || type == ChatType.SYSTEM)) { -@@ -1688,6 +1686,7 @@ public class ServerPlayer extends Player implements ContainerListener { +@@ -1709,6 +1706,7 @@ public class ServerPlayer extends Player { } public String locale = "en_us"; // CraftBukkit - add, lowercase @@ -1238,7 +1215,7 @@ index 8d7fa186b0b47688f2822038b46c33b3f32d28ae..ca647b3afbe8da5847dc8fa890ae9ca5 public void updateOptions(ServerboundClientInformationPacket packet) { // CraftBukkit start if (getMainArm() != packet.getMainHand()) { -@@ -1699,6 +1698,10 @@ public class ServerPlayer extends Player implements ContainerListener { +@@ -1720,6 +1718,10 @@ public class ServerPlayer extends Player { this.server.server.getPluginManager().callEvent(event); } this.locale = packet.language; @@ -1250,26 +1227,26 @@ index 8d7fa186b0b47688f2822038b46c33b3f32d28ae..ca647b3afbe8da5847dc8fa890ae9ca5 // CraftBukkit end this.chatVisibility = packet.getChatVisibility(); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 466c4322803bedf1fa61be281b954bf94fb8ff02..016e91a6ca1c8457e3e367ac0597b73e81919b68 100644 +index 4ada0aaca513cbac51b93b298f4e2587de46f0d8..94ebbcb7731c01fcb93f053eea109f544132139a 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -168,6 +168,8 @@ import org.apache.logging.log4j.LogManager; +@@ -162,6 +162,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; // CraftBukkit start +import io.papermc.paper.adventure.ChatProcessor; // Paper +import io.papermc.paper.adventure.PaperAdventure; // Paper import java.util.concurrent.ExecutionException; - import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; - import org.bukkit.Location; -@@ -388,21 +390,24 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { + import java.util.concurrent.atomic.AtomicInteger; + import net.minecraft.world.inventory.AbstractContainerMenu; +@@ -385,21 +387,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser return this.server.isSingleplayerOwner(this.player.getGameProfile()); } - // CraftBukkit start - @Deprecated - public void disconnect(Component reason) { -- disconnect(CraftChatMessage.fromComponent(reason)); +- this.disconnect(CraftChatMessage.fromComponent(reason)); + public void disconnect(String s) { + // Paper start + this.disconnect(PaperAdventure.LEGACY_SECTION_UXRC.deserialize(s)); @@ -1290,12 +1267,12 @@ index 466c4322803bedf1fa61be281b954bf94fb8ff02..016e91a6ca1c8457e3e367ac0597b73e - String leaveMessage = ChatFormatting.YELLOW + this.player.getScoreboardName() + " left the game."; + net.kyori.adventure.text.Component leaveMessage = net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, this.player.getBukkitEntity().displayName()); // Paper - Adventure -- PlayerKickEvent event = new PlayerKickEvent(this.craftServer.getPlayer(this.player), s, leaveMessage); -+ PlayerKickEvent event = new PlayerKickEvent(this.craftServer.getPlayer(this.player), reason, leaveMessage); // Paper - Adventure +- PlayerKickEvent event = new PlayerKickEvent(this.cserver.getPlayer(this.player), s, leaveMessage); ++ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), reason, leaveMessage); // Paper - Adventure - if (this.craftServer.getServer().isRunning()) { - this.craftServer.getPluginManager().callEvent(event); -@@ -413,8 +418,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { + if (this.cserver.getServer().isRunning()) { + this.cserver.getPluginManager().callEvent(event); +@@ -410,8 +415,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser return; } // Send the possibly modified leave message @@ -1305,7 +1282,7 @@ index 466c4322803bedf1fa61be281b954bf94fb8ff02..016e91a6ca1c8457e3e367ac0597b73e // CraftBukkit end this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), (future) -> { -@@ -1631,9 +1635,11 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -1671,9 +1675,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser */ this.player.disconnect(); @@ -1315,62 +1292,68 @@ index 466c4322803bedf1fa61be281b954bf94fb8ff02..016e91a6ca1c8457e3e367ac0597b73e + // Paper start - Adventure + net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().disconnect(this.player); + if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) { -+ this.server.getPlayerList().sendMessage(PaperAdventure.asVanilla(quitMessage)); ++ this.server.getPlayerList().broadcastMessage(PaperAdventure.asVanilla(quitMessage), ChatType.SYSTEM, Util.NIL_UUID); + // Paper end } // CraftBukkit end - TextFilter itextfilter = this.player.getTextFilter(); -@@ -1849,8 +1855,13 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { + this.player.getTextFilter().leave(); +@@ -1855,7 +1861,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser this.handleCommand(s); } else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) { // Do nothing, this is coming from a plugin - } else { -- Player player = this.getPlayer(); + // Paper start + } else if (true) { + final ChatProcessor cp = new ChatProcessor(this.server, this.player, s, async); + cp.process(); -+ // Paper end ++ // Paper end + } else if (false) { // Paper -+ Player player = this.getPlayer(); // Paper - AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(server)); - this.craftServer.getPluginManager().callEvent(event); - -@@ -2668,21 +2679,20 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { + Player player = this.getCraftPlayer(); + AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(this.server)); + this.cserver.getPluginManager().callEvent(event); +@@ -2646,30 +2657,28 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser return; } - // CraftBukkit start -- Player player = this.craftServer.getPlayer(this.player); -- int x = packetplayinupdatesign.getPos().getX(); -- int y = packetplayinupdatesign.getPos().getY(); -- int z = packetplayinupdatesign.getPos().getZ(); -- String[] lines = new String[4]; + // CraftBukkit start // Paper start - Adventure + Player player = this.cserver.getPlayer(this.player); + int x = packetplayinupdatesign.getPos().getX(); + int y = packetplayinupdatesign.getPos().getY(); + int z = packetplayinupdatesign.getPos().getZ(); +- String[] lines = new String[4]; + List lines = new java.util.ArrayList<>(); for (int i = 0; i < list.size(); ++i) { -- lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting((String) list.get(i))).getString()); -+ lines.add(net.kyori.adventure.text.Component.text(list.get(i))); +- TextFilter.FilteredText itextfilter_a = (TextFilter.FilteredText) list.get(i); +- + if (this.player.isTextFilteringEnabled()) { +- lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(itextfilter_a.getFiltered())).getString()); ++ lines.add(net.kyori.adventure.text.Component.text(list.get(i).getFiltered())); + } else { +- lines[i] = ChatFormatting.stripFormatting(new TextComponent(ChatFormatting.stripFormatting(itextfilter_a.getRaw())).getString()); ++ lines.add(net.kyori.adventure.text.Component.text(list.get(i).getRaw())); + } } -- SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.craftServer.getPlayer(this.player), lines); -+ SignChangeEvent event = new SignChangeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldserver, blockposition), this.getPlayer(), lines); - this.craftServer.getPluginManager().callEvent(event); + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.cserver.getPlayer(this.player), lines); + this.cserver.getPluginManager().callEvent(event); if (!event.isCancelled()) { -- System.arraycopy(org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()), 0, tileentitysign.messages, 0, 4); +- Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); +- for (int i = 0; i < components.length; i++) { +- tileentitysign.setMessage(i, components[i]); + for (int i = 0; i < 4; i++) { + tileentitysign.setMessage(i, PaperAdventure.asVanilla(event.line(i))); -+ } + } + // Paper end tileentitysign.isEditable = false; - } + } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index a1dd76f49c59ed0a0b7f2b68fbd1a9a70a89128b..9dbb3bb79ae2de6635f71e5ee5bebeb5e57b624e 100644 +index 89d3a7ab019e735c5057568aa2971018f1a05324..11c0da9b36aecc1a7d3acb2dccdae962426dd2e7 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -35,6 +35,7 @@ import net.minecraft.world.entity.player.Player; +@@ -36,6 +36,7 @@ import net.minecraft.world.entity.player.Player; import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -1378,7 +1361,7 @@ index a1dd76f49c59ed0a0b7f2b68fbd1a9a70a89128b..9dbb3bb79ae2de6635f71e5ee5bebeb5 import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerPreLoginEvent; -@@ -299,7 +300,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -315,7 +316,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) { final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId); if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) { @@ -1387,36 +1370,36 @@ index a1dd76f49c59ed0a0b7f2b68fbd1a9a70a89128b..9dbb3bb79ae2de6635f71e5ee5bebeb5 } Waitable waitable = new Waitable() { @Override -@@ -310,12 +311,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -326,12 +327,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener ServerLoginPacketListenerImpl.this.server.processQueue.add(waitable); if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) { -- disconnect(event.getKickMessage()); -+ disconnect(PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure +- ServerLoginPacketListenerImpl.this.disconnect(event.getKickMessage()); ++ ServerLoginPacketListenerImpl.this.disconnect(PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure return; } } else { if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { -- disconnect(asyncEvent.getKickMessage()); -+ disconnect(PaperAdventure.asVanilla(asyncEvent.kickMessage())); // Paper - Adventure +- ServerLoginPacketListenerImpl.this.disconnect(asyncEvent.getKickMessage()); ++ ServerLoginPacketListenerImpl.this.disconnect(PaperAdventure.asVanilla(asyncEvent.kickMessage())); // Paper - Adventure return; } } diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -index de19aa66e7b6ddde17e9acf65643b4a71573d759..223df8d27c2ff1cbff634bca3dbde5cc24de7f98 100644 +index b632280e057ae6893bf5ebcde75cefac3ee62a09..9baa56d6da9c24706f1dbc8851fd68ca752cab26 100644 --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java @@ -55,7 +55,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene CraftIconCache icon = server.server.getServerIcon(); ServerListPingEvent() { -- super(((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers()); -+ super(((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.server.motd(), server.getPlayerList().getMaxPlayers()); // Paper - Adventure +- super(((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), ServerStatusPacketListenerImpl.this.server.getMotd(), ServerStatusPacketListenerImpl.this.server.getPlayerList().getMaxPlayers()); ++ super(((InetSocketAddress) ServerStatusPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(), ServerStatusPacketListenerImpl.this.server.server.getMotd(), ServerStatusPacketListenerImpl.this.server.getPlayerList().getMaxPlayers()); // Paper - Adventure } @Override diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b40e072c8a 100644 +index 34e386efda7ea52fb6f53333eda0f015b0666ff3..446dd8c15d4ccdced316deeaba379cb6937496ca 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile; @@ -1427,30 +1410,30 @@ index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b4 import java.io.File; import java.net.SocketAddress; import java.text.SimpleDateFormat; -@@ -83,6 +84,7 @@ import org.apache.logging.log4j.LogManager; +@@ -89,6 +90,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; // CraftBukkit start +import io.papermc.paper.adventure.PaperAdventure; // Paper import com.google.common.base.Predicate; - import com.google.common.collect.Iterables; + import java.util.stream.Collectors; import net.minecraft.server.dedicated.DedicatedServer; -@@ -251,7 +253,7 @@ public abstract class PlayerList { +@@ -255,7 +257,7 @@ public abstract class PlayerList { } // CraftBukkit start chatmessage.withStyle(ChatFormatting.YELLOW); - String joinMessage = CraftChatMessage.fromComponent(chatmessage); + Component joinMessage = chatmessage; // Paper - Adventure - playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.yRot, player.xRot); + playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot()); this.players.add(player); -@@ -260,19 +262,18 @@ public abstract class PlayerList { +@@ -264,19 +266,18 @@ public abstract class PlayerList { // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below // CraftBukkit start -- PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(player), joinMessage); -+ PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(cserver.getPlayer(player), PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure - cserver.getPluginManager().callEvent(playerJoinEvent); +- PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(player), joinMessage); ++ PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(this.cserver.getPlayer(player), PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure + this.cserver.getPluginManager().callEvent(playerJoinEvent); if (!player.connection.connection.isConnected()) { return; @@ -1461,15 +1444,15 @@ index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b4 - if (joinMessage != null && joinMessage.length() > 0) { - for (Component line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { -- server.getPlayerList().broadcastAll(new ClientboundChatPacket(line, ChatType.SYSTEM, Util.NIL_UUID)); +- this.server.getPlayerList().broadcastAll(new ClientboundChatPacket(line, ChatType.SYSTEM, Util.NIL_UUID)); - } + if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure + joinMessage = PaperAdventure.asVanilla(jm); // Paper - Adventure -+ server.getPlayerList().broadcastAll(new ClientboundChatPacket(joinMessage, ChatType.SYSTEM, Util.NIL_UUID)); // Paper - Adventure ++ this.server.getPlayerList().broadcastAll(new ClientboundChatPacket(joinMessage, ChatType.SYSTEM, Util.NIL_UUID)); // Paper - Adventure } // CraftBukkit end -@@ -469,7 +470,7 @@ public abstract class PlayerList { +@@ -473,7 +474,7 @@ public abstract class PlayerList { } @@ -1478,17 +1461,17 @@ index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b4 ServerLevel worldserver = entityplayer.getLevel(); entityplayer.awardStat(Stats.LEAVE_GAME); -@@ -480,7 +481,7 @@ public abstract class PlayerList { +@@ -484,7 +485,7 @@ public abstract class PlayerList { entityplayer.closeContainer(); } -- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); -+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName()))); - cserver.getPluginManager().callEvent(playerQuitEvent); +- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getScoreboardName() + " left the game"); ++ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName()))); + this.cserver.getPluginManager().callEvent(playerQuitEvent); entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); -@@ -541,7 +542,7 @@ public abstract class PlayerList { - cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); +@@ -537,7 +538,7 @@ public abstract class PlayerList { + this.cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); // CraftBukkit end - return playerQuitEvent.getQuitMessage(); // CraftBukkit @@ -1496,7 +1479,7 @@ index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b4 } // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer -@@ -587,10 +588,10 @@ public abstract class PlayerList { +@@ -583,10 +584,10 @@ public abstract class PlayerList { } // return chatmessage; @@ -1506,31 +1489,31 @@ index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b4 chatmessage = new TranslatableComponent("multiplayer.disconnect.not_whitelisted"); - 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 - } else if (getIpBans().isBanned(socketaddress) && !getIpBans().get(socketaddress).hasExpired()) { + } else if (this.getIpBans().isBanned(socketaddress) && !this.getIpBans().get(socketaddress).hasExpired()) { IpBanListEntry ipbanentry = this.ipBans.get(socketaddress); -@@ -600,17 +601,17 @@ public abstract class PlayerList { +@@ -596,17 +597,17 @@ public abstract class PlayerList { } // return chatmessage; - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure } else { - // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; + // return this.players.size() >= this.maxPlayers && !this.d(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; 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, PaperAdventure.LEGACY_SECTION_UXRC.deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure } } - cserver.getPluginManager().callEvent(event); + this.cserver.getPluginManager().callEvent(event); if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { - loginlistener.disconnect(event.getKickMessage()); + loginlistener.disconnect(PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure return null; } return entity; -@@ -1131,7 +1132,7 @@ public abstract class PlayerList { +@@ -1109,7 +1110,7 @@ public abstract class PlayerList { public void removeAll() { // CraftBukkit start - disconnect safely for (ServerPlayer player : this.players) { @@ -1540,7 +1523,7 @@ index 88af57699d7f9e45ad1366243049e4f3565703ff..8cdecaf2f63c78196e0c5046fe2431b4 // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/BossEvent.java b/src/main/java/net/minecraft/world/BossEvent.java -index 8718449abc08ed7795ac70c2bef12d15b94d4127..adb7c8db8e173801a83e5ff1f4cad0dda2abeb82 100644 +index d289e8321a62f7c8d1e5b83f038e7331a26fc24e..658aff27155b32a0323f55152c7315fdc7b4a82d 100644 --- a/src/main/java/net/minecraft/world/BossEvent.java +++ b/src/main/java/net/minecraft/world/BossEvent.java @@ -1,5 +1,6 @@ @@ -1550,7 +1533,7 @@ index 8718449abc08ed7795ac70c2bef12d15b94d4127..adb7c8db8e173801a83e5ff1f4cad0dd import java.util.UUID; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -@@ -14,6 +15,7 @@ public abstract class BossEvent { +@@ -13,6 +14,7 @@ public abstract class BossEvent { protected boolean darkenScreen; protected boolean playBossMusic; protected boolean createWorldFog; @@ -1559,10 +1542,10 @@ index 8718449abc08ed7795ac70c2bef12d15b94d4127..adb7c8db8e173801a83e5ff1f4cad0dd public BossEvent(UUID uuid, Component name, BossEvent.BossBarColor color, BossEvent.BossBarOverlay style) { this.id = uuid; diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 2a6a6e291efbd7cc8fed6532f18321bd141e1306..3faf52e7ac5e7e22d09cfb73cfda6b9f622137d4 100644 +index d5b8931243e2f9cac9b0f92ab8df043a831bbe70..ac05b201167d8e17f39d3df732adf676dc24b409 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -865,6 +865,7 @@ public final class ItemStack { +@@ -1152,6 +1152,7 @@ public final class ItemStack { } // CraftBukkit end @@ -1571,56 +1554,55 @@ index 2a6a6e291efbd7cc8fed6532f18321bd141e1306..3faf52e7ac5e7e22d09cfb73cfda6b9f MutableComponent ichatmutablecomponent = (new TextComponent("")).append(this.getHoverName()); diff --git a/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java b/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java -index 72367311f79e3ef2868c05b38bae98c5a9fb129c..c23ec1b31950471905c65e46273ae105de853d9b 100644 +index 75d52cc90a015588ffbbae77b4c272f938a7c0a9..6d3df3d1bcaa016611320e7ba1f005e71bf0bfdf 100644 --- a/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java +++ b/src/main/java/net/minecraft/world/item/enchantment/Enchantment.java -@@ -94,6 +94,7 @@ public abstract class Enchantment { +@@ -95,6 +95,7 @@ public abstract class Enchantment { return this.getOrCreateDescriptionId(); } + public final Component getTranslationComponentForLevel(int level) { return this.getFullname(level); } // Paper - OBFHELPER public Component getFullname(int level) { - TranslatableComponent chatmessage = new TranslatableComponent(this.getDescriptionId()); - + MutableComponent mutableComponent = new TranslatableComponent(this.getDescriptionId()); + if (this.isCurse()) { diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 2cccec66fbc7114c65336769e354fe6f756c9fca..d44505b3ee2a35422568e9bce0d868191e348fc0 100644 +index 7a0e7961df1e62b311ea2ecc76d7343a8646723b..6859fafa42527d45366018f737c19e6c3777d152 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -32,6 +32,7 @@ import org.apache.logging.log4j.LogManager; +@@ -33,6 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; // CraftBukkit start +import io.papermc.paper.adventure.PaperAdventure; // Paper import java.util.UUID; - import org.bukkit.craftbukkit.CraftServer; -@@ -473,7 +474,7 @@ public class MapItemSavedData extends SavedData { - for ( org.bukkit.map.MapCursor cursor : render.cursors) { + import org.bukkit.Bukkit; +@@ -599,7 +600,7 @@ public class MapItemSavedData extends SavedData { - if (cursor.isVisible()) { -- icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); -+ icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), PaperAdventure.asVanilla(cursor.caption()))); // Paper - Adventure + for (org.bukkit.map.MapCursor cursor : render.cursors) { + if (cursor.isVisible()) { +- icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); ++ icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), PaperAdventure.asVanilla(cursor.caption()))); // Paper - Adventure + } } - } - + collection = icons; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f6755e61e 100644 +index c85f69cc6ef8a61ca1b07beb5f2b2159fbaa887d..ea8d5d95d9aa2d0036f82eca782cb5a633cbc388 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -561,8 +561,10 @@ public final class CraftServer implements Server { +@@ -564,8 +564,10 @@ public final class CraftServer implements Server { } @Override + @Deprecated // Paper start public int broadcastMessage(String message) { -- return broadcast(message, BROADCAST_CHANNEL_USERS); -+ return this.broadcast(message, BROADCAST_CHANNEL_USERS); + return this.broadcast(message, BROADCAST_CHANNEL_USERS); + // Paper end } public Player getPlayer(final ServerPlayer entity) { -@@ -1306,7 +1308,15 @@ public final class CraftServer implements Server { - return configuration.getInt("settings.spawn-radius", -1); +@@ -1309,7 +1311,15 @@ public final class CraftServer implements Server { + return this.configuration.getInt("settings.spawn-radius", -1); } + // Paper start @@ -1633,9 +1615,9 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f + @Override + @Deprecated // Paper public String getShutdownMessage() { - return configuration.getString("settings.shutdown-message"); + return this.configuration.getString("settings.shutdown-message"); } -@@ -1422,7 +1432,20 @@ public final class CraftServer implements Server { +@@ -1425,7 +1435,20 @@ public final class CraftServer implements Server { } @Override @@ -1654,15 +1636,15 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f + public int broadcast(net.kyori.adventure.text.Component message, String permission) { + // Paper end Set recipients = new HashSet<>(); - for (Permissible permissible : getPluginManager().getPermissionSubscriptions(permission)) { + for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) { if (permissible instanceof CommandSender && permissible.hasPermission(permission)) { -@@ -1430,14 +1453,14 @@ public final class CraftServer implements Server { +@@ -1433,14 +1456,14 @@ public final class CraftServer implements Server { } } - BroadcastMessageEvent broadcastMessageEvent = new BroadcastMessageEvent(!Bukkit.isPrimaryThread(), message, recipients); + BroadcastMessageEvent broadcastMessageEvent = new BroadcastMessageEvent(!Bukkit.isPrimaryThread(), message, recipients); // Paper - Adventure - getPluginManager().callEvent(broadcastMessageEvent); + this.getPluginManager().callEvent(broadcastMessageEvent); if (broadcastMessageEvent.isCancelled()) { return 0; @@ -1673,7 +1655,7 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f for (CommandSender recipient : recipients) { recipient.sendMessage(message); -@@ -1663,6 +1686,14 @@ public final class CraftServer implements Server { +@@ -1666,6 +1689,14 @@ public final class CraftServer implements Server { return CraftInventoryCreator.INSTANCE.createInventory(owner, type); } @@ -1688,7 +1670,7 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f @Override public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { Validate.isTrue(type.isCreatable(), "Cannot open an inventory of type ", type); -@@ -1675,13 +1706,28 @@ public final class CraftServer implements Server { +@@ -1678,13 +1709,28 @@ public final class CraftServer implements Server { return CraftInventoryCreator.INSTANCE.createInventory(owner, size); } @@ -1717,8 +1699,8 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f public Merchant createMerchant(String title) { return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title); } -@@ -1725,6 +1771,12 @@ public final class CraftServer implements Server { - return Thread.currentThread().equals(console.serverThread) || console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) +@@ -1728,6 +1774,12 @@ public final class CraftServer implements Server { + return Thread.currentThread().equals(console.serverThread) || this.console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) } + // Paper start @@ -1729,8 +1711,8 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f + // Paper end @Override public String getMotd() { - return console.getMotd(); -@@ -2153,5 +2205,15 @@ public final class CraftServer implements Server { + return this.console.getMotd(); +@@ -2156,5 +2208,15 @@ public final class CraftServer implements Server { return null; } } @@ -1747,7 +1729,7 @@ index c4cf1394fe4c2782b1fea8b3653a817157d857eb..f7f5457d20586e0ba72368e64ff6025f // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 05aedca561919a12ced1925c5cc9af585bb04523..ce9f10f890a5866ab6208c7253b15b09fe323a81 100644 +index 3c4281ad770598ecf3b9fae0d6ed6e9130136dbb..4df6b2a155a610953d8d5789bffa33d290d62aaa 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -19,6 +19,12 @@ public class Main { @@ -1764,7 +1746,7 @@ index 05aedca561919a12ced1925c5cc9af585bb04523..ce9f10f890a5866ab6208c7253b15b09 OptionParser parser = new OptionParser() { { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java -index 639577ab8b6467302a243c99ba5a4eede3aed655..940fef58f14e06213c7f305f67dcb8918976c03d 100644 +index 95b8d32adedf579172187c594e18177f3a84850e..5abf219e86c6b4cf0c6b2e8ea72d7ed7b4f612e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -70,6 +70,19 @@ public class CraftBeacon extends CraftBlockEntityState implem @@ -1836,7 +1818,7 @@ index add5b68d5fbd887e3fc2d226eff9ab00ed01ce73..2c3d6ba06d876df168aae4cc09b7b440 public String getCustomName() { 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 -index 7157facf2df5f3fe6377513cd353e96584788bd8..65e8a349c80a700f63dd27b11bb2099f65cbc069 100644 +index 2509a39bec5edd38b54709fec241c7c18e0d1c26..6e89b039479a034d98d1ec183b06d5418ab51733 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -12,8 +12,10 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; @@ -1852,25 +1834,26 @@ index 7157facf2df5f3fe6377513cd353e96584788bd8..65e8a349c80a700f63dd27b11bb2099f public CraftSign(final Block block) { super(block, SignBlockEntity.class); -@@ -23,27 +25,52 @@ public class CraftSign extends CraftBlockEntityState implements +@@ -23,27 +25,51 @@ public class CraftSign extends CraftBlockEntityState implements super(material, te); } + // Paper start @Override - public String[] getLines() { -- if (lines == null) { +- if (this.lines == null) { - // Lazy initialization: - SignBlockEntity sign = this.getSnapshot(); -- lines = new String[sign.messages.length]; -- System.arraycopy(revertComponents(sign.messages), 0, lines, 0, lines.length); -- originalLines = new String[lines.length]; +- this.lines = new String[sign.messages.length]; +- System.arraycopy(CraftSign.revertComponents(sign.messages), 0, lines, 0, lines.length); +- this.originalLines = new String[lines.length]; - System.arraycopy(lines, 0, originalLines, 0, originalLines.length); +- } + public java.util.List lines() { + this.loadLines(); -+ return this.lines; -+ } -+ + return this.lines; + } + + @Override + public net.kyori.adventure.text.Component line(int index) { + this.loadLines(); @@ -1886,9 +1869,7 @@ index 7157facf2df5f3fe6377513cd353e96584788bd8..65e8a349c80a700f63dd27b11bb2099f + private void loadLines() { + if (lines != null) { + return; - } -- return lines; -+ ++ } + // Lazy initialization: + SignBlockEntity sign = this.getSnapshot(); + lines = io.papermc.paper.adventure.PaperAdventure.asAdventure(com.google.common.collect.Lists.newArrayList(sign.messages)); @@ -1899,30 +1880,30 @@ index 7157facf2df5f3fe6377513cd353e96584788bd8..65e8a349c80a700f63dd27b11bb2099f + public String[] getLines() { + this.loadLines(); + return this.lines.stream().map(io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC::serialize).toArray(String[]::new); // Paper - } - ++ } ++ @Override public String getLine(int index) throws IndexOutOfBoundsException { -- return getLines()[index]; +- return this.getLines()[index]; + this.loadLines(); + return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(this.lines.get(index)); // Paper } @Override public void setLine(int index, String line) throws IndexOutOfBoundsException { -- getLines()[index] = line; +- this.getLines()[index] = line; + 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 } @Override -@@ -71,16 +98,32 @@ public class CraftSign extends CraftBlockEntityState implements +@@ -81,16 +107,32 @@ public class CraftSign extends CraftBlockEntityState implements super.applyTo(sign); - if (lines != null) { + if (this.lines != null) { - for (int i = 0; i < lines.length; i++) { -- String line = (lines[i] == null) ? "" : lines[i]; -- if (line.equals(originalLines[i])) { +- String line = (this.lines[i] == null) ? "" : this.lines[i]; +- if (line.equals(this.originalLines[i])) { + // Paper start + for (int i = 0; i < this.lines.size(); ++i) { + net.kyori.adventure.text.Component component = this.lines.get(i); @@ -1930,7 +1911,7 @@ index 7157facf2df5f3fe6377513cd353e96584788bd8..65e8a349c80a700f63dd27b11bb2099f + if (component.equals(origComp)) { continue; // The line contents are still the same, skip. } -- sign.messages[i] = CraftChatMessage.fromString(line)[0]; +- sign.setMessage(i, CraftChatMessage.fromString(line)[0]); + sign.messages[i] = io.papermc.paper.adventure.PaperAdventure.asVanilla(component); } + // Paper end @@ -1954,12 +1935,12 @@ index 7157facf2df5f3fe6377513cd353e96584788bd8..65e8a349c80a700f63dd27b11bb2099f Component[] components = new Component[4]; diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java -index 089fe4a3458ed3106fa214f89a7004a5d3c6bb95..af986adfdb547cb61fbd52f0f89858f1a9e52cc3 100644 +index 8bf9dd8f83c5e17447d8603fa5551e1fea06705d..a885eb537d6475eefe7d06f8312ecf0a278c5a00 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -80,4 +80,11 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co public boolean isConversing() { - return conversationTracker.isConversing(); + return this.conversationTracker.isConversing(); } + + // Paper start @@ -1970,12 +1951,12 @@ index 089fe4a3458ed3106fa214f89a7004a5d3c6bb95..af986adfdb547cb61fbd52f0f89858f1 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java -index fd473d213f4050f420bd7d729fe0df757d5398bc..b1ffe6c7a5915f00a476e88f3a38349b740b4910 100644 +index cf69a45f038c2b8336010f5fe277313fd0513b5b..a7966aa0846637efdc43df1ca97cbc5d29616953 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -187,6 +187,12 @@ public class CraftEnchantment extends Enchantment { CraftEnchantment ench = (CraftEnchantment) other; - return !target.isCompatibleWith(ench.target); + return !this.target.isCompatibleWith(ench.target); } + // Paper start + @Override @@ -1985,13 +1966,13 @@ index fd473d213f4050f420bd7d729fe0df757d5398bc..b1ffe6c7a5915f00a476e88f3a38349b + // Paper end public net.minecraft.world.item.enchantment.Enchantment getHandle() { - return target; + return this.target; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index eb61c803cf74c5ca2c51d5027a02ed3db6b53096..53c231925ef1b17e48c5863570e3c54124874621 100644 +index fdd3a7990cd63d44a154698449a472969ed9efdc..f4bcf48060bc704e0b6c690f78faaecfe90d8db3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -768,6 +768,19 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { - return getHandle().getVehicle().getBukkitEntity(); +@@ -806,6 +806,19 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { + return this.getHandle().getVehicle().getBukkitEntity(); } + // Paper start @@ -2011,7 +1992,7 @@ index eb61c803cf74c5ca2c51d5027a02ed3db6b53096..53c231925ef1b17e48c5863570e3c541 public void setCustomName(String name) { // sane limit for name length diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java -index 7c200e43bdc170ecf8b8fbfadd7bb38c66133443..b5c0f3d91cf451a972f0cf293db03a306073c493 100644 +index 450eea6e518de0493d4af4ad384d24217a3c7acf..d27a7ac64d1daf85319ab0069b9196f1958f6f46 100644 --- a/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 { @@ -2026,8 +2007,8 @@ index 7c200e43bdc170ecf8b8fbfadd7bb38c66133443..b5c0f3d91cf451a972f0cf293db03a30 - 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.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - getHandle().containerMenu = container; - getHandle().containerMenu.addSlotListener(player); + player.containerMenu = container; + player.initMenu(container); } @@ -388,8 +391,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -2042,24 +2023,24 @@ index 7c200e43bdc170ecf8b8fbfadd7bb38c66133443..b5c0f3d91cf451a972f0cf293db03a30 + //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.containerMenu = container; - player.containerMenu.addSlotListener(player); + player.initMenu(container); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05b891167b 100644 +index 457506210f041291be6bcdef7286d0860cb85946..f4dff38b0f9e33be3495433559935765f77d662e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -238,14 +238,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -243,14 +243,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public String getDisplayName() { + if(true) return io.papermc.paper.adventure.DisplayNames.getLegacy(this); // Paper - return getHandle().displayName; + return this.getHandle().displayName; } @Override 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 - getHandle().displayName = name == null ? getName() : name; + this.getHandle().displayName = name == null ? getName() : name; } + // Paper start @@ -2087,8 +2068,8 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + // Paper end @Override public String getPlayerListName() { - return getHandle().listName == null ? getName() : CraftChatMessage.fromComponent(getHandle().listName); -@@ -264,35 +289,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + return this.getHandle().listName == null ? getName() : CraftChatMessage.fromComponent(this.getHandle().listName); +@@ -269,42 +294,42 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } @@ -2099,28 +2080,28 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 @Override public String getPlayerListHeader() { -- return (playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader); -+ return (playerListHeader == null) ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(playerListHeader); // Paper - Adventure +- return (this.playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader); ++ return (this.playerListHeader == null) ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(playerListHeader); } @Override public String getPlayerListFooter() { -- return (playerListFooter == null) ? null : CraftChatMessage.fromComponent(playerListFooter); -+ return (playerListFooter == null) ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(playerListFooter); // Paper - Adventure +- 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 } @Override public void setPlayerListHeader(String header) { - this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); + this.playerListHeader = header == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(header); // Paper - Adventure - updatePlayerListHeaderFooter(); + this.updatePlayerListHeaderFooter(); } @Override public void setPlayerListFooter(String footer) { - this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); + this.playerListFooter = footer == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(footer); // Paper - Adventure - updatePlayerListHeaderFooter(); + this.updatePlayerListHeaderFooter(); } @Override @@ -2129,22 +2110,19 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 - this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); + this.playerListHeader = header == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(header); // Paper - Adventure + this.playerListFooter = footer == null ? null : io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(footer); // Paper - Adventure - updatePlayerListHeaderFooter(); + this.updatePlayerListHeaderFooter(); } -@@ -300,8 +325,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - if (getHandle().connection == null) return; + private void updatePlayerListHeaderFooter() { + if (this.getHandle().connection == null) return; - ClientboundTabListPacket packet = new ClientboundTabListPacket(); -- packet.header = (this.playerListHeader == null) ? new TextComponent("") : this.playerListHeader; -- packet.footer = (this.playerListFooter == null) ? new TextComponent("") : this.playerListFooter; -+ packet.header = (this.playerListHeader == null) ? new TextComponent("") : io.papermc.paper.adventure.PaperAdventure.asVanilla(this.playerListHeader); // Paper - Adventure -+ packet.footer = (this.playerListFooter == null) ? new TextComponent("") : io.papermc.paper.adventure.PaperAdventure.asVanilla(this.playerListFooter); // Paper - Adventure - getHandle().connection.send(packet); +- ClientboundTabListPacket packet = new ClientboundTabListPacket((this.playerListHeader == null) ? new TextComponent("") : this.playerListHeader, (this.playerListFooter == null) ? new TextComponent("") : this.playerListFooter); ++ ClientboundTabListPacket packet = new ClientboundTabListPacket((this.playerListHeader == null) ? new TextComponent("") : io.papermc.paper.adventure.PaperAdventure.asVanilla(this.playerListHeader), (this.playerListFooter == null) ? new TextComponent("") : io.papermc.paper.adventure.PaperAdventure.asVanilla(this.playerListFooter)); + this.getHandle().connection.send(packet); } -@@ -333,6 +358,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - getHandle().connection.disconnect(message == null ? "" : message); +@@ -336,6 +361,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.getHandle().connection.disconnect(message == null ? "" : message); } + // Paper start @@ -2160,9 +2138,9 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + @Override public void setCompassTarget(Location loc) { - if (getHandle().connection == null) return; -@@ -559,6 +595,37 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - getHandle().connection.send(packet); + if (this.getHandle().connection == null) return; +@@ -562,6 +598,36 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.getHandle().connection.send(packet); } + // Paper start @@ -2188,8 +2166,7 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + } + + private void sendSignChange0(Component[] components, Location loc, DyeColor dyeColor) { -+ SignBlockEntity sign = new SignBlockEntity(); -+ sign.setPosition(new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); ++ SignBlockEntity sign = new SignBlockEntity(new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.defaultBlockState()); + sign.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); + System.arraycopy(components, 0, sign.messages, 0, sign.messages.length); + @@ -2198,28 +2175,28 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + // Paper end @Override public void sendSignChange(Location loc, String[] lines) { - sendSignChange(loc, lines, DyeColor.BLACK); -@@ -581,12 +648,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.sendSignChange(loc, lines, DyeColor.BLACK); +@@ -584,13 +650,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } Component[] components = CraftSign.sanitizeLines(lines); -- SignBlockEntity sign = new SignBlockEntity(); -- sign.setPosition(new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); +- SignBlockEntity sign = new SignBlockEntity(new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.defaultBlockState()); - sign.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); -- System.arraycopy(components, 0, sign.messages, 0, sign.messages.length); -+ /*TileEntitySign sign = new TileEntitySign(); // Paper -+ sign.setPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); +- for (int i = 0; i < components.length; i++) { +- sign.setMessage(i, components[i]); +- } ++ /*SignBlockEntity sign = new SignBlockEntity(new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.defaultBlockState()); + sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData())); + System.arraycopy(components, 0, sign.lines, 0, sign.lines.length); -- getHandle().connection.send(sign.getUpdatePacket()); -+ getHandle().playerConnection.sendPacket(sign.getUpdatePacket());*/ // Paper +- this.getHandle().connection.send(sign.getUpdatePacket()); ++ this.getHandle().connection.send(sign.getUpdatePacket());*/ // Paper + this.sendSignChange0(components, loc, dyeColor); // Paper } @Override -@@ -1686,6 +1754,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return (getHandle().clientViewDistance == null) ? Bukkit.getViewDistance() : getHandle().clientViewDistance; +@@ -1690,6 +1755,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + return (this.getHandle().clientViewDistance == null) ? Bukkit.getViewDistance() : this.getHandle().clientViewDistance; } + // Paper start @@ -2230,8 +2207,8 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + // Paper end @Override public int getPing() { - return getHandle().latency; -@@ -1714,6 +1788,138 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + return this.getHandle().latency; +@@ -1718,6 +1789,138 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getInventory().setItemInMainHand(hand); } @@ -2256,8 +2233,8 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + + @Override + public void sendActionBar(final net.kyori.adventure.text.Component message) { -+ final ClientboundSetTitlesPacket packet = new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.ACTIONBAR, null); -+ packet.adventure$text = message; ++ final net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket packet = new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(message)); ++ // packet.adventure$text = message; // TODO: kashike add fields to packet + this.getHandle().connection.send(packet); + } + @@ -2283,9 +2260,9 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + private void adventure$sendPlayerListHeaderAndFooter() { + final ServerGamePacketListenerImpl connection = this.getHandle().connection; + if (connection == null) return; -+ final ClientboundTabListPacket packet = new ClientboundTabListPacket(); -+ packet.adventure$header = (this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader; -+ packet.adventure$footer = (this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter; ++ final ClientboundTabListPacket packet = new net.minecraft.network.protocol.game.ClientboundTabListPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla((this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader), io.papermc.paper.adventure.PaperAdventure.asVanilla((this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter)); ++ // packet.adventure$header = (this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader; // TODO: kashike add fields to packet ++ // packet.adventure$footer = (this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter; + connection.send(packet); + } + @@ -2294,13 +2271,13 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + final ServerGamePacketListenerImpl connection = this.getHandle().connection; + final net.kyori.adventure.title.Title.Times times = title.times(); + if (times != null) { -+ connection.send(new ClientboundSetTitlesPacket(ticks(times.fadeIn()), ticks(times.stay()), ticks(times.fadeOut()))); ++ connection.send(new ClientboundSetTitlesAnimationPacket(ticks(times.fadeIn()), ticks(times.stay()), ticks(times.fadeOut()))); + } -+ final ClientboundSetTitlesPacket sp = new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.SUBTITLE, null); -+ sp.adventure$text = title.subtitle(); ++ final ClientboundSetSubtitleTextPacket sp = new ClientboundSetSubtitleTextPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(title.subtitle())); ++ // sp.adventure$text = title.subtitle(); // TODO: kashike add fields to packet + connection.send(sp); -+ final ClientboundSetTitlesPacket tp = new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.TITLE, null); -+ tp.adventure$text = title.title(); ++ final ClientboundSetTitleTextPacket tp = new ClientboundSetTitleTextPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(title.title())); ++ // tp.adventure$text = title.title(); + connection.send(tp); + } + @@ -2313,7 +2290,7 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + + @Override + public void clearTitle() { -+ this.getHandle().connection.send(new ClientboundSetTitlesPacket(ClientboundSetTitlesPacket.Type.CLEAR, null)); ++ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundClearTitlesPacket(false)); + } + + // resetTitle implemented above @@ -2359,7 +2336,7 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 + final net.minecraft.world.item.ItemStack item = io.papermc.paper.adventure.PaperAdventure.asItemStack(book, locale); + final ServerPlayer player = this.getHandle(); + final ServerGamePacketListenerImpl connection = player.connection; -+ final net.minecraft.world.entity.player.Inventory inventory = player.inventory; ++ final net.minecraft.world.entity.player.Inventory inventory = player.getInventory(); + final int slot = inventory.items.size() + inventory.selected; + connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(0, slot, item)); + connection.send(new net.minecraft.network.protocol.game.ClientboundOpenBookPacket(net.minecraft.world.InteractionHand.MAIN_HAND)); @@ -2371,10 +2348,10 @@ index 61e2d92471d1498eb97d42dc642605a2e00e6089..50d11611702e3d1f0e980fb8f2280b05 private final Player.Spigot spigot = new Player.Spigot() { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index abd65693aca1964b65d091e633a36c97513c1d69..7fde1bb7587e567270e3f936381c6d361870211f 100644 +index cd54ba211070d34581068d6c1f3cceb858411415..fdb97878a6e73b729dbf09292d214e42c57d720a 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -776,9 +776,9 @@ public class CraftEventFactory { +@@ -770,9 +770,9 @@ public class CraftEventFactory { return event; } @@ -2386,7 +2363,7 @@ index abd65693aca1964b65d091e633a36c97513c1d69..7fde1bb7587e567270e3f936381c6d36 event.setKeepInventory(keepInventory); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); -@@ -802,7 +802,7 @@ public class CraftEventFactory { +@@ -796,7 +796,7 @@ public class CraftEventFactory { * Server methods */ public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, int numPlayers, int maxPlayers) { @@ -2396,36 +2373,10 @@ index abd65693aca1964b65d091e633a36c97513c1d69..7fde1bb7587e567270e3f936381c6d36 return event; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java -index a393bdae6ef588289c8814a1896146a993c92e71..680c7818a7097355158eb76662ecebbae6dd6637 100644 +index 25826a4f019a3084517f84cd3e5a7810c7958f0e..dfca1161da8009e508c5c5ef788422441145cfdf 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java -@@ -1,6 +1,5 @@ - package org.bukkit.craftbukkit.inventory; - --import net.minecraft.network.chat.TextComponent; - import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket; - import net.minecraft.world.Container; - import net.minecraft.world.entity.player.Player; -@@ -38,6 +37,7 @@ public class CraftContainer extends AbstractContainerMenu { - - private final InventoryView view; - private InventoryType cachedType; -+ private net.kyori.adventure.text.Component adventure$title; // Paper - private String cachedTitle; - private AbstractContainerMenu delegate; - private final int cachedSize; -@@ -49,7 +49,9 @@ public class CraftContainer extends AbstractContainerMenu { - Container top = ((CraftInventory) view.getTopInventory()).getInventory(); - net.minecraft.world.entity.player.Inventory bottom = (net.minecraft.world.entity.player.Inventory) ((CraftInventory) view.getBottomInventory()).getInventory(); - cachedType = view.getType(); -- cachedTitle = view.getTitle(); -+ this.adventure$title = view.title(); // Paper -+ if (this.adventure$title == null) this.adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(view.getTitle()); // Paper -+ //cachedTitle = view.getTitle(); // Paper - comment - cachedSize = getSize(); - setupSlots(top, bottom, player); - } -@@ -76,6 +78,13 @@ public class CraftContainer extends AbstractContainerMenu { +@@ -69,6 +69,13 @@ public class CraftContainer extends AbstractContainerMenu { return inventory.getType(); } @@ -2439,39 +2390,11 @@ index a393bdae6ef588289c8814a1896146a993c92e71..680c7818a7097355158eb76662ecebba @Override public String getTitle() { return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle(); -@@ -94,7 +103,8 @@ public class CraftContainer extends AbstractContainerMenu { - - @Override - public boolean isSynched(Player player) { -- if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) { -+ if (cachedType == view.getType() && cachedSize == getSize() && this.adventure$title.equals(view.title())) { // Paper -+ //if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) { // Paper - comment - return true; - } - // If the window type has changed for some reason, update the player -@@ -102,7 +112,9 @@ public class CraftContainer extends AbstractContainerMenu { - // as good a place as any to put something like this. - boolean typeChanged = (cachedType != view.getType()); - cachedType = view.getType(); -- cachedTitle = view.getTitle(); -+ this.adventure$title = view.title(); // Paper -+ if (this.adventure$title == null) this.adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(view.getTitle()); // Paper -+ //cachedTitle = view.getTitle(); // Paper - comment - if (view.getPlayer() instanceof CraftPlayer) { - CraftPlayer player1 = (CraftPlayer) view.getPlayer(); - MenuType type = getNotchInventoryType(view.getTopInventory()); -@@ -114,7 +126,8 @@ public class CraftContainer extends AbstractContainerMenu { - setupSlots(top, bottom, player1.getHandle()); - } - int size = getSize(); -- player1.getHandle().connection.send(new ClientboundOpenScreenPacket(this.containerId, type, new TextComponent(cachedTitle))); -+ player1.getHandle().connection.send(new ClientboundOpenScreenPacket(this.containerId, type, io.papermc.paper.adventure.PaperAdventure.asVanilla(this.adventure$title))); // Paper -+ //player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle))); // Paper - comment - player1.updateInventory(); - } - return true; +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.javaED5zI7 b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.javaED5zI7 +new file mode 100644 +index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java -index 397cd9651381a8a0ddb4ca173690e9b80428b182..46805a25c0273b76c19a3bbd40078d78c5379f43 100644 +index 6486a76466691f958349a4706d7c9caff9cb8f64..1a4e2534e8a2114125c505f46868ba4e3f2880a0 100644 --- a/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 { @@ -2520,7 +2443,7 @@ index 397cd9651381a8a0ddb4ca173690e9b80428b182..46805a25c0273b76c19a3bbd40078d78 this.type = type; @@ -57,11 +77,24 @@ public class CraftInventoryCustom extends CraftInventory { Validate.notNull(title, "Title cannot be null"); - this.items = NonNullList.a(size, ItemStack.EMPTY); + this.items = NonNullList.withSize(size, ItemStack.EMPTY); this.title = title; + this.adventure$title = io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(title); this.viewers = new ArrayList(); @@ -2542,7 +2465,7 @@ index 397cd9651381a8a0ddb4ca173690e9b80428b182..46805a25c0273b76c19a3bbd40078d78 + @Override public int getContainerSize() { - return items.size(); + return this.items.size(); @@ -183,6 +216,12 @@ public class CraftInventoryCustom extends CraftInventory { return null; } @@ -2554,14 +2477,14 @@ index 397cd9651381a8a0ddb4ca173690e9b80428b182..46805a25c0273b76c19a3bbd40078d78 + // Paper end + public String getTitle() { - return title; + return this.title; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java -index 326e8eb49e67ccfbf8f9b23bd6f03ea3576b9d35..945a80ca026c12e16a7ac5bebe56f846a437f847 100644 +index 6a64fbb8b4937f39d5fdc2e2cbec26c83c74c486..7d6b5fdb00a5c1614849735634262a36a4efbd66 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java @@ -64,6 +64,13 @@ public class CraftInventoryView extends InventoryView { - return CraftItemStack.asCraftMirror(container.getSlot(slot).getItem()); + return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem()); } + // Paper start @@ -2573,12 +2496,12 @@ index 326e8eb49e67ccfbf8f9b23bd6f03ea3576b9d35..945a80ca026c12e16a7ac5bebe56f846 + @Override public String getTitle() { - return CraftChatMessage.fromComponent(container.getTitle()); + return CraftChatMessage.fromComponent(this.container.getTitle()); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index 89a3617068421bb86baf4e8bfd9df2d0626adff7..32fa5ca0df07466e40817341d85d359b282f3078 100644 +index 27bbec5f779e7193818e546dbf02a761ff950719..921d838afc5b7ae47a9ee81b7ae4450543a32d98 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -334,4 +334,17 @@ public final class CraftItemFactory implements ItemFactory { +@@ -337,4 +337,17 @@ public final class CraftItemFactory implements ItemFactory { public Material updateMaterial(ItemMeta meta, Material material) throws IllegalArgumentException { return ((CraftMetaItem) meta).updateMaterial(material); } @@ -2597,7 +2520,7 @@ index 89a3617068421bb86baf4e8bfd9df2d0626adff7..32fa5ca0df07466e40817341d85d359b + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java -index 71136bb009d6c8c92595f957ee7680a771ea9a63..306c6483708ae1b41bd16f122d36beec1916a776 100644 +index b7cb3c94d88b2753fd1fc17c2842607576fd7874..f40d6a0048ad5b3f6e31d83894ee89f5ca64fb3a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -14,10 +14,17 @@ import org.apache.commons.lang.Validate; @@ -2607,7 +2530,7 @@ index 71136bb009d6c8c92595f957ee7680a771ea9a63..306c6483708ae1b41bd16f122d36beec + @Deprecated // Paper - Adventure public CraftMerchantCustom(String title) { super(new MinecraftMerchant(title)); - getMerchant().craftMerchant = this; + this.getMerchant().craftMerchant = this; } + // Paper start + public CraftMerchantCustom(net.kyori.adventure.text.Component title) { @@ -2637,7 +2560,7 @@ index 71136bb009d6c8c92595f957ee7680a771ea9a63..306c6483708ae1b41bd16f122d36beec @Override 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 -index 6dba12c4f58a462c8d466461eb8b804dd045766d..a592d4a286a775a61192dde2a4d21a0681090415 100644 +index ca359cb1ac5f48d4f75d33946fcddedb270407c2..f8796e5b450cfcd5091d7bd50e873f45bcdbf484 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -1,8 +1,9 @@ @@ -2805,7 +2728,7 @@ index 6dba12c4f58a462c8d466461eb8b804dd045766d..a592d4a286a775a61192dde2a4d21a06 + // Paper end @Override public String getPage(final int page) { - Validate.isTrue(isValidPage(page), "Invalid page number"); + Validate.isTrue(this.isValidPage(page), "Invalid page number"); @@ -413,7 +552,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { } @@ -2814,7 +2737,7 @@ index 6dba12c4f58a462c8d466461eb8b804dd045766d..a592d4a286a775a61192dde2a4d21a06 + ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { super.serialize(builder); - if (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 index 00445fc7373c70f4cecc4114f9bcfb4b6f27c0e8..0cf60eb9b6ba1a79c9b603c4349debd478101f9a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java @@ -2837,11 +2760,11 @@ index 00445fc7373c70f4cecc4114f9bcfb4b6f27c0e8..0cf60eb9b6ba1a79c9b603c4349debd4 return builder; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 2e819849e83967d751f7b0612a7cf4edb5a7264b..cca04daf84e506382365c0ba945cb024bd4d4475 100644 +index 2d775fe575e61a6503aee1bc9623aebce75143cc..970fa1e98c873ea4dfd4b58c56b7ea88283b0512 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -744,6 +744,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers()); +@@ -745,6 +745,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + return !(this.hasDisplayName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isUnbreakable() || this.hasDamage() || this.hasAttributeModifiers()); } + // Paper start @@ -2859,7 +2782,7 @@ index 2e819849e83967d751f7b0612a7cf4edb5a7264b..cca04daf84e506382365c0ba945cb024 @Override public String getDisplayName() { return CraftChatMessage.fromJSONComponent(displayName); -@@ -779,6 +791,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { +@@ -780,6 +792,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { return this.lore != null && !this.lore.isEmpty(); } @@ -2877,7 +2800,7 @@ index 2e819849e83967d751f7b0612a7cf4edb5a7264b..cca04daf84e506382365c0ba945cb024 + @Override public boolean hasRepairCost() { - return repairCost > 0; + return this.repairCost > 0; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftCustomInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftCustomInventoryConverter.java index ed4415f6dd588c08c922efd5beebb3b124beb9d6..78a7ac47f20e84ccd67ff44d0bc7a2f2faa0d476 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftCustomInventoryConverter.java @@ -2910,11 +2833,11 @@ index ed4415f6dd588c08c922efd5beebb3b124beb9d6..78a7ac47f20e84ccd67ff44d0bc7a2f2 return new CraftInventoryCustom(owner, size, title); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java -index b51321c8dd70a90ab149f456c7ffb4587c4fbd34..94d807c5d09f165c6eedd0a1c4026c2b833806a0 100644 +index 4e705b7367b78c2da98d0b174807ecbce75f3a59..0899afd175f969da0df9371d96d3b5e1de4c8533 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java @@ -43,6 +43,17 @@ public final class CraftInventoryCreator { - return converterMap.get(type).createInventory(holder, type); + return this.converterMap.get(type).createInventory(holder, type); } + // Paper start @@ -2929,10 +2852,10 @@ index b51321c8dd70a90ab149f456c7ffb4587c4fbd34..94d807c5d09f165c6eedd0a1c4026c2b + // Paper end + public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { - return converterMap.get(type).createInventory(holder, type, title); + return this.converterMap.get(type).createInventory(holder, type, title); } @@ -51,6 +62,12 @@ public final class CraftInventoryCreator { - return DEFAULT_CONVERTER.createInventory(holder, size); + return this.DEFAULT_CONVERTER.createInventory(holder, size); } + // Paper start @@ -2942,7 +2865,7 @@ index b51321c8dd70a90ab149f456c7ffb4587c4fbd34..94d807c5d09f165c6eedd0a1c4026c2b + // Paper end + public Inventory createInventory(InventoryHolder holder, int size, String title) { - return DEFAULT_CONVERTER.createInventory(holder, size, title); + return this.DEFAULT_CONVERTER.createInventory(holder, size, title); } @@ -59,6 +76,10 @@ public final class CraftInventoryCreator { @@ -2956,11 +2879,11 @@ index b51321c8dd70a90ab149f456c7ffb4587c4fbd34..94d807c5d09f165c6eedd0a1c4026c2b } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java -index 0395a6235d62126540e370d6ef77e6966c50ca1d..3ef9742a68084d159ea8ed5709298f9863e04a67 100644 +index 1980240d3dc0331ddf2ff56e163e2bfbd3b231ab..7a7f3f53aef601f124d474d9890e23d87dd96900 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java @@ -31,6 +31,18 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat - return getInventory(getTileEntity()); + return this.getInventory(this.getTileEntity()); } + // Paper start @@ -2977,8 +2900,8 @@ index 0395a6235d62126540e370d6ef77e6966c50ca1d..3ef9742a68084d159ea8ed5709298f98 + @Override public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { - Container te = getTileEntity(); -@@ -54,6 +66,15 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat + Container te = this.getTileEntity(); +@@ -53,6 +65,15 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat return furnace; } @@ -2993,9 +2916,9 @@ index 0395a6235d62126540e370d6ef77e6966c50ca1d..3ef9742a68084d159ea8ed5709298f98 + @Override public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { - Container tileEntity = getTileEntity(); -@@ -74,6 +95,18 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat - return new BrewingStandBlockEntity(); + Container tileEntity = this.getTileEntity(); +@@ -73,6 +94,18 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat + return new BrewingStandBlockEntity(BlockPos.ZERO, Blocks.BREWING_STAND.defaultBlockState()); } + // Paper start @@ -3014,11 +2937,11 @@ index 0395a6235d62126540e370d6ef77e6966c50ca1d..3ef9742a68084d159ea8ed5709298f98 public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { // BrewingStand does not extend TileEntityLootable diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java -index d5ebb11447a8effa41138a13874fd3e5246dfe71..96ba508c87336d012c1ed5aa982588f55782a2fe 100644 +index c80424fa0494272900ee141eefbf2522ee66d657..2477bb1f2b37406e2c73f18956201762a61ca324 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java @@ -30,6 +30,21 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective - return objective.getName(); + return this.objective.getName(); } + // Paper start @@ -3038,14 +2961,14 @@ index d5ebb11447a8effa41138a13874fd3e5246dfe71..96ba508c87336d012c1ed5aa982588f5 + // Paper end @Override public String getDisplayName() throws IllegalStateException { - CraftScoreboard scoreboard = checkState(); + CraftScoreboard scoreboard = this.checkState(); diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java -index af160d3bdb82f07c6c836a438b8ab37b803c29e2..4c93be31fd95d731327479519ecb34a08785c1ca 100644 +index 589cb3bebb4bb193477cc5064c66830eec3e9138..68aa66c340b7a686a353e2a15084d811a3955a0a 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java @@ -27,6 +27,27 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { public CraftObjective registerNewObjective(String name, String criteria) throws IllegalArgumentException { - return registerNewObjective(name, criteria, name); + return this.registerNewObjective(name, criteria, name); } + // Paper start + @Override @@ -3064,7 +2987,7 @@ index af160d3bdb82f07c6c836a438b8ab37b803c29e2..4c93be31fd95d731327479519ecb34a0 + Validate.isTrue(name.length() <= 16, "The name '" + name + "' is longer than the limit of 16 characters"); + Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists"); + CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); -+ net.minecraft.world.scores.Objective objective = board.registerObjective(name, craftCriteria.criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); ++ net.minecraft.world.scores.Objective objective = board.addObjective(name, craftCriteria.criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); + return new CraftObjective(this, objective); + } + // Paper end @@ -3080,12 +3003,13 @@ index af160d3bdb82f07c6c836a438b8ab37b803c29e2..4c93be31fd95d731327479519ecb34a0 Validate.notNull(criteria, "Criteria cannot be null"); Validate.notNull(displayName, "Display name cannot be null"); Validate.notNull(renderType, "RenderType cannot be null"); -@@ -44,8 +65,9 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { - Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists"); +@@ -45,7 +66,11 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); -- net.minecraft.world.scores.Objective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); + net.minecraft.world.scores.Objective objective = this.board.addObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); - return new CraftObjective(this, objective); ++ ++ CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); + ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); + return new CraftObjective(this, objective);*/ // Paper + return registerNewObjective(name, criteria, io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.deserialize(displayName), renderType); // Paper @@ -3093,12 +3017,12 @@ index af160d3bdb82f07c6c836a438b8ab37b803c29e2..4c93be31fd95d731327479519ecb34a0 @Override diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java -index f5237ff19d8b26be0b762659ad0ea6887205b3f9..7ebcba4ada42f5599d56cfdeb75dbf62f2a09b78 100644 +index 81f16dc1ed6e102af298600db75cab21a09bc00f..c2dc4d65170eba2d914cf2efdcc231254fec7c02 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -28,6 +28,55 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { - return team.getName(); + return this.team.getName(); } + // Paper start + @Override @@ -3153,7 +3077,7 @@ index f5237ff19d8b26be0b762659ad0ea6887205b3f9..7ebcba4ada42f5599d56cfdeb75dbf62 @Override public String getDisplayName() throws IllegalStateException { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -index 35e6ce5f33b3d6b86c3654e6a207e26aa44badb5..b27af66795d902a2e95d692fa0ff18eccbef8a75 100644 +index f9b7b8f7ccc95b73967a51420fd6ce88d80d75fe..0de5a46423ae0403dcbfca630dfd7c5ac1e1761d 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -290,6 +290,7 @@ public final class CraftChatMessage { @@ -3165,7 +3089,7 @@ index 35e6ce5f33b3d6b86c3654e6a207e26aa44badb5..b27af66795d902a2e95d692fa0ff18ec boolean hadFormat = false; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index ef7715774fbdc4c42b217d8192784e09a43fe66f..2d4faef5a2b9c4fe8b65ff4f1346b8375e0e02c8 100644 +index 0f0ffedd2cc3cf1b30b338d8ae3a8ad388dfde53..409515c406f5b5cfac9872f925dbc67159a5d41f 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -57,6 +57,33 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -3200,26 +3124,26 @@ index ef7715774fbdc4c42b217d8192784e09a43fe66f..2d4faef5a2b9c4fe8b65ff4f1346b837 + // Paper end + public static BlockState getBlock(MaterialData material) { - return getBlock(material.getItemType(), material.getData()); + return CraftMagicNumbers.getBlock(material.getItemType(), material.getData()); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java -index f194cf2663919ea18309a0501ddfab5e2ed639dd..4b110d6c6f22ff7c2fa0fd4b459820797066199d 100644 +index 62c66e3179b9557cdba46242df0fb15bce7e7710..73a37638abacdffbff8274291a64ea6cd0be7a5e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java +++ b/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java @@ -80,7 +80,7 @@ public abstract class LazyHashSet implements Set { - return this.reference = makeReference(); + return this.reference = this.makeReference(); } - abstract Set makeReference(); + protected abstract Set makeReference(); // Paper - protected public boolean isLazy() { - return reference == null; + return this.reference == null; diff --git a/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java b/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java -index 103c1407b2946e9cae2271646178e5f243c8abb1..b22b7603f3f66e1b64f413106e7989b30475110b 100644 +index 838d5b877c01be3ef353f434d98e27b46c0a3fb4..5c4c0ba05f10d2d83b22d3e86805cfa85c3b50a9 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java +++ b/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java -@@ -15,10 +15,15 @@ public class LazyPlayerSet extends LazyHashSet { +@@ -15,11 +15,17 @@ public class LazyPlayerSet extends LazyHashSet { } @Override @@ -3228,11 +3152,13 @@ index 103c1407b2946e9cae2271646178e5f243c8abb1..b22b7603f3f66e1b64f413106e7989b3 if (reference != null) { throw new IllegalStateException("Reference already created!"); } + List players = this.server.getPlayerList().players; + // Paper start + return makePlayerSet(this.server); + } + public static HashSet makePlayerSet(final MinecraftServer server) { + // Paper end - List players = server.getPlayerList().players; ++ List players = server.getPlayerList().players; HashSet reference = new HashSet(players.size()); for (ServerPlayer player : players) { + reference.add(player.getBukkitEntity());