diff options
author | Shane Freeder <[email protected]> | 2024-07-05 22:52:54 +0100 |
---|---|---|
committer | Shane Freeder <[email protected]> | 2024-07-05 22:52:54 +0100 |
commit | faf23b2076eaf78dfe625a91487e6af0b2e85eb7 (patch) | |
tree | e548d6e32511909be7aa7b47f6565a4448f383f6 /patches/server/0010-Adventure.patch | |
parent | e21ab955f5759cd3eb804e5474d11da858a0795e (diff) | |
parent | 8d91b859cbeb64ecbc3916249fce26a085b320aa (diff) | |
download | Paper-faf23b2076eaf78dfe625a91487e6af0b2e85eb7.tar.gz Paper-faf23b2076eaf78dfe625a91487e6af0b2e85eb7.zip |
Merge remote-tracking branch 'origin/master' into chore/terminal
Diffstat (limited to 'patches/server/0010-Adventure.patch')
-rw-r--r-- | patches/server/0010-Adventure.patch | 412 |
1 files changed, 224 insertions, 188 deletions
diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index a8f126f3a8..9d84d97b3c 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -651,7 +651,7 @@ index 0000000000000000000000000000000000000000..23bd6d2d8fed5a3491e856f8b875456d +} diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java new file mode 100644 -index 0000000000000000000000000000000000000000..69347ac0547cba3842040f89615e721b5d1ac3ca +index 0000000000000000000000000000000000000000..b9a64a40dbb025e34a3de81df1208de45df3cfcc --- /dev/null +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java @@ -0,0 +1,376 @@ @@ -705,7 +705,7 @@ index 0000000000000000000000000000000000000000..69347ac0547cba3842040f89615e721b + +@DefaultQualifier(NonNull.class) +public final class ChatProcessor { -+ static final ResourceKey<ChatType> PAPER_RAW = ResourceKey.create(Registries.CHAT_TYPE, new ResourceLocation(ResourceLocation.PAPER_NAMESPACE, "raw")); ++ static final ResourceKey<ChatType> PAPER_RAW = ResourceKey.create(Registries.CHAT_TYPE, ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "raw")); + static final String DEFAULT_LEGACY_FORMAT = "<%1$s> %2$s"; // copied from PlayerChatEvent/AsyncPlayerChatEvent + final MinecraftServer server; + final ServerPlayer player; @@ -1157,15 +1157,16 @@ index 0000000000000000000000000000000000000000..2fd6c3e65354071af71c7d8ebb97b559 +} diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java new file mode 100644 -index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4dcfc21908 +index 0000000000000000000000000000000000000000..dc4837c577676115f0653acc35f55962a432e425 --- /dev/null +++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java -@@ -0,0 +1,478 @@ +@@ -0,0 +1,479 @@ +package io.papermc.paper.adventure; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.serialization.JavaOps; ++import com.mojang.serialization.JsonOps; +import io.netty.util.AttributeKey; +import java.io.IOException; +import java.util.ArrayList; @@ -1302,7 +1303,7 @@ index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4d + return decoded.toString(); + } + }; -+ public static final ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> WRAPPER_AWARE_SERIALIZER = new WrapperAwareSerializer(); ++ public static final ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> WRAPPER_AWARE_SERIALIZER = new WrapperAwareSerializer(() -> CraftRegistry.getMinecraftRegistry().createSerializationContext(JavaOps.INSTANCE)); + + private PaperAdventure() { + } @@ -1310,7 +1311,7 @@ index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4d + // Key + + public static ResourceLocation asVanilla(final Key key) { -+ return new ResourceLocation(key.namespace(), key.value()); ++ return ResourceLocation.fromNamespaceAndPath(key.namespace(), key.value()); + } + + public static ResourceLocation asVanillaNullable(final Key key) { @@ -1594,7 +1595,7 @@ index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4d + + @Override + public @NotNull BinaryTagHolder asBinaryTag() { -+ return BinaryTagHolder.encode(this.codec.encodeStart(NbtOps.INSTANCE, this.value).getOrThrow(IllegalArgumentException::new), NBT_CODEC); ++ return BinaryTagHolder.encode(this.codec.encodeStart(CraftRegistry.getMinecraftRegistry().createSerializationContext(NbtOps.INSTANCE), this.value).getOrThrow(IllegalArgumentException::new), NBT_CODEC); + } + } + @@ -1622,7 +1623,7 @@ index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4d + // Style + + public static net.minecraft.network.chat.Style asVanilla(final Style style) { -+ final RegistryOps<Object> ops = RegistryOps.create(JavaOps.INSTANCE, CraftRegistry.getMinecraftRegistry()); ++ final RegistryOps<Object> ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JavaOps.INSTANCE); + final Object encoded = AdventureCodecs.STYLE_MAP_CODEC.codec() + .encodeStart(ops, style).getOrThrow(IllegalStateException::new); + @@ -1631,7 +1632,7 @@ index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4d + } + + public static Style asAdventure(final net.minecraft.network.chat.Style style) { -+ final RegistryOps<Object> ops = RegistryOps.create(JavaOps.INSTANCE, CraftRegistry.getMinecraftRegistry()); ++ final RegistryOps<Object> ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JavaOps.INSTANCE); + final Object encoded = net.minecraft.network.chat.Style.Serializer.CODEC + .encodeStart(ops, style).getOrThrow(IllegalStateException::new); + @@ -1641,27 +1642,36 @@ index 0000000000000000000000000000000000000000..fc6e13e4f2408ccbfa645eae2d7ebf4d +} diff --git a/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java new file mode 100644 -index 0000000000000000000000000000000000000000..e58e8ac574eb60205b17e31589f5a7610c60a4e2 +index 0000000000000000000000000000000000000000..a16344476abbb4f3e8aac26d4add9da53b7fc7df --- /dev/null +++ b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java -@@ -0,0 +1,34 @@ +@@ -0,0 +1,43 @@ +package io.papermc.paper.adventure; + ++import com.google.common.base.Suppliers; +import com.mojang.datafixers.util.Pair; +import com.mojang.serialization.JavaOps; ++import java.util.function.Supplier; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.ComponentSerializer; +import net.minecraft.network.chat.ComponentSerialization; +import net.minecraft.resources.RegistryOps; +import org.bukkit.craftbukkit.CraftRegistry; + -+final class WrapperAwareSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> { ++public final class WrapperAwareSerializer implements ComponentSerializer<Component, Component, net.minecraft.network.chat.Component> { ++ ++ private final Supplier<RegistryOps<Object>> javaOps; ++ ++ public WrapperAwareSerializer(final Supplier<RegistryOps<Object>> javaOps) { ++ this.javaOps = Suppliers.memoize(javaOps::get); ++ } ++ + @Override + public Component deserialize(final net.minecraft.network.chat.Component input) { + if (input instanceof AdventureComponent) { + return ((AdventureComponent) input).adventure; + } -+ final RegistryOps<Object> ops = RegistryOps.create(JavaOps.INSTANCE, CraftRegistry.getMinecraftRegistry()); ++ final RegistryOps<Object> ops = this.javaOps.get(); + final Object obj = ComponentSerialization.CODEC.encodeStart(ops, input) + .getOrThrow(s -> new RuntimeException("Failed to encode Minecraft Component: " + input + "; " + s)); + final Pair<Component, Object> converted = AdventureCodecs.COMPONENT_CODEC.decode(ops, obj) @@ -1671,7 +1681,7 @@ index 0000000000000000000000000000000000000000..e58e8ac574eb60205b17e31589f5a761 + + @Override + public net.minecraft.network.chat.Component serialize(final Component component) { -+ final RegistryOps<Object> ops = RegistryOps.create(JavaOps.INSTANCE, CraftRegistry.getMinecraftRegistry()); ++ final RegistryOps<Object> ops = this.javaOps.get(); + final Object obj = AdventureCodecs.COMPONENT_CODEC.encodeStart(ops, component) + .getOrThrow(s -> new RuntimeException("Failed to encode adventure Component: " + component + "; " + s)); + final Pair<net.minecraft.network.chat.Component, Object> converted = ComponentSerialization.CODEC.decode(ops, obj) @@ -1829,14 +1839,15 @@ index 0000000000000000000000000000000000000000..8323f135d6bf2e1f12525e05094ffa3f +} diff --git a/src/main/java/io/papermc/paper/adventure/providers/DataComponentValueConverterProviderImpl.java b/src/main/java/io/papermc/paper/adventure/providers/DataComponentValueConverterProviderImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..ef19891a895e699cac638bd9b9f2fa0eaf1371ba +index 0000000000000000000000000000000000000000..6b37c0ebda4a0cfcf9c3b2c3483ffababe622555 --- /dev/null +++ b/src/main/java/io/papermc/paper/adventure/providers/DataComponentValueConverterProviderImpl.java -@@ -0,0 +1,75 @@ +@@ -0,0 +1,82 @@ +package io.papermc.paper.adventure.providers; + +import com.google.gson.JsonElement; +import com.mojang.brigadier.exceptions.CommandSyntaxException; ++import com.mojang.serialization.DynamicOps; +import com.mojang.serialization.JsonOps; +import io.papermc.paper.adventure.PaperAdventure; +import java.util.List; @@ -1849,6 +1860,8 @@ index 0000000000000000000000000000000000000000..ef19891a895e699cac638bd9b9f2fa0e +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.Tag; ++import net.minecraft.resources.RegistryOps; ++import org.bukkit.craftbukkit.CraftRegistry; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; @@ -1865,6 +1878,10 @@ index 0000000000000000000000000000000000000000..ef19891a895e699cac638bd9b9f2fa0e + return ID; + } + ++ private static <T> RegistryOps<T> createOps(final DynamicOps<T> delegate) { ++ return CraftRegistry.getMinecraftRegistry().createSerializationContext(delegate); ++ } ++ + @SuppressWarnings({"unchecked", "rawtypes"}) + @Override + public Iterable<DataComponentValueConverterRegistry.Conversion<?, ?>> conversions() { @@ -1872,7 +1889,7 @@ index 0000000000000000000000000000000000000000..ef19891a895e699cac638bd9b9f2fa0e + DataComponentValueConverterRegistry.Conversion.convert( + PaperAdventure.DataComponentValueImpl.class, + GsonDataComponentValue.class, -+ (key, dataComponentValue) -> gsonDataComponentValue((JsonElement) dataComponentValue.codec().encodeStart(JsonOps.INSTANCE, dataComponentValue.value()).getOrThrow()) ++ (key, dataComponentValue) -> gsonDataComponentValue((JsonElement) dataComponentValue.codec().encodeStart(createOps(JsonOps.INSTANCE), dataComponentValue.value()).getOrThrow()) + ), + DataComponentValueConverterRegistry.Conversion.convert( + GsonDataComponentValue.class, @@ -1882,13 +1899,13 @@ index 0000000000000000000000000000000000000000..ef19891a895e699cac638bd9b9f2fa0e + if (type == null) { + throw new IllegalArgumentException("Unknown data component type: " + key); + } -+ return new PaperAdventure.DataComponentValueImpl(type.codecOrThrow(), type.codecOrThrow().parse(JsonOps.INSTANCE, dataComponentValue.element()).getOrThrow(IllegalArgumentException::new)); ++ return new PaperAdventure.DataComponentValueImpl(type.codecOrThrow(), type.codecOrThrow().parse(createOps(JsonOps.INSTANCE), dataComponentValue.element()).getOrThrow(IllegalArgumentException::new)); + } + ), + DataComponentValueConverterRegistry.Conversion.convert( + PaperAdventure.DataComponentValueImpl.class, + DataComponentValue.TagSerializable.class, -+ (key, dataComponentValue) -> BinaryTagHolder.encode((Tag) dataComponentValue.codec().encodeStart(NbtOps.INSTANCE, dataComponentValue.value()).getOrThrow(), PaperAdventure.NBT_CODEC) ++ (key, dataComponentValue) -> BinaryTagHolder.encode((Tag) dataComponentValue.codec().encodeStart(createOps(NbtOps.INSTANCE), dataComponentValue.value()).getOrThrow(), PaperAdventure.NBT_CODEC) + ), + DataComponentValueConverterRegistry.Conversion.convert( + DataComponentValue.TagSerializable.class, @@ -1899,7 +1916,7 @@ index 0000000000000000000000000000000000000000..ef19891a895e699cac638bd9b9f2fa0e + throw new IllegalArgumentException("Unknown data component type: " + key); + } + try { -+ return new PaperAdventure.DataComponentValueImpl(type.codecOrThrow(), type.codecOrThrow().parse(NbtOps.INSTANCE, tagSerializable.asBinaryTag().get(PaperAdventure.NBT_CODEC)).getOrThrow(IllegalArgumentException::new)); ++ return new PaperAdventure.DataComponentValueImpl(type.codecOrThrow(), type.codecOrThrow().parse(createOps(NbtOps.INSTANCE), tagSerializable.asBinaryTag().get(PaperAdventure.NBT_CODEC)).getOrThrow(IllegalArgumentException::new)); + } catch (final CommandSyntaxException e) { + throw new IllegalArgumentException(e); + } @@ -2139,10 +2156,10 @@ index 0000000000000000000000000000000000000000..c0701d4f93a4d77a8177d2dd8d5076f9 + } +} diff --git a/src/main/java/net/minecraft/ChatFormatting.java b/src/main/java/net/minecraft/ChatFormatting.java -index f5ec57f68dff18c8b2622b58df5df2fd83761b7e..5c01964acd4182467c4de437d6a3b79b268b50dd 100644 +index 08dcd817bfe1ba0121d4ce701825e4aee384db85..d5f63d06d921d731b4e64b38228377712fe9c75b 100644 --- a/src/main/java/net/minecraft/ChatFormatting.java +++ b/src/main/java/net/minecraft/ChatFormatting.java -@@ -110,6 +110,18 @@ public enum ChatFormatting implements StringRepresentable { +@@ -112,6 +112,18 @@ public enum ChatFormatting implements StringRepresentable { return name == null ? null : FORMATTING_BY_NAME.get(cleanName(name)); } @@ -2205,20 +2222,20 @@ index 0047fd758ad43cc7b13355b60c410a9bcc37bec0..982b2bab27e3d55d0ba07060862c0c31 private static CompletableFuture<FilteredText> filterPlainText(CommandSourceStack source, PlayerChatMessage message) { diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -index d120fff432d9c4fc7a35ddffdc4186459e45e950..676a1499747b071515479130875157263d3a8352 100644 +index dd66979bcae33096d72001678e8e55569bea6f53..c8d39e6e1c570c9219f6066da273dc0130920519 100644 --- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -92,7 +92,7 @@ public class EntitySelector { +@@ -93,7 +93,7 @@ public class EntitySelector { } private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException { - if (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit -+ if (source.bypassSelectorPermissions || (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms ++ if (!source.bypassSelectorPermissions && (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create(); } } diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index a7419bcb0954f0adbf7ce2d1e9738e690c265f4d..aafeb9c61ddba6a8671f0238eda47b227619f1af 100644 +index 6d7545a925156aef6badcfa2bc40dbdad18c4ac0..0cd6a50837efce87ca052a0e1e24db2b75761196 100644 --- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java +++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java @@ -72,6 +72,7 @@ public class FriendlyByteBuf extends ByteBuf { @@ -2427,7 +2444,7 @@ index 739ef5fb6f4fa37382153ba6a308ca3b451e6b05..7c3154af5d7732037c0ee965f6f8b894 public static final int BYTES = 256; diff --git a/src/main/java/net/minecraft/network/chat/MutableComponent.java b/src/main/java/net/minecraft/network/chat/MutableComponent.java -index 1ce6b84e0d0bb708ced06955cd62281369b5fd4f..82e2a02336da4ee8cfd84bc82b143f8b9dbcf449 100644 +index 0a70fb7df0d4532edbc2468b13520c34ae1500e9..e34a8a66411b7571813117ce47d9dec08e567978 100644 --- a/src/main/java/net/minecraft/network/chat/MutableComponent.java +++ b/src/main/java/net/minecraft/network/chat/MutableComponent.java @@ -94,6 +94,11 @@ public class MutableComponent implements Component { @@ -2589,18 +2606,18 @@ index bb97fdb9aa6167083442a928276ebe4225a586ef..5d1758086ed4fce5b36a5b31df44ccea @Override diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 977275f767c374a1be9055e4aa9e124025d55828..953e28f0cf60412a4ec9e311daa98f9d3cadea85 100644 +index 9eb987f9d86396d6b7e9d4f3834bea3326640ac7..25d6be308be03815301cfbefdc4199c898f7b9c0 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -195,6 +195,7 @@ import org.bukkit.craftbukkit.SpigotTimings; // Spigot - public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements ServerInfo, CommandSource, AutoCloseable { +@@ -201,6 +201,7 @@ import org.bukkit.craftbukkit.SpigotTimings; // Spigot + public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements ServerInfo, ChunkIOErrorReporter, CommandSource, AutoCloseable { public static final Logger LOGGER = LogUtils.getLogger(); + public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper public static final String VANILLA_BRAND = "vanilla"; private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F; private static final int TICK_STATS_SPAN = 100; -@@ -245,8 +246,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa +@@ -251,8 +252,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa private boolean preventProxyConnections; private boolean pvp; private boolean allowFlight; @@ -2610,7 +2627,7 @@ index 977275f767c374a1be9055e4aa9e124025d55828..953e28f0cf60412a4ec9e311daa98f9d private int playerIdleTimeout; private final long[] tickTimesNanos; private long aggregatedTickTimesNanos; -@@ -1369,7 +1369,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa +@@ -1397,7 +1397,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa private ServerStatus buildServerStatus() { ServerStatus.Players serverping_serverpingplayersample = this.buildPlayerStatus(); @@ -2619,7 +2636,7 @@ index 977275f767c374a1be9055e4aa9e124025d55828..953e28f0cf60412a4ec9e311daa98f9d } private ServerStatus.Players buildPlayerStatus() { -@@ -1401,6 +1401,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa +@@ -1429,6 +1429,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa SpigotTimings.schedulerTimer.startTiming(); // Spigot this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit SpigotTimings.schedulerTimer.stopTiming(); // Spigot @@ -2627,7 +2644,7 @@ index 977275f767c374a1be9055e4aa9e124025d55828..953e28f0cf60412a4ec9e311daa98f9d this.profiler.push("commandFunctions"); SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot this.getFunctions().tick(); -@@ -1777,10 +1778,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa +@@ -1800,10 +1801,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @Override public String getMotd() { @@ -2649,7 +2666,7 @@ index 977275f767c374a1be9055e4aa9e124025d55828..953e28f0cf60412a4ec9e311daa98f9d this.motd = motd; } -@@ -2542,23 +2553,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa +@@ -2565,23 +2576,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa } public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) { @@ -2682,10 +2699,10 @@ index 977275f767c374a1be9055e4aa9e124025d55828..953e28f0cf60412a4ec9e311daa98f9d public boolean logIPs() { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d76560c2fa9a8 100644 +index d02e958d74fe4bb97ce36ca04a36bcf7e73de016..dc92e1cd0a10ec4e6b4ad6145d5fc0a4ef199365 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -170,6 +170,7 @@ import net.minecraft.world.damagesource.CombatTracker; +@@ -171,6 +171,7 @@ import net.minecraft.world.item.trading.MerchantOffers; import net.minecraft.world.scores.Scoreboard; import net.minecraft.world.scores.Team; import net.minecraft.world.scores.criteria.ObjectiveCriteria; @@ -2693,7 +2710,7 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.WeatherType; -@@ -233,6 +234,7 @@ public class ServerPlayer extends Player { +@@ -236,6 +237,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { private boolean disconnected; private int requestedViewDistance; public String language = "en_us"; // CraftBukkit - default @@ -2701,7 +2718,7 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 @Nullable private Vec3 startingToFallPosition; @Nullable -@@ -265,6 +267,7 @@ public class ServerPlayer extends Player { +@@ -269,6 +271,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { // CraftBukkit start public CraftPlayer.TransferCookieConnection transferCookieConnection; public String displayName; @@ -2709,7 +2726,7 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 public Component listName; public org.bukkit.Location compassTarget; public int newExp = 0; -@@ -350,6 +353,7 @@ public class ServerPlayer extends Player { +@@ -355,6 +358,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { // CraftBukkit start this.displayName = this.getScoreboardName(); @@ -2717,12 +2734,12 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 this.bukkitPickUpLoot = true; this.maxHealthCache = this.getMaxHealth(); } -@@ -903,22 +907,17 @@ public class ServerPlayer extends Player { +@@ -912,22 +916,17 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { String deathmessage = defaultMessage.getString(); this.keepLevel = keepInventory; // SPIGOT-2222: pre-set keepLevel -- org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); -+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, PaperAdventure.asAdventure(defaultMessage), keepInventory); // Paper - Adventure +- org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, damageSource, loot, deathmessage, keepInventory); ++ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, damageSource, loot, PaperAdventure.asAdventure(defaultMessage), keepInventory); // Paper - Adventure // SPIGOT-943 - only call if they have an inventory open if (this.containerMenu != this.inventoryMenu) { @@ -2744,7 +2761,7 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; -@@ -1985,8 +1984,13 @@ public class ServerPlayer extends Player { +@@ -2027,8 +2026,13 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { } public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) { @@ -2759,7 +2776,7 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 } } -@@ -2013,6 +2017,7 @@ public class ServerPlayer extends Player { +@@ -2055,6 +2059,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { } // CraftBukkit end this.language = clientOptions.language(); @@ -2768,10 +2785,10 @@ index 240d7831d7f05e245e4103ec22f4967657e1040b..8292f45aa100e2788584f568430d7656 this.chatVisibility = clientOptions.chatVisibility(); this.canChatColor = clientOptions.chatColors(); diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 6f17aeae2941c43205fa6db5950d65f510774104..26b8a69a528db8a836b138a2a223c385508ce2c4 100644 +index 677ee8dfa0d2f5bcb23ee870a76bcee63e557813..678f12679985c6fa9effe8beec306d95d5e0bdac 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -66,7 +66,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -67,7 +67,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack private static final Component TIMEOUT_DISCONNECTION_MESSAGE = Component.translatable("disconnect.timeout"); static final Component DISCONNECT_UNEXPECTED_QUERY = Component.translatable("multiplayer.disconnect.unexpected_query_response"); protected final MinecraftServer server; @@ -2780,7 +2797,7 @@ index 6f17aeae2941c43205fa6db5950d65f510774104..26b8a69a528db8a836b138a2a223c385 private final boolean transferred; private long keepAliveTime; private boolean keepAlivePending; -@@ -75,6 +75,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -76,6 +76,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack private boolean closed = false; private int latency; private volatile boolean suspendFlushingOnServerThread = false; @@ -2788,9 +2805,9 @@ index 6f17aeae2941c43205fa6db5950d65f510774104..26b8a69a528db8a836b138a2a223c385 public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit this.server = minecraftserver; -@@ -188,6 +189,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -189,6 +190,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), packet.id()); - this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect")); + this.disconnect((Component) Component.translatable("multiplayer.requiredTexturePrompt.disconnect")); } + // Paper start - adventure pack callbacks + // call the callbacks before the previously-existing event so the event has final say @@ -2807,63 +2824,45 @@ index 6f17aeae2941c43205fa6db5950d65f510774104..26b8a69a528db8a836b138a2a223c385 this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()])); // CraftBukkit } -@@ -276,12 +289,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - - // CraftBukkit start - @Deprecated -- public void disconnect(Component reason) { -- this.disconnect(CraftChatMessage.fromComponent(reason)); -+ public void disconnect(String s) { // Paper -+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s)); // Paper +@@ -275,6 +288,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + } } - // CraftBukkit end -- public void disconnect(String s) { -+ // Paper start -+ public void disconnect(final Component reason) { -+ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asAdventure(reason)); ++ // Paper start - adventure ++ public void disconnect(final net.kyori.adventure.text.Component reason) { ++ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(reason)); + } ++ // Paper end - adventure + -+ public void disconnect(net.kyori.adventure.text.Component reason) { -+ // Paper end - // CraftBukkit start - fire PlayerKickEvent - if (this.processedDisconnect) { - return; -@@ -290,7 +309,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - Waitable waitable = new Waitable() { - @Override - protected Object evaluate() { -- ServerCommonPacketListenerImpl.this.disconnect(s); -+ ServerCommonPacketListenerImpl.this.disconnect(reason); // Paper - adventure - return null; - } - }; -@@ -307,9 +326,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + public void disconnect(Component reason) { + this.disconnect(new DisconnectionDetails(reason)); + } +@@ -305,9 +324,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack return; } - 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, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? this.player.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(this.player.getScoreboardName())); // Paper - Adventure -- PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage); -+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), reason, leaveMessage); // Paper - adventure +- PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), CraftChatMessage.fromComponent(disconnectionInfo.reason()), leaveMessage); ++ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), io.papermc.paper.adventure.PaperAdventure.asAdventure(disconnectionInfo.reason()), leaveMessage); // Paper - adventure if (this.cserver.getServer().isRunning()) { this.cserver.getPluginManager().callEvent(event); -@@ -321,7 +340,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -319,7 +338,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent // Send the possibly modified leave message -- final Component ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0]; -+ final Component ichatbasecomponent = io.papermc.paper.adventure.PaperAdventure.asVanilla(event.reason()); // Paper - Adventure - // CraftBukkit end +- this.disconnect0(new DisconnectionDetails(CraftChatMessage.fromString(event.getReason(), true)[0], disconnectionInfo.report(), disconnectionInfo.bugReportLink())); ++ this.disconnect0(new DisconnectionDetails(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.reason()), disconnectionInfo.report(), disconnectionInfo.bugReportLink())); // Paper - Adventure + } - this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> { + private void disconnect0(DisconnectionDetails disconnectiondetails) { diff --git a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -index bd7107279ca004f35c932e5d6e82f8302ec781ae..970d1ddf0a014b47b0ac97440489706137324991 100644 +index e7c407039fef88ef01ba9b6be9ae5bcc3edc026f..5457358bc76889153036818fdfd70a043ec4e40f 100644 --- a/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java -@@ -100,6 +100,7 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis +@@ -120,6 +120,7 @@ public class ServerConfigurationPacketListenerImpl extends ServerCommonPacketLis @Override public void handleClientInformation(ServerboundClientInformationPacket packet) { this.clientInformation = packet.information(); @@ -2872,12 +2871,12 @@ index bd7107279ca004f35c932e5d6e82f8302ec781ae..970d1ddf0a014b47b0ac974404897061 @Override diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index dfeb64d614e0da9f1bc0df9dcae71b509cf4178f..97b5e3cc18dbf712f5f60d92a4f9beabd90f2e0f 100644 +index e244ac9f51a08603a7877e7e655fda26cd396772..556d8f23ee2de77cea71abcc0e56718e60b20b05 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -44,6 +44,7 @@ import net.minecraft.core.registries.Registries; - import net.minecraft.nbt.CompoundTag; +@@ -45,6 +45,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; + import net.minecraft.network.DisconnectionDetails; import net.minecraft.network.TickablePacketListener; +import net.minecraft.network.chat.ChatDecorator; import net.minecraft.network.chat.ChatType; @@ -2892,7 +2891,7 @@ index dfeb64d614e0da9f1bc0df9dcae71b509cf4178f..97b5e3cc18dbf712f5f60d92a4f9beab import com.mojang.datafixers.util.Pair; import java.util.Arrays; import java.util.concurrent.ExecutionException; -@@ -1711,9 +1714,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1728,9 +1731,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl */ this.player.disconnect(); @@ -2907,7 +2906,7 @@ index dfeb64d614e0da9f1bc0df9dcae71b509cf4178f..97b5e3cc18dbf712f5f60d92a4f9beab } // CraftBukkit end this.player.getTextFilter().leave(); -@@ -1774,10 +1779,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1791,10 +1796,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } CompletableFuture<FilteredText> completablefuture = this.filterTextPacket(playerchatmessage.signedContent()).thenApplyAsync(Function.identity(), this.server.chatExecutor); // CraftBukkit - async chat @@ -2921,7 +2920,7 @@ index dfeb64d614e0da9f1bc0df9dcae71b509cf4178f..97b5e3cc18dbf712f5f60d92a4f9beab this.broadcastChatMessage(playerchatmessage1); }); -@@ -1997,7 +2002,15 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -2014,7 +2019,15 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl this.handleCommand(s); } else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) { // Do nothing, this is coming from a plugin @@ -2938,20 +2937,7 @@ index dfeb64d614e0da9f1bc0df9dcae71b509cf4178f..97b5e3cc18dbf712f5f60d92a4f9beab Player player = this.getCraftPlayer(); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(this.server)); String originalFormat = event.getFormat(), originalMessage = event.getMessage(); -@@ -2300,7 +2313,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - - public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) { - // CraftBukkit start - SPIGOT-7262: if hidden we have to send as disguised message. Query whether we should send at all (but changing this may not be expected). -- if (!this.getCraftPlayer().canSee(message.link().sender())) { -+ // Paper start - Do not query the world for players, if they're not in the player list, then they're not in the world - don't query world state -+ // Also, mirror the logic for canSee in terms of "missing" players -+ final ServerPlayer sender = this.server.getPlayerList().getPlayer(message.link().sender()); -+ if (sender == null || !this.getCraftPlayer().canSee(sender.getBukkitEntity())) { -+ // Paper end - this.sendDisguisedChatMessage(message.decoratedContent(), params); - return; - } -@@ -2994,6 +3011,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3011,6 +3024,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl public void handleClientInformation(ServerboundClientInformationPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); this.player.updateOptions(packet.information()); @@ -2960,10 +2946,10 @@ index dfeb64d614e0da9f1bc0df9dcae71b509cf4178f..97b5e3cc18dbf712f5f60d92a4f9beab @Override diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 47a1c62dd6f927cb01f679a597d1526bbca9e433..7beda9a16addb2dbcd4bdc45e58b343e91323af5 100644 +index 8e715261b99bcc19b6f4b9787987c59aa19ba70e..851e4bdf1739736fd193786a6541ffb341525dcb 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -331,7 +331,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -333,7 +333,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) { @@ -2972,7 +2958,7 @@ index 47a1c62dd6f927cb01f679a597d1526bbca9e433..7beda9a16addb2dbcd4bdc45e58b343e } Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() { @Override -@@ -343,12 +343,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -345,12 +345,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, ServerLoginPacketListenerImpl.this.server.processQueue.add(waitable); if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) { @@ -2988,10 +2974,10 @@ index 47a1c62dd6f927cb01f679a597d1526bbca9e433..7beda9a16addb2dbcd4bdc45e58b343e } } diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -index a4d8d4400a1f6f6d05a3c362f2bc4a391d4ee9a1..9e62aa13845f19faf0dc0b7b27d958626e77d96e 100644 +index 2c555c5ad05992b19f67b883c3c0ec7018180747..71540687b4212702cdaaad5fd4815fb3eb97ddd6 100644 --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -@@ -57,7 +57,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene +@@ -58,7 +58,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene CraftIconCache icon = server.server.getServerIcon(); ServerListPingEvent() { @@ -3001,7 +2987,7 @@ index a4d8d4400a1f6f6d05a3c362f2bc4a391d4ee9a1..9e62aa13845f19faf0dc0b7b27d95862 @Override diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d67742d9d 100644 +index 6abe921099ff00ecfaf0f423ef27d708420f6f48..e9109526880159e2341cc97b53939ba2bcfaeaf9 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -271,7 +271,7 @@ public abstract class PlayerList { @@ -3038,7 +3024,7 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d } // CraftBukkit end -@@ -499,7 +498,7 @@ public abstract class PlayerList { +@@ -492,7 +491,7 @@ public abstract class PlayerList { } @@ -3047,7 +3033,7 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d ServerLevel worldserver = entityplayer.serverLevel(); entityplayer.awardStat(Stats.LEAVE_GAME); -@@ -510,7 +509,7 @@ public abstract class PlayerList { +@@ -503,7 +502,7 @@ public abstract class PlayerList { entityplayer.closeContainer(); } @@ -3056,7 +3042,7 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d this.cserver.getPluginManager().callEvent(playerQuitEvent); entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); -@@ -563,7 +562,7 @@ public abstract class PlayerList { +@@ -556,7 +555,7 @@ public abstract class PlayerList { this.cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); // CraftBukkit end @@ -3065,7 +3051,7 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d } // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer -@@ -610,11 +609,11 @@ public abstract class PlayerList { +@@ -603,11 +602,11 @@ public abstract class PlayerList { } // return chatmessage; @@ -3080,7 +3066,7 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d IpBanListEntry ipbanentry = this.ipBans.get(socketaddress); ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason()); -@@ -623,17 +622,17 @@ public abstract class PlayerList { +@@ -616,17 +615,17 @@ public abstract class PlayerList { } // return chatmessage; @@ -3101,16 +3087,16 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d return null; } return entity; -@@ -1153,7 +1152,7 @@ public abstract class PlayerList { +@@ -1122,7 +1121,7 @@ public abstract class PlayerList { public void removeAll() { // CraftBukkit start - disconnect safely for (ServerPlayer player : this.players) { -- player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message -+ player.connection.disconnect(this.server.server.shutdownMessage()); // CraftBukkit - add custom shutdown message // Paper - Adventure +- player.connection.disconnect(CraftChatMessage.fromStringOrEmpty(this.server.server.getShutdownMessage())); // CraftBukkit - add custom shutdown message ++ player.connection.disconnect(java.util.Objects.requireNonNullElseGet(this.server.server.shutdownMessage(), net.kyori.adventure.text.Component::empty)); // CraftBukkit - add custom shutdown message // Paper - Adventure } // CraftBukkit end -@@ -1194,24 +1193,43 @@ public abstract class PlayerList { +@@ -1163,24 +1162,43 @@ public abstract class PlayerList { } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) { @@ -3157,7 +3143,7 @@ index 54fee00a462c2f6fcc567d762b1afd24cf5c7d06..0ff094a90bf471ce57a3054c7701dc3d } if (flag1 && sender != null) { -@@ -1220,7 +1238,7 @@ public abstract class PlayerList { +@@ -1189,7 +1207,7 @@ public abstract class PlayerList { } @@ -3255,10 +3241,10 @@ index ed54c81a3269360acce674aa4e1d54ccb2461841..c9c849534c3998cfcab7ddcb12a71ccb } diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index bf19e8e8aa96d646f057b8727f2f01ad2e2497cd..d6b02a946bd18ea71278a5026468ec49fabd3a3b 100644 +index b6cb1de08e955dfc99a0cb736b2ed456c99fde5c..abf502b8395bb0a8a32c1fdcd62532790deb1c6e 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -186,7 +186,15 @@ public final class ItemStack implements DataComponentHolder { +@@ -183,7 +183,15 @@ public final class ItemStack implements DataComponentHolder { CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); // Spigot end ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error @@ -3307,7 +3293,7 @@ index 8ec376f453ac1f4c9423483f5ae1625b295858c7..e535fb3b5194b8412c0c26c079934091 } } 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 3db3c6858d98d2eaf7c9bd8d395b83b22c447bb9..d42d39dff5aeb91c5b1e6a7fb967ce70f1a88b7e 100644 +index 6acee03278c8005a06d9cd2577761f2f5355a7ec..5e469bd4d9ca428abdd9d758993164635dc86f27 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 @@ -45,6 +45,7 @@ import net.minecraft.world.level.saveddata.SavedData; @@ -3318,7 +3304,7 @@ index 3db3c6858d98d2eaf7c9bd8d395b83b22c447bb9..d42d39dff5aeb91c5b1e6a7fb967ce70 import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.CraftServer; -@@ -610,7 +611,7 @@ public class MapItemSavedData extends SavedData { +@@ -615,7 +616,7 @@ public class MapItemSavedData extends SavedData { for (org.bukkit.map.MapCursor cursor : render.cursors) { if (cursor.isVisible()) { @@ -3327,11 +3313,23 @@ index 3db3c6858d98d2eaf7c9bd8d395b83b22c447bb9..d42d39dff5aeb91c5b1e6a7fb967ce70 } } collection = icons; +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java b/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java +index 49c037e961c5ca5ba8d6a870cb32ffe8719adc91..2772c19f58a35713d61aab24f6f0d6f5070153c6 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftJukeboxSong.java +@@ -59,6 +59,7 @@ public class CraftJukeboxSong implements JukeboxSong, Handleable<net.minecraft.w + @NotNull + @Override + public String getTranslationKey() { ++ if (!(this.handle.description().getContents() instanceof TranslatableContents)) throw new UnsupportedOperationException("Description isn't translatable!"); // Paper + return ((TranslatableContents) this.handle.description().getContents()).getKey(); + } + } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75be9f541f3 100644 +index 9babfd8e6c847ea26863be6243f17fc252dc9e1d..0e3ff653211b0210f8679b475d5f62eecbdfd946 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -610,8 +610,10 @@ public final class CraftServer implements Server { +@@ -636,8 +636,10 @@ public final class CraftServer implements Server { } @Override @@ -3342,7 +3340,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b } @Override -@@ -1586,7 +1588,15 @@ public final class CraftServer implements Server { +@@ -1613,7 +1615,15 @@ public final class CraftServer implements Server { return this.configuration.getInt("settings.spawn-radius", -1); } @@ -3358,7 +3356,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b public String getShutdownMessage() { return this.configuration.getString("settings.shutdown-message"); } -@@ -1760,7 +1770,20 @@ public final class CraftServer implements Server { +@@ -1787,7 +1797,20 @@ public final class CraftServer implements Server { } @Override @@ -3379,7 +3377,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b Set<CommandSender> recipients = new HashSet<>(); for (Permissible permissible : this.getPluginManager().getPermissionSubscriptions(permission)) { if (permissible instanceof CommandSender && permissible.hasPermission(permission)) { -@@ -1768,14 +1791,14 @@ public final class CraftServer implements Server { +@@ -1795,14 +1818,14 @@ public final class CraftServer implements Server { } } @@ -3396,7 +3394,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b for (CommandSender recipient : recipients) { recipient.sendMessage(message); -@@ -2037,6 +2060,14 @@ public final class CraftServer implements Server { +@@ -2064,6 +2087,14 @@ public final class CraftServer implements Server { return CraftInventoryCreator.INSTANCE.createInventory(owner, type); } @@ -3411,7 +3409,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b @Override public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { Preconditions.checkArgument(type != null, "InventoryType cannot be null"); -@@ -2051,13 +2082,28 @@ public final class CraftServer implements Server { +@@ -2078,13 +2109,28 @@ public final class CraftServer implements Server { return CraftInventoryCreator.INSTANCE.createInventory(owner, size); } @@ -3440,7 +3438,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b public Merchant createMerchant(String title) { return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title); } -@@ -2122,6 +2168,17 @@ public final class CraftServer implements Server { +@@ -2149,6 +2195,17 @@ public final class CraftServer implements Server { return Thread.currentThread().equals(this.console.serverThread) || this.console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) } @@ -3458,7 +3456,7 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b @Override public String getMotd() { return this.console.getMotd(); -@@ -2566,4 +2623,57 @@ public final class CraftServer implements Server { +@@ -2598,4 +2655,57 @@ public final class CraftServer implements Server { public double[] getTPS() { return new double[]{0, 0, 0}; // TODO } @@ -3516,8 +3514,46 @@ index 9b299f74336ad0efecd05a4b771ac58549d5fb6a..9e34d3f009184981e4f4cd34b0c0c75b + } + // Paper end } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java b/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java +index cbdb1a56a97150c164515a4ce6d3ba06428bf321..b214e7b302abbfe1641485a05f1371ac65ffb517 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java +@@ -61,6 +61,19 @@ public class CraftServerLinks implements ServerLinks { + return link; + } + ++ // Paper start - Adventure ++ @Override ++ public ServerLink addLink(net.kyori.adventure.text.Component displayName, URI url) { ++ Preconditions.checkArgument(displayName != null, "displayName cannot be null"); ++ Preconditions.checkArgument(url != null, "url cannot be null"); ++ ++ CraftServerLink link = new CraftServerLink(net.minecraft.server.ServerLinks.Entry.custom(io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), url)); ++ this.addLink(link); ++ ++ return link; ++ } ++ // Paper end - Adventure ++ + @Override + public ServerLink addLink(String displayName, URI url) { + Preconditions.checkArgument(displayName != null, "displayName cannot be null"); +@@ -134,6 +147,13 @@ public class CraftServerLinks implements ServerLinks { + return CraftChatMessage.fromComponent(this.handle.displayName()); + } + ++ // Paper start - Adventure ++ @Override ++ public net.kyori.adventure.text.Component displayName() { ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.displayName()); ++ } ++ // Paper end - Adventure ++ + @Override + public URI getUrl() { + return this.handle.link(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 6ce2b09c4bb7153c960a7eed865296a9c93dd1cb..5bbbb9ee266879291e4ff56ad2ee39aa6151bfff 100644 +index a59eebb89d11788b999d1e5cb4fd2f4e55e023ab..1e8d93d81b7a391bbd1e9926ff35a68d4c563f0f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -162,6 +162,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -3528,7 +3564,7 @@ index 6ce2b09c4bb7153c960a7eed865296a9c93dd1cb..5bbbb9ee266879291e4ff56ad2ee39aa private static final Random rand = new Random(); -@@ -1684,6 +1685,42 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1709,6 +1710,42 @@ public class CraftWorld extends CraftRegionAccessor implements World { entityTracker.broadcastAndSend(packet); } } @@ -3571,7 +3607,7 @@ index 6ce2b09c4bb7153c960a7eed865296a9c93dd1cb..5bbbb9ee266879291e4ff56ad2ee39aa private static Map<String, GameRules.Key<?>> gamerules; public static synchronized Map<String, GameRules.Key<?>> getGameRulesNMS() { -@@ -2125,5 +2162,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2150,5 +2187,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { public void setSendViewDistance(final int viewDistance) { throw new UnsupportedOperationException("Not implemented yet"); } @@ -3979,12 +4015,12 @@ index 1e82312c24cb752d63b165926861fc178cd7849b..7f22950ae61436e91a59cd29a345809c + // 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 276af7b86bf21843aaf7266baae37a8e7efabcbd..d839a0edf31f6803e5813b28a23fa17e20916b2c 100644 +index ed6944418382dbd02e5ddbf50c6ac4bb26415807..97a7dc31fe7a2defed2202ccc518c66b7ff4b0da 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java -@@ -140,6 +140,12 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine +@@ -166,6 +166,12 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine CraftEnchantment ench = (CraftEnchantment) other; - return !this.handle.isCompatibleWith(ench.getHandle()); + return !net.minecraft.world.item.enchantment.Enchantment.areCompatible(this.handle, ench.handle); } + // Paper start + @Override @@ -3996,10 +4032,10 @@ index 276af7b86bf21843aaf7266baae37a8e7efabcbd..d839a0edf31f6803e5813b28a23fa17e @Override public String getTranslationKey() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 941035a6cf73c8757e3ea75358d5d405b22c1a6f..0996bfe664e0085dcacdd2b6c08a2737d3b2fa6a 100644 +index d09102fe44dffa61dff883488f47715effaa8211..269326e7689eba91bcfd3475006e8cbf8f5694ef 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -67,6 +67,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -69,6 +69,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { private final EntityType entityType; private EntityDamageEvent lastDamageEvent; private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftEntity.DATA_TYPE_REGISTRY); @@ -4007,7 +4043,7 @@ index 941035a6cf73c8757e3ea75358d5d405b22c1a6f..0996bfe664e0085dcacdd2b6c08a2737 public CraftEntity(final CraftServer server, final Entity entity) { this.server = server; -@@ -523,6 +524,32 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -525,6 +526,32 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return this.getHandle().getVehicle().getBukkitEntity(); } @@ -4040,7 +4076,7 @@ index 941035a6cf73c8757e3ea75358d5d405b22c1a6f..0996bfe664e0085dcacdd2b6c08a2737 @Override public void setCustomName(String name) { // sane limit for name length -@@ -619,6 +646,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -621,6 +648,17 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public String getName() { return CraftChatMessage.fromComponent(this.getHandle().getName()); } @@ -4111,10 +4147,10 @@ index 55945b83a5426b352bad9507cc9e94afb1278032..9ea1537408ff2d790747b6e5a681d917 public boolean isOp() { return true; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93de8c5570 100644 +index c025542b1073ce7e6e30a43744276fd1fa1ca484..03c70d45941822239a0894f910cbaf114b939bec 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -386,14 +386,40 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -388,14 +388,40 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public String getDisplayName() { @@ -4155,7 +4191,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 @Override public String getPlayerListName() { return this.getHandle().listName == null ? this.getName() : CraftChatMessage.fromComponent(this.getHandle().listName); -@@ -405,6 +431,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -407,6 +433,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { name = this.getName(); } this.getHandle().listName = name.equals(this.getName()) ? null : CraftChatMessage.fromStringOrNull(name); @@ -4163,7 +4199,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 for (ServerPlayer player : (List<ServerPlayer>) this.server.getHandle().players) { if (player.getBukkitEntity().canSee(this)) { player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, this.getHandle())); -@@ -412,42 +439,42 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -414,42 +441,42 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } @@ -4215,8 +4251,8 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 this.getHandle().connection.send(packet); } -@@ -479,6 +506,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - this.getHandle().connection.disconnect(message == null ? "" : message); +@@ -481,6 +508,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message)); } + // Paper start @@ -4239,7 +4275,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 @Override public void setCompassTarget(Location loc) { Preconditions.checkArgument(loc != null, "Location cannot be null"); -@@ -775,6 +819,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -777,6 +821,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player { this.getHandle().connection.send(packet); } @@ -4264,7 +4300,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 @Override public void sendSignChange(Location loc, String[] lines) { this.sendSignChange(loc, lines, DyeColor.BLACK); -@@ -798,6 +860,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -800,6 +862,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (this.getHandle().connection == null) return; Component[] components = CraftSign.sanitizeLines(lines); @@ -4277,7 +4313,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 SignBlockEntity sign = new SignBlockEntity(CraftLocation.toBlockPosition(loc), Blocks.OAK_SIGN.defaultBlockState()); SignText text = sign.getFrontText(); text = text.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); -@@ -1805,7 +1873,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1815,7 +1883,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setResourcePack(String url) { @@ -4286,7 +4322,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 } @Override -@@ -1820,7 +1888,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1830,7 +1898,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setResourcePack(String url, byte[] hash, boolean force) { @@ -4295,7 +4331,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 } @Override -@@ -1857,6 +1925,59 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1867,6 +1935,59 @@ public class CraftPlayer extends CraftHumanEntity implements Player { this.handlePushResourcePack(new ClientboundResourcePackPushPacket(id, url, hashStr, force, CraftChatMessage.fromStringOrOptional(prompt, true)), false); } @@ -4330,7 +4366,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 + final Component prompt = io.papermc.paper.adventure.PaperAdventure.asVanilla(request.prompt()); + for (final java.util.Iterator<net.kyori.adventure.resource.ResourcePackInfo> iter = request.packs().iterator(); iter.hasNext();) { + final net.kyori.adventure.resource.ResourcePackInfo pack = iter.next(); -+ packs.add(new ClientboundResourcePackPushPacket(pack.id(), pack.uri().toASCIIString(), pack.hash(), request.required(), iter.hasNext() ? Optional.empty() : Optional.of(prompt))); ++ packs.add(new ClientboundResourcePackPushPacket(pack.id(), pack.uri().toASCIIString(), pack.hash(), request.required(), iter.hasNext() ? Optional.empty() : Optional.ofNullable(prompt))); + if (request.callback() != net.kyori.adventure.resource.ResourcePackCallback.noOp()) { + this.getHandle().connection.packCallbacks.put(pack.id(), request.callback()); // just override if there is a previously existing callback + } @@ -4355,7 +4391,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 @Override public void removeResourcePack(UUID id) { Preconditions.checkArgument(id != null, "Resource pack id cannot be null"); -@@ -2268,6 +2389,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2287,6 +2408,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return (this.getHandle().requestedViewDistance() == 0) ? Bukkit.getViewDistance() : this.getHandle().requestedViewDistance(); } @@ -4368,7 +4404,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 @Override public int getPing() { return this.getHandle().connection.latency(); -@@ -2318,6 +2445,248 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2337,6 +2464,248 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this.getHandle().allowsListing(); } @@ -4555,7 +4591,7 @@ index 13c3ac65f26e6cfc55ee3538b6308ef93f9936aa..0b15c8a3906221ef09261f3d42c0aa93 + + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound) { -+ final Vec3 pos = this.getHandle().position(); ++ final net.minecraft.world.phys.Vec3 pos = this.getHandle().position(); + this.playSound(sound, pos.x, pos.y, pos.z); + } + @@ -4640,19 +4676,19 @@ index 5725b0281ac53a2354b233223259d6784353bc6e..9ef939b76d06874b856e0c850addb364 @Override public int getLineWidth() { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 8de924b91f74321896bbef8468cbd04b992f2f8a..387305bb835dca0cee7ab398d5630e3522c6162f 100644 +index 889af27e3fe5ce98b68b3177639c338ca287b024..a29dfbe7aa06113358a2078d927fc53662a5f91f 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -905,7 +905,7 @@ public class CraftEventFactory { +@@ -907,7 +907,7 @@ public class CraftEventFactory { return event; } -- public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage, boolean keepInventory) { -+ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, List<org.bukkit.inventory.ItemStack> drops, net.kyori.adventure.text.Component deathMessage, boolean keepInventory) { // Paper - Adventure +- public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, DamageSource damageSource, List<org.bukkit.inventory.ItemStack> drops, String deathMessage, boolean keepInventory) { ++ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, DamageSource damageSource, List<org.bukkit.inventory.ItemStack> drops, net.kyori.adventure.text.Component deathMessage, boolean keepInventory) { // Paper - Adventure CraftPlayer entity = victim.getBukkitEntity(); - PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage); - event.setKeepInventory(keepInventory); -@@ -932,7 +932,7 @@ public class CraftEventFactory { + CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); + PlayerDeathEvent event = new PlayerDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity()), 0, deathMessage); +@@ -935,7 +935,7 @@ public class CraftEventFactory { * Server methods */ public static ServerListPingEvent callServerListPingEvent(SocketAddress address, String motd, int numPlayers, int maxPlayers) { @@ -4662,10 +4698,10 @@ index 8de924b91f74321896bbef8468cbd04b992f2f8a..387305bb835dca0cee7ab398d5630e35 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 d47b248535882bb58ae6c1b6ef756464a1989918..39be45585835eabc8d8bcae0158c094c3dcb1aa3 100644 +index 42c888af154a133e118a9ff9fef587e345c13e19..867091ff253541ec45b6ae7f1fb3acc83a5c4966 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java -@@ -73,6 +73,13 @@ public class CraftContainer extends AbstractContainerMenu { +@@ -72,6 +72,13 @@ public class CraftContainer extends AbstractContainerMenu { return inventory.getType(); } @@ -4766,10 +4802,10 @@ index c9cc23757a9fcc58d30b2915d4c5cfbc7d1c767a..fc0e1212022d1aa3506699b60ef33819 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 4dd9a80af9901287ab6740b072f2b89678c3d0cb..b2586684295b295a3196a2a9cf724cec975b5a40 100644 +index 6871fbde3498f18274029638e0cd27d1a78bb1d7..5888a44d7f1f06e6308b068e57c295de366061cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java -@@ -73,6 +73,13 @@ public class CraftInventoryView extends InventoryView { +@@ -73,6 +73,13 @@ public class CraftInventoryView extends CraftAbstractInventoryView { return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem()); } @@ -4784,12 +4820,12 @@ index 4dd9a80af9901287ab6740b072f2b89678c3d0cb..b2586684295b295a3196a2a9cf724cec public String getTitle() { return this.title; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index 01963ef944da9251c038208c20012939afc77830..319ad3342740657175ad78a1c1cc383046fe2fb5 100644 +index 500bfe5dd745327f953a314e863f7318953bf3bc..e2daeeba1bacbb5c5ca2aa922fa67b02cd050755 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -501,4 +501,21 @@ public final class CraftItemFactory implements ItemFactory { - CraftItemStack craft = (CraftItemStack) itemStack; - return CraftItemStack.asCraftMirror(EnchantmentHelper.enchantItem(MinecraftServer.getServer().getWorldData().enabledFeatures(), source, craft.handle, level, allowTreasures)); +@@ -206,4 +206,21 @@ public final class CraftItemFactory implements ItemFactory { + Optional<HolderSet.Named<Enchantment>> optional = (allowTreasures) ? Optional.empty() : registry.registryOrThrow(Registries.ENCHANTMENT).getTag(EnchantmentTags.IN_ENCHANTING_TABLE); + return CraftItemStack.asCraftMirror(EnchantmentHelper.enchantItem(source, craft.handle, level, registry, optional)); } + + // Paper start - Adventure @@ -5005,7 +5041,7 @@ index 61ad00c38cfef8a1de61b4597ec1042428feccf4..4da38ebb7fdbdb0f8fa422ebcd2e3eec if (this.pages != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java -index 9c57b883783145ad4483481a2c2e7f0f188cd174..b653c2c80e8e8524ea6d7625c6a86f8204c50709 100644 +index 2e6f0a0f4bbe4ae3c7c85e679f6187e89d1298ff..c7360e2b2d6e50abc371c21b09cdadd63892f439 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java @@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.inventory; @@ -5141,11 +5177,11 @@ index 9c57b883783145ad4483481a2c2e7f0f188cd174..b653c2c80e8e8524ea6d7625c6a86f82 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index 8abb72c2c38d9b28be6c4e6cfd502371eb3a27ed..899995f30b54db93a4f44313384b316825693e36 100644 +index 607456854e6bce3f7b58469af4ce42b8bacb72fc..9ecbdd50aa2eb7851ce1716946fa31e5db8765b4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -@@ -853,6 +853,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null); +@@ -952,6 +952,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + return !(this.hasDisplayName() || this.hasItemName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.build().isEmpty() || !this.removedTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isHideTooltip() || this.isUnbreakable() || this.hasEnchantmentGlintOverride() || this.isFireResistant() || this.hasMaxStackSize() || this.hasRarity() || this.hasFood() || this.hasTool() || this.hasDamage() || this.hasMaxDamage() || this.hasAttributeModifiers() || this.customTag != null); } + // Paper start @@ -5163,7 +5199,7 @@ index 8abb72c2c38d9b28be6c4e6cfd502371eb3a27ed..899995f30b54db93a4f44313384b3168 @Override public String getDisplayName() { return CraftChatMessage.fromComponent(this.displayName); -@@ -883,6 +895,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { +@@ -982,6 +994,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { return this.itemName != null; } @@ -5182,7 +5218,7 @@ index 8abb72c2c38d9b28be6c4e6cfd502371eb3a27ed..899995f30b54db93a4f44313384b3168 @Override public String getLocalizedName() { return this.getDisplayName(); -@@ -902,6 +926,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { +@@ -1001,6 +1025,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { return this.lore != null && !this.lore.isEmpty(); } @@ -5553,10 +5589,10 @@ index 4d586e1375ed8782939c9d480479e0dd981f8cbc..7900adb0b158bc17dd792dd082c33854 + } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -index b963d471b33cacaeec385dba6b2bf369e3d4426f..51094fe6e37d3c0fad2682353f8de3d1b9c9aef5 100644 +index 28038c3a531680201dcc8f2716b8f46f3886e769..5a9ddf71dc186c537a23083ac59434fb446a2140 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java -@@ -299,6 +299,7 @@ public final class CraftChatMessage { +@@ -308,6 +308,7 @@ public final class CraftChatMessage { public static String fromComponent(Component component) { if (component == null) return ""; @@ -5565,10 +5601,10 @@ index b963d471b33cacaeec385dba6b2bf369e3d4426f..51094fe6e37d3c0fad2682353f8de3d1 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 3f91fce6df9b87a6e84df21ed04f25be3729814b..e57ba8af99f0ac0151ec1d4c4279393ace6826e4 100644 +index 2fc68d129e2fdfd51e310ea5bdfb83322666c87b..fb22e04a4a9f039f0e942ff837124b00ca1b12be 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -76,6 +76,43 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -81,6 +81,43 @@ public final class CraftMagicNumbers implements UnsafeValues { private CraftMagicNumbers() {} @@ -5724,7 +5760,7 @@ index 0000000000000000000000000000000000000000..3aedd0bbc97edacc1ebf71264b310e55 +} diff --git a/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java b/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..0b23e6aab901d359845573e12e939a231ee30ada +index 0000000000000000000000000000000000000000..69b3aa957161e75d6344e437a8b4a4533ef00523 --- /dev/null +++ b/src/test/java/io/papermc/paper/adventure/AdventureCodecsTest.java @@ -0,0 +1,403 @@ @@ -5936,7 +5972,7 @@ index 0000000000000000000000000000000000000000..0b23e6aab901d359845573e12e939a23 + JavaOps.INSTANCE, + JsonOps.INSTANCE + ) -+ .map(ops -> RegistryOps.create(ops, AbstractTestingBase.REGISTRY_CUSTOM)) ++ .map(ops -> AbstractTestingBase.REGISTRY_CUSTOM.createSerializationContext(ops)) + .toList(); + } + |