From 2e419805adb39737676aed19b22c259e70672707 Mon Sep 17 00:00:00 2001 From: Riley Park Date: Sun, 21 Feb 2021 11:45:33 -0800 Subject: [PATCH] We're going on an Adventure! (#4842) Co-authored-by: Jake Potrebic Co-authored-by: zml Co-authored-by: Mariell Hoversholm --- ...support.patch => 0222-Brand-support.patch} | 0 ...e-PlayerProfile-in-AsyncPreLoginEven.patch | 4 +- .../Add-API-for-quit-reason.patch | 17 +- .../Add-Ban-Methods-to-Player-Objects.patch | 4 +- ...t-sendMessage-methods-to-CommandSend.patch | 25 +- Spigot-API-Patches/Add-Heightmap-API.patch | 2 +- Spigot-API-Patches/Add-Mob-Goal-API.patch | 2 +- .../Add-Player-Client-Options-API.patch | 2 +- ...Add-Raw-Byte-ItemStack-Serialization.patch | 2 +- .../Add-String-based-Action-Bar-API.patch | 26 +- .../Add-UnknownCommandEvent.patch | 38 +- .../Add-World.getEntity-UUID-API.patch | 2 +- ...CanPlaceOn-and-CanDestroy-NBT-values.patch | 8 +- ...eload-permissions.yml-and-require-co.patch | 2 +- ...n-option-to-prevent-player-names-fro.patch | 2 +- ...dd-extended-PaperServerListPingEvent.patch | 11 + .../Add-getI18NDisplayName-API.patch | 2 +- .../Add-getOfflinePlayerIfCached-String.patch | 2 +- Spigot-API-Patches/Add-getTPS-method.patch | 2 +- ...ent-to-allow-plugins-to-handle-clien.patch | 32 +- Spigot-API-Patches/Add-moon-phase-API.patch | 2 +- .../Add-setMaxPlayers-API.patch | 2 +- Spigot-API-Patches/Add-sun-related-API.patch | 4 +- Spigot-API-Patches/Add-tick-times-API.patch | 2 +- ...tional-world.getNearbyEntities-API-s.patch | 2 +- Spigot-API-Patches/Adventure.patch | 3169 +++++++++++++++++ ...Blocks-to-be-accessed-via-a-long-key.patch | 2 +- .../Allow-Reloading-of-Command-Aliases.patch | 2 +- ...llow-delegation-to-vanilla-chunk-gen.patch | 2 +- Spigot-API-Patches/Async-Chunks-API.patch | 2 +- .../Basic-PlayerProfile-API.patch | 2 +- .../Complete-resource-pack-API.patch | 14 +- ...ate-HoverEvent-from-ItemStack-Entity.patch | 8 + Spigot-API-Patches/Entity-Origin-API.patch | 9 +- .../Expand-Explosions-API.patch | 2 +- ...ld.spawnParticle-API-and-add-Builder.patch | 2 +- .../Expose-MinecraftServer-isRunning.patch | 2 +- ...nt-protocol-version-and-virtual-host.patch | 8 +- Spigot-API-Patches/Expose-game-version.patch | 2 +- .../Expose-server-CommandMap.patch | 2 +- .../Expose-the-internal-current-tick.patch | 2 +- ...upstream-javadoc-warnings-and-errors.patch | 58 +- ...lip-some-Spigot-API-null-annotations.patch | 6 +- ...cord-chat-API-from-spigot-subclasses.patch | 16 +- ...PI-additions-for-quantity-flags-lore.patch | 2 +- .../ItemStack-getMaxItemUseDuration.patch | 2 +- ...ault-permission-message-configurable.patch | 2 +- .../Player-Tab-List-and-Title-APIs.patch | 32 +- .../Player-affects-spawning-API.patch | 2 +- .../Player.setPlayerProfile-API.patch | 4 +- .../PlayerDeathEvent-getItemsToKeep.patch | 19 +- ...layerDeathEvent-shouldDropExperience.patch | 59 +- .../ProfileWhitelistVerifyEvent.patch | 33 +- ...vide-Chunk-Coordinates-as-a-Long-API.patch | 2 +- ...rovide-E-TE-Chunk-count-stat-methods.patch | 2 +- ...deadlock-risk-in-firing-async-events.patch | 2 +- ...onent-with-empty-text-instead-of-thr.patch | 2 +- Spigot-API-Patches/Spawn-Reason-API.patch | 4 +- .../Support-components-in-ItemMeta.patch | 20 +- .../World-view-distance-api.patch | 2 +- .../ensureServerConversions-API.patch | 19 +- .../getPlayerUniqueId-API.patch | 2 +- Spigot-API-Patches/isChunkGenerated-API.patch | 2 +- ...support.patch => 0547-Brand-support.patch} | 0 ...support.patch => 0557-Brand-support.patch} | 1 + ...-get-a-BlockState-without-a-snapshot.patch | 2 +- ...e-PlayerProfile-in-AsyncPreLoginEven.patch | 4 +- .../Add-API-for-quit-reason.patch | 6 +- ...n-for-console-having-all-permissions.patch | 7 +- .../Add-sun-related-API.patch | 4 +- .../Add-tick-times-API-and-mspt-command.patch | 2 +- Spigot-Server-Patches/Adventure.patch | 2909 +++++++++++++++ ...llow-Reloading-of-Custom-Permissions.patch | 2 +- .../Broadcast-join-message-to-console.patch | 10 +- ...layer-is-attempted-to-be-removed-fro.patch | 2 +- ...-don-t-need-to-when-cerealising-text.patch | 2 +- .../Entity-Activation-Range-2.0.patch | 6 +- ...e-attack-cooldown-methods-for-Player.patch | 12 +- ...isPrimaryThread-and-MinecraftServer-.patch | 2 +- ...g-Broken-behavior-of-PlayerJoinEvent.patch | 2 +- ...-allowed-colored-signs-to-be-created.patch | 8 +- ...ering-entities-from-unloading-chunks.patch | 2 +- .../Further-improve-server-tick-loop.patch | 2 +- .../Implement-Player-Client-Options-API.patch | 4 +- .../Implement-PlayerLocaleChangeEvent.patch | 9 +- ...-for-CanPlaceOn-and-CanDestroy-NBT-v.patch | 2 +- ...mplement-ensureServerConversions-API.patch | 7 +- ...Implemented-BlockFailedDispenseEvent.patch | 44 + .../Improve-death-events.patch | 4 +- .../Improved-Watchdog-Support.patch | 2 +- .../InventoryCloseEvent-Reason-API.patch | 4 +- ...-track-plugin-scoreboards-by-default.patch | 4 +- .../Limit-Client-Sign-length-more.patch | 8 +- .../Limit-recipe-packets.patch | 4 +- ...Load-Chunks-for-Login-Asynchronously.patch | 6 +- Spigot-Server-Patches/MC-Utils.patch | 15 +- ...nilla-per-world-scoreboard-coloring-.patch | 58 +- .../Paper-config-files.patch | 2 +- .../Player-Tab-List-and-Title-APIs.patch | 21 +- .../Player-affects-spawning-API.patch | 9 +- ...vent-opening-inventories-when-frozen.patch | 18 +- ...event-tile-entity-and-entity-crashes.patch | 6 +- .../ProfileWhitelistVerifyEvent.patch | 9 +- ...le-async-calls-to-restart-the-server.patch | 7 +- ...store-custom-InventoryHolder-support.patch | 3 + .../Support-components-in-ItemMeta.patch | 12 - Spigot-Server-Patches/Timings-v2.patch | 7 +- .../Tracking-Range-Improvements.patch | 2 +- ...pdate-itemstack-legacy-name-and-lore.patch | 12 - .../Use-ConcurrentHashMap-in-JsonList.patch | 2 +- ...ength-when-serialising-BungeeCord-te.patch | 2 +- ...ement-optional-per-player-mob-spawns.patch | 2 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- work/Spigot | 2 +- 115 files changed, 6625 insertions(+), 370 deletions(-) rename Spigot-API-Patches/{0221-Brand-support.patch => 0222-Brand-support.patch} (100%) create mode 100644 Spigot-API-Patches/Adventure.patch rename Spigot-Server-Patches/{0546-Brand-support.patch => 0547-Brand-support.patch} (100%) rename Spigot-Server-Patches/{0556-Brand-support.patch => 0557-Brand-support.patch} (93%) create mode 100644 Spigot-Server-Patches/Adventure.patch diff --git a/Spigot-API-Patches/0221-Brand-support.patch b/Spigot-API-Patches/0222-Brand-support.patch similarity index 100% rename from Spigot-API-Patches/0221-Brand-support.patch rename to Spigot-API-Patches/0222-Brand-support.patch diff --git a/Spigot-API-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/Spigot-API-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch index b8151a2ecf..b399ef8c8b 100644 --- a/Spigot-API-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch +++ b/Spigot-API-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { private static final HandlerList handlers = new HandlerList(); private Result result; - private String message; + private net.kyori.adventure.text.Component message; // Paper - private final String name; + //private String name; // Paper - Not used anymore private final InetAddress ipAddress; @@ -62,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.profile = profile; + // Paper end this.result = Result.ALLOWED; - this.message = ""; + this.message = net.kyori.adventure.text.Component.empty(); // Paper - this.name = name; + //this.name = name; // Paper - Not used anymore this.ipAddress = ipAddress; diff --git a/Spigot-API-Patches/Add-API-for-quit-reason.patch b/Spigot-API-Patches/Add-API-for-quit-reason.patch index 4c0966cdab..ef921afd41 100644 --- a/Spigot-API-Patches/Add-API-for-quit-reason.patch +++ b/Spigot-API-Patches/Add-API-for-quit-reason.patch @@ -9,23 +9,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java @@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; - */ public class PlayerQuitEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); + private net.kyori.adventure.text.Component quitMessage; // Paper + private final QuitReason reason; // Paper - private String quitMessage; + @Deprecated // Paper public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) { + // Paper start + this(who, quitMessage, null); + } ++ @Deprecated // Paper + public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage, @Nullable QuitReason quitReason) { super(who); + this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; -+ // Paper end + } + // Paper start ++ @Deprecated + public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) { ++ this(who, quitMessage, null); ++ } ++ public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage, @Nullable QuitReason quitReason) { + super(who); this.quitMessage = quitMessage; ++ this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; } + /** @@ -0,0 +0,0 @@ public class PlayerQuitEvent extends PlayerEvent { public static HandlerList getHandlerList() { return handlers; diff --git a/Spigot-API-Patches/Add-Ban-Methods-to-Player-Objects.patch b/Spigot-API-Patches/Add-Ban-Methods-to-Player-Objects.patch index 8efa731f17..c770bfca60 100644 --- a/Spigot-API-Patches/Add-Ban-Methods-to-Player-Objects.patch +++ b/Spigot-API-Patches/Add-Ban-Methods-to-Player-Objects.patch @@ -77,9 +77,9 @@ diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/buk index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -0,0 +0,0 @@ import java.net.InetSocketAddress; - import java.util.UUID; +@@ -0,0 +0,0 @@ import java.util.UUID; import com.destroystokyo.paper.Title; // Paper + import net.kyori.adventure.text.Component; import com.destroystokyo.paper.profile.PlayerProfile; // Paper +import java.util.Date; // Paper +import org.bukkit.BanEntry; // Paper diff --git a/Spigot-API-Patches/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch b/Spigot-API-Patches/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch index ee551b4171..8f878513fa 100644 --- a/Spigot-API-Patches/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch +++ b/Spigot-API-Patches/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch @@ -8,12 +8,21 @@ diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/command/CommandSender.java +++ b/src/main/java/org/bukkit/command/CommandSender.java -@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { - @NotNull - Spigot spigot(); - // Spigot end +@@ -0,0 +0,0 @@ + package org.bukkit.command; + + import java.util.UUID; ++import net.kyori.adventure.audience.MessageType; ++import net.kyori.adventure.identity.Identity; ++import net.kyori.adventure.text.Component; + import org.bukkit.Server; + import org.bukkit.permissions.Permissible; + import org.jetbrains.annotations.NotNull; +@@ -0,0 +0,0 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe + default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { + this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message)); + } + -+ // Paper start + /** + * Sends the component to the sender + * @@ -21,7 +30,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * the component will be sent as legacy text.

+ * + * @param component the component to send ++ * @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead + */ ++ @Deprecated + default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + this.sendMessage(component.toLegacyText()); + } @@ -33,9 +44,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * the components will be sent as legacy text.

+ * + * @param components the components to send ++ * @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead + */ ++ @Deprecated + default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + this.sendMessage(new net.md_5.bungee.api.chat.TextComponent(components).toLegacyText()); + } -+ // Paper end + // Paper end } diff --git a/Spigot-API-Patches/Add-Heightmap-API.patch b/Spigot-API-Patches/Add-Heightmap-API.patch index 9fde12961a..47c601e9f4 100644 --- a/Spigot-API-Patches/Add-Heightmap-API.patch +++ b/Spigot-API-Patches/Add-Heightmap-API.patch @@ -106,7 +106,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @NotNull public Block getHighestBlockAt(@NotNull Location location); diff --git a/Spigot-API-Patches/Add-Mob-Goal-API.patch b/Spigot-API-Patches/Add-Mob-Goal-API.patch index d7212f3286..eef545bd33 100644 --- a/Spigot-API-Patches/Add-Mob-Goal-API.patch +++ b/Spigot-API-Patches/Add-Mob-Goal-API.patch @@ -465,7 +465,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @return true if server is in the process of being shutdown */ boolean isStopping(); diff --git a/Spigot-API-Patches/Add-Player-Client-Options-API.patch b/Spigot-API-Patches/Add-Player-Client-Options-API.patch index 9701aa4ede..e1a66a70d0 100644 --- a/Spigot-API-Patches/Add-Player-Client-Options-API.patch +++ b/Spigot-API-Patches/Add-Player-Client-Options-API.patch @@ -185,8 +185,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.UUID; +import com.destroystokyo.paper.ClientOption; // Paper import com.destroystokyo.paper.Title; // Paper + import net.kyori.adventure.text.Component; import com.destroystokyo.paper.profile.PlayerProfile; // Paper - import java.util.Date; // Paper @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * Reset the cooldown counter to 0, effectively starting the cooldown period. */ diff --git a/Spigot-API-Patches/Add-Raw-Byte-ItemStack-Serialization.patch b/Spigot-API-Patches/Add-Raw-Byte-ItemStack-Serialization.patch index 3369e5329c..ff1945465e 100644 --- a/Spigot-API-Patches/Add-Raw-Byte-ItemStack-Serialization.patch +++ b/Spigot-API-Patches/Add-Raw-Byte-ItemStack-Serialization.patch @@ -23,7 +23,7 @@ diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/o index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor return Bukkit.getServer().getItemFactory().ensureServerConversions(this); } diff --git a/Spigot-API-Patches/Add-String-based-Action-Bar-API.patch b/Spigot-API-Patches/Add-String-based-Action-Bar-API.patch index 41b11c8f70..40c557dabf 100644 --- a/Spigot-API-Patches/Add-String-based-Action-Bar-API.patch +++ b/Spigot-API-Patches/Add-String-based-Action-Bar-API.patch @@ -8,6 +8,14 @@ diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/buk index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java +@@ -0,0 +0,0 @@ package org.bukkit.entity; + import java.net.InetSocketAddress; + import java.util.UUID; + import com.destroystokyo.paper.Title; // Paper ++import net.kyori.adventure.text.Component; + import org.bukkit.DyeColor; + import org.bukkit.Effect; + import org.bukkit.GameMode; @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM public void sendMap(@NotNull MapView map); @@ -19,7 +27,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Use Section symbols for legacy color codes to send formatting. + * + * @param message The message to send ++ * @deprecated use {@link #sendActionBar(Component)} + */ ++ @Deprecated + public void sendActionBar(@NotNull String message); + + /** @@ -29,14 +39,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param alternateChar Alternate symbol such as '&' + * @param message The message to send ++ * @deprecated use {@link #sendActionBar(Component)} + */ ++ @Deprecated + public void sendActionBar(char alternateChar, @NotNull String message); + + /** + * Sends an Action Bar message to the client. + * + * @param message The components to send ++ * @deprecated use {@link #sendActionBar(Component)} + */ ++ @Deprecated + public void sendActionBar(@NotNull net.md_5.bungee.api.chat.BaseComponent... message); + /** @@ -61,11 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} for a more proper Action Bar API. This deprecated API may send unsafe items to the client. * @param position the screen position * @param component the components to send - */ -+ @Deprecated - public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @NotNull net.md_5.bungee.api.chat.BaseComponent component) { - throw new UnsupportedOperationException("Not supported yet."); - } + * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM /** * Sends an array of components as a single message to the specified screen position of this player @@ -73,8 +83,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} for a more proper Action Bar API. This deprecated API may send unsafe items to the client. * @param position the screen position * @param components the components to send - */ -+ @Deprecated - public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) { - throw new UnsupportedOperationException("Not supported yet."); - } + * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} diff --git a/Spigot-API-Patches/Add-UnknownCommandEvent.patch b/Spigot-API-Patches/Add-UnknownCommandEvent.patch index 9ac4edab03..6aa95ce301 100644 --- a/Spigot-API-Patches/Add-UnknownCommandEvent.patch +++ b/Spigot-API-Patches/Add-UnknownCommandEvent.patch @@ -12,6 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package org.bukkit.event.command; + ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.command.CommandSender; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Event; @@ -26,9 +28,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final HandlerList handlers = new HandlerList(); + @NotNull private CommandSender sender; + @NotNull private String commandLine; -+ @Nullable private String message; ++ @Nullable private Component message; + ++ @Deprecated + public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final String message) { ++ this(sender, commandLine, message == null ? null : LegacyComponentSerializer.legacySection().deserialize(message)); ++ } ++ ++ public UnknownCommandEvent(@NotNull final CommandSender sender, @NotNull final String commandLine, @Nullable final Component message) { + super(false); + this.sender = sender; + this.commandLine = commandLine; @@ -62,12 +69,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + *

+ * + * @return Unknown command message ++ * @deprecated use {@link #message()} + */ + @Nullable ++ @Deprecated + public String getMessage() { -+ return message; ++ return this.message == null ? null : LegacyComponentSerializer.legacySection().serialize(this.message); + } + ++ /** ++ * Sets message that will be returned ++ *

++ * Set to null to avoid any message being sent ++ * ++ * @param message the message to be returned, or null ++ * @deprecated use {@link #message(Component)} ++ */ ++ @Deprecated ++ public void setMessage(@Nullable String message) { ++ this.message(message == null ? null : LegacyComponentSerializer.legacySection().deserialize(message)); ++ } ++ ++ /** ++ * Gets message that will be returned ++ *

++ * ++ * @return Unknown command message ++ */ ++ @Nullable ++ public Component message() { ++ return this.message; ++ } + + /** + * Sets message that will be returned @@ -76,7 +108,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param message the message to be returned, or null + */ -+ public void setMessage(@Nullable String message) { ++ public void message(@Nullable Component message) { + this.message = message; + } + diff --git a/Spigot-API-Patches/Add-World.getEntity-UUID-API.patch b/Spigot-API-Patches/Add-World.getEntity-UUID-API.patch index d34773e74e..efa2fb77c8 100644 --- a/Spigot-API-Patches/Add-World.getEntity-UUID-API.patch +++ b/Spigot-API-Patches/Add-World.getEntity-UUID-API.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @NotNull public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z); diff --git a/Spigot-API-Patches/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch b/Spigot-API-Patches/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch index 8f49dc6c6f..7e5ca9a179 100644 --- a/Spigot-API-Patches/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch +++ b/Spigot-API-Patches/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch @@ -202,16 +202,16 @@ diff --git a/src/main/java/org/bukkit/NamespacedKey.java b/src/main/java/org/buk index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/NamespacedKey.java +++ b/src/main/java/org/bukkit/NamespacedKey.java -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; * underscores, hyphens, and forward slashes. * */ --public final class NamespacedKey { -+public final class NamespacedKey implements com.destroystokyo.paper.Namespaced { // Paper - implement namespaced +-public final class NamespacedKey implements net.kyori.adventure.key.Key { // Paper - implement Key ++public final class NamespacedKey implements net.kyori.adventure.key.Key, com.destroystokyo.paper.Namespaced { // Paper - implement Key and Namespaced /** * The namespace representing all inbuilt keys. -@@ -0,0 +0,0 @@ public final class NamespacedKey { +@@ -0,0 +0,0 @@ public final class NamespacedKey implements net.kyori.adventure.key.Key { // Pap } @NotNull diff --git a/Spigot-API-Patches/Add-command-to-reload-permissions.yml-and-require-co.patch b/Spigot-API-Patches/Add-command-to-reload-permissions.yml-and-require-co.patch index 4e88150439..d3103ec730 100644 --- a/Spigot-API-Patches/Add-command-to-reload-permissions.yml-and-require-co.patch +++ b/Spigot-API-Patches/Add-command-to-reload-permissions.yml-and-require-co.patch @@ -27,7 +27,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @NotNull Spigot spigot(); // Spigot end diff --git a/Spigot-API-Patches/Add-configuration-option-to-prevent-player-names-fro.patch b/Spigot-API-Patches/Add-configuration-option-to-prevent-player-names-fro.patch index a05dc3eeea..5c6331c286 100644 --- a/Spigot-API-Patches/Add-configuration-option-to-prevent-player-names-fro.patch +++ b/Spigot-API-Patches/Add-configuration-option-to-prevent-player-names-fro.patch @@ -30,7 +30,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi void reloadPermissions(); // Paper boolean reloadCommandAliases(); // Paper diff --git a/Spigot-API-Patches/Add-extended-PaperServerListPingEvent.patch b/Spigot-API-Patches/Add-extended-PaperServerListPingEvent.patch index 993120957f..867a7a4d2c 100644 --- a/Spigot-API-Patches/Add-extended-PaperServerListPingEvent.patch +++ b/Spigot-API-Patches/Add-extended-PaperServerListPingEvent.patch @@ -55,6 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private boolean originalPlayerCount = true; + private Object[] players; + ++ @Deprecated + public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers, + @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) { + super(client.getAddress().getAddress(), motd, numPlayers, maxPlayers); @@ -65,6 +66,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + setServerIcon(favicon); + } + ++ public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull net.kyori.adventure.text.Component motd, int numPlayers, int maxPlayers, ++ @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) { ++ super(client.getAddress().getAddress(), motd, numPlayers, maxPlayers); ++ this.client = client; ++ this.numPlayers = numPlayers; ++ this.version = version; ++ this.protocolVersion = protocolVersion; ++ setServerIcon(favicon); ++ } ++ + /** + * Returns the {@link StatusClient} pinging the server. + * diff --git a/Spigot-API-Patches/Add-getI18NDisplayName-API.patch b/Spigot-API-Patches/Add-getI18NDisplayName-API.patch index 41eaf73ccd..ab34aeefde 100644 --- a/Spigot-API-Patches/Add-getI18NDisplayName-API.patch +++ b/Spigot-API-Patches/Add-getI18NDisplayName-API.patch @@ -32,7 +32,7 @@ diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/o index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor public ItemStack ensureServerConversions() { return Bukkit.getServer().getItemFactory().ensureServerConversions(this); } diff --git a/Spigot-API-Patches/Add-getOfflinePlayerIfCached-String.patch b/Spigot-API-Patches/Add-getOfflinePlayerIfCached-String.patch index 0fe7ab027a..af66cd702b 100644 --- a/Spigot-API-Patches/Add-getOfflinePlayerIfCached-String.patch +++ b/Spigot-API-Patches/Add-getOfflinePlayerIfCached-String.patch @@ -40,7 +40,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @NotNull public OfflinePlayer getOfflinePlayer(@NotNull String name); diff --git a/Spigot-API-Patches/Add-getTPS-method.patch b/Spigot-API-Patches/Add-getTPS-method.patch index c21e8981e5..f8197fc296 100644 --- a/Spigot-API-Patches/Add-getTPS-method.patch +++ b/Spigot-API-Patches/Add-getTPS-method.patch @@ -30,7 +30,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @Nullable Entity getEntity(@NotNull UUID uuid); diff --git a/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch b/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch index 965b5608ef..4140a3a524 100644 --- a/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch +++ b/Spigot-API-Patches/Add-handshake-event-to-allow-plugins-to-handle-clien.patch @@ -13,6 +13,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper.event.player; + ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.format.NamedTextColor; ++import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.apache.commons.lang.Validate; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; @@ -40,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Nullable private UUID uniqueId; + @Nullable private String propertiesJson; + private boolean failed; -+ private String failMessage = "If you wish to use IP forwarding, please enable it in your BungeeCord config as well!"; ++ private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW); + + /** + * Creates a new {@link PlayerHandshakeEvent}. @@ -208,7 +211,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the message to display to the client + */ + @NotNull -+ public String getFailMessage() { ++ public Component failMessage() { + return this.failMessage; + } + @@ -217,9 +220,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param failMessage the message to display to the client + */ ++ public void failMessage(@NotNull Component failMessage) { ++ this.failMessage = failMessage; ++ } ++ ++ /** ++ * Gets the message to display to the client when authentication fails. ++ * ++ * @return the message to display to the client ++ * @deprecated use {@link #failMessage()} ++ */ ++ @NotNull ++ @Deprecated ++ public String getFailMessage() { ++ return LegacyComponentSerializer.legacySection().serialize(this.failMessage()); ++ } ++ ++ /** ++ * Sets the message to display to the client when authentication fails. ++ * ++ * @param failMessage the message to display to the client ++ * @deprecated use {@link #failMessage(Component)} ++ */ ++ @Deprecated + public void setFailMessage(@NotNull String failMessage) { + Validate.notEmpty(failMessage, "fail message cannot be null or empty"); -+ this.failMessage = failMessage; ++ this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage)); + } + + @NotNull diff --git a/Spigot-API-Patches/Add-moon-phase-API.patch b/Spigot-API-Patches/Add-moon-phase-API.patch index b49930cf04..a896539d9f 100644 --- a/Spigot-API-Patches/Add-moon-phase-API.patch +++ b/Spigot-API-Patches/Add-moon-phase-API.patch @@ -50,7 +50,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad * @return The amount of Players in this world */ int getPlayerCount(); diff --git a/Spigot-API-Patches/Add-setMaxPlayers-API.patch b/Spigot-API-Patches/Add-setMaxPlayers-API.patch index 5544f22500..4fe279ad35 100644 --- a/Spigot-API-Patches/Add-setMaxPlayers-API.patch +++ b/Spigot-API-Patches/Add-setMaxPlayers-API.patch @@ -30,7 +30,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ public int getMaxPlayers(); diff --git a/Spigot-API-Patches/Add-sun-related-API.patch b/Spigot-API-Patches/Add-sun-related-API.patch index dc671f6cc7..b3cd1380c1 100644 --- a/Spigot-API-Patches/Add-sun-related-API.patch +++ b/Spigot-API-Patches/Add-sun-related-API.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad */ public void setFullTime(long time); @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + /** - * Gets the full in-game time on this world since the world generation + * Returns whether the world has an ongoing storm. * diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/Spigot-API-Patches/Add-tick-times-API.patch b/Spigot-API-Patches/Add-tick-times-API.patch index 979b97d259..db763554c9 100644 --- a/Spigot-API-Patches/Add-tick-times-API.patch +++ b/Spigot-API-Patches/Add-tick-times-API.patch @@ -38,7 +38,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull public double[] getTPS(); diff --git a/Spigot-API-Patches/Additional-world.getNearbyEntities-API-s.patch b/Spigot-API-Patches/Additional-world.getNearbyEntities-API-s.patch index 5aecca769b..cf3a42a65a 100644 --- a/Spigot-API-Patches/Additional-world.getNearbyEntities-API-s.patch +++ b/Spigot-API-Patches/Additional-world.getNearbyEntities-API-s.patch @@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.Collection; import java.util.HashMap; import java.util.List; -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @NotNull public Collection getEntitiesByClasses(@NotNull Class... classes); diff --git a/Spigot-API-Patches/Adventure.patch b/Spigot-API-Patches/Adventure.patch new file mode 100644 index 0000000000..2d698c606e --- /dev/null +++ b/Spigot-API-Patches/Adventure.patch @@ -0,0 +1,3169 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Riley Park +Date: Fri, 29 Jan 2021 17:21:55 +0100 +Subject: [PATCH] Adventure + +Co-authored-by: zml +Co-authored-by: Jake Potrebic + +diff --git a/pom.xml b/pom.xml +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -0,0 +0,0 @@ + + + ++ ++ ++ net.kyori ++ adventure-api ++ 4.4.0 ++ ++ ++ net.kyori ++ adventure-text-serializer-gson ++ 4.4.0 ++ ++ ++ net.kyori ++ adventure-text-serializer-legacy ++ 4.4.0 ++ ++ ++ net.kyori ++ adventure-text-serializer-plain ++ 4.4.0 ++ ++ + + it.unimi.dsi + fastutil +diff --git a/src/main/java/co/aikar/timings/TimingsReportListener.java b/src/main/java/co/aikar/timings/TimingsReportListener.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/co/aikar/timings/TimingsReportListener.java ++++ b/src/main/java/co/aikar/timings/TimingsReportListener.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + import org.jetbrains.annotations.Nullable; + + @SuppressWarnings("WeakerAccess") +-public class TimingsReportListener implements MessageCommandSender { ++public class TimingsReportListener implements net.kyori.adventure.audience.ForwardingAudience, MessageCommandSender { // Paper + private final List senders; + private final Runnable onDone; + private String timingsURL; +@@ -0,0 +0,0 @@ public class TimingsReportListener implements MessageCommandSender { + this.senders.add(Bukkit.getConsoleSender()); + } + } ++ ++ // Paper start ++ @Override ++ public void sendMessage(final @NotNull net.kyori.adventure.identity.Identity source, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { ++ net.kyori.adventure.audience.ForwardingAudience.super.sendMessage(source, message, type); ++ } ++ ++ @NotNull ++ @Override ++ public Iterable audiences() { ++ return this.senders; ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Bukkit.java ++++ b/src/main/java/org/bukkit/Bukkit.java +@@ -0,0 +0,0 @@ public final class Bukkit { + * + * @param message the message + * @return the number of players ++ * @deprecated in favour of {@link Server#sendMessage(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public static int broadcastMessage(@NotNull String message) { + return server.broadcastMessage(message); + } +@@ -0,0 +0,0 @@ public final class Bukkit { + server.shutdown(); + } + ++ // Paper start + /** + * Broadcasts the specified message to every user with the given + * permission name. +@@ -0,0 +0,0 @@ public final class Bukkit { + * permissibles} must have to receive the broadcast + * @return number of message recipients + */ ++ public static int broadcast(@NotNull net.kyori.adventure.text.Component message, @NotNull String permission) { ++ return server.broadcast(message, permission); ++ } ++ // Paper end ++ /** ++ * Broadcasts the specified message to every user with the given ++ * permission name. ++ * ++ * @param message message to broadcast ++ * @param permission the required permission {@link Permissible ++ * permissibles} must have to receive the broadcast ++ * @return number of message recipients ++ * @deprecated in favour of {@link #broadcast(net.kyori.adventure.text.Component, String)} ++ */ ++ @Deprecated // Paper + public static int broadcast(@NotNull String message, @NotNull String permission) { + return server.broadcast(message, permission); + } +@@ -0,0 +0,0 @@ public final class Bukkit { + return server.createInventory(owner, type); + } + ++ // Paper start + /** + * Creates an empty inventory with the specified type and title. If the type + * is {@link InventoryType#CHEST}, the new inventory has a size of 27; +@@ -0,0 +0,0 @@ public final class Bukkit { + * @see InventoryType#isCreatable() + */ + @NotNull ++ public static Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull net.kyori.adventure.text.Component title) { ++ return server.createInventory(owner, type, title); ++ } ++ // Paper end ++ ++ /** ++ * Creates an empty inventory with the specified type and title. If the type ++ * is {@link InventoryType#CHEST}, the new inventory has a size of 27; ++ * otherwise the new inventory has the normal size for its type.
++ * It should be noted that some inventory types do not support titles and ++ * may not render with said titles on the Minecraft client. ++ *
++ * {@link InventoryType#WORKBENCH} will not process crafting recipes if ++ * created with this method. Use ++ * {@link Player#openWorkbench(Location, boolean)} instead. ++ *
++ * {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s ++ * for possible enchanting results. Use ++ * {@link Player#openEnchanting(Location, boolean)} instead. ++ * ++ * @param owner The holder of the inventory; can be null if there's no holder. ++ * @param type The type of inventory to create. ++ * @param title The title of the inventory, to be displayed when it is viewed. ++ * @return The new inventory. ++ * @throws IllegalArgumentException if the {@link InventoryType} cannot be ++ * viewed. ++ * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)} ++ * ++ * @see InventoryType#isCreatable() ++ */ ++ @Deprecated // Paper ++ @NotNull + public static Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title) { + return server.createInventory(owner, type, title); + } +@@ -0,0 +0,0 @@ public final class Bukkit { + return server.createInventory(owner, size); + } + ++ // Paper start + /** + * Creates an empty inventory of type {@link InventoryType#CHEST} with the + * specified size and title. +@@ -0,0 +0,0 @@ public final class Bukkit { + * @throws IllegalArgumentException if the size is not a multiple of 9 + */ + @NotNull ++ public static Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull net.kyori.adventure.text.Component title) throws IllegalArgumentException { ++ return server.createInventory(owner, size, title); ++ } ++ // Paper end ++ ++ /** ++ * Creates an empty inventory of type {@link InventoryType#CHEST} with the ++ * specified size and title. ++ * ++ * @param owner the holder of the inventory, or null to indicate no holder ++ * @param size a multiple of 9 as the size of inventory to create ++ * @param title the title of the inventory, displayed when inventory is ++ * viewed ++ * @return a new inventory ++ * @throws IllegalArgumentException if the size is not a multiple of 9 ++ * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)} ++ */ ++ @Deprecated // Paper ++ @NotNull + public static Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull String title) throws IllegalArgumentException { + return server.createInventory(owner, size, title); + } + ++ // Paper start + /** + * Creates an empty merchant. + * +@@ -0,0 +0,0 @@ public final class Bukkit { + * when the merchant inventory is viewed + * @return a new merchant + */ ++ public static @NotNull Merchant createMerchant(@Nullable net.kyori.adventure.text.Component title) { ++ return server.createMerchant(title); ++ } ++ // Paper start ++ /** ++ * Creates an empty merchant. ++ * ++ * @param title the title of the corresponding merchant inventory, displayed ++ * when the merchant inventory is viewed ++ * @return a new merchant ++ * @deprecated in favour of {@link #createMerchant(net.kyori.adventure.text.Component)} ++ */ + @NotNull ++ @Deprecated // Paper + public static Merchant createMerchant(@Nullable String title) { + return server.createMerchant(title); + } +@@ -0,0 +0,0 @@ public final class Bukkit { + return server.isPrimaryThread(); + } + ++ // Paper start ++ /** ++ * Gets the message that is displayed on the server list. ++ * ++ * @return the server's MOTD ++ */ ++ @NotNull public static net.kyori.adventure.text.Component motd() { ++ return server.motd(); ++ } ++ // Paper end ++ + /** + * Gets the message that is displayed on the server list. + * + * @return the servers MOTD ++ * @deprecated in favour of {@link #motd()} + */ + @NotNull ++ @Deprecated // Paper + public static String getMotd() { + return server.getMotd(); + } + ++ // Paper start ++ /** ++ * Gets the default message that is displayed when the server is stopped. ++ * ++ * @return the shutdown message ++ */ ++ public static @Nullable net.kyori.adventure.text.Component shutdownMessage() { ++ return server.shutdownMessage(); ++ } ++ // Paper end + /** + * Gets the default message that is displayed when the server is stopped. + * + * @return the shutdown message ++ * @deprecated in favour of {@link #shutdownMessage()} + */ + @Nullable ++ @Deprecated // Paper + public static String getShutdownMessage() { + return server.getShutdownMessage(); + } +diff --git a/src/main/java/org/bukkit/Nameable.java b/src/main/java/org/bukkit/Nameable.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Nameable.java ++++ b/src/main/java/org/bukkit/Nameable.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + + public interface Nameable { + ++ // Paper start ++ /** ++ * Gets the custom name. ++ * ++ *

This value has no effect on players, they will always use their real name.

++ * ++ * @return the custom name ++ */ ++ @Nullable net.kyori.adventure.text.Component customName(); ++ ++ /** ++ * Sets the custom name. ++ * ++ *

This name will be used in death messages and can be sent to the client as a nameplate over the mob.

++ * ++ *

Setting the name to {@code null} will clear it.

++ * ++ *

This value has no effect on players, they will always use their real name.

++ * ++ * @param customName the custom name to set ++ */ ++ void customName(final @Nullable net.kyori.adventure.text.Component customName); ++ // Paper end ++ + /** + * Gets the custom name on a mob or block. If there is no name this method + * will return null. +diff --git a/src/main/java/org/bukkit/NamespacedKey.java b/src/main/java/org/bukkit/NamespacedKey.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/NamespacedKey.java ++++ b/src/main/java/org/bukkit/NamespacedKey.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + * underscores, hyphens, and forward slashes. + * + */ +-public final class NamespacedKey { ++public final class NamespacedKey implements net.kyori.adventure.key.Key { // Paper - implement Key + + /** + * The namespace representing all inbuilt keys. +@@ -0,0 +0,0 @@ public final class NamespacedKey { + public static NamespacedKey minecraft(@NotNull String key) { + return new NamespacedKey(MINECRAFT, key); + } ++ ++ // Paper start ++ @NotNull ++ @Override ++ public String namespace() { ++ return this.getNamespace(); ++ } ++ ++ @NotNull ++ @Override ++ public String value() { ++ return this.getKey(); ++ } ++ ++ @NotNull ++ @Override ++ public String asString() { ++ return this.namespace + ':' + this.key; ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Server.java ++++ b/src/main/java/org/bukkit/Server.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + /** + * Represents a server implementation. + */ +-public interface Server extends PluginMessageRecipient { ++public interface Server extends PluginMessageRecipient, net.kyori.adventure.audience.ForwardingAudience { // Paper + + /** + * Used for all administrative messages, such as an operator using a +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + * + * @param message the message + * @return the number of players ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public int broadcastMessage(@NotNull String message); + + /** +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + * @param permission the required permission {@link Permissible + * permissibles} must have to receive the broadcast + * @return number of message recipients ++ * @deprecated in favour of {@link #broadcast(net.kyori.adventure.text.Component, String)} + */ ++ @Deprecated // Paper + public int broadcast(@NotNull String message, @NotNull String permission); ++ // Paper start ++ /** ++ * Broadcasts the specified message to every user with the given ++ * permission name. ++ * ++ * @param message message to broadcast ++ * @param permission the required permission {@link Permissible ++ * permissibles} must have to receive the broadcast ++ * @return number of message recipients ++ */ ++ int broadcast(@NotNull net.kyori.adventure.text.Component message, @NotNull String permission); ++ // Paper end + + /** + * Gets the player by the given name, regardless if they are offline or +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + @NotNull + Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type); + ++ // Paper start + /** + * Creates an empty inventory with the specified type and title. If the type + * is {@link InventoryType#CHEST}, the new inventory has a size of 27; +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + * @see InventoryType#isCreatable() + */ + @NotNull ++ Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull net.kyori.adventure.text.Component title); ++ // Paper end ++ ++ /** ++ * Creates an empty inventory with the specified type and title. If the type ++ * is {@link InventoryType#CHEST}, the new inventory has a size of 27; ++ * otherwise the new inventory has the normal size for its type.
++ * It should be noted that some inventory types do not support titles and ++ * may not render with said titles on the Minecraft client. ++ *
++ * {@link InventoryType#WORKBENCH} will not process crafting recipes if ++ * created with this method. Use ++ * {@link Player#openWorkbench(Location, boolean)} instead. ++ *
++ * {@link InventoryType#ENCHANTING} will not process {@link ItemStack}s ++ * for possible enchanting results. Use ++ * {@link Player#openEnchanting(Location, boolean)} instead. ++ * ++ * @param owner The holder of the inventory; can be null if there's no holder. ++ * @param type The type of inventory to create. ++ * @param title The title of the inventory, to be displayed when it is viewed. ++ * @return The new inventory. ++ * @throws IllegalArgumentException if the {@link InventoryType} cannot be ++ * viewed. ++ * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)} ++ * ++ * @see InventoryType#isCreatable() ++ */ ++ @Deprecated // Paper ++ @NotNull + Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title); + + /** +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + @NotNull + Inventory createInventory(@Nullable InventoryHolder owner, int size) throws IllegalArgumentException; + ++ // Paper start ++ /** ++ * Creates an empty inventory of type {@link InventoryType#CHEST} with the ++ * specified size and title. ++ * ++ * @param owner the holder of the inventory, or null to indicate no holder ++ * @param size a multiple of 9 as the size of inventory to create ++ * @param title the title of the inventory, displayed when inventory is ++ * viewed ++ * @return a new inventory ++ * @throws IllegalArgumentException if the size is not a multiple of 9 ++ */ ++ @NotNull ++ Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull net.kyori.adventure.text.Component title) throws IllegalArgumentException; ++ // Paper end ++ + /** + * Creates an empty inventory of type {@link InventoryType#CHEST} with the + * specified size and title. +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + * viewed + * @return a new inventory + * @throws IllegalArgumentException if the size is not a multiple of 9 ++ * @deprecated in favour of {@link #createInventory(InventoryHolder, int, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + @NotNull + Inventory createInventory(@Nullable InventoryHolder owner, int size, @NotNull String title) throws IllegalArgumentException; + ++ // Paper start ++ /** ++ * Creates an empty merchant. ++ * ++ * @param title the title of the corresponding merchant inventory, displayed ++ * when the merchant inventory is viewed ++ * @return a new merchant ++ */ ++ @NotNull Merchant createMerchant(@Nullable net.kyori.adventure.text.Component title); ++ // Paper start + /** + * Creates an empty merchant. + * + * @param title the title of the corresponding merchant inventory, displayed + * when the merchant inventory is viewed + * @return a new merchant ++ * @deprecated in favour of {@link #createMerchant(net.kyori.adventure.text.Component)} + */ + @NotNull ++ @Deprecated // Paper + Merchant createMerchant(@Nullable String title); + + /** +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + */ + boolean isPrimaryThread(); + ++ // Paper start ++ /** ++ * Gets the message that is displayed on the server list. ++ * ++ * @return the server's MOTD ++ */ ++ @NotNull net.kyori.adventure.text.Component motd(); ++ // Paper end ++ + /** + * Gets the message that is displayed on the server list. + * + * @return the servers MOTD ++ * @deprecated in favour of {@link #motd()} + */ + @NotNull ++ @Deprecated // Paper + String getMotd(); + ++ // Paper start ++ /** ++ * Gets the default message that is displayed when the server is stopped. ++ * ++ * @return the shutdown message ++ */ ++ @Nullable net.kyori.adventure.text.Component shutdownMessage(); ++ // Paper end + /** + * Gets the default message that is displayed when the server is stopped. + * + * @return the shutdown message ++ * @deprecated in favour of {@link #shutdownMessage()} + */ + @Nullable ++ @Deprecated // Paper + String getShutdownMessage(); + + /** +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + * Sends the component to the player + * + * @param component the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { + * Sends an array of components as a single message to the player + * + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + throw new UnsupportedOperationException("Not supported yet."); + } +diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/World.java ++++ b/src/main/java/org/bukkit/World.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + /** + * Represents a world, which may contain entities, chunks and blocks + */ +-public interface World extends PluginMessageRecipient, Metadatable { ++public interface World extends PluginMessageRecipient, Metadatable, net.kyori.adventure.audience.ForwardingAudience { // Paper + + /** + * Gets the {@link Block} at the given coordinates +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { + @NotNull + public List getPlayers(); + ++ // Paper start ++ @NotNull ++ @Override ++ default Iterable audiences() { ++ return this.getPlayers(); ++ } ++ // Paper end ++ + /** + * Returns a list of entities within a bounding box centered around a + * Location. +diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/Sign.java ++++ b/src/main/java/org/bukkit/block/Sign.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + * Represents a captured state of either a SignPost or a WallSign. + */ + public interface Sign extends TileState, Colorable { ++ // Paper start ++ /** ++ * Gets all the lines of text currently on this sign. ++ * ++ * @return Array of Strings containing each line of text ++ */ ++ @NotNull ++ public java.util.List lines(); ++ ++ /** ++ * Gets the line of text at the specified index. ++ *

++ * For example, getLine(0) will return the first line of text. ++ * ++ * @param index Line number to get the text from, starting at 0 ++ * @throws IndexOutOfBoundsException Thrown when the line does not exist ++ * @return Text on the given line ++ */ ++ @NotNull ++ public net.kyori.adventure.text.Component line(int index) throws IndexOutOfBoundsException; ++ ++ /** ++ * Sets the line of text at the specified index. ++ *

++ * For example, setLine(0, "Line One") will set the first line of text to ++ * "Line One". ++ * ++ * @param index Line number to set the text at, starting from 0 ++ * @param line New text to set at the specified index ++ * @throws IndexOutOfBoundsException If the index is out of the range 0..3 ++ */ ++ public void line(int index, @NotNull net.kyori.adventure.text.Component line) throws IndexOutOfBoundsException; ++ // Paper end + + /** + * Gets all the lines of text currently on this sign. + * + * @return Array of Strings containing each line of text ++ * @deprecated in favour of {@link #lines()} + */ + @NotNull ++ @Deprecated // Paper + public String[] getLines(); + + /** +@@ -0,0 +0,0 @@ public interface Sign extends TileState, Colorable { + * @param index Line number to get the text from, starting at 0 + * @throws IndexOutOfBoundsException Thrown when the line does not exist + * @return Text on the given line ++ * @deprecated in favour of {@link #line(int)} + */ + @NotNull ++ @Deprecated // Paper + public String getLine(int index) throws IndexOutOfBoundsException; + + /** +@@ -0,0 +0,0 @@ public interface Sign extends TileState, Colorable { + * @param index Line number to set the text at, starting from 0 + * @param line New text to set at the specified index + * @throws IndexOutOfBoundsException If the index is out of the range 0..3 ++ * @deprecated in favour of {@link #line(int, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setLine(int index, @NotNull String line) throws IndexOutOfBoundsException; + + /** +diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/command/CommandSender.java ++++ b/src/main/java/org/bukkit/command/CommandSender.java +@@ -0,0 +0,0 @@ import org.bukkit.permissions.Permissible; + import org.jetbrains.annotations.NotNull; + import org.jetbrains.annotations.Nullable; + +-public interface CommandSender extends Permissible { ++public interface CommandSender extends net.kyori.adventure.audience.Audience, Permissible { // Paper + + /** + * Sends this sender a message + * + * @param message Message to be displayed ++ * @see #sendMessage(net.kyori.adventure.text.Component) + */ + public void sendMessage(@NotNull String message); + +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * Sends this sender multiple messages + * + * @param messages An array of messages to be displayed ++ * @see #sendMessage(net.kyori.adventure.text.Component) + */ + public void sendMessage(@NotNull String[] messages); + +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * + * @param message Message to be displayed + * @param sender The sender of this message ++ * @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component) + */ + public void sendMessage(@Nullable UUID sender, @NotNull String message); + +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * + * @param messages An array of messages to be displayed + * @param sender The sender of this message ++ * @see #sendMessage(net.kyori.adventure.identity.Identified, net.kyori.adventure.text.Component) + */ + public void sendMessage(@Nullable UUID sender, @NotNull String[] messages); + +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * Sends this sender a chat component. + * + * @param component the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * Sends an array of components as a single message to the sender. + * + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * + * @param component the components to send + * @param sender the sender of the message ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent component) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + * + * @param components the components to send + * @param sender the sender of the message ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface CommandSender extends Permissible { + @NotNull + Spigot spigot(); + // Spigot end ++ ++ // Paper start ++ @Override ++ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { ++ this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message)); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/command/ProxiedCommandSender.java b/src/main/java/org/bukkit/command/ProxiedCommandSender.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/command/ProxiedCommandSender.java ++++ b/src/main/java/org/bukkit/command/ProxiedCommandSender.java +@@ -0,0 +0,0 @@ package org.bukkit.command; + + import org.jetbrains.annotations.NotNull; + +-public interface ProxiedCommandSender extends CommandSender { ++public interface ProxiedCommandSender extends CommandSender, net.kyori.adventure.audience.ForwardingAudience.Single { // Paper + + /** + * Returns the CommandSender which triggered this proxied command +@@ -0,0 +0,0 @@ public interface ProxiedCommandSender extends CommandSender { + @NotNull + CommandSender getCallee(); + ++ // Paper start ++ @Override ++ default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity source, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { ++ net.kyori.adventure.audience.ForwardingAudience.Single.super.sendMessage(source, message, type); ++ } ++ ++ @NotNull ++ @Override ++ default net.kyori.adventure.audience.Audience audience() { ++ return this.getCaller(); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/enchantments/Enchantment.java ++++ b/src/main/java/org/bukkit/enchantments/Enchantment.java +@@ -0,0 +0,0 @@ public abstract class Enchantment implements Keyed { + * @return True if the enchantment may be applied, otherwise False + */ + public abstract boolean canEnchantItem(@NotNull ItemStack item); ++ // Paper start ++ /** ++ * Get the name of the enchantment with its applied level. ++ *

++ * If the given {@code level} is either less than the {@link #getStartLevel()} or greater than the {@link #getMaxLevel()}, ++ * the level may not be shown in the numeral format one may otherwise expect. ++ *

++ * ++ * @param level the level of the enchantment to show ++ * @return the name of the enchantment with {@code level} applied ++ */ ++ public abstract @NotNull net.kyori.adventure.text.Component displayName(int level); ++ // Paper end + + @Override + public boolean equals(Object obj) { +diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java ++++ b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +@@ -0,0 +0,0 @@ public class EnchantmentWrapper extends Enchantment { + public boolean conflictsWith(@NotNull Enchantment other) { + return getEnchantment().conflictsWith(other); + } ++ // Paper start ++ @NotNull ++ @Override ++ public net.kyori.adventure.text.Component displayName(int level) { ++ return getEnchantment().displayName(level); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Entity.java ++++ b/src/main/java/org/bukkit/entity/Entity.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + /** + * Represents a base entity in the world + */ +-public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder { ++public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource { // Paper + + /** + * Gets the entity's current position +@@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent + @Override + Spigot spigot(); + // Spigot end ++ ++ // Paper start ++ @NotNull ++ @Override ++ default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { ++ return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName()))); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/Player.java ++++ b/src/main/java/org/bukkit/entity/Player.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + /** + * Represents a player, connected or not + */ +-public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient { ++public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified { // Paper ++ ++ // Paper start ++ @Override ++ default @NotNull net.kyori.adventure.identity.Identity identity() { ++ return net.kyori.adventure.identity.Identity.identity(this.getUniqueId()); ++ } ++ ++ /** ++ * Gets the "friendly" name to display of this player. ++ * ++ * @return the display name ++ */ ++ @NotNull net.kyori.adventure.text.Component displayName(); ++ ++ /** ++ * Sets the "friendly" name to display of this player. ++ * ++ * @param displayName the display name to set ++ */ ++ void displayName(final @Nullable net.kyori.adventure.text.Component displayName); ++ // Paper end + + /** + * Gets the "friendly" name to display of this player. This may include +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * places defined by plugins. + * + * @return the friendly name ++ * @deprecated in favour of {@link #displayName()} + */ ++ @Deprecated // Paper + @NotNull + public String getDisplayName(); + +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * places defined by plugins. + * + * @param name The new display name. ++ * @deprecated in favour of {@link #displayName(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setDisplayName(@Nullable String name); + ++ // Paper start ++ /** ++ * Sets the name that is shown on the in-game player list. ++ *

++ * If the value is null, the name will be identical to {@link #getName()}. ++ * ++ * @param name new player list name ++ */ ++ void playerListName(@Nullable net.kyori.adventure.text.Component name); ++ ++ /** ++ * Gets the currently displayed player list header for this player. ++ * ++ * @return player list header or null ++ */ ++ @Nullable net.kyori.adventure.text.Component playerListName(); ++ ++ /** ++ * Gets the currently displayed player list header for this player. ++ * ++ * @return player list header or null ++ * @deprecated in favour of {@link #playerListName()} ++ */ ++ @Nullable net.kyori.adventure.text.Component playerListHeader(); ++ ++ /** ++ * Gets the currently displayed player list footer for this player. ++ * ++ * @return player list header or null ++ */ ++ @Nullable net.kyori.adventure.text.Component playerListFooter(); ++ // Paper end + /** + * Gets the name that is shown on the player list. + * + * @return the player list name ++ * @deprecated in favour of {@link #playerListName()} + */ + @NotNull ++ @Deprecated // Paper + public String getPlayerListName(); + + /** +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * If the value is null, the name will be identical to {@link #getName()}. + * + * @param name new player list name ++ * @deprecated in favour of {@link #playerListName(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setPlayerListName(@Nullable String name); + + /** + * Gets the currently displayed player list header for this player. + * + * @return player list header or null ++ * @deprecated in favour of {@link #playerListHeader()} + */ ++ @Deprecated // Paper + @Nullable + public String getPlayerListHeader(); + +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * Gets the currently displayed player list footer for this player. + * + * @return player list header or null ++ * @deprecated in favour of {@link #playerListFooter()} + */ ++ @Deprecated // Paper + @Nullable + public String getPlayerListFooter(); + +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * Sets the currently displayed player list header for this player. + * + * @param header player list header, null for empty ++ * @deprecated in favour of {@link #sendPlayerListHeader(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setPlayerListHeader(@Nullable String header); + + /** + * Sets the currently displayed player list footer for this player. + * + * @param footer player list footer, null for empty ++ * @deprecated in favour of {@link #sendPlayerListFooter(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setPlayerListFooter(@Nullable String footer); + + /** +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * + * @param header player list header, null for empty + * @param footer player list footer, null for empty ++ * @deprecated in favour of {@link #sendPlayerListHeaderAndFooter(net.kyori.adventure.text.Component, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setPlayerListHeaderFooter(@Nullable String header, @Nullable String footer); + + /** +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * Kicks player with custom kick message. + * + * @param message kick message ++ * @deprecated in favour of {@link #kick(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void kickPlayer(@Nullable String message); + ++ // Paper start ++ /** ++ * Kicks player with custom kick message. ++ * ++ * @param message kick message ++ */ ++ void kick(final @Nullable net.kyori.adventure.text.Component message); ++ // Paper end ++ + /** + * Says a message (or runs a command). + * +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + @Deprecated + public boolean sendChunkChange(@NotNull Location loc, int sx, int sy, int sz, @NotNull byte[] data); + ++ // Paper start + /** + * Send a sign change. This fakes a sign change packet for a user at + * a certain location. This will not actually change the world in any way. +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * @throws IllegalArgumentException if location is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 + */ ++ void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines) throws IllegalArgumentException; ++ /** ++ * Send a sign change. This fakes a sign change packet for a user at ++ * a certain location. This will not actually change the world in any way. ++ * This method will use a sign at the location's block or a faked sign ++ * sent via ++ * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}. ++ *

++ * If the client does not have a sign at the given location it will ++ * display an error message to the user. ++ * ++ * @param loc the location of the sign ++ * @param lines the new text on the sign or null to clear it ++ * @param dyeColor the color of the sign ++ * @throws IllegalArgumentException if location is null ++ * @throws IllegalArgumentException if dyeColor is null ++ * @throws IllegalArgumentException if lines is non-null and has a length less than 4 ++ */ ++ void sendSignChange(@NotNull Location loc, @Nullable java.util.List lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException; ++ // Paper end ++ /** ++ * Send a sign change. This fakes a sign change packet for a user at ++ * a certain location. This will not actually change the world in any way. ++ * This method will use a sign at the location's block or a faked sign ++ * sent via ++ * {@link #sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte)}. ++ *

++ * If the client does not have a sign at the given location it will ++ * display an error message to the user. ++ * ++ * @param loc the location of the sign ++ * @param lines the new text on the sign or null to clear it ++ * @throws IllegalArgumentException if location is null ++ * @throws IllegalArgumentException if lines is non-null and has a length less than 4 ++ * @deprecated in favour of {@link #sendSignChange(org.bukkit.Location, java.util.List)} ++ */ ++ @Deprecated // Paper + public void sendSignChange(@NotNull Location loc, @Nullable String[] lines) throws IllegalArgumentException; + + +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * @throws IllegalArgumentException if location is null + * @throws IllegalArgumentException if dyeColor is null + * @throws IllegalArgumentException if lines is non-null and has a length less than 4 ++ * @deprecated in favour of {@link #sendSignChange(org.bukkit.Location, java.util.List, org.bukkit.DyeColor)} + */ ++ @Deprecated // Paper + public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException; + + /** +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + */ + public int getClientViewDistance(); + ++ // Paper start ++ /** ++ * Gets the player's current locale. ++ * ++ * @return the player's locale ++ */ ++ @NotNull java.util.Locale locale(); ++ // Paper end + /** + * Gets the player's current locale. + * +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * they wish. + * + * @return the player's locale ++ * @deprecated in favour of {@link #locale()} + */ + @NotNull ++ @Deprecated // Paper + public String getLocale(); + + /** +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + */ + public void openBook(@NotNull ItemStack book); + ++ // Paper start ++ @NotNull ++ @Override ++ default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { ++ return net.kyori.adventure.text.event.HoverEvent.showEntity(this.getType().getKey(), this.getUniqueId(), this.displayName()); ++ } ++ // Paper end ++ + // Spigot start + public class Spigot extends Entity.Spigot { + +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + throw new UnsupportedOperationException("Not supported yet."); + } + ++ @Deprecated // Paper + @Override + public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + throw new UnsupportedOperationException("Not supported yet."); + } + ++ @Deprecated // Paper + @Override + public void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + throw new UnsupportedOperationException("Not supported yet."); +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * + * @param position the screen position + * @param component the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @NotNull net.md_5.bungee.api.chat.BaseComponent component) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * + * @param position the screen position + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * @param position the screen position + * @param sender the sender of the message + * @param component the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent component) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * @param position the screen position + * @param sender the sender of the message + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated // Paper + public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + throw new UnsupportedOperationException("Not supported yet."); + +diff --git a/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java b/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java ++++ b/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java +@@ -0,0 +0,0 @@ public interface CommandMinecart extends Minecart { + * same as setting it to "@". + * + * @param name New name for this CommandMinecart. ++ * @deprecated in favour of {@link #customName(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setName(@Nullable String name); + + } +diff --git a/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/src/main/java/org/bukkit/event/block/SignChangeEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/block/SignChangeEvent.java ++++ b/src/main/java/org/bukkit/event/block/SignChangeEvent.java +@@ -0,0 +0,0 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + private final Player player; +- private final String[] lines; ++ // Paper start ++ private final java.util.List adventure$lines; + ++ public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List adventure$lines) { ++ super(theBlock); ++ this.player = player; ++ this.adventure$lines = adventure$lines; ++ } ++ ++ @Deprecated // Paper end + public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines) { + super(theBlock); + this.player = thePlayer; +- this.lines = theLines; ++ // Paper start ++ this.adventure$lines = new java.util.ArrayList<>(); ++ for (String theLine : theLines) { ++ this.adventure$lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(theLine)); ++ } ++ // Paper end + } + + /** +@@ -0,0 +0,0 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { + return player; + } + ++ // Paper start ++ /** ++ * Gets all of the lines of text from the sign involved in this event. ++ * ++ * @return the String array for the sign's lines new text ++ */ ++ public @NotNull java.util.List lines() { ++ return this.adventure$lines; ++ } ++ ++ /** ++ * Gets a single line of text from the sign involved in this event. ++ * ++ * @param index index of the line to get ++ * @return the String containing the line of text associated with the ++ * provided index ++ * @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3 ++ * or < 0} ++ */ ++ public @Nullable net.kyori.adventure.text.Component line(int index) throws IndexOutOfBoundsException { ++ return this.adventure$lines.get(index); ++ } ++ ++ /** ++ * Sets a single line for the sign involved in this event ++ * ++ * @param index index of the line to set ++ * @param line text to set ++ * @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3 ++ * or < 0} ++ */ ++ public void line(int index, @Nullable net.kyori.adventure.text.Component line) throws IndexOutOfBoundsException { ++ this.adventure$lines.set(index, line); ++ } ++ // Paper end ++ + /** + * Gets all of the lines of text from the sign involved in this event. + * + * @return the String array for the sign's lines new text ++ * @deprecated in favour of {@link #lines()} + */ + @NotNull ++ @Deprecated // Paper + public String[] getLines() { +- return lines; ++ return adventure$lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { + * provided index + * @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3 + * or < 0} ++ * @deprecated in favour of {@link #line(int)} + */ + @Nullable ++ @Deprecated // Paper + public String getLine(int index) throws IndexOutOfBoundsException { +- return lines[index]; ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.adventure$lines.get(index)); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { + * @param line text to set + * @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3 + * or < 0} ++ * @deprecated in favour of {@link #line(int, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException { +- lines[index] = line; ++ adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper + } + + @Override +diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java ++++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + */ + public class PlayerDeathEvent extends EntityDeathEvent { + private int newExp = 0; +- private String deathMessage = ""; ++ private net.kyori.adventure.text.Component deathMessage; // Paper + private int newLevel = 0; + private int newTotalExp = 0; + private boolean keepLevel = false; + private boolean keepInventory = false; ++ // Paper start ++ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final net.kyori.adventure.text.Component deathMessage) { ++ this(player, drops, droppedExp, 0, deathMessage); ++ } ++ ++ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, @Nullable final net.kyori.adventure.text.Component deathMessage) { ++ this(player, drops, droppedExp, newExp, 0, 0, deathMessage); ++ } + ++ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final net.kyori.adventure.text.Component deathMessage) { ++ super(player, drops, droppedExp); ++ this.newExp = newExp; ++ this.newTotalExp = newTotalExp; ++ this.newLevel = newLevel; ++ this.deathMessage = deathMessage; ++ } ++ // Paper end ++ ++ @Deprecated // Paper + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { + this(player, drops, droppedExp, 0, deathMessage); + } + ++ @Deprecated // Paper + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, @Nullable final String deathMessage) { + this(player, drops, droppedExp, newExp, 0, 0, deathMessage); + } + ++ @Deprecated // Paper + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { + super(player, drops, droppedExp); + this.newExp = newExp; + this.newTotalExp = newTotalExp; + this.newLevel = newLevel; +- this.deathMessage = deathMessage; ++ this.deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper + } + + @NotNull +@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { + return (Player) entity; + } + ++ // Paper start + /** + * Set the death message that will appear to everyone on the server. + * + * @param deathMessage Message to appear to other players on the server. + */ +- public void setDeathMessage(@Nullable String deathMessage) { ++ public void deathMessage(@Nullable net.kyori.adventure.text.Component deathMessage) { + this.deathMessage = deathMessage; + } + +@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { + * + * @return Message to appear to other players on the server. + */ ++ public @Nullable net.kyori.adventure.text.Component deathMessage() { ++ return this.deathMessage; ++ } ++ // Paper end ++ ++ /** ++ * Set the death message that will appear to everyone on the server. ++ * ++ * @param deathMessage Message to appear to other players on the server. ++ * @deprecated in favour of {@link #deathMessage(net.kyori.adventure.text.Component)} ++ */ ++ @Deprecated // Paper ++ public void setDeathMessage(@Nullable String deathMessage) { ++ this.deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper ++ } ++ ++ /** ++ * Get the death message that will appear to everyone on the server. ++ * ++ * @return Message to appear to other players on the server. ++ * @deprecated in favour of {@link #deathMessage()} ++ */ + @Nullable ++ @Deprecated // Paper + public String getDeathMessage() { +- return deathMessage; ++ return this.deathMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.deathMessage); // Paper + } + + /** +diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/inventory/InventoryType.java ++++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java +@@ -0,0 +0,0 @@ public enum InventoryType { + private final String title; + private final boolean isCreatable; + ++ // Paper start ++ private final net.kyori.adventure.text.Component defaultTitleComponent; ++ ++ /** ++ * Gets the inventory's default title. ++ * ++ * @return the inventory's default title ++ */ ++ public @NotNull net.kyori.adventure.text.Component defaultTitle() { ++ return defaultTitleComponent; ++ } ++ // Paper end + private InventoryType(int defaultSize, /*@NotNull*/ String defaultTitle) { + this(defaultSize, defaultTitle, true); + } +@@ -0,0 +0,0 @@ public enum InventoryType { + size = defaultSize; + title = defaultTitle; + this.isCreatable = isCreatable; ++ this.defaultTitleComponent = net.kyori.adventure.text.Component.text(defaultTitle); // Paper - Adventure + } + + public int getDefaultSize() { +@@ -0,0 +0,0 @@ public enum InventoryType { + } + + @NotNull ++ @Deprecated // Paper + public String getDefaultTitle() { + return title; + } +diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java ++++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + public class AsyncPlayerPreLoginEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private Result result; +- private String message; ++ private net.kyori.adventure.text.Component message; // Paper + private final String name; + private final InetAddress ipAddress; + private final UUID uniqueId; +@@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { + public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { + super(true); + this.result = Result.ALLOWED; +- this.message = ""; ++ this.message = net.kyori.adventure.text.Component.empty(); // Paper + this.name = name; + this.ipAddress = ipAddress; + this.uniqueId = uniqueId; +@@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { + this.result = result == null ? null : Result.valueOf(result.name()); + } + ++ // Paper start + /** + * Gets the current kick message that will be used if getResult() != + * Result.ALLOWED +@@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { + * @return Current kick message + */ + @NotNull +- public String getKickMessage() { ++ public net.kyori.adventure.text.Component kickMessage() { + return message; + } + +@@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { + * + * @param message New kick message + */ +- public void setKickMessage(@NotNull final String message) { ++ public void kickMessage(@NotNull final net.kyori.adventure.text.Component message) { ++ this.message = message; ++ } ++ ++ /** ++ * Disallows the player from logging in, with the given reason ++ * ++ * @param result New result for disallowing the player ++ * @param message Kick message to display to the user ++ */ ++ public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) { ++ this.result = result; + this.message = message; + } + ++ /** ++ * Disallows the player from logging in, with the given reason ++ * ++ * @param result New result for disallowing the player ++ * @param message Kick message to display to the user ++ * @deprecated This method uses a deprecated enum from {@link ++ * PlayerPreLoginEvent} ++ * @see #disallow(Result, String) ++ */ ++ @Deprecated ++ public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final net.kyori.adventure.text.Component message) { ++ this.result = result == null ? null : Result.valueOf(result.name()); ++ this.message = message; ++ } ++ // Paper end ++ /** ++ * Gets the current kick message that will be used if getResult() != ++ * Result.ALLOWED ++ * ++ * @return Current kick message ++ * @deprecated in favour of {@link #kickMessage()} ++ */ ++ @NotNull ++ @Deprecated // Paper ++ public String getKickMessage() { ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper ++ } ++ ++ /** ++ * Sets the kick message to display if getResult() != Result.ALLOWED ++ * ++ * @param message New kick message ++ * @deprecated in favour of {@link #kickMessage(net.kyori.adventure.text.Component)} ++ */ ++ @Deprecated // Paper ++ public void setKickMessage(@NotNull final String message) { ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper ++ } ++ + /** + * Allows the player to log in + */ + public void allow() { + result = Result.ALLOWED; +- message = ""; ++ message = net.kyori.adventure.text.Component.empty(); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { + * + * @param result New result for disallowing the player + * @param message Kick message to display to the user ++ * @deprecated in favour of {@link #disallow(org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void disallow(@NotNull final Result result, @NotNull final String message) { + this.result = result; +- this.message = message; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class AsyncPlayerPreLoginEvent extends Event { + @Deprecated + public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final String message) { + this.result = result == null ? null : Result.valueOf(result.name()); +- this.message = message; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + } + + /** +diff --git a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + */ + public class PlayerJoinEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); +- private String joinMessage; ++ // Paper start ++ private net.kyori.adventure.text.Component joinMessage; ++ public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final net.kyori.adventure.text.Component joinMessage) { ++ super(playerJoined); ++ this.joinMessage = joinMessage; ++ } + ++ @Deprecated // Paper end + public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) { + super(playerJoined); ++ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : net.kyori.adventure.text.Component.empty(); // Paper end ++ } ++ ++ // Paper start ++ /** ++ * Gets the join message to send to all online players ++ * ++ * @return string join message. Can be null ++ */ ++ public @Nullable net.kyori.adventure.text.Component joinMessage() { ++ return this.joinMessage; ++ } ++ ++ /** ++ * Sets the join message to send to all online players ++ * ++ * @param joinMessage join message. If null, no message will be sent ++ */ ++ public void joinMessage(@Nullable net.kyori.adventure.text.Component joinMessage) { + this.joinMessage = joinMessage; + } ++ // Paper end + + /** + * Gets the join message to send to all online players + * + * @return string join message. Can be null ++ * @deprecated in favour of {@link #joinMessage()} + */ + @Nullable ++ @Deprecated // Paper + public String getJoinMessage() { +- return joinMessage; ++ return this.joinMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.joinMessage); // Paper + } + + /** + * Sets the join message to send to all online players + * + * @param joinMessage join message. If null, no message will be sent ++ * @deprecated in favour of {@link #joinMessage(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setJoinMessage(@Nullable String joinMessage) { +- this.joinMessage = joinMessage; ++ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : net.kyori.adventure.text.Component.empty(); // Paper + } + + @NotNull +diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + */ + public class PlayerKickEvent extends PlayerEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); +- private String leaveMessage; +- private String kickReason; ++ private net.kyori.adventure.text.Component leaveMessage; // Paper ++ private net.kyori.adventure.text.Component kickReason; // Paper + private Boolean cancel; + ++ @Deprecated // Paper + public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) { ++ super(playerKicked); ++ this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper ++ this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper ++ this.cancel = false; ++ } ++ // Paper start ++ public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final net.kyori.adventure.text.Component kickReason, @NotNull final net.kyori.adventure.text.Component leaveMessage) { + super(playerKicked); + this.kickReason = kickReason; + this.leaveMessage = leaveMessage; + this.cancel = false; + } + ++ /** ++ * Gets the leave message send to all online players ++ * ++ * @return string kick reason ++ */ ++ public @NotNull net.kyori.adventure.text.Component leaveMessage() { ++ return this.leaveMessage; ++ } ++ ++ /** ++ * Sets the leave message send to all online players ++ * ++ * @param leaveMessage leave message ++ */ ++ public void leaveMessage(@NotNull net.kyori.adventure.text.Component leaveMessage) { ++ this.leaveMessage = leaveMessage; ++ } ++ + /** + * Gets the reason why the player is getting kicked + * + * @return string kick reason + */ ++ public @NotNull net.kyori.adventure.text.Component reason() { ++ return this.kickReason; ++ } ++ ++ /** ++ * Sets the reason why the player is getting kicked ++ * ++ * @param kickReason kick reason ++ */ ++ public void reason(@NotNull net.kyori.adventure.text.Component kickReason) { ++ this.kickReason = kickReason; ++ } ++ // Paper end ++ ++ /** ++ * Gets the reason why the player is getting kicked ++ * ++ * @return string kick reason ++ * @deprecated in favour of {@link #reason()} ++ */ + @NotNull ++ @Deprecated // Paper + public String getReason() { +- return kickReason; ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.kickReason); // Paper + } + + /** + * Gets the leave message send to all online players + * + * @return string kick reason ++ * @deprecated in favour of {@link #leaveMessage()} + */ + @NotNull ++ @Deprecated // Paper + public String getLeaveMessage() { +- return leaveMessage; ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.leaveMessage); // Paper + } + + @Override +@@ -0,0 +0,0 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { + * Sets the reason why the player is getting kicked + * + * @param kickReason kick reason ++ * @deprecated in favour of {@link #reason(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setReason(@NotNull String kickReason) { +- this.kickReason = kickReason; ++ this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper + } + + /** + * Sets the leave message send to all online players + * + * @param leaveMessage leave message ++ * @deprecated in favour of {@link #leaveMessage(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setLeaveMessage(@NotNull String leaveMessage) { +- this.leaveMessage = leaveMessage; ++ this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper + } + + @NotNull +diff --git a/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java b/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java +@@ -0,0 +0,0 @@ public class PlayerLocaleChangeEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); + // + private final String locale; ++ // Paper start ++ private final java.util.Locale adventure$locale; ++ /** ++ * @see Player#getLocale() ++ * ++ * @return the player's new locale ++ */ ++ public @NotNull java.util.Locale locale() { ++ return this.adventure$locale; ++ } ++ // Paper end + + public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) { + super(who); + this.locale = locale; ++ this.adventure$locale = net.kyori.adventure.translation.Translator.parseLocale(locale); // Paper + } + + /** + * @see Player#getLocale() + * + * @return the player's new locale ++ * @deprecated in favour of {@link #locale()} + */ + @NotNull ++ @Deprecated // Paper + public String getLocale() { + return locale; + } +diff --git a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +@@ -0,0 +0,0 @@ public class PlayerLoginEvent extends PlayerEvent { + private final InetAddress address; + private final String hostname; + private Result result = Result.ALLOWED; +- private String message = ""; ++ private net.kyori.adventure.text.Component message = net.kyori.adventure.text.Component.empty(); + private final InetAddress realAddress; // Spigot + + /** +@@ -0,0 +0,0 @@ public class PlayerLoginEvent extends PlayerEvent { + * @param result The result status for this event + * @param message The message to be displayed if result denies login + * @param realAddress the actual, unspoofed connecting address ++ * @deprecated in favour of {@link #PlayerLoginEvent(Player, String, InetAddress, Result, net.kyori.adventure.text.Component, InetAddress)} + */ ++ @Deprecated // Paper + public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message, @NotNull final InetAddress realAddress) { // Spigot + this(player, hostname, address, realAddress); // Spigot + this.result = result; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper ++ } ++ ++ // Paper start ++ /** ++ * This constructor pre-configures the event with a result and message ++ * ++ * @param player The {@link Player} for this event ++ * @param hostname The hostname that was used to connect to the server ++ * @param address The address the player used to connect, provided for ++ * timing issues ++ * @param result The result status for this event ++ * @param message The message to be displayed if result denies login ++ * @param realAddress the actual, unspoofed connecting address ++ */ ++ public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message, @NotNull final InetAddress realAddress) { // Spigot ++ this(player, hostname, address, realAddress); // Spigot ++ this.result = result; ++ this.message = message; ++ } ++ ++ /** ++ * Gets the current kick message that will be used if getResult() != ++ * Result.ALLOWED ++ * ++ * @return Current kick message ++ */ ++ public @NotNull net.kyori.adventure.text.Component kickMessage() { ++ return this.message; ++ } ++ ++ /** ++ * Sets the kick message to display if getResult() != Result.ALLOWED ++ * ++ * @param message New kick message ++ */ ++ public void kickMessage(@NotNull net.kyori.adventure.text.Component message) { + this.message = message; + } ++ // Paper end + + // Spigot start + /** +@@ -0,0 +0,0 @@ public class PlayerLoginEvent extends PlayerEvent { + * Result.ALLOWED + * + * @return Current kick message ++ * @deprecated in favour of {@link #kickMessage()} + */ + @NotNull ++ @Deprecated // Paper + public String getKickMessage() { +- return message; ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + } + + /** + * Sets the kick message to display if getResult() != Result.ALLOWED + * + * @param message New kick message ++ * @deprecated in favour of {@link #kickMessage(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setKickMessage(@NotNull final String message) { +- this.message = message; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class PlayerLoginEvent extends PlayerEvent { + */ + public void allow() { + result = Result.ALLOWED; +- message = ""; ++ message = net.kyori.adventure.text.Component.empty(); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class PlayerLoginEvent extends PlayerEvent { + * + * @param result New result for disallowing the player + * @param message Kick message to display to the user ++ * @deprecated in favour of {@link #disallow(Result, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper start + public void disallow(@NotNull final Result result, @NotNull final String message) { ++ this.result = result; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); ++ } ++ /** ++ * Disallows the player from logging in, with the given reason ++ * ++ * @param result New result for disallowing the player ++ * @param message Kick message to display to the user ++ */ ++ public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) { ++ // Paper end + this.result = result; + this.message = message; + } +diff --git a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + public class PlayerPreLoginEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + private Result result; +- private String message; ++ private net.kyori.adventure.text.Component message; // Paper + private final String name; + private final InetAddress ipAddress; + private final UUID uniqueId; +@@ -0,0 +0,0 @@ public class PlayerPreLoginEvent extends Event { + + public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { + this.result = Result.ALLOWED; +- this.message = ""; ++ this.message = net.kyori.adventure.text.Component.empty(); // Paper + this.name = name; + this.ipAddress = ipAddress; + this.uniqueId = uniqueId; +@@ -0,0 +0,0 @@ public class PlayerPreLoginEvent extends Event { + this.result = result; + } + ++ // Paper start + /** + * Gets the current kick message that will be used if getResult() != + * Result.ALLOWED +@@ -0,0 +0,0 @@ public class PlayerPreLoginEvent extends Event { + * @return Current kick message + */ + @NotNull +- public String getKickMessage() { ++ public net.kyori.adventure.text.Component kickMessage() { + return message; + } + +@@ -0,0 +0,0 @@ public class PlayerPreLoginEvent extends Event { + * + * @param message New kick message + */ +- public void setKickMessage(@NotNull final String message) { ++ public void kickMessage(@NotNull final net.kyori.adventure.text.Component message) { + this.message = message; + } + ++ /** ++ * Disallows the player from logging in, with the given reason ++ * ++ * @param result New result for disallowing the player ++ * @param message Kick message to display to the user ++ */ ++ public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) { ++ this.result = result; ++ this.message = message; ++ } ++ // Paper end ++ /** ++ * Gets the current kick message that will be used if getResult() != ++ * Result.ALLOWED ++ * ++ * @return Current kick message ++ * @deprecated in favour of {@link #kickMessage()} ++ */ ++ @Deprecated // Paper ++ @NotNull ++ public String getKickMessage() { ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper ++ } ++ ++ /** ++ * Sets the kick message to display if getResult() != Result.ALLOWED ++ * ++ * @param message New kick message ++ * @deprecated in favour of {@link #kickMessage(net.kyori.adventure.text.Component)} ++ */ ++ @Deprecated // Paper ++ public void setKickMessage(@NotNull final String message) { ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper ++ } ++ + /** + * Allows the player to log in + */ + public void allow() { + result = Result.ALLOWED; +- message = ""; ++ message = net.kyori.adventure.text.Component.empty(); // Paper + } + + /** +@@ -0,0 +0,0 @@ public class PlayerPreLoginEvent extends Event { + * + * @param result New result for disallowing the player + * @param message Kick message to display to the user ++ * @deprecated in favour of {@link #disallow(org.bukkit.event.player.PlayerPreLoginEvent.Result, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void disallow(@NotNull final Result result, @NotNull final String message) { + this.result = result; +- this.message = message; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + } + + /** +diff --git a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + */ + public class PlayerQuitEvent extends PlayerEvent { + private static final HandlerList handlers = new HandlerList(); +- private String quitMessage; ++ private net.kyori.adventure.text.Component quitMessage; // Paper + ++ @Deprecated // Paper + public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) { + super(who); ++ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : net.kyori.adventure.text.Component.empty(); // Paper ++ } ++ // Paper start ++ public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) { ++ super(who); ++ this.quitMessage = quitMessage; ++ } ++ ++ /** ++ * Gets the quit message to send to all online players ++ * ++ * @return string quit message ++ */ ++ public @Nullable net.kyori.adventure.text.Component quitMessage() { ++ return quitMessage; ++ } ++ ++ /** ++ * Sets the quit message to send to all online players ++ * ++ * @param quitMessage quit message ++ */ ++ public void quitMessage(@Nullable net.kyori.adventure.text.Component quitMessage) { + this.quitMessage = quitMessage; + } ++ // Paper end + + /** + * Gets the quit message to send to all online players + * + * @return string quit message ++ * @deprecated in favour of {@link #quitMessage()} + */ + @Nullable ++ @Deprecated // Paper + public String getQuitMessage() { +- return quitMessage; ++ return this.quitMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.quitMessage); // Paper + } + + /** + * Sets the quit message to send to all online players + * + * @param quitMessage quit message ++ * @deprecated in favour of {@link #quitMessage(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setQuitMessage(@Nullable String quitMessage) { +- this.quitMessage = quitMessage; ++ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : net.kyori.adventure.text.Component.empty(); // Paper + } + + @NotNull +diff --git a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java ++++ b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + public class BroadcastMessageEvent extends ServerEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); +- private String message; ++ private net.kyori.adventure.text.Component message; // Paper + private final Set recipients; + private boolean cancelled = false; + +@@ -0,0 +0,0 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { + this(false, message, recipients); + } + ++ @Deprecated // Paper + public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set recipients) { ++ // Paper start ++ super(isAsync); ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); ++ this.recipients = recipients; ++ } ++ ++ @Deprecated ++ public BroadcastMessageEvent(@NotNull net.kyori.adventure.text.Component message, @NotNull Set recipients) { ++ this(false, message, recipients); ++ } ++ ++ public BroadcastMessageEvent(boolean isAsync, @NotNull net.kyori.adventure.text.Component message, @NotNull Set recipients) { ++ // Paper end + super(isAsync); + this.message = message; + this.recipients = recipients; + } ++ // Paper start ++ /** ++ * Get the broadcast message. ++ * ++ * @return Message to broadcast ++ */ ++ public @NotNull net.kyori.adventure.text.Component message() { ++ return this.message; ++ } ++ ++ /** ++ * Set the broadcast message. ++ * ++ * @param message New message to broadcast ++ */ ++ public void message(@NotNull net.kyori.adventure.text.Component message) { ++ this.message = message; ++ } ++ // Paper end + + /** + * Get the message to broadcast. + * + * @return Message to broadcast ++ * @deprecated in favour of {@link #message()} + */ + @NotNull ++ @Deprecated // Paper + public String getMessage() { +- return message; ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + } + + /** + * Set the message to broadcast. + * + * @param message New message to broadcast ++ * @deprecated in favour of {@link #message(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setMessage(@NotNull String message) { +- this.message = message; ++ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + } + + /** +diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java ++++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +@@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable + private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE; + private static final HandlerList handlers = new HandlerList(); + private final InetAddress address; +- private String motd; ++ private net.kyori.adventure.text.Component motd; // Paper + private final int numPlayers; + private int maxPlayers; + ++ @Deprecated // Paper + public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) { + super(true); + Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); + this.address = address; +- this.motd = motd; ++ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper + this.numPlayers = numPlayers; + this.maxPlayers = maxPlayers; + } +@@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable + * @param address the address of the pinger + * @param motd the message of the day + * @param maxPlayers the max number of players ++ * @deprecated in favour of {@link #ServerListPingEvent(java.net.InetAddress, net.kyori.adventure.text.Component, int)} + */ ++ @Deprecated // Paper + protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) { ++ super(true); ++ this.numPlayers = MAGIC_PLAYER_COUNT; ++ this.address = address; ++ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper ++ this.maxPlayers = maxPlayers; ++ } ++ // Paper start ++ public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int numPlayers, final int maxPlayers) { ++ super(true); ++ Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); ++ this.address = address; ++ this.motd = motd; ++ this.numPlayers = numPlayers; ++ this.maxPlayers = maxPlayers; ++ } ++ /** ++ * This constructor is intended for implementations that provide the ++ * {@link #iterator()} method, thus provided the {@link #getNumPlayers()} ++ * count. ++ * ++ * @param address the address of the pinger ++ * @param motd the message of the day ++ * @param maxPlayers the max number of players ++ */ ++ protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int maxPlayers) { + super(true); + this.numPlayers = MAGIC_PLAYER_COUNT; + this.address = address; + this.motd = motd; + this.maxPlayers = maxPlayers; + } ++ /** ++ * Get the message of the day message. ++ * ++ * @return the message of the day ++ */ ++ public @NotNull net.kyori.adventure.text.Component motd() { ++ return motd; ++ } ++ /** ++ * Change the message of the day message. ++ * ++ * @param motd the message of the day ++ */ ++ public void motd(@NotNull net.kyori.adventure.text.Component motd) { ++ this.motd = motd; ++ } ++ // Paper end + + /** + * Get the address the ping is coming from. +@@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable + * Get the message of the day message. + * + * @return the message of the day ++ * @deprecated in favour of {@link #motd()} + */ + @NotNull ++ @Deprecated // Paper + public String getMotd() { +- return motd; ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.motd); // Paper + } + + /** + * Change the message of the day message. + * + * @param motd the message of the day ++ * @deprecated in favour of {@link #motd(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setMotd(@NotNull String motd) { +- this.motd = motd; ++ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper + } + + /** +diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/InventoryView.java ++++ b/src/main/java/org/bukkit/inventory/InventoryView.java +@@ -0,0 +0,0 @@ public abstract class InventoryView { + return getPlayer().setWindowProperty(prop, value); + } + ++ // Paper start + /** + * Get the title of this inventory window. + * + * @return The title. + */ + @NotNull ++ public abstract net.kyori.adventure.text.Component title(); ++ // Paper end ++ ++ /** ++ * Get the title of this inventory window. ++ * ++ * @return The title. ++ * @deprecated in favour of {@link #title()} ++ */ ++ @Deprecated // Paper ++ @NotNull + public abstract String getTitle(); + } +diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/ItemFactory.java ++++ b/src/main/java/org/bukkit/inventory/ItemFactory.java +@@ -0,0 +0,0 @@ public interface ItemFactory { + @Deprecated + @NotNull + Material updateMaterial(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException; ++ ++ // Paper start ++ /** ++ * Creates a hover event for the given item. ++ * ++ * @param item The item ++ * @return A hover event ++ */ ++ @NotNull ++ net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator op); ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/ItemStack.java ++++ b/src/main/java/org/bukkit/inventory/ItemStack.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * use this class to encapsulate Materials for which {@link Material#isItem()} + * returns false. + */ +-public class ItemStack implements Cloneable, ConfigurationSerializable { ++public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyori.adventure.text.event.HoverEventSource { // Paper + private Material type = Material.AIR; + private int amount = 0; + private MaterialData data = null; +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { + + return true; + } ++ ++ // Paper start ++ @NotNull ++ @Override ++ public net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { ++ return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/src/main/java/org/bukkit/inventory/meta/BookMeta.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/meta/BookMeta.java ++++ b/src/main/java/org/bukkit/inventory/meta/BookMeta.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * Represents a book ({@link Material#WRITABLE_BOOK} or {@link + * Material#WRITTEN_BOOK}) that can have a title, an author, and pages. + */ +-public interface BookMeta extends ItemMeta { ++public interface BookMeta extends ItemMeta, net.kyori.adventure.inventory.Book { // Paper + + /** + * Represents the generation (or level of copying) of a written book +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + */ + boolean hasPages(); + ++ // Paper start ++ /** ++ * Gets the title of the book. ++ *

++ * Plugins should check that hasTitle() returns true before calling this ++ * method. ++ * ++ * @return the title of the book ++ */ ++ @Nullable ++ @Override ++ net.kyori.adventure.text.Component title(); ++ ++ /** ++ * Sets the title of the book. ++ *

++ * Limited to 32 characters. Removes title when given null. ++ * ++ * @param title the title to set ++ * @return true if the title was successfully set ++ */ ++ @NotNull ++ @Override ++ BookMeta title(@Nullable net.kyori.adventure.text.Component title); ++ ++ /** ++ * Gets the author of the book. ++ *

++ * Plugins should check that hasAuthor() returns true before calling this ++ * method. ++ * ++ * @return the author of the book ++ */ ++ @Nullable ++ @Override ++ net.kyori.adventure.text.Component author(); ++ ++ /** ++ * Sets the author of the book. Removes author when given null. ++ * ++ * @param author the author to set ++ */ ++ @NotNull ++ @Override ++ BookMeta author(@Nullable net.kyori.adventure.text.Component author); ++ /** ++ * Gets the specified page in the book. The page must exist. ++ *

++ * Pages are 1-indexed. ++ * ++ * @param page the page number to get, in range [1, getPageCount()] ++ * @return the page from the book ++ */ ++ @NotNull net.kyori.adventure.text.Component page(int page); ++ ++ /** ++ * Sets the specified page in the book. Pages of the book must be ++ * contiguous. ++ *

++ * The data can be up to 256 characters in length, additional characters ++ * are truncated. ++ *

++ * Pages are 1-indexed. ++ * ++ * @param page the page number to set, in range [1, getPageCount()] ++ * @param data the data to set for that page ++ */ ++ void page(int page, @NotNull net.kyori.adventure.text.Component data); ++ ++ /** ++ * Adds new pages to the end of the book. Up to a maximum of 50 pages with ++ * 256 characters per page. ++ * ++ * @param pages A list of strings, each being a page ++ */ ++ void addPages(@NotNull net.kyori.adventure.text.Component... pages); ++ ++ interface BookMetaBuilder extends Builder { ++ ++ @NotNull ++ @Override ++ BookMetaBuilder title(@Nullable net.kyori.adventure.text.Component title); ++ ++ @NotNull ++ @Override ++ BookMetaBuilder author(@Nullable net.kyori.adventure.text.Component author); ++ ++ @NotNull ++ @Override ++ BookMetaBuilder addPage(@NotNull net.kyori.adventure.text.Component page); ++ ++ @NotNull ++ @Override ++ BookMetaBuilder pages(@NotNull net.kyori.adventure.text.Component... pages); ++ ++ @NotNull ++ @Override ++ BookMetaBuilder pages(@NotNull java.util.Collection pages); ++ ++ @NotNull ++ @Override ++ BookMeta build(); ++ } ++ // Paper end ++ + /** + * Gets the specified page in the book. The given page must exist. + *

+@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * + * @param page the page number to get, in range [1, getPageCount()] + * @return the page from the book ++ * @deprecated in favour of {@link #page(int)} + */ + @NotNull ++ @Deprecated // Paper + String getPage(int page); + + /** +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * + * @param page the page number to set, in range [1, getPageCount()] + * @param data the data to set for that page ++ * @deprecated in favour of {@link #page(int, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + void setPage(int page, @NotNull String data); + + /** + * Gets all the pages in the book. + * + * @return list of all the pages in the book ++ * @deprecated in favour of {@link #pages()} + */ + @NotNull ++ @Deprecated // Paper + List getPages(); + + /** +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * pages. Maximum 100 pages with 256 characters per page. + * + * @param pages A list of pages to set the book to use ++ * @deprecated in favour of {@link #pages(List)} + */ ++ @Deprecated // Paper + void setPages(@NotNull List pages); + + /** +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * pages. Maximum 50 pages with 256 characters per page. + * + * @param pages A list of strings, each being a page ++ * @deprecated in favour of {@link #pages(net.kyori.adventure.text.Component...)} + */ ++ @Deprecated // Paper + void setPages(@NotNull String... pages); + + /** +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * 256 characters per page. + * + * @param pages A list of strings, each being a page ++ * @deprecated in favour of {@link #addPages(net.kyori.adventure.text.Component...)} + */ ++ @Deprecated // Paper + void addPage(@NotNull String... pages); + + /** +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * + * @param page the page number to get + * @return the page from the book ++ * @deprecated in favour of {@link #page(int)} + */ + @NotNull ++ @Deprecated // Paper + public BaseComponent[] getPage(int page) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * + * @param page the page number to set + * @param data the data to set for that page ++ * @deprecated in favour of {@link #page(int, net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setPage(int page, @Nullable BaseComponent... data) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * Gets all the pages in the book. + * + * @return list of all the pages in the book ++ * @deprecated in favour of {@link #pages()} + */ + @NotNull ++ @Deprecated // Paper + public List getPages() { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * pages. Maximum 50 pages with 256 characters per page. + * + * @param pages A list of pages to set the book to use ++ * @deprecated in favour of {@link #pages(java.util.List)} + */ ++ @Deprecated // Paper + public void setPages(@NotNull List pages) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * pages. Maximum 50 pages with 256 characters per page. + * + * @param pages A list of component arrays, each being a page ++ * @deprecated in favour of {@link #pages(net.kyori.adventure.text.Component...)} + */ ++ @Deprecated // Paper + public void setPages(@NotNull BaseComponent[]... pages) { + throw new UnsupportedOperationException("Not supported yet."); + } +@@ -0,0 +0,0 @@ public interface BookMeta extends ItemMeta { + * with 256 characters per page. + * + * @param pages A list of component arrays, each being a page ++ * @deprecated in favour of {@link #addPages(net.kyori.adventure.text.Component...)} + */ ++ @Deprecated // Paper + public void addPage(@NotNull BaseComponent[]... pages) { + throw new UnsupportedOperationException("Not supported yet."); + } +diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java ++++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + */ + boolean hasDisplayName(); + ++ // Paper start ++ /** ++ * Gets the display name. ++ * ++ *

Plugins should check that {@link #hasDisplayName()} returns true before calling this method.

++ * ++ * @return the display name ++ */ ++ @Nullable net.kyori.adventure.text.Component displayName(); ++ ++ /** ++ * Sets the display name. ++ * ++ * @param displayName the display name to set ++ */ ++ void displayName(final @Nullable net.kyori.adventure.text.Component displayName); ++ // Paper end ++ + /** + * Gets the display name that is set. + *

+@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + * before calling this method. + * + * @return the display name that is set ++ * @deprecated in favour of {@link #displayName()} + */ ++ @Deprecated // Paper + @NotNull + String getDisplayName(); + +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + * Sets the display name. + * + * @param name the name to set ++ * @deprecated in favour of {@link #displayName(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + void setDisplayName(@Nullable String name); + + /** +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + */ + boolean hasLore(); + ++ // Paper start ++ /** ++ * Gets the lore. ++ * ++ *

Plugins should check that {@link #hasLore()} returns true before calling this method.

++ * ++ * @return the display name ++ */ ++ @Nullable List lore(); ++ ++ /** ++ * Sets the lore. ++ * ++ * @param lore the lore to set ++ */ ++ void lore(final @Nullable List lore); ++ // Paper end ++ + /** + * Gets the lore that is set. + *

+@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + * calling this method. + * + * @return a list of lore that is set ++ * @deprecated in favour of {@link #lore()} + */ ++ @Deprecated // Paper + @Nullable + List getLore(); + +@@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste + * Removes lore when given null. + * + * @param lore the lore that will be set ++ * @deprecated in favour of {@link #lore(List)} + */ ++ @Deprecated // Paper + void setLore(@Nullable List lore); + + /** +diff --git a/src/main/java/org/bukkit/map/MapCursor.java b/src/main/java/org/bukkit/map/MapCursor.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/map/MapCursor.java ++++ b/src/main/java/org/bukkit/map/MapCursor.java +@@ -0,0 +0,0 @@ public final class MapCursor { + private byte x, y; + private byte direction, type; + private boolean visible; +- private String caption; ++ private net.kyori.adventure.text.Component caption; // Paper + + /** + * Initialize the map cursor. +@@ -0,0 +0,0 @@ public final class MapCursor { + */ + @Deprecated + public MapCursor(byte x, byte y, byte direction, byte type, boolean visible) { +- this(x, y, direction, type, visible, null); ++ this(x, y, direction, type, visible, (String) null); // Paper + } + + /** +@@ -0,0 +0,0 @@ public final class MapCursor { + * @param visible Whether the cursor is visible by default. + */ + public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible) { +- this(x, y, direction, type, visible, null); ++ this(x, y, direction, type, visible, (String) null); // Paper + } + + /** +@@ -0,0 +0,0 @@ public final class MapCursor { + * @param type The type (color/style) of the map cursor. + * @param visible Whether the cursor is visible by default. + * @param caption cursor caption +- * @deprecated Magic value ++ * @deprecated Magic value. Use {@link #MapCursor(byte, byte, byte, byte, boolean, net.kyori.adventure.text.Component)} + */ + @Deprecated + public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable String caption) { +@@ -0,0 +0,0 @@ public final class MapCursor { + setDirection(direction); + setRawType(type); + this.visible = visible; +- this.caption = caption; ++ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper + } ++ // Paper start ++ /** ++ * Initialize the map cursor. ++ * ++ * @param x The x coordinate, from -128 to 127. ++ * @param y The y coordinate, from -128 to 127. ++ * @param direction The facing of the cursor, from 0 to 15. ++ * @param type The type (color/style) of the map cursor. ++ * @param visible Whether the cursor is visible by default. ++ * @param caption cursor caption ++ * @deprecated Magic value ++ */ ++ @Deprecated ++ public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, @Nullable net.kyori.adventure.text.Component caption) { ++ this.x = x; this.y = y; this.visible = visible; this.caption = caption; ++ setDirection(direction); ++ setRawType(type); ++ } ++ /** ++ * Initialize the map cursor. ++ * ++ * @param x The x coordinate, from -128 to 127. ++ * @param y The y coordinate, from -128 to 127. ++ * @param direction The facing of the cursor, from 0 to 15. ++ * @param type The type (color/style) of the map cursor. ++ * @param visible Whether the cursor is visible by default. ++ * @param caption cursor caption ++ */ ++ public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible, @Nullable net.kyori.adventure.text.Component caption) { ++ this.x = x; this.y = y; this.visible = visible; this.caption = caption; ++ setDirection(direction); ++ setType(type); ++ } ++ // Paper end + + /** + * Initialize the map cursor. +@@ -0,0 +0,0 @@ public final class MapCursor { + setDirection(direction); + setType(type); + this.visible = visible; +- this.caption = caption; ++ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper + } + + /** +@@ -0,0 +0,0 @@ public final class MapCursor { + this.visible = visible; + } + ++ // Paper start ++ /** ++ * Gets the caption on this cursor. ++ * ++ * @return caption ++ */ ++ public @Nullable net.kyori.adventure.text.Component caption() { ++ return this.caption; ++ } ++ /** ++ * Sets the caption on this cursor. ++ * ++ * @param caption new caption ++ */ ++ public void caption(@Nullable net.kyori.adventure.text.Component caption) { ++ this.caption = caption; ++ } ++ // Paper end + /** + * Gets the caption on this cursor. + * + * @return caption ++ * @deprecated in favour of {@link #caption()} + */ + @Nullable ++ @Deprecated // Paper + public String getCaption() { +- return caption; ++ return this.caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.caption); // Paper + } + + /** + * Sets the caption on this cursor. + * + * @param caption new caption ++ * @deprecated in favour of {@link #caption(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + public void setCaption(@Nullable String caption) { +- this.caption = caption; ++ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper + } + + /** +diff --git a/src/main/java/org/bukkit/map/MapCursorCollection.java b/src/main/java/org/bukkit/map/MapCursorCollection.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/map/MapCursorCollection.java ++++ b/src/main/java/org/bukkit/map/MapCursorCollection.java +@@ -0,0 +0,0 @@ public final class MapCursorCollection { + public MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, @Nullable String caption) { + return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible, caption)); + } ++ // Paper start ++ /** ++ * Add a cursor to the collection. ++ * ++ * @param x The x coordinate, from -128 to 127. ++ * @param y The y coordinate, from -128 to 127. ++ * @param direction The facing of the cursor, from 0 to 15. ++ * @param type The type (color/style) of the map cursor. ++ * @param visible Whether the cursor is visible. ++ * @param caption banner caption ++ * @return The newly added MapCursor. ++ * @deprecated Magic value ++ */ ++ @Deprecated ++ public @NotNull MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, @Nullable net.kyori.adventure.text.Component caption) { ++ return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible, caption)); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/scoreboard/Objective.java ++++ b/src/main/java/org/bukkit/scoreboard/Objective.java +@@ -0,0 +0,0 @@ public interface Objective { + */ + @NotNull + String getName() throws IllegalStateException; ++ // Paper start ++ /** ++ * Gets the name displayed to players for this objective ++ * ++ * @return this objective's display name ++ * @throws IllegalStateException if this objective has been unregistered ++ */ ++ @NotNull net.kyori.adventure.text.Component displayName() throws IllegalStateException; ++ /** ++ * Sets the name displayed to players for this objective. ++ * ++ * @param displayName Display name to set ++ * @throws IllegalStateException if this objective has been unregistered ++ * @throws IllegalArgumentException if displayName is null ++ * @throws IllegalArgumentException if displayName is longer than 128 ++ * characters. ++ */ ++ void displayName(@Nullable net.kyori.adventure.text.Component displayName) throws IllegalStateException, IllegalArgumentException; ++ // Paper end + + /** + * Gets the name displayed to players for this objective + * + * @return this objective's display name + * @throws IllegalStateException if this objective has been unregistered ++ * @deprecated in favour of {@link #displayName()} + */ + @NotNull ++ @Deprecated // Paper + String getDisplayName() throws IllegalStateException; + + /** +@@ -0,0 +0,0 @@ public interface Objective { + * @throws IllegalArgumentException if displayName is null + * @throws IllegalArgumentException if displayName is longer than 128 + * characters. ++ * @deprecated in favour of {@link #displayName(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + void setDisplayName(@NotNull String displayName) throws IllegalStateException, IllegalArgumentException; + + /** +diff --git a/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/src/main/java/org/bukkit/scoreboard/Scoreboard.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java ++++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java +@@ -0,0 +0,0 @@ public interface Scoreboard { + @Deprecated + @NotNull + Objective registerNewObjective(@NotNull String name, @NotNull String criteria) throws IllegalArgumentException; ++ // Paper start ++ /** ++ * Registers an Objective on this Scoreboard ++ * ++ * @param name Name of the Objective ++ * @param criteria Criteria for the Objective ++ * @param displayName Name displayed to players for the Objective. ++ * @return The registered Objective ++ * @throws IllegalArgumentException if name is null ++ * @throws IllegalArgumentException if name is longer than 16 ++ * characters. ++ * @throws IllegalArgumentException if criteria is null ++ * @throws IllegalArgumentException if displayName is null ++ * @throws IllegalArgumentException if displayName is longer than 128 ++ * characters. ++ * @throws IllegalArgumentException if an objective by that name already ++ * exists ++ */ ++ @NotNull ++ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @Nullable net.kyori.adventure.text.Component displayName) throws IllegalArgumentException; ++ /** ++ * Registers an Objective on this Scoreboard ++ * ++ * @param name Name of the Objective ++ * @param criteria Criteria for the Objective ++ * @param displayName Name displayed to players for the Objective. ++ * @param renderType Manner of rendering the Objective ++ * @return The registered Objective ++ * @throws IllegalArgumentException if name is null ++ * @throws IllegalArgumentException if name is longer than 16 ++ * characters. ++ * @throws IllegalArgumentException if criteria is null ++ * @throws IllegalArgumentException if displayName is null ++ * @throws IllegalArgumentException if displayName is longer than 128 ++ * characters. ++ * @throws IllegalArgumentException if renderType is null ++ * @throws IllegalArgumentException if an objective by that name already ++ * exists ++ */ ++ @NotNull ++ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @Nullable net.kyori.adventure.text.Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException; ++ // Paper end + + /** + * Registers an Objective on this Scoreboard +@@ -0,0 +0,0 @@ public interface Scoreboard { + * characters. + * @throws IllegalArgumentException if an objective by that name already + * exists ++ * @deprecated in favour of {@link #registerNewObjective(String, String, net.kyori.adventure.text.Component)} + */ + @NotNull ++ @Deprecated // Paper + Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName) throws IllegalArgumentException; + + /** +@@ -0,0 +0,0 @@ public interface Scoreboard { + * @throws IllegalArgumentException if renderType is null + * @throws IllegalArgumentException if an objective by that name already + * exists ++ * @deprecated in favour of {@link #registerNewObjective(String, String, net.kyori.adventure.text.Component, RenderType)} + */ + @NotNull ++ @Deprecated // Paper + Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException; + + /** +diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/scoreboard/Team.java ++++ b/src/main/java/org/bukkit/scoreboard/Team.java +@@ -0,0 +0,0 @@ public interface Team { + */ + @NotNull + String getName() throws IllegalStateException; ++ // Paper start ++ /** ++ * Gets the name displayed to entries for this team ++ * ++ * @return Team display name ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ @NotNull net.kyori.adventure.text.Component displayName() throws IllegalStateException; ++ ++ /** ++ * Sets the name displayed to entries for this team ++ * ++ * @param displayName New display name ++ * @throws IllegalArgumentException if displayName is longer than 128 ++ * characters. ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ void displayName(@Nullable net.kyori.adventure.text.Component displayName) throws IllegalStateException, IllegalArgumentException; ++ ++ /** ++ * Gets the prefix prepended to the display of entries on this team. ++ * ++ * @return Team prefix ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ @NotNull net.kyori.adventure.text.Component prefix() throws IllegalStateException; ++ ++ /** ++ * Sets the prefix prepended to the display of entries on this team. ++ * ++ * @param prefix New prefix ++ * @throws IllegalArgumentException if prefix is null ++ * @throws IllegalArgumentException if prefix is longer than 64 ++ * characters ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ void prefix(@Nullable net.kyori.adventure.text.Component prefix) throws IllegalStateException, IllegalArgumentException; ++ ++ /** ++ * Gets the suffix appended to the display of entries on this team. ++ * ++ * @return the team's current suffix ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ @NotNull net.kyori.adventure.text.Component suffix() throws IllegalStateException; ++ ++ /** ++ * Sets the suffix appended to the display of entries on this team. ++ * ++ * @param suffix the new suffix for this team. ++ * @throws IllegalArgumentException if suffix is null ++ * @throws IllegalArgumentException if suffix is longer than 64 ++ * characters ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ void suffix(@Nullable net.kyori.adventure.text.Component suffix) throws IllegalStateException, IllegalArgumentException; ++ ++ /** ++ * Gets the color of the team. ++ *
++ * This only sets the team outline, other occurrences of colors such as in ++ * names are handled by prefixes / suffixes. ++ * ++ * @return team color, defaults to {@link ChatColor#RESET} ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ @NotNull net.kyori.adventure.text.format.TextColor color() throws IllegalStateException; ++ ++ /** ++ * Sets the color of the team. ++ *
++ * This only sets the team outline, other occurrences of colors such as in ++ * names are handled by prefixes / suffixes. ++ * ++ * @param color new color, must be non-null. Use {@link ChatColor#RESET} for ++ * no color ++ */ ++ void color(@Nullable net.kyori.adventure.text.format.NamedTextColor color); ++ // Paper end + + /** + * Gets the name displayed to entries for this team + * + * @return Team display name + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #displayName()} + */ + @NotNull ++ @Deprecated // Paper + String getDisplayName() throws IllegalStateException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * @throws IllegalArgumentException if displayName is longer than 128 + * characters. + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #displayName(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + void setDisplayName(@NotNull String displayName) throws IllegalStateException, IllegalArgumentException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * + * @return Team prefix + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #prefix()} + */ + @NotNull ++ @Deprecated // Paper + String getPrefix() throws IllegalStateException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * @throws IllegalArgumentException if prefix is longer than 64 + * characters + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #prefix(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + void setPrefix(@NotNull String prefix) throws IllegalStateException, IllegalArgumentException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * + * @return the team's current suffix + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #suffix()} + */ + @NotNull ++ @Deprecated // Paper + String getSuffix() throws IllegalStateException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * @throws IllegalArgumentException if suffix is longer than 64 + * characters + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #suffix(net.kyori.adventure.text.Component)} + */ ++ @Deprecated // Paper + void setSuffix(@NotNull String suffix) throws IllegalStateException, IllegalArgumentException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * + * @return team color, defaults to {@link ChatColor#RESET} + * @throws IllegalStateException if this team has been unregistered ++ * @deprecated in favour of {@link #color()} + */ + @NotNull ++ @Deprecated // Paper + ChatColor getColor() throws IllegalStateException; + + /** +@@ -0,0 +0,0 @@ public interface Team { + * + * @param color new color, must be non-null. Use {@link ChatColor#RESET} for + * no color ++ * @deprecated in favour of {@link #color(net.kyori.adventure.text.format.NamedTextColor)} + */ ++ @Deprecated // Paper + void setColor(@NotNull ChatColor color); + + /** diff --git a/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch b/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch index 9c58868df1..76cd9dcb89 100644 --- a/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch +++ b/Spigot-API-Patches/Allow-Blocks-to-be-accessed-via-a-long-key.patch @@ -51,7 +51,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @NotNull public Block getBlockAt(@NotNull Location location); diff --git a/Spigot-API-Patches/Allow-Reloading-of-Command-Aliases.patch b/Spigot-API-Patches/Allow-Reloading-of-Command-Aliases.patch index 7fac61d268..00b1aaf938 100644 --- a/Spigot-API-Patches/Allow-Reloading-of-Command-Aliases.patch +++ b/Spigot-API-Patches/Allow-Reloading-of-Command-Aliases.patch @@ -29,7 +29,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi // Spigot end void reloadPermissions(); // Paper diff --git a/Spigot-API-Patches/Allow-delegation-to-vanilla-chunk-gen.patch b/Spigot-API-Patches/Allow-delegation-to-vanilla-chunk-gen.patch index a5be3bc829..ee37e4bdd7 100644 --- a/Spigot-API-Patches/Allow-delegation-to-vanilla-chunk-gen.patch +++ b/Spigot-API-Patches/Allow-delegation-to-vanilla-chunk-gen.patch @@ -35,7 +35,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @NotNull public ChunkGenerator.ChunkData createChunkData(@NotNull World world); diff --git a/Spigot-API-Patches/Async-Chunks-API.patch b/Spigot-API-Patches/Async-Chunks-API.patch index e26575cbe4..5626ed6096 100644 --- a/Spigot-API-Patches/Async-Chunks-API.patch +++ b/Spigot-API-Patches/Async-Chunks-API.patch @@ -11,7 +11,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad public default Chunk getChunkAt(long chunkKey) { return getChunkAt((int) chunkKey, (int) (chunkKey >> 32)); } diff --git a/Spigot-API-Patches/Basic-PlayerProfile-API.patch b/Spigot-API-Patches/Basic-PlayerProfile-API.patch index 7583bbbec2..bd984c2922 100644 --- a/Spigot-API-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-API-Patches/Basic-PlayerProfile-API.patch @@ -315,7 +315,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @return true if player names should be suggested */ boolean suggestPlayerNamesWhenNullTabCompletions(); diff --git a/Spigot-API-Patches/Complete-resource-pack-API.patch b/Spigot-API-Patches/Complete-resource-pack-API.patch index 3d36b7cd0c..1b8e6cc823 100644 --- a/Spigot-API-Patches/Complete-resource-pack-API.patch +++ b/Spigot-API-Patches/Complete-resource-pack-API.patch @@ -19,10 +19,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - */ - public void openBook(@NotNull ItemStack book); - -+ // Paper start + default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { + return net.kyori.adventure.text.event.HoverEvent.showEntity(this.getType().getKey(), this.getUniqueId(), this.displayName()); + } ++ + /** + * Request that the player's client download and switch resource packs. + *

@@ -76,11 +76,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * was {@link org.bukkit.event.player.PlayerResourcePackStatusEvent.Status#SUCCESSFULLY_LOADED} + */ + boolean hasResourcePack(); -+ // Paper end -+ - // Spigot start - public class Spigot extends Entity.Spigot { + // Paper end + // Spigot start diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java diff --git a/Spigot-API-Patches/Create-HoverEvent-from-ItemStack-Entity.patch b/Spigot-API-Patches/Create-HoverEvent-from-ItemStack-Entity.patch index a643a9e5ed..14f854c189 100644 --- a/Spigot-API-Patches/Create-HoverEvent-from-ItemStack-Entity.patch +++ b/Spigot-API-Patches/Create-HoverEvent-from-ItemStack-Entity.patch @@ -28,8 +28,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param entity Entity to create the HoverEvent for + * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} ++ * @deprecated use {@link org.bukkit.entity.Entity#asHoverEvent()} + */ + @NotNull ++ @Deprecated + net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity); + + /** @@ -38,8 +40,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param entity Entity to create the HoverEvent for + * @param customName a custom name that should be displayed, if not passed entity name will be displayed + * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} ++ * @deprecated use {@link org.bukkit.entity.Entity#asHoverEvent(java.util.function.UnaryOperator)} + */ + @NotNull ++ @Deprecated + net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @Nullable String customName); + + /** @@ -48,8 +52,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param entity Entity to create the HoverEvent for + * @param customName a custom name that should be displayed, if not passed entity name will be displayed + * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} ++ * @deprecated use {@link org.bukkit.entity.Entity#asHoverEvent(java.util.function.UnaryOperator)} + */ + @NotNull ++ @Deprecated + net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @Nullable net.md_5.bungee.api.chat.BaseComponent customName); + + /** @@ -58,8 +64,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param entity Entity to create the HoverEvent for + * @param customName a custom name that should be displayed, if not passed entity name will be displayed + * @return the {@link net.md_5.bungee.api.chat.hover.content.Content} of that {@link org.bukkit.entity.Entity} ++ * @deprecated use {@link org.bukkit.entity.Entity#asHoverEvent(java.util.function.UnaryOperator)} + */ + @NotNull ++ @Deprecated + net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @NotNull net.md_5.bungee.api.chat.BaseComponent[] customName); // Paper end } diff --git a/Spigot-API-Patches/Entity-Origin-API.patch b/Spigot-API-Patches/Entity-Origin-API.patch index 55462474d7..3841c91d11 100644 --- a/Spigot-API-Patches/Entity-Origin-API.patch +++ b/Spigot-API-Patches/Entity-Origin-API.patch @@ -9,11 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -0,0 +0,0 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent - @Override - Spigot spigot(); - // Spigot end + default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { + return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName()))); + } + -+ // Paper start + /** + * Gets the location where this entity originates from. + *

@@ -23,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @Nullable + Location getOrigin(); -+ // Paper end + // Paper end } diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/Spigot-API-Patches/Expand-Explosions-API.patch b/Spigot-API-Patches/Expand-Explosions-API.patch index f657af4a74..587339b496 100644 --- a/Spigot-API-Patches/Expand-Explosions-API.patch +++ b/Spigot-API-Patches/Expand-Explosions-API.patch @@ -109,7 +109,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad */ public boolean createExplosion(@NotNull Location loc, float power, boolean setFire); diff --git a/Spigot-API-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch b/Spigot-API-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch index 6c4a763b5e..06401e1c10 100644 --- a/Spigot-API-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch +++ b/Spigot-API-Patches/Expand-World.spawnParticle-API-and-add-Builder.patch @@ -518,7 +518,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad * @param data the data to use for the particle or null, * the type of this depends on {@link Particle#getDataType()} */ diff --git a/Spigot-API-Patches/Expose-MinecraftServer-isRunning.patch b/Spigot-API-Patches/Expose-MinecraftServer-isRunning.patch index 143d3a303f..e655840f49 100644 --- a/Spigot-API-Patches/Expose-MinecraftServer-isRunning.patch +++ b/Spigot-API-Patches/Expose-MinecraftServer-isRunning.patch @@ -29,7 +29,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @return Current tick */ int getCurrentTick(); diff --git a/Spigot-API-Patches/Expose-client-protocol-version-and-virtual-host.patch b/Spigot-API-Patches/Expose-client-protocol-version-and-virtual-host.patch index f713dac035..09902ce13b 100644 --- a/Spigot-API-Patches/Expose-client-protocol-version-and-virtual-host.patch +++ b/Spigot-API-Patches/Expose-client-protocol-version-and-virtual-host.patch @@ -64,8 +64,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Represents a player, connected or not */ --public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient { -+public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, com.destroystokyo.paper.network.NetworkClient { // Paper - Extend NetworkClient +-public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified { // Paper ++public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient { // Paper - /** - * Gets the "friendly" name to display of this player. This may include + // Paper start + @Override diff --git a/Spigot-API-Patches/Expose-game-version.patch b/Spigot-API-Patches/Expose-game-version.patch index 2626be6b37..eadd8c70bd 100644 --- a/Spigot-API-Patches/Expose-game-version.patch +++ b/Spigot-API-Patches/Expose-game-version.patch @@ -31,7 +31,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @NotNull public String getBukkitVersion(); diff --git a/Spigot-API-Patches/Expose-server-CommandMap.patch b/Spigot-API-Patches/Expose-server-CommandMap.patch index d623f28d83..5a2ca55574 100644 --- a/Spigot-API-Patches/Expose-server-CommandMap.patch +++ b/Spigot-API-Patches/Expose-server-CommandMap.patch @@ -32,7 +32,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi public double[] getTPS(); // Paper end diff --git a/Spigot-API-Patches/Expose-the-internal-current-tick.patch b/Spigot-API-Patches/Expose-the-internal-current-tick.patch index 49cdb7d8dd..91eaba901e 100644 --- a/Spigot-API-Patches/Expose-the-internal-current-tick.patch +++ b/Spigot-API-Patches/Expose-the-internal-current-tick.patch @@ -23,7 +23,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name); diff --git a/Spigot-API-Patches/Fix-upstream-javadoc-warnings-and-errors.patch b/Spigot-API-Patches/Fix-upstream-javadoc-warnings-and-errors.patch index a1b9992a0d..0a5eee681e 100644 --- a/Spigot-API-Patches/Fix-upstream-javadoc-warnings-and-errors.patch +++ b/Spigot-API-Patches/Fix-upstream-javadoc-warnings-and-errors.patch @@ -16,64 +16,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - * @param alternateChar Alternate symbol such as '&' + * @param alternateChar Alternate symbol such as '&' * @param message The message to send + * @deprecated use {@link #sendActionBar(Component)} */ - public void sendActionBar(char alternateChar, @NotNull String message); -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - /** - * Update the subtitle of titles displayed to the player - * -+ * @param subtitle Subtitle to set - * @deprecated Use {@link #updateTitle(Title)} - */ - @Deprecated -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - /** - * Update the subtitle of titles displayed to the player - * -+ * @param subtitle Subtitle to set - * @deprecated Use {@link #updateTitle(Title)} - */ - @Deprecated -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - /** - * Show the given title to the player, along with the last subtitle set, using the last set times - * -+ * @param title Title to set - * @deprecated Use {@link #sendTitle(Title)} or {@link #updateTitle(Title)} - */ - @Deprecated -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - /** - * Show the given title to the player, along with the last subtitle set, using the last set times - * -+ * @param title Title to set - * @deprecated Use {@link #sendTitle(Title)} or {@link #updateTitle(Title)} - */ - @Deprecated -diff --git a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java -+++ b/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java -@@ -0,0 +0,0 @@ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { - * {@link Player#setBedSpawnLocation(Location)}. - * - * @return true if the spawn location will be changed -+ * @deprecated NOT IMPLEMENTED - */ -+ @Deprecated // Paper - public boolean shouldSetSpawnLocation() { - return setBedSpawn; - } -@@ -0,0 +0,0 @@ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { - * {@link Player#setBedSpawnLocation(Location)}. - * - * @param setBedSpawn true to change the new spawn location -+ * @deprecated NOT IMPLEMENTED - */ -+ @Deprecated // Paper - public void setSpawnLocation(boolean setBedSpawn) { - this.setBedSpawn = setBedSpawn; - } diff --git a/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java diff --git a/Spigot-API-Patches/Flip-some-Spigot-API-null-annotations.patch b/Spigot-API-Patches/Flip-some-Spigot-API-null-annotations.patch index 077a9779b6..754ac70886 100644 --- a/Spigot-API-Patches/Flip-some-Spigot-API-null-annotations.patch +++ b/Spigot-API-Patches/Flip-some-Spigot-API-null-annotations.patch @@ -65,7 +65,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * * @return the scoreboard manager or null if no worlds are loaded. */ @@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ScoreboardManager getScoreboardManager(); /** -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @param clazz the class of the tag entries * @return the tag or null */ @@ -116,7 +116,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.Utility; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.enchantments.Enchantment; -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor * * @return a copy of the current ItemStack's ItemData */ diff --git a/Spigot-API-Patches/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch b/Spigot-API-Patches/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch index c32ade3265..c824642001 100644 --- a/Spigot-API-Patches/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch +++ b/Spigot-API-Patches/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch @@ -18,7 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sends the component to all online players. + * + * @param component the component to send ++ * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated + public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + server.broadcast(component); + } @@ -27,7 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sends an array of components as a single message to all online players. + * + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated + public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + server.broadcast(components); + } @@ -40,8 +44,8 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { - */ +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + @Deprecated // Paper public int broadcastMessage(@NotNull String message); + // Paper start @@ -49,7 +53,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sends the component to all online players. + * + * @param component the component to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated + public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + spigot().broadcast(component); + } @@ -58,7 +64,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sends an array of components as a single message to all online players. + * + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ ++ @Deprecated + public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + spigot().broadcast(components); + } @@ -80,8 +88,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sends the component to the player + * + * @param component the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ + @Override ++ @Deprecated + public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { + spigot().sendMessage(component); + } @@ -90,8 +100,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sends an array of components as a single message to the player + * + * @param components the components to send ++ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} + */ + @Override ++ @Deprecated + public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { + spigot().sendMessage(components); + } diff --git a/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch b/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch index 2ecdb3bdea..29f11c8436 100644 --- a/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch +++ b/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Material; -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor // Requires access to NMS return ensureServerConversions().getMaxItemUseDuration(); } diff --git a/Spigot-API-Patches/ItemStack-getMaxItemUseDuration.patch b/Spigot-API-Patches/ItemStack-getMaxItemUseDuration.patch index d83d2cc4e1..361192d6cd 100644 --- a/Spigot-API-Patches/ItemStack-getMaxItemUseDuration.patch +++ b/Spigot-API-Patches/ItemStack-getMaxItemUseDuration.patch @@ -9,7 +9,7 @@ diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/o index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor public String getI18NDisplayName() { return Bukkit.getServer().getItemFactory().getI18NDisplayName(this); } diff --git a/Spigot-API-Patches/Make-the-default-permission-message-configurable.patch b/Spigot-API-Patches/Make-the-default-permission-message-configurable.patch index 5b7750ccac..9910afea85 100644 --- a/Spigot-API-Patches/Make-the-default-permission-message-configurable.patch +++ b/Spigot-API-Patches/Make-the-default-permission-message-configurable.patch @@ -28,7 +28,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ boolean suggestPlayerNamesWhenNullTabCompletions(); diff --git a/Spigot-API-Patches/Player-Tab-List-and-Title-APIs.patch b/Spigot-API-Patches/Player-Tab-List-and-Title-APIs.patch index d8a530e218..7d7d129e72 100644 --- a/Spigot-API-Patches/Player-Tab-List-and-Title-APIs.patch +++ b/Spigot-API-Patches/Player-Tab-List-and-Title-APIs.patch @@ -34,7 +34,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Represents a title to may be sent to a {@link Player}. + * + *

A title can be sent without subtitle text.

++ * ++ * @deprecated use {@link net.kyori.adventure.title.Title} + */ ++@Deprecated +public final class Title { + + /** @@ -450,7 +453,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param header content for the top of the player list + * @param footer content for the bottom of the player list ++ * @deprecated in favour of {@link #sendPlayerListHeaderAndFooter(net.kyori.adventure.text.Component, net.kyori.adventure.text.Component)} + */ ++ @Deprecated + public void setPlayerListHeaderFooter(@Nullable net.md_5.bungee.api.chat.BaseComponent[] header, @Nullable net.md_5.bungee.api.chat.BaseComponent[] footer); + + /** @@ -458,7 +463,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param header content for the top of the player list + * @param footer content for the bottom of the player list ++ * @deprecated in favour of {@link #sendPlayerListHeaderAndFooter(net.kyori.adventure.text.Component, net.kyori.adventure.text.Component)} + */ ++ @Deprecated + public void setPlayerListHeaderFooter(@Nullable net.md_5.bungee.api.chat.BaseComponent header, @Nullable net.md_5.bungee.api.chat.BaseComponent footer); + + /** @@ -467,7 +474,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param fadeInTicks ticks to fade-in + * @param stayTicks ticks to stay visible + * @param fadeOutTicks ticks to fade-out -+ * @deprecated Use {@link #updateTitle(Title)} ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks); @@ -475,7 +482,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Update the subtitle of titles displayed to the player + * -+ * @deprecated Use {@link #updateTitle(Title)} ++ * @param subtitle Subtitle to set ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void setSubtitle(net.md_5.bungee.api.chat.BaseComponent[] subtitle); @@ -483,7 +491,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Update the subtitle of titles displayed to the player + * -+ * @deprecated Use {@link #updateTitle(Title)} ++ * @param subtitle Subtitle to set ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void setSubtitle(net.md_5.bungee.api.chat.BaseComponent subtitle); @@ -491,7 +500,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Show the given title to the player, along with the last subtitle set, using the last set times + * -+ * @deprecated Use {@link #sendTitle(Title)} or {@link #updateTitle(Title)} ++ * @param title Title to set ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void showTitle(@Nullable net.md_5.bungee.api.chat.BaseComponent[] title); @@ -499,7 +509,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * Show the given title to the player, along with the last subtitle set, using the last set times + * -+ * @deprecated Use {@link #sendTitle(Title)} or {@link #updateTitle(Title)} ++ * @param title Title to set ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void showTitle(@Nullable net.md_5.bungee.api.chat.BaseComponent title); @@ -512,7 +523,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param fadeInTicks ticks to fade-in + * @param stayTicks ticks to stay visible + * @param fadeOutTicks ticks to fade-out -+ * @deprecated Use {@link #sendTitle(Title)} or {@link #updateTitle(Title)} ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void showTitle(@Nullable net.md_5.bungee.api.chat.BaseComponent[] title, @Nullable net.md_5.bungee.api.chat.BaseComponent[] subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks); @@ -525,7 +536,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param fadeInTicks ticks to fade-in + * @param stayTicks ticks to stay visible + * @param fadeOutTicks ticks to fade-out -+ * @deprecated Use {@link #sendTitle(Title)} or {@link #updateTitle(Title)} ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ + @Deprecated + public void showTitle(@Nullable net.md_5.bungee.api.chat.BaseComponent title, @Nullable net.md_5.bungee.api.chat.BaseComponent subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks); @@ -537,7 +548,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param title the title to send + * @throws NullPointerException if the title is null ++ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} + */ ++ @Deprecated + void sendTitle(@NotNull Title title); + + /** @@ -547,12 +560,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param title the title to send + * @throws NullPointerException if title is null ++ * @deprecated use {@link #showTitle(net.kyori.adventure.title.Title)} + */ ++ @Deprecated + void updateTitle(@NotNull Title title); + + /** + * Hide any title that is currently visible to the player ++ * ++ * @deprecated use {@link #clearTitle()} + */ ++ @Deprecated + public void hideTitle(); // Paper end diff --git a/Spigot-API-Patches/Player-affects-spawning-API.patch b/Spigot-API-Patches/Player-affects-spawning-API.patch index 12b100d878..2ebc9e6ba7 100644 --- a/Spigot-API-Patches/Player-affects-spawning-API.patch +++ b/Spigot-API-Patches/Player-affects-spawning-API.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - @NotNull + @Deprecated // Paper public String getLocale(); + // Paper start diff --git a/Spigot-API-Patches/Player.setPlayerProfile-API.patch b/Spigot-API-Patches/Player.setPlayerProfile-API.patch index 0d5922f21c..a99e290d5e 100644 --- a/Spigot-API-Patches/Player.setPlayerProfile-API.patch +++ b/Spigot-API-Patches/Player.setPlayerProfile-API.patch @@ -9,10 +9,10 @@ diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/buk index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -0,0 +0,0 @@ package org.bukkit.entity; - import java.net.InetSocketAddress; +@@ -0,0 +0,0 @@ import java.net.InetSocketAddress; import java.util.UUID; import com.destroystokyo.paper.Title; // Paper + import net.kyori.adventure.text.Component; +import com.destroystokyo.paper.profile.PlayerProfile; // Paper import org.bukkit.DyeColor; import org.bukkit.Effect; diff --git a/Spigot-API-Patches/PlayerDeathEvent-getItemsToKeep.patch b/Spigot-API-Patches/PlayerDeathEvent-getItemsToKeep.patch index 1bea338973..37b5e25e06 100644 --- a/Spigot-API-Patches/PlayerDeathEvent-getItemsToKeep.patch +++ b/Spigot-API-Patches/PlayerDeathEvent-getItemsToKeep.patch @@ -12,9 +12,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { - private boolean keepLevel = false; - private boolean keepInventory = false; + } + // Paper end +- @Deprecated // Paper + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { + this(player, drops, droppedExp, 0, deathMessage); + } +@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { + this.deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : net.kyori.adventure.text.Component.empty(); // Paper + } + ++ @Deprecated // Paper + // Paper start + private List itemsToKeep = new java.util.ArrayList<>(); + @@ -49,6 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end + - public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { - this(player, drops, droppedExp, 0, deathMessage); - } + @NotNull + @Override + public Player getEntity() { diff --git a/Spigot-API-Patches/PlayerDeathEvent-shouldDropExperience.patch b/Spigot-API-Patches/PlayerDeathEvent-shouldDropExperience.patch index 22b5783f2f..f6fe19a666 100644 --- a/Spigot-API-Patches/PlayerDeathEvent-shouldDropExperience.patch +++ b/Spigot-API-Patches/PlayerDeathEvent-shouldDropExperience.patch @@ -17,13 +17,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; +@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { + private boolean keepLevel = false; + private boolean keepInventory = false; + // Paper start ++ private boolean doExpDrop; ++ + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final net.kyori.adventure.text.Component deathMessage) { + this(player, drops, droppedExp, 0, deathMessage); + } +@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { + } + + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final net.kyori.adventure.text.Component deathMessage) { ++ this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, true); ++ } ++ ++ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final net.kyori.adventure.text.Component deathMessage, boolean doExpDrop) { + super(player, drops, droppedExp); + this.newExp = newExp; + this.newTotalExp = newTotalExp; + this.newLevel = newLevel; + this.deathMessage = deathMessage; ++ this.doExpDrop = doExpDrop; + } + // Paper end + +@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { + + @Deprecated // Paper + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { ++ this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, true); ++ } ++ ++ @Deprecated // Paper ++ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage, boolean doExpDrop) { + super(player, drops, droppedExp); + this.newExp = newExp; + this.newTotalExp = newTotalExp; @@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { public List getItemsToKeep() { return itemsToKeep; } + -+ private boolean doExpDrop; -+ + /** + * @return should experience be dropped from this death + */ @@ -37,25 +73,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setShouldDropExperience(boolean doExpDrop) { + this.doExpDrop = doExpDrop; + } -+ // Paper end - public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { -@@ -0,0 +0,0 @@ public class PlayerDeathEvent extends EntityDeathEvent { - } - - public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { -+ // Paper start -+ this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, player.getGameMode() != GameMode.SPECTATOR); -+ } -+ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage, boolean doExpDrop) { -+ // Paper end - super(player, drops, droppedExp); - this.newExp = newExp; - this.newTotalExp = newTotalExp; - this.newLevel = newLevel; - this.deathMessage = deathMessage; -+ this.doExpDrop = doExpDrop; // Paper - } - @NotNull diff --git a/Spigot-API-Patches/ProfileWhitelistVerifyEvent.patch b/Spigot-API-Patches/ProfileWhitelistVerifyEvent.patch index a1a33453da..617d89de3d 100644 --- a/Spigot-API-Patches/ProfileWhitelistVerifyEvent.patch +++ b/Spigot-API-Patches/ProfileWhitelistVerifyEvent.patch @@ -39,6 +39,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +package com.destroystokyo.paper.event.profile; + +import com.destroystokyo.paper.profile.PlayerProfile; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; @@ -49,7 +51,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * Plugins may override/control the servers whitelist with this event, + * and dynamically change the kick message. -+ * + */ +public class ProfileWhitelistVerifyEvent extends Event { + private static final HandlerList handlers = new HandlerList(); @@ -57,9 +58,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final boolean whitelistEnabled; + private boolean whitelisted; + private final boolean isOp; -+ @Nullable private String kickMessage; ++ @Nullable private Component kickMessage; + ++ @Deprecated + public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable String kickMessage) { ++ this(profile, whitelistEnabled, whitelisted, isOp, kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); ++ } ++ ++ public ProfileWhitelistVerifyEvent(@NotNull final PlayerProfile profile, boolean whitelistEnabled, boolean whitelisted, boolean isOp, @Nullable Component kickMessage) { + this.profile = profile; + this.whitelistEnabled = whitelistEnabled; + this.whitelisted = whitelisted; @@ -69,16 +75,35 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + /** + * @return the currently planned message to send to the user if they are not whitelisted ++ * @deprecated use {@link #kickMessage()} + */ ++ @Deprecated + @Nullable + public String getKickMessage() { -+ return kickMessage; ++ return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(kickMessage); ++ } ++ ++ /** ++ * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default ++ * @deprecated Use {@link #kickMessage(Component)} ++ */ ++ @Deprecated ++ public void setKickMessage(@Nullable String kickMessage) { ++ this.kickMessage(kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage)); ++ } ++ ++ /** ++ * @return the currently planned message to send to the user if they are not whitelisted ++ */ ++ @Nullable ++ public Component kickMessage() { ++ return this.kickMessage; + } + + /** + * @param kickMessage The message to send to the player on kick if not whitelisted. May set to null to use the server configured default + */ -+ public void setKickMessage(@Nullable String kickMessage) { ++ public void kickMessage(@Nullable Component kickMessage) { + this.kickMessage = kickMessage; + } + diff --git a/Spigot-API-Patches/Provide-Chunk-Coordinates-as-a-Long-API.patch b/Spigot-API-Patches/Provide-Chunk-Coordinates-as-a-Long-API.patch index a68defc19a..f06f54f58b 100644 --- a/Spigot-API-Patches/Provide-Chunk-Coordinates-as-a-Long-API.patch +++ b/Spigot-API-Patches/Provide-Chunk-Coordinates-as-a-Long-API.patch @@ -47,7 +47,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @NotNull public Chunk getChunkAt(@NotNull Block block); diff --git a/Spigot-API-Patches/Provide-E-TE-Chunk-count-stat-methods.patch b/Spigot-API-Patches/Provide-E-TE-Chunk-count-stat-methods.patch index 793e2d1ccb..d60381de60 100644 --- a/Spigot-API-Patches/Provide-E-TE-Chunk-count-stat-methods.patch +++ b/Spigot-API-Patches/Provide-E-TE-Chunk-count-stat-methods.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/World.java @@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; */ - public interface World extends PluginMessageRecipient, Metadatable { + public interface World extends PluginMessageRecipient, Metadatable, net.kyori.adventure.audience.ForwardingAudience { // Paper + // Paper start + /** diff --git a/Spigot-API-Patches/Remove-deadlock-risk-in-firing-async-events.patch b/Spigot-API-Patches/Remove-deadlock-risk-in-firing-async-events.patch index 46db9f411c..fdbc0b68ad 100644 --- a/Spigot-API-Patches/Remove-deadlock-risk-in-firing-async-events.patch +++ b/Spigot-API-Patches/Remove-deadlock-risk-in-firing-async-events.patch @@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; */ - public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder { + public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource { // Paper - /** + /* diff --git a/Spigot-API-Patches/Return-chat-component-with-empty-text-instead-of-thr.patch b/Spigot-API-Patches/Return-chat-component-with-empty-text-instead-of-thr.patch index 7592cddff0..612e9e1f64 100644 --- a/Spigot-API-Patches/Return-chat-component-with-empty-text-instead-of-thr.patch +++ b/Spigot-API-Patches/Return-chat-component-with-empty-text-instead-of-thr.patch @@ -17,4 +17,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return The title or empty string when title is {@code null}. */ @NotNull - public abstract String getTitle(); + public abstract net.kyori.adventure.text.Component title(); diff --git a/Spigot-API-Patches/Spawn-Reason-API.patch b/Spigot-API-Patches/Spawn-Reason-API.patch index ab92ab5648..5998c94f93 100644 --- a/Spigot-API-Patches/Spawn-Reason-API.patch +++ b/Spigot-API-Patches/Spawn-Reason-API.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.generator.ChunkGenerator; import java.util.ArrayList; -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @NotNull public T spawn(@NotNull Location location, @NotNull Class clazz) throws IllegalArgumentException; @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Spawn an entity of a specific class at the given {@link Location}, with * the supplied function run before the entity is added to the world. -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad * {@link Entity} requested cannot be spawned */ @NotNull diff --git a/Spigot-API-Patches/Support-components-in-ItemMeta.patch b/Spigot-API-Patches/Support-components-in-ItemMeta.patch index 14a28f8eb2..f9fac522fb 100644 --- a/Spigot-API-Patches/Support-components-in-ItemMeta.patch +++ b/Spigot-API-Patches/Support-components-in-ItemMeta.patch @@ -8,6 +8,14 @@ diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +@@ -0,0 +0,0 @@ import java.util.Collection; + import java.util.List; + import java.util.Map; + import java.util.Set; ++import net.kyori.adventure.text.Component; + import org.bukkit.attribute.Attribute; + import org.bukkit.attribute.AttributeModifier; + import org.bukkit.configuration.serialization.ConfigurationSerializable; @@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @NotNull String getDisplayName(); @@ -20,15 +28,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * before calling this method. + * + * @return the display name that is set ++ * @deprecated use {@link #displayName()} + */ + @NotNull ++ @Deprecated + net.md_5.bungee.api.chat.BaseComponent[] getDisplayNameComponent(); + // Paper end /** * Sets the display name. * @@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste - */ + @Deprecated // Paper void setDisplayName(@Nullable String name); + // Paper start @@ -36,7 +46,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sets the display name. + * + * @param component the name component to set ++ * @deprecated use {@link #displayName(Component)} + */ ++ @Deprecated + void setDisplayNameComponent(@Nullable net.md_5.bungee.api.chat.BaseComponent[] component); + // Paper end /** @@ -53,15 +65,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * calling this method. + * + * @return a list of lore that is set ++ * @deprecated use {@link #lore()} + */ + @Nullable ++ @Deprecated + List getLoreComponents(); + /** * Sets the lore for this item. * Removes lore when given null. @@ -0,0 +0,0 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste - */ + @Deprecated // Paper void setLore(@Nullable List lore); + /** @@ -69,7 +83,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Removes lore when given null. + * + * @param lore the lore that will be set ++ * @deprecated use {@link #lore(List)} + */ ++ @Deprecated + void setLoreComponents(@Nullable List lore); + /** diff --git a/Spigot-API-Patches/World-view-distance-api.patch b/Spigot-API-Patches/World-view-distance-api.patch index bea7c314b5..59775644fe 100644 --- a/Spigot-API-Patches/World-view-distance-api.patch +++ b/Spigot-API-Patches/World-view-distance-api.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad int getViewDistance(); // Spigot end diff --git a/Spigot-API-Patches/ensureServerConversions-API.patch b/Spigot-API-Patches/ensureServerConversions-API.patch index dd85d88693..0e64dea686 100644 --- a/Spigot-API-Patches/ensureServerConversions-API.patch +++ b/Spigot-API-Patches/ensureServerConversions-API.patch @@ -11,10 +11,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -0,0 +0,0 @@ public interface ItemFactory { - @Deprecated + */ @NotNull - Material updateMaterial(@NotNull final ItemMeta meta, @NotNull final Material material) throws IllegalArgumentException; -+ // Paper start + net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator op); ++ + /** + * Minecart updates are converting simple item stacks into more complex NBT oriented Item Stacks. + * @@ -26,13 +26,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + ItemStack ensureServerConversions(@NotNull ItemStack item); -+ // Paper end + // Paper end } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor } } @@ -41,12 +41,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } /** -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { - - return true; +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor + public net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { + return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op); } + -+ // Paper start + /** + * Minecart updates are converting simple item stacks into more complex NBT oriented Item Stacks. + * @@ -59,5 +58,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public ItemStack ensureServerConversions() { + return Bukkit.getServer().getItemFactory().ensureServerConversions(this); + } -+ // Paper end + // Paper end } diff --git a/Spigot-API-Patches/getPlayerUniqueId-API.patch b/Spigot-API-Patches/getPlayerUniqueId-API.patch index ff5a4a6934..862d3247a4 100644 --- a/Spigot-API-Patches/getPlayerUniqueId-API.patch +++ b/Spigot-API-Patches/getPlayerUniqueId-API.patch @@ -37,7 +37,7 @@ diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Ser index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient { +@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @Nullable public Player getPlayer(@NotNull UUID id); diff --git a/Spigot-API-Patches/isChunkGenerated-API.patch b/Spigot-API-Patches/isChunkGenerated-API.patch index b000421ffa..fcf1dded40 100644 --- a/Spigot-API-Patches/isChunkGenerated-API.patch +++ b/Spigot-API-Patches/isChunkGenerated-API.patch @@ -37,7 +37,7 @@ diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/Worl index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable { +@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad return getChunkAt((int) chunkKey, (int) (chunkKey >> 32)); } diff --git a/Spigot-Server-Patches/0546-Brand-support.patch b/Spigot-Server-Patches/0547-Brand-support.patch similarity index 100% rename from Spigot-Server-Patches/0546-Brand-support.patch rename to Spigot-Server-Patches/0547-Brand-support.patch diff --git a/Spigot-Server-Patches/0556-Brand-support.patch b/Spigot-Server-Patches/0557-Brand-support.patch similarity index 93% rename from Spigot-Server-Patches/0556-Brand-support.patch rename to Spigot-Server-Patches/0557-Brand-support.patch index c1789d2900..87a3a77701 100644 --- a/Spigot-Server-Patches/0556-Brand-support.patch +++ b/Spigot-Server-Patches/0557-Brand-support.patch @@ -3,6 +3,7 @@ From: DigitalRegent Date: Sat, 11 Apr 2020 13:10:58 +0200 Subject: [PATCH] Brand support +TODO(Proximyst): Fixup this into the other brand support patch diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/Spigot-Server-Patches/API-to-get-a-BlockState-without-a-snapshot.patch b/Spigot-Server-Patches/API-to-get-a-BlockState-without-a-snapshot.patch index 25a82c3c3c..64f87ae33d 100644 --- a/Spigot-Server-Patches/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/Spigot-Server-Patches/API-to-get-a-BlockState-without-a-snapshot.patch @@ -86,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -0,0 +0,0 @@ public class CraftBlockEntityState extends CraftBlockState this.tileEntity = tileEntityClass.cast(world.getHandle().getTileEntity(this.getPosition())); - Preconditions.checkState(this.tileEntity != null, "Tile is null, asynchronous access? %s", block); + Preconditions.checkState(this.tileEntity != null, "Tile is null, asynchronous access? " + block); + // Paper start + this.snapshotDisabled = DISABLE_SNAPSHOT; diff --git a/Spigot-Server-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/Spigot-Server-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch index daff1ce6e6..6ec8ef2fa1 100644 --- a/Spigot-Server-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch +++ b/Spigot-Server-Patches/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch @@ -17,10 +17,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.mojang.authlib.GameProfile; import com.mojang.authlib.exceptions.AuthenticationUnavailableException; import java.math.BigInteger; -@@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; // CraftBukkit start + import io.papermc.paper.adventure.PaperAdventure; // Paper +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; diff --git a/Spigot-Server-Patches/Add-API-for-quit-reason.patch b/Spigot-Server-Patches/Add-API-for-quit-reason.patch index 9266b6fa90..18fac92334 100644 --- a/Spigot-Server-Patches/Add-API-for-quit-reason.patch +++ b/Spigot-Server-Patches/Add-API-for-quit-reason.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { - final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(s, true)[0]; + final IChatBaseComponent ichatbasecomponent = PaperAdventure.asVanilla(event.reason()); // Paper - Adventure // CraftBukkit end + this.player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.KICKED; // Paper @@ -56,8 +56,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entityplayer.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper } -- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game"); -+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game", entityplayer.quitReason); // Paper - quit reason +- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); ++ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW), entityplayer.quitReason); // Paper - quit reason if (entityplayer.didPlayerJoinEvent) cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); diff --git a/Spigot-Server-Patches/Add-option-for-console-having-all-permissions.patch b/Spigot-Server-Patches/Add-option-for-console-having-all-permissions.patch index ff489c689c..ce8f4c28b4 100644 --- a/Spigot-Server-Patches/Add-option-for-console-having-all-permissions.patch +++ b/Spigot-Server-Patches/Add-option-for-console-having-all-permissions.patch @@ -23,11 +23,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -0,0 +0,0 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co - public boolean isConversing() { - return conversationTracker.isConversing(); + public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { + this.sendRawMessage(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer.plain().serialize(message)); } + -+ // Paper start + @Override + public boolean hasPermission(String name) { + return com.destroystokyo.paper.PaperConfig.consoleHasAllPermissions || super.hasPermission(name); @@ -37,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean hasPermission(org.bukkit.permissions.Permission perm) { + return com.destroystokyo.paper.PaperConfig.consoleHasAllPermissions || super.hasPermission(perm); + } -+ // Paper end + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/Spigot-Server-Patches/Add-sun-related-API.patch b/Spigot-Server-Patches/Add-sun-related-API.patch index ec4f07fb6b..20fe3bb188 100644 --- a/Spigot-Server-Patches/Add-sun-related-API.patch +++ b/Spigot-Server-Patches/Add-sun-related-API.patch @@ -32,8 +32,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + @Override - public long getGameTime() { - return world.worldData.getTime(); + public boolean createExplosion(double x, double y, double z, float power) { + return createExplosion(x, y, z, power, false, true); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java diff --git a/Spigot-Server-Patches/Add-tick-times-API-and-mspt-command.patch b/Spigot-Server-Patches/Add-tick-times-API-and-mspt-command.patch index 7be8315621..b7bd347a19 100644 --- a/Spigot-Server-Patches/Add-tick-times-API-and-mspt-command.patch +++ b/Spigot-Server-Patches/Add-tick-times-API-and-mspt-command.patch @@ -166,4 +166,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // Paper end - // Spigot start + private final Spigot spigot = new Spigot() diff --git a/Spigot-Server-Patches/Adventure.patch b/Spigot-Server-Patches/Adventure.patch new file mode 100644 index 0000000000..9a2b420fd6 --- /dev/null +++ b/Spigot-Server-Patches/Adventure.patch @@ -0,0 +1,2909 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Riley Park +Date: Fri, 29 Jan 2021 17:54:03 +0100 +Subject: [PATCH] Adventure + +Co-authored-by: zml +Co-authored-by: Jake Potrebic + +diff --git a/src/main/java/io/papermc/paper/adventure/AdventureComponent.java b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/AdventureComponent.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.adventure; ++ ++import com.google.gson.JsonElement; ++import com.google.gson.JsonSerializationContext; ++import com.google.gson.JsonSerializer; ++import java.lang.reflect.Type; ++import java.util.List; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.TextComponent; ++import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer; ++import net.minecraft.server.ChatModifier; ++import net.minecraft.server.IChatBaseComponent; ++import net.minecraft.server.IChatMutableComponent; ++import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ++import org.checkerframework.checker.nullness.qual.Nullable; ++ ++public final class AdventureComponent implements IChatBaseComponent { ++ final Component wrapped; ++ private @MonotonicNonNull IChatBaseComponent converted; ++ ++ public AdventureComponent(final Component wrapped) { ++ this.wrapped = wrapped; ++ } ++ ++ IChatBaseComponent deepConverted() { ++ IChatBaseComponent converted = this.converted; ++ if (converted == null) { ++ converted = PaperAdventure.WRAPPER_AWARE_SERIALIZER.serialize(this.wrapped); ++ this.converted = converted; ++ } ++ return converted; ++ } ++ ++ public @Nullable IChatBaseComponent deepConvertedIfPresent() { ++ return this.converted; ++ } ++ ++ @Override ++ public ChatModifier getChatModifier() { ++ return this.deepConverted().getChatModifier(); ++ } ++ ++ @Override ++ public String getText() { ++ if (this.wrapped instanceof TextComponent) { ++ return ((TextComponent) this.wrapped).content(); ++ } else { ++ return this.deepConverted().getText(); ++ } ++ } ++ ++ @Override ++ public String getString() { ++ return PlainComponentSerializer.plain().serialize(this.wrapped); ++ } ++ ++ @Override ++ public List getSiblings() { ++ return this.deepConverted().getSiblings(); ++ } ++ ++ @Override ++ public IChatMutableComponent g() { ++ return this.deepConverted().g(); ++ } ++ ++ @Override ++ public IChatMutableComponent mutableCopy() { ++ return this.deepConverted().mutableCopy(); ++ } ++ ++ public static class Serializer implements JsonSerializer { ++ @Override ++ public JsonElement serialize(final AdventureComponent src, final Type type, final JsonSerializationContext context) { ++ return PaperAdventure.GSON.serializer().toJsonTree(src.wrapped, Component.class); ++ } ++ } ++} +diff --git a/src/main/java/io/papermc/paper/adventure/NBTLegacyHoverEventSerializer.java b/src/main/java/io/papermc/paper/adventure/NBTLegacyHoverEventSerializer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/NBTLegacyHoverEventSerializer.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.adventure; ++ ++import com.mojang.brigadier.exceptions.CommandSyntaxException; ++import java.io.IOException; ++import java.util.UUID; ++import net.kyori.adventure.key.Key; ++import net.kyori.adventure.nbt.api.BinaryTagHolder; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.event.HoverEvent; ++import net.kyori.adventure.text.serializer.gson.LegacyHoverEventSerializer; ++import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer; ++import net.kyori.adventure.util.Codec; ++import net.minecraft.server.MojangsonParser; ++import net.minecraft.server.NBTBase; ++import net.minecraft.server.NBTTagCompound; ++ ++final class NBTLegacyHoverEventSerializer implements LegacyHoverEventSerializer { ++ public static final NBTLegacyHoverEventSerializer INSTANCE = new NBTLegacyHoverEventSerializer(); ++ private static final Codec SNBT_CODEC = Codec.of(MojangsonParser::parse, NBTBase::toString); ++ ++ static final String ITEM_TYPE = "id"; ++ static final String ITEM_COUNT = "Count"; ++ static final String ITEM_TAG = "tag"; ++ ++ static final String ENTITY_NAME = "name"; ++ static final String ENTITY_TYPE = "type"; ++ static final String ENTITY_ID = "id"; ++ ++ NBTLegacyHoverEventSerializer() { ++ } ++ ++ @Override ++ public HoverEvent.ShowItem deserializeShowItem(final Component input) throws IOException { ++ final String raw = PlainComponentSerializer.plain().serialize(input); ++ try { ++ final NBTTagCompound contents = SNBT_CODEC.decode(raw); ++ final NBTTagCompound tag = contents.getCompound(ITEM_TAG); ++ return HoverEvent.ShowItem.of( ++ Key.key(contents.getString(ITEM_TYPE)), ++ contents.hasKey(ITEM_COUNT) ? contents.getByte(ITEM_COUNT) : 1, ++ tag.isEmpty() ? null : BinaryTagHolder.encode(tag, SNBT_CODEC) ++ ); ++ } catch (final CommandSyntaxException ex) { ++ throw new IOException(ex); ++ } ++ } ++ ++ @Override ++ public HoverEvent.ShowEntity deserializeShowEntity(final Component input, final Codec.Decoder componentCodec) throws IOException { ++ final String raw = PlainComponentSerializer.plain().serialize(input); ++ try { ++ final NBTTagCompound contents = SNBT_CODEC.decode(raw); ++ return HoverEvent.ShowEntity.of( ++ Key.key(contents.getString(ENTITY_TYPE)), ++ UUID.fromString(contents.getString(ENTITY_ID)), ++ componentCodec.decode(contents.getString(ENTITY_NAME)) ++ ); ++ } catch (final CommandSyntaxException ex) { ++ throw new IOException(ex); ++ } ++ } ++ ++ @Override ++ public Component serializeShowItem(final HoverEvent.ShowItem input) throws IOException { ++ final NBTTagCompound tag = new NBTTagCompound(); ++ tag.setString(ITEM_TYPE, input.item().asString()); ++ tag.setByte(ITEM_COUNT, (byte) input.count()); ++ if (input.nbt() != null) { ++ try { ++ tag.set(ITEM_TAG, input.nbt().get(SNBT_CODEC)); ++ } catch (final CommandSyntaxException ex) { ++ throw new IOException(ex); ++ } ++ } ++ return Component.text(SNBT_CODEC.encode(tag)); ++ } ++ ++ @Override ++ public Component serializeShowEntity(final HoverEvent.ShowEntity input, final Codec.Encoder componentCodec) throws IOException { ++ final NBTTagCompound tag = new NBTTagCompound(); ++ tag.setString(ENTITY_ID, input.id().toString()); ++ tag.setString(ENTITY_TYPE, input.type().asString()); ++ if (input.name() != null) { ++ tag.setString(ENTITY_NAME, componentCodec.encode(input.name())); ++ } ++ return Component.text(SNBT_CODEC.encode(tag)); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.adventure; ++ ++import com.mojang.brigadier.exceptions.CommandSyntaxException; ++import io.netty.util.AttributeKey; ++import java.io.IOException; ++import java.util.ArrayList; ++import java.util.List; ++import java.util.Locale; ++import net.kyori.adventure.bossbar.BossBar; ++import net.kyori.adventure.inventory.Book; ++import net.kyori.adventure.key.Key; ++import net.kyori.adventure.nbt.api.BinaryTagHolder; ++import net.kyori.adventure.sound.Sound; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.format.TextColor; ++import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; ++import net.kyori.adventure.translation.GlobalTranslator; ++import net.kyori.adventure.util.Codec; ++import net.minecraft.server.BossBattle; ++import net.minecraft.server.EnumChatFormat; ++import net.minecraft.server.IChatBaseComponent; ++import net.minecraft.server.ItemStack; ++import net.minecraft.server.MinecraftKey; ++import net.minecraft.server.MojangsonParser; ++import net.minecraft.server.NBTTagCompound; ++import net.minecraft.server.NBTTagList; ++import net.minecraft.server.NBTTagString; ++import net.minecraft.server.SoundCategory; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.checker.nullness.qual.Nullable; ++ ++public final class PaperAdventure { ++ public static final AttributeKey LOCALE_ATTRIBUTE = AttributeKey.valueOf("adventure:locale"); ++ static final GsonComponentSerializer GSON = GsonComponentSerializer.builder() ++ .legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.INSTANCE) ++ .build(); ++ private static final Codec NBT_CODEC = new Codec() { ++ @Override ++ public @NonNull NBTTagCompound decode(final @NonNull String encoded) throws IOException { ++ try { ++ return MojangsonParser.parse(encoded); ++ } catch (final CommandSyntaxException e) { ++ throw new IOException(e); ++ } ++ } ++ ++ @Override ++ public @NonNull String encode(final @NonNull NBTTagCompound decoded) { ++ return decoded.toString(); ++ } ++ }; ++ static final WrapperAwareSerializer WRAPPER_AWARE_SERIALIZER = new WrapperAwareSerializer(); ++ ++ private PaperAdventure() { ++ } ++ ++ // Key ++ ++ public static MinecraftKey asVanilla(final Key key) { ++ return new MinecraftKey(key.namespace(), key.value()); ++ } ++ ++ public static MinecraftKey asVanillaNullable(final Key key) { ++ if (key == null) { ++ return null; ++ } ++ return new MinecraftKey(key.namespace(), key.value()); ++ } ++ ++ // Component ++ ++ public static Component asAdventure(final IChatBaseComponent component) { ++ return GSON.serializer().fromJson(IChatBaseComponent.ChatSerializer.toJsonTree(component), Component.class); ++ } ++ ++ public static ArrayList asAdventure(final List vanillas) { ++ final ArrayList adventures = new ArrayList<>(vanillas.size()); ++ for (final IChatBaseComponent vanilla : vanillas) { ++ adventures.add(asAdventure(vanilla)); ++ } ++ return adventures; ++ } ++ ++ public static ArrayList asAdventureFromJson(final List jsonStrings) { ++ final ArrayList adventures = new ArrayList<>(jsonStrings.size()); ++ for (final String json : jsonStrings) { ++ adventures.add(GsonComponentSerializer.gson().deserialize(json)); ++ } ++ return adventures; ++ } ++ ++ public static List asJson(final List adventures) { ++ final List jsons = new ArrayList<>(adventures.size()); ++ for (final Component component : adventures) { ++ jsons.add(GsonComponentSerializer.gson().serialize(component)); ++ } ++ return jsons; ++ } ++ ++ public static IChatBaseComponent asVanilla(final Component component) { ++ if (true) return new AdventureComponent(component); ++ return IChatBaseComponent.ChatSerializer.fromJsonTree(GSON.serializer().toJsonTree(component)); ++ } ++ ++ public static List asVanilla(final List adventures) { ++ final List vanillas = new ArrayList<>(adventures.size()); ++ for (final Component adventure : adventures) { ++ vanillas.add(asVanilla(adventure)); ++ } ++ return vanillas; ++ } ++ ++ public static String asJsonString(final Component component, final Locale locale) { ++ return GSON.serialize( ++ GlobalTranslator.render( ++ component, ++ // play it safe ++ locale != null ++ ? locale ++ : Locale.US ++ ) ++ ); ++ } ++ ++ public static String asJsonString(final IChatBaseComponent component, final Locale locale) { ++ if (component instanceof AdventureComponent) { ++ return asJsonString(((AdventureComponent) component).wrapped, locale); ++ } ++ return IChatBaseComponent.ChatSerializer.componentToJson(component); ++ } ++ ++ // BossBar ++ ++ public static BossBattle.BarColor asVanilla(final BossBar.Color color) { ++ if (color == BossBar.Color.PINK) { ++ return BossBattle.BarColor.PINK; ++ } else if (color == BossBar.Color.BLUE) { ++ return BossBattle.BarColor.BLUE; ++ } else if (color == BossBar.Color.RED) { ++ return BossBattle.BarColor.RED; ++ } else if (color == BossBar.Color.GREEN) { ++ return BossBattle.BarColor.GREEN; ++ } else if (color == BossBar.Color.YELLOW) { ++ return BossBattle.BarColor.YELLOW; ++ } else if (color == BossBar.Color.PURPLE) { ++ return BossBattle.BarColor.PURPLE; ++ } else if (color == BossBar.Color.WHITE) { ++ return BossBattle.BarColor.WHITE; ++ } ++ throw new IllegalArgumentException(color.name()); ++ } ++ ++ public static BossBar.Color asAdventure(final BossBattle.BarColor color) { ++ if(color == BossBattle.BarColor.PINK) { ++ return BossBar.Color.PINK; ++ } else if(color == BossBattle.BarColor.BLUE) { ++ return BossBar.Color.BLUE; ++ } else if(color == BossBattle.BarColor.RED) { ++ return BossBar.Color.RED; ++ } else if(color == BossBattle.BarColor.GREEN) { ++ return BossBar.Color.GREEN; ++ } else if(color == BossBattle.BarColor.YELLOW) { ++ return BossBar.Color.YELLOW; ++ } else if(color == BossBattle.BarColor.PURPLE) { ++ return BossBar.Color.PURPLE; ++ } else if(color == BossBattle.BarColor.WHITE) { ++ return BossBar.Color.WHITE; ++ } ++ throw new IllegalArgumentException(color.name()); ++ } ++ ++ public static BossBattle.BarStyle asVanilla(final BossBar.Overlay overlay) { ++ if (overlay == BossBar.Overlay.PROGRESS) { ++ return BossBattle.BarStyle.PROGRESS; ++ } else if (overlay == BossBar.Overlay.NOTCHED_6) { ++ return BossBattle.BarStyle.NOTCHED_6; ++ } else if (overlay == BossBar.Overlay.NOTCHED_10) { ++ return BossBattle.BarStyle.NOTCHED_10; ++ } else if (overlay == BossBar.Overlay.NOTCHED_12) { ++ return BossBattle.BarStyle.NOTCHED_12; ++ } else if (overlay == BossBar.Overlay.NOTCHED_20) { ++ return BossBattle.BarStyle.NOTCHED_20; ++ } ++ throw new IllegalArgumentException(overlay.name()); ++ } ++ ++ public static BossBar.Overlay asAdventure(final BossBattle.BarStyle overlay) { ++ if (overlay == BossBattle.BarStyle.PROGRESS) { ++ return BossBar.Overlay.PROGRESS; ++ } else if (overlay == BossBattle.BarStyle.NOTCHED_6) { ++ return BossBar.Overlay.NOTCHED_6; ++ } else if (overlay == BossBattle.BarStyle.NOTCHED_10) { ++ return BossBar.Overlay.NOTCHED_10; ++ } else if (overlay == BossBattle.BarStyle.NOTCHED_12) { ++ return BossBar.Overlay.NOTCHED_12; ++ } else if (overlay == BossBattle.BarStyle.NOTCHED_20) { ++ return BossBar.Overlay.NOTCHED_20; ++ } ++ throw new IllegalArgumentException(overlay.name()); ++ } ++ ++ public static void setFlag(final BossBar bar, final BossBar.Flag flag, final boolean value) { ++ if (value) { ++ bar.addFlag(flag); ++ } else { ++ bar.removeFlag(flag); ++ } ++ } ++ ++ // Book ++ ++ public static ItemStack asItemStack(final Book book, final Locale locale) { ++ final ItemStack item = new ItemStack(net.minecraft.server.Items.WRITTEN_BOOK, 1); ++ final NBTTagCompound tag = item.getOrCreateTag(); ++ tag.setString("title", asJsonString(book.title(), locale)); ++ tag.setString("author", asJsonString(book.author(), locale)); ++ final NBTTagList pages = new NBTTagList(); ++ for (final Component page : book.pages()) { ++ pages.add(NBTTagString.create(asJsonString(page, locale))); ++ } ++ tag.set("pages", pages); ++ return item; ++ } ++ ++ // Sounds ++ ++ public static SoundCategory asVanilla(final Sound.Source source) { ++ if (source == Sound.Source.MASTER) { ++ return SoundCategory.MASTER; ++ } else if (source == Sound.Source.MUSIC) { ++ return SoundCategory.MUSIC; ++ } else if (source == Sound.Source.RECORD) { ++ return SoundCategory.RECORDS; ++ } else if (source == Sound.Source.WEATHER) { ++ return SoundCategory.WEATHER; ++ } else if (source == Sound.Source.BLOCK) { ++ return SoundCategory.BLOCKS; ++ } else if (source == Sound.Source.HOSTILE) { ++ return SoundCategory.HOSTILE; ++ } else if (source == Sound.Source.NEUTRAL) { ++ return SoundCategory.NEUTRAL; ++ } else if (source == Sound.Source.PLAYER) { ++ return SoundCategory.PLAYERS; ++ } else if (source == Sound.Source.AMBIENT) { ++ return SoundCategory.AMBIENT; ++ } else if (source == Sound.Source.VOICE) { ++ return SoundCategory.VOICE; ++ } ++ throw new IllegalArgumentException(source.name()); ++ } ++ ++ public static @Nullable SoundCategory asVanillaNullable(final Sound.@Nullable Source source) { ++ if (source == null) { ++ return null; ++ } ++ return asVanilla(source); ++ } ++ ++ // NBT ++ ++ public static @Nullable BinaryTagHolder asBinaryTagHolder(final @Nullable NBTTagCompound tag) { ++ if (tag == null) { ++ return null; ++ } ++ try { ++ return BinaryTagHolder.encode(tag, NBT_CODEC); ++ } catch (final IOException e) { ++ return null; ++ } ++ } ++ ++ // Colors ++ ++ public static @NonNull TextColor asAdventure(EnumChatFormat minecraftColor) { ++ if (minecraftColor.e() == null) { ++ throw new IllegalArgumentException("Not a valid color"); ++ } ++ return TextColor.color(minecraftColor.e()); ++ } ++ ++ public static @Nullable EnumChatFormat asVanilla(TextColor color) { ++ return EnumChatFormat.getByHexValue(color.value()); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/adventure/VanillaBossBarListener.java b/src/main/java/io/papermc/paper/adventure/VanillaBossBarListener.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/VanillaBossBarListener.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.adventure; ++ ++import java.util.Set; ++import java.util.function.Consumer; ++import net.kyori.adventure.bossbar.BossBar; ++import net.kyori.adventure.text.Component; ++import net.minecraft.server.PacketPlayOutBoss; ++import org.checkerframework.checker.nullness.qual.NonNull; ++ ++public final class VanillaBossBarListener implements BossBar.Listener { ++ private final Consumer action; ++ ++ public VanillaBossBarListener(final Consumer action) { ++ this.action = action; ++ } ++ ++ @Override ++ public void bossBarNameChanged(final @NonNull BossBar bar, final @NonNull Component oldName, final @NonNull Component newName) { ++ this.action.accept(PacketPlayOutBoss.Action.UPDATE_NAME); ++ } ++ ++ @Override ++ public void bossBarProgressChanged(final @NonNull BossBar bar, final float oldProgress, final float newProgress) { ++ this.action.accept(PacketPlayOutBoss.Action.UPDATE_PCT); ++ } ++ ++ @Override ++ public void bossBarColorChanged(final @NonNull BossBar bar, final BossBar.@NonNull Color oldColor, final BossBar.@NonNull Color newColor) { ++ this.action.accept(PacketPlayOutBoss.Action.UPDATE_STYLE); ++ } ++ ++ @Override ++ public void bossBarOverlayChanged(final @NonNull BossBar bar, final BossBar.@NonNull Overlay oldOverlay, final BossBar.@NonNull Overlay newOverlay) { ++ this.action.accept(PacketPlayOutBoss.Action.UPDATE_STYLE); ++ } ++ ++ @Override ++ public void bossBarFlagsChanged(final @NonNull BossBar bar, final @NonNull Set flagsAdded, final @NonNull Set flagsRemoved) { ++ this.action.accept(PacketPlayOutBoss.Action.UPDATE_PROPERTIES); ++ } ++} +diff --git a/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java b/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.adventure; ++ ++import java.util.function.BiFunction; ++import java.util.regex.MatchResult; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.ComponentLike; ++import net.kyori.adventure.text.TextComponent; ++import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; ++import org.bukkit.craftbukkit.entity.CraftPlayer; ++ ++public class VanillaChatMessageLogic { ++ public static Component displayNameForChat(final CraftPlayer player) { ++ return player.displayName(); ++ } ++ ++ public static Component formatChat(final Component displayName, final String format, final String message) { ++ final class Replacement implements BiFunction { ++ private int index = 0; ++ ++ @Override ++ public ComponentLike apply(final MatchResult result, final TextComponent.Builder builder) { ++ if (this.index == 0) { ++ this.index++; ++ return displayName; ++ } else if (this.index == 1) { ++ this.index++; ++ return LegacyComponentSerializer.legacySection().deserialize(message).mergeStyle(builder.asComponent()); ++ } else { ++ return builder; ++ } ++ } ++ } ++ final Replacement replacement = new Replacement(); ++ if (format.contains("%2$s") && !format.contains("%1$s")) { ++ replacement.index = 1; ++ } ++ return LegacyComponentSerializer.legacySection().deserialize(format) ++ .replaceText(config -> { ++ config.times(2); ++ config.match("%(\\d+\\$)?s"); ++ config.replacement(replacement); ++ }); ++ } ++} +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..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/adventure/WrapperAwareSerializer.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.adventure; ++ ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.serializer.ComponentSerializer; ++import net.minecraft.server.IChatBaseComponent; ++ ++final class WrapperAwareSerializer implements ComponentSerializer { ++ @Override ++ public Component deserialize(final IChatBaseComponent input) { ++ if (input instanceof AdventureComponent) { ++ return ((AdventureComponent) input).wrapped; ++ } ++ return PaperAdventure.GSON.serializer().fromJson(IChatBaseComponent.ChatSerializer.toJsonTree(input), Component.class); ++ } ++ ++ @Override ++ public IChatBaseComponent serialize(final Component component) { ++ return IChatBaseComponent.ChatSerializer.fromJsonTree(PaperAdventure.GSON.serializer().toJsonTree(component)); ++ } ++} +diff --git a/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java b/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/net/kyori/adventure/bossbar/HackyBossBarPlatformBridge.java +@@ -0,0 +0,0 @@ ++package net.kyori.adventure.bossbar; ++ ++import io.papermc.paper.adventure.PaperAdventure; ++import io.papermc.paper.adventure.VanillaBossBarListener; ++import net.minecraft.server.BossBattleServer; ++import org.bukkit.craftbukkit.entity.CraftPlayer; ++ ++public abstract class HackyBossBarPlatformBridge { ++ public BossBattleServer vanilla$bar; ++ private VanillaBossBarListener vanilla$listener; ++ ++ public final void paper$playerShow(final CraftPlayer player) { ++ if (this.vanilla$bar == null) { ++ final BossBar $this = (BossBar) this; ++ this.vanilla$bar = new BossBattleServer( ++ PaperAdventure.asVanilla($this.name()), ++ PaperAdventure.asVanilla($this.color()), ++ PaperAdventure.asVanilla($this.overlay()) ++ ); ++ this.vanilla$bar.adventure = $this; ++ this.vanilla$listener = new VanillaBossBarListener(this.vanilla$bar::sendUpdate); ++ $this.addListener(this.vanilla$listener); ++ } ++ this.vanilla$bar.addPlayer(player.getHandle()); ++ } ++ ++ public final void paper$playerHide(final CraftPlayer player) { ++ if (this.vanilla$bar != null) { ++ this.vanilla$bar.removePlayer(player.getHandle()); ++ if (this.vanilla$bar.getPlayers().isEmpty()) { ++ ((BossBar) this).removeListener(this.vanilla$listener); ++ this.vanilla$bar = null; ++ } ++ } ++ } ++} +diff --git a/src/main/java/net/minecraft/server/BossBattle.java b/src/main/java/net/minecraft/server/BossBattle.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/BossBattle.java ++++ b/src/main/java/net/minecraft/server/BossBattle.java +@@ -0,0 +0,0 @@ + package net.minecraft.server; + ++import io.papermc.paper.adventure.PaperAdventure; + import java.util.UUID; + + public abstract class BossBattle { +@@ -0,0 +0,0 @@ public abstract class BossBattle { + protected boolean e; + protected boolean f; + protected boolean g; ++ public net.kyori.adventure.bossbar.BossBar adventure; // Paper + + public BossBattle(UUID uuid, IChatBaseComponent ichatbasecomponent, BossBattle.BarColor bossbattle_barcolor, BossBattle.BarStyle bossbattle_barstyle) { + this.h = uuid; +@@ -0,0 +0,0 @@ public abstract class BossBattle { + } + + public IChatBaseComponent j() { ++ if(this.adventure != null) return PaperAdventure.asVanilla(this.adventure.name()); // Paper + return this.title; + } + + public void a(IChatBaseComponent ichatbasecomponent) { ++ if (this.adventure != null) this.adventure.name(PaperAdventure.asAdventure(ichatbasecomponent)); // Paper + this.title = ichatbasecomponent; + } + + public float getProgress() { ++ if (this.adventure != null) return this.adventure.progress(); // Paper + return this.b; + } + + public void a(float f) { ++ if (this.adventure != null) this.adventure.progress(f); // Paper + this.b = f; + } + + public BossBattle.BarColor l() { ++ if (this.adventure != null) return PaperAdventure.asVanilla(this.adventure.color()); // Paper + return this.color; + } + + public void a(BossBattle.BarColor bossbattle_barcolor) { ++ if(this.adventure != null) this.adventure.color(PaperAdventure.asAdventure(bossbattle_barcolor)); // Paper + this.color = bossbattle_barcolor; + } + + public BossBattle.BarStyle m() { ++ if(this.adventure != null) return PaperAdventure.asVanilla(this.adventure.overlay()); // Paper + return this.style; + } + + public void a(BossBattle.BarStyle bossbattle_barstyle) { ++ if(this.adventure != null) this.adventure.overlay(PaperAdventure.asAdventure(bossbattle_barstyle)); // Paper + this.style = bossbattle_barstyle; + } + + public boolean isDarkenSky() { ++ if(this.adventure != null) return this.adventure.hasFlag(net.kyori.adventure.bossbar.BossBar.Flag.DARKEN_SCREEN); // Paper + return this.e; + } + + public BossBattle a(boolean flag) { ++ if(this.adventure != null) PaperAdventure.setFlag(this.adventure, net.kyori.adventure.bossbar.BossBar.Flag.DARKEN_SCREEN, flag); // Paper + this.e = flag; + return this; + } + + public boolean isPlayMusic() { ++ if(this.adventure != null) return this.adventure.hasFlag(net.kyori.adventure.bossbar.BossBar.Flag.PLAY_BOSS_MUSIC); // Paper + return this.f; + } + + public BossBattle b(boolean flag) { ++ if(this.adventure != null) PaperAdventure.setFlag(this.adventure, net.kyori.adventure.bossbar.BossBar.Flag.PLAY_BOSS_MUSIC, flag); // Paper + this.f = flag; + return this; + } + + public BossBattle c(boolean flag) { ++ if(this.adventure != null) PaperAdventure.setFlag(this.adventure, net.kyori.adventure.bossbar.BossBar.Flag.CREATE_WORLD_FOG, flag); // Paper + this.g = flag; + return this; + } + + public boolean isCreateFog() { ++ if(this.adventure != null) return this.adventure.hasFlag(net.kyori.adventure.bossbar.BossBar.Flag.CREATE_WORLD_FOG); // Paper + return this.g; + } + +diff --git a/src/main/java/net/minecraft/server/Enchantment.java b/src/main/java/net/minecraft/server/Enchantment.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/Enchantment.java ++++ b/src/main/java/net/minecraft/server/Enchantment.java +@@ -0,0 +0,0 @@ public abstract class Enchantment { + return this.f(); + } + ++ public final IChatBaseComponent getTranslationComponentForLevel(int level) { return this.d(level); } // Paper - OBFHELPER + public IChatBaseComponent d(int i) { + ChatMessage chatmessage = new ChatMessage(this.g()); + +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/EntityPlayer.java ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java +@@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + + // CraftBukkit start ++import io.papermc.paper.adventure.PaperAdventure; // Paper + import org.bukkit.Bukkit; + import org.bukkit.GameMode; + import org.bukkit.Location; +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + + // CraftBukkit start + public String displayName; ++ public net.kyori.adventure.text.Component adventure$displayName; // Paper + public IChatBaseComponent listName; + public org.bukkit.Location compassTarget; + public int newExp = 0; +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + + // CraftBukkit start + this.displayName = this.getName(); ++ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getName()); // Paper + this.canPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); + } +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + + IChatBaseComponent defaultMessage = this.getCombatTracker().getDeathMessage(); + +- String deathmessage = defaultMessage.getString(); +- 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 + + // SPIGOT-943 - only call if they have an inventory open + if (this.activeContainer != this.defaultContainer) { + this.closeInventory(); + } + +- String deathMessage = event.getDeathMessage(); ++ net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure + +- if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override? +- IChatBaseComponent ichatbasecomponent; +- if (deathMessage.equals(deathmessage)) { +- ichatbasecomponent = this.getCombatTracker().getDeathMessage(); +- } else { +- ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage); +- } ++ if (deathMessage != null && deathMessage != net.kyori.adventure.text.Component.empty() && flag) { // Paper - Adventure // TODO: allow plugins to override? ++ IChatBaseComponent ichatbasecomponent = PaperAdventure.asVanilla(deathMessage); // Paper - Adventure + + this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> { + if (!future.isSuccess()) { +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + } + + public String locale = "en_us"; // CraftBukkit - add, lowercase ++ public java.util.Locale adventure$locale = java.util.Locale.US; // Paper + public void a(PacketPlayInSettings packetplayinsettings) { + // CraftBukkit start + if (getMainHand() != packetplayinsettings.getMainHand()) { +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + this.server.server.getPluginManager().callEvent(event); + } + this.locale = packetplayinsettings.locale; ++ // Paper start ++ this.adventure$locale = net.kyori.adventure.translation.Translator.parseLocale(this.locale); ++ this.playerConnection.networkManager.channel.attr(PaperAdventure.LOCALE_ATTRIBUTE).set(this.adventure$locale); ++ // Paper end + this.clientViewDistance = packetplayinsettings.viewDistance; + // CraftBukkit end + this.bY = packetplayinsettings.d(); +diff --git a/src/main/java/net/minecraft/server/EnumChatFormat.java b/src/main/java/net/minecraft/server/EnumChatFormat.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/EnumChatFormat.java ++++ b/src/main/java/net/minecraft/server/EnumChatFormat.java +@@ -0,0 +0,0 @@ public enum EnumChatFormat { + return !this.A && this != EnumChatFormat.RESET; + } + ++ @Nullable public Integer getHexValue() { return this.e(); } // Paper - OBFHELPER + @Nullable + public Integer e() { + return this.D; +@@ -0,0 +0,0 @@ public enum EnumChatFormat { + return s == null ? null : (EnumChatFormat) EnumChatFormat.w.get(c(s)); + } + ++ // Paper start ++ @Nullable public static EnumChatFormat getByHexValue(int i) { ++ for (EnumChatFormat value : values()) { ++ if (value.getHexValue() != null && value.getHexValue() == i) { ++ return value; ++ } ++ } ++ ++ return null; ++ } ++ // Paper end ++ + @Nullable + public static EnumChatFormat a(int i) { + if (i < 0) { +diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java ++++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java +@@ -0,0 +0,0 @@ + package net.minecraft.server; + ++import io.papermc.paper.adventure.AdventureComponent; // Paper + import com.google.gson.Gson; + import com.google.gson.GsonBuilder; + import com.google.gson.JsonArray; +@@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, IChatFormatted, Iterable waitable = new Waitable() { + @Override +@@ -0,0 +0,0 @@ public class LoginListener implements PacketLoginInListener { + + LoginListener.this.server.processQueue.add(waitable); + if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) { +- disconnect(event.getKickMessage()); ++ 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 + return; + } + } +diff --git a/src/main/java/net/minecraft/server/NBTTagString.java b/src/main/java/net/minecraft/server/NBTTagString.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/NBTTagString.java ++++ b/src/main/java/net/minecraft/server/NBTTagString.java +@@ -0,0 +0,0 @@ public class NBTTagString implements NBTBase { + this.data = s; + } + ++ public static NBTTagString create(final String value) { return a(value); } // Paper - OBFHELPER + public static NBTTagString a(String s) { + return s.isEmpty() ? NBTTagString.b : new NBTTagString(s); + } +diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java ++++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java +@@ -0,0 +0,0 @@ import io.netty.buffer.ByteBufOutputStream; + import io.netty.handler.codec.DecoderException; + import io.netty.handler.codec.EncoderException; + import io.netty.util.ByteProcessor; ++import io.papermc.paper.adventure.PaperAdventure; // Paper + import java.io.DataInput; + import java.io.DataOutput; + import java.io.IOException; +@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit + public class PacketDataSerializer extends ByteBuf { + + private final ByteBuf a; ++ public java.util.Locale adventure$locale; // Paper + + public PacketDataSerializer(ByteBuf bytebuf) { + this.a = bytebuf; +@@ -0,0 +0,0 @@ public class PacketDataSerializer extends ByteBuf { + return IChatBaseComponent.ChatSerializer.a(this.e(262144)); + } + ++ // Paper start ++ public PacketDataSerializer writeComponent(final net.kyori.adventure.text.Component component) { ++ return this.writeUtf(PaperAdventure.asJsonString(component, this.adventure$locale), 262144); ++ } ++ // Paper end ++ + public PacketDataSerializer a(IChatBaseComponent ichatbasecomponent) { +- return this.a(IChatBaseComponent.ChatSerializer.a(ichatbasecomponent), 262144); ++ //return this.a(IChatBaseComponent.ChatSerializer.a(ichatbasecomponent), 262144); // Paper - comment ++ return this.writeUtf(PaperAdventure.asJsonString(ichatbasecomponent, this.adventure$locale), 262144); // Paper + } + + public > T a(Class oclass) { +@@ -0,0 +0,0 @@ public class PacketDataSerializer extends ByteBuf { + return this.a(s, 32767); + } + ++ public PacketDataSerializer writeUtf(final String string, final int maxLength) { return this.a(string, maxLength); } // Paper - OBFHELPER + public PacketDataSerializer a(String s, int i) { + byte[] abyte = s.getBytes(StandardCharsets.UTF_8); + +diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketEncoder.java ++++ b/src/main/java/net/minecraft/server/PacketEncoder.java +@@ -0,0 +0,0 @@ package net.minecraft.server; + import io.netty.buffer.ByteBuf; + import io.netty.channel.ChannelHandlerContext; + import io.netty.handler.codec.MessageToByteEncoder; ++import io.papermc.paper.adventure.PaperAdventure; // Paper + import java.io.IOException; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder> { + throw new IOException("Can't serialize unregistered packet"); + } else { + PacketDataSerializer packetdataserializer = new PacketDataSerializer(bytebuf); ++ packetdataserializer.adventure$locale = channelhandlercontext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper + + packetdataserializer.d(integer); + +diff --git a/src/main/java/net/minecraft/server/PacketPlayOutChat.java b/src/main/java/net/minecraft/server/PacketPlayOutChat.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketPlayOutChat.java ++++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java +@@ -0,0 +0,0 @@ import java.util.UUID; + public class PacketPlayOutChat implements Packet { + + private IChatBaseComponent a; ++ public net.kyori.adventure.text.Component adventure$message; // Paper + public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot + private ChatMessageType b; + private UUID c; +@@ -0,0 +0,0 @@ public class PacketPlayOutChat implements Packet { + + @Override + public void b(PacketDataSerializer packetdataserializer) throws IOException { ++ // Paper start ++ if (this.adventure$message != null) { ++ packetdataserializer.writeComponent(this.adventure$message); ++ } else ++ // Paper end + // Spigot start + if (components != null) { + packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components)); +diff --git a/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java ++++ b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java +@@ -0,0 +0,0 @@ public class PacketPlayOutPlayerListHeaderFooter implements Packet { + + private PacketPlayOutTitle.EnumTitleAction a; + private IChatBaseComponent b; ++ public net.kyori.adventure.text.Component adventure$text; // Paper + private int c; + private int d; + private int e; +@@ -0,0 +0,0 @@ public class PacketPlayOutTitle implements Packet { + public void b(PacketDataSerializer packetdataserializer) throws IOException { + packetdataserializer.a((Enum) this.a); + if (this.a == PacketPlayOutTitle.EnumTitleAction.TITLE || this.a == PacketPlayOutTitle.EnumTitleAction.SUBTITLE || this.a == PacketPlayOutTitle.EnumTitleAction.ACTIONBAR) { ++ // Paper start ++ if (this.adventure$text != null) { ++ packetdataserializer.writeComponent(this.adventure$text); ++ } else ++ // Paper end + packetdataserializer.a(this.b); + } + +diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PacketStatusListener.java ++++ b/src/main/java/net/minecraft/server/PacketStatusListener.java +@@ -0,0 +0,0 @@ public class PacketStatusListener implements PacketStatusInListener { + CraftIconCache icon = minecraftServer.server.getServerIcon(); + + ServerListPingEvent() { +- super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers()); ++ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.server.motd(), minecraftServer.getPlayerList().getMaxPlayers()); // Paper - Adventure + } + + @Override +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -0,0 +0,0 @@ import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + + // CraftBukkit start ++import io.papermc.paper.adventure.PaperAdventure; // Paper ++import io.papermc.paper.adventure.VanillaChatMessageLogic; // Paper + import java.util.concurrent.ExecutionException; + import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; + import org.bukkit.Location; +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + return this.minecraftServer.a(this.player.getProfile()); + } + +- // CraftBukkit start +- @Deprecated +- public void disconnect(IChatBaseComponent ichatbasecomponent) { +- disconnect(CraftChatMessage.fromComponent(ichatbasecomponent)); ++ public void disconnect(String s) { ++ // Paper start - Adventure ++ this.disconnect(CraftChatMessage.fromStringOrNull(s)); + } +- // CraftBukkit end + +- public void disconnect(String s) { ++ public void disconnect(IChatBaseComponent reason) { ++ // Paper end + // CraftBukkit start - fire PlayerKickEvent + if (this.processedDisconnect) { + return; + } +- String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " 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); // Paper - Adventure + +- PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage); ++ PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), PaperAdventure.asAdventure(reason), leaveMessage); // Paper - Adventure + + if (this.server.getServer().isRunning()) { + this.server.getPluginManager().callEvent(event); +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + return; + } + // Send the possibly modified leave message +- s = event.getReason(); +- final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(s, true)[0]; ++ final IChatBaseComponent ichatbasecomponent = PaperAdventure.asVanilla(event.reason()); // Paper - Adventure + // CraftBukkit end + + this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> { +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + */ + + this.player.p(); +- String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); +- if ((quitMessage != null) && (quitMessage.length() > 0)) { +- this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); ++ // Paper start - Adventure ++ net.kyori.adventure.text.Component quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); ++ if ((quitMessage != null) && (quitMessage.equals(net.kyori.adventure.text.Component.empty()))) { ++ this.minecraftServer.getPlayerList().sendMessage(PaperAdventure.asVanilla(quitMessage)); ++ // Paper end + } + // CraftBukkit end + ITextFilter itextfilter = this.player.Q(); +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + return null; + } + +- String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); +- PlayerConnection.this.minecraftServer.console.sendMessage(message); ++ final net.kyori.adventure.text.Component adventure$msg = VanillaChatMessageLogic.formatChat(VanillaChatMessageLogic.displayNameForChat((CraftPlayer) player), queueEvent.getFormat(), queueEvent.getMessage()); // Paper ++ //String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); // Paper - comment ++ //PlayerConnection.this.minecraftServer.console.sendMessage(message); // Paper - comment ++ PlayerConnection.this.minecraftServer.console.sendMessage(adventure$msg); // Paper + if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { ++ final IChatBaseComponent vanilla$msg = PaperAdventure.asVanilla(adventure$msg); // Paper + for (Object player : PlayerConnection.this.minecraftServer.getPlayerList().players) { +- ((EntityPlayer) player).sendMessage(PlayerConnection.this.player.getUniqueID(), CraftChatMessage.fromString(message)); ++ //((EntityPlayer) player).sendMessage(PlayerConnection.this.player.getUniqueID(), CraftChatMessage.fromString(message)); // Paper - comment ++ ((EntityPlayer) player).sendMessage(vanilla$msg, PlayerConnection.this.player.getUniqueID()); + } + } else { + for (Player player : queueEvent.getRecipients()) { +- player.sendMessage(PlayerConnection.this.player.getUniqueID(), message); ++ //player.sendMessage(PlayerConnection.this.player.getUniqueID(), message); // Paper - comment ++ player.sendMessage(PlayerConnection.this.player.getBukkitEntity(), adventure$msg); // Paper + } + } + return null; +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + return; + } + +- s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); +- minecraftServer.console.sendMessage(s); ++ final net.kyori.adventure.text.Component adventure$msg = VanillaChatMessageLogic.formatChat(VanillaChatMessageLogic.displayNameForChat((CraftPlayer) player), event.getFormat(), event.getMessage()); // Paper ++ //s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); // Paper - comment ++ //minecraftServer.console.sendMessage(s); // Paper - comment ++ minecraftServer.console.sendMessage(adventure$msg); // Paper + if (((LazyPlayerSet) event.getRecipients()).isLazy()) { ++ final IChatBaseComponent vanilla$msg = PaperAdventure.asVanilla(adventure$msg); // Paper + for (Object recipient : minecraftServer.getPlayerList().players) { +- ((EntityPlayer) recipient).sendMessage(PlayerConnection.this.player.getUniqueID(), CraftChatMessage.fromString(s)); ++ //((EntityPlayer) recipient).sendMessage(PlayerConnection.this.player.getUniqueID(), CraftChatMessage.fromString(s)); // Paper - comment ++ ((EntityPlayer) recipient).sendMessage(vanilla$msg, PlayerConnection.this.player.getUniqueID()); // Paper + } + } else { + for (Player recipient : event.getRecipients()) { +- recipient.sendMessage(PlayerConnection.this.player.getUniqueID(), s); ++ //recipient.sendMessage(PlayerConnection.this.player.getUniqueID(), s); // Paper - comment ++ recipient.sendMessage(PlayerConnection.this.player.getBukkitEntity(), adventure$msg); // Paper + } + } + } +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + return; + } + +- // CraftBukkit start +- Player player = this.server.getPlayer(this.player); +- int x = packetplayinupdatesign.b().getX(); +- int y = packetplayinupdatesign.b().getY(); +- int z = packetplayinupdatesign.b().getZ(); +- String[] lines = new String[4]; ++ // CraftBukkit start // Paper start - Adventure ++ List lines = new java.util.ArrayList<>(); + + for (int i = 0; i < list.size(); ++i) { +- lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a((String) list.get(i))).getString()); ++ lines.add(net.kyori.adventure.text.Component.text(list.get(i))); + } +- SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); ++ SignChangeEvent event = new SignChangeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldserver, blockposition), this.getPlayer(), lines); + this.server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { +- System.arraycopy(org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()), 0, tileentitysign.lines, 0, 4); ++ for (int i = 0; i < 4; i++) { ++ tileentitysign.a(i, PaperAdventure.asVanilla(event.line(i))); ++ } ++ // Paper end + tileentitysign.isEditable = false; + } + // CraftBukkit end +diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/PlayerList.java ++++ b/src/main/java/net/minecraft/server/PlayerList.java +@@ -0,0 +0,0 @@ import com.mojang.authlib.GameProfile; + import com.mojang.serialization.DataResult; + import com.mojang.serialization.Dynamic; + import io.netty.buffer.Unpooled; ++import io.papermc.paper.adventure.PaperAdventure; + import java.io.File; + import java.net.SocketAddress; + import java.text.SimpleDateFormat; +@@ -0,0 +0,0 @@ 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; + +@@ -0,0 +0,0 @@ public abstract class PlayerList { + } + // CraftBukkit start + chatmessage.a(EnumChatFormat.YELLOW); +- String joinMessage = CraftChatMessage.fromComponent(chatmessage); ++ IChatBaseComponent joinMessage = chatmessage; // Paper - Adventure + + playerconnection.a(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch); + this.players.add(entityplayer); +@@ -0,0 +0,0 @@ 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(entityplayer), joinMessage); ++ PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(cserver.getPlayer(entityplayer), PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure + cserver.getPluginManager().callEvent(playerJoinEvent); + + if (!entityplayer.playerConnection.networkManager.isConnected()) { + return; + } + +- joinMessage = playerJoinEvent.getJoinMessage(); ++ joinMessage = PaperAdventure.asVanilla(playerJoinEvent.joinMessage()); // Paper - Adventure + +- if (joinMessage != null && joinMessage.length() > 0) { +- for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { +- server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b)); +- } ++ if (playerJoinEvent.joinMessage() != net.kyori.adventure.text.Component.empty()) { // Paper - Adventure ++ server.getPlayerList().sendAll(new PacketPlayOutChat(joinMessage, ChatMessageType.SYSTEM, SystemUtils.b)); // Paper - Adventure + } + // CraftBukkit end + +@@ -0,0 +0,0 @@ public abstract class PlayerList { + + } + +- public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string ++ public net.kyori.adventure.text.Component disconnect(EntityPlayer entityplayer) { // Paper - return Component + WorldServer worldserver = entityplayer.getWorldServer(); + + entityplayer.a(StatisticList.LEAVE_GAME); +@@ -0,0 +0,0 @@ public abstract class PlayerList { + entityplayer.closeInventory(); + } + +- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " 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)); + cserver.getPluginManager().callEvent(playerQuitEvent); + entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); + +@@ -0,0 +0,0 @@ public abstract class PlayerList { + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end + +- return playerQuitEvent.getQuitMessage(); // CraftBukkit ++ return playerQuitEvent.quitMessage(); // Paper - Adventure + } + + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer +@@ -0,0 +0,0 @@ public abstract class PlayerList { + } + + // return chatmessage; +- if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); // Spigot ++ if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Spigot // Paper - Adventure + } else if (!this.isWhitelisted(gameprofile)) { + chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); +- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot ++ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure + } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { + IpBanEntry ipbanentry = this.l.get(socketaddress); + +@@ -0,0 +0,0 @@ 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; + if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) { +- event.disallow(PlayerLoginEvent.Result.KICK_FULL, org.spigotmc.SpigotConfig.serverFullMessage); // Spigot ++ event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure + } + } + + 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; +@@ -0,0 +0,0 @@ public abstract class PlayerList { + public void shutdown() { + // CraftBukkit start - disconnect safely + for (EntityPlayer player : this.players) { +- player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message ++ player.playerConnection.disconnect(PaperAdventure.asVanilla(this.server.server.shutdownMessage())); // CraftBukkit - add custom shutdown message // Paper - Adventure + } + // CraftBukkit end + +diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/WorldMap.java ++++ b/src/main/java/net/minecraft/server/WorldMap.java +@@ -0,0 +0,0 @@ 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; +@@ -0,0 +0,0 @@ public class WorldMap extends PersistentBase { + for ( org.bukkit.map.MapCursor cursor : render.cursors) { + + if (cursor.isVisible()) { +- icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); ++ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), PaperAdventure.asVanilla(cursor.caption()))); // Paper - Adventure + } + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + } + + @Override ++ @Deprecated // Paper start + public int broadcastMessage(String message) { +- return broadcast(message, BROADCAST_CHANNEL_USERS); ++ this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message)); ++ return this.getOnlinePlayers().size() + 1; ++ // Paper end + } + + public Player getPlayer(final EntityPlayer entity) { +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + return configuration.getInt("settings.spawn-radius", -1); + } + ++ // Paper start + @Override ++ public net.kyori.adventure.text.Component shutdownMessage() { ++ String msg = getShutdownMessage(); ++ return msg != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(msg) : null; ++ } ++ // Paper end ++ @Override ++ @Deprecated // Paper + public String getShutdownMessage() { + return configuration.getString("settings.shutdown-message"); + } +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + } + + @Override ++ @Deprecated // Paper + public int broadcast(String message, String permission) { ++ // Paper start - Adventure ++ return this.broadcast(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message), permission); ++ } ++ ++ @Override ++ public int broadcast(net.kyori.adventure.text.Component message, String permission) { ++ // Paper end + Set recipients = new HashSet<>(); + for (Permissible permissible : getPluginManager().getPermissionSubscriptions(permission)) { + if (permissible instanceof CommandSender && permissible.hasPermission(permission)) { +@@ -0,0 +0,0 @@ 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); + + if (broadcastMessageEvent.isCancelled()) { + return 0; + } + +- message = broadcastMessageEvent.getMessage(); ++ message = broadcastMessageEvent.message(); // Paper - Adventure + + for (CommandSender recipient : recipients) { + recipient.sendMessage(message); +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + return CraftInventoryCreator.INSTANCE.createInventory(owner, type); + } + ++ // Paper start ++ @Override ++ public Inventory createInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ Validate.isTrue(type.isCreatable(), "Cannot open an inventory of type ", type); ++ return CraftInventoryCreator.INSTANCE.createInventory(owner, type, title); ++ } ++ // Paper end ++ + @Override + public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { + Validate.isTrue(type.isCreatable(), "Cannot open an inventory of type ", type); +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + return CraftInventoryCreator.INSTANCE.createInventory(owner, size); + } + ++ // Paper start ++ @Override ++ public Inventory createInventory(InventoryHolder owner, int size, net.kyori.adventure.text.Component title) throws IllegalArgumentException { ++ Validate.isTrue(9 <= size && size <= 54 && size % 9 == 0, "Size for custom inventory must be a multiple of 9 between 9 and 54 slots (got " + size + ")"); ++ return CraftInventoryCreator.INSTANCE.createInventory(owner, size, title); ++ } ++ // Paper end ++ + @Override + public Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException { + Validate.isTrue(9 <= size && size <= 54 && size % 9 == 0, "Size for custom inventory must be a multiple of 9 between 9 and 54 slots (got " + size + ")"); + return CraftInventoryCreator.INSTANCE.createInventory(owner, size, title); + } + ++ // Paper start + @Override ++ public Merchant createMerchant(net.kyori.adventure.text.Component title) { ++ return new org.bukkit.craftbukkit.inventory.CraftMerchantCustom(title == null ? InventoryType.MERCHANT.defaultTitle() : title); ++ } ++ // Paper end ++ @Override ++ @Deprecated // Paper + public Merchant createMerchant(String title) { + return new CraftMerchantCustom(title == null ? InventoryType.MERCHANT.getDefaultTitle() : title); + } +@@ -0,0 +0,0 @@ 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) + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component motd() { ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(new net.minecraft.server.ChatComponentText(console.getMotd())); ++ } ++ // Paper end + @Override + public String getMotd() { + return console.getMotd(); +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + return null; + } + } ++ ++ // Paper start ++ private Iterable adventure$audiences; ++ @Override ++ public Iterable audiences() { ++ if (this.adventure$audiences == null) { ++ this.adventure$audiences = com.google.common.collect.Iterables.concat(java.util.Collections.singleton(this.getConsoleSender()), this.getOnlinePlayers()); ++ } ++ return this.adventure$audiences; ++ } + // Paper end + } +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +@@ -0,0 +0,0 @@ public class CraftBeacon extends CraftBlockEntityState impleme + this.getSnapshot().secondaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component customName() { ++ final TileEntityBeacon be = this.getSnapshot(); ++ return be.customName != null ? io.papermc.paper.adventure.PaperAdventure.asAdventure(be.customName) : null; ++ } ++ ++ @Override ++ public void customName(final net.kyori.adventure.text.Component customName) { ++ this.getSnapshot().setCustomName(customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null); ++ } ++ // Paper end ++ + @Override + public String getCustomName() { + TileEntityBeacon beacon = this.getSnapshot(); +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +@@ -0,0 +0,0 @@ + package org.bukkit.craftbukkit.block; + + import net.minecraft.server.ChestLock; ++import net.minecraft.server.TileEntityBeacon; + import net.minecraft.server.TileEntityContainer; + import org.bukkit.Material; + import org.bukkit.block.Block; +@@ -0,0 +0,0 @@ public abstract class CraftContainer extends Craf + this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component customName() { ++ final T be = this.getSnapshot(); ++ return be.hasCustomName() ? io.papermc.paper.adventure.PaperAdventure.asAdventure(be.getCustomName()) : null; ++ } ++ ++ @Override ++ public void customName(final net.kyori.adventure.text.Component customName) { ++ this.getSnapshot().setCustomName(customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null); ++ } ++ // Paper end ++ + @Override + public String getCustomName() { + T container = this.getSnapshot(); +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java +@@ -0,0 +0,0 @@ public class CraftEnchantingTable extends CraftBlockEntityState implements Sign { + + // Lazily initialized only if requested: +- private String[] originalLines = null; +- private String[] lines = null; ++ // Paper start ++ private java.util.ArrayList originalLines = null; // ArrayList for RandomAccess ++ private java.util.ArrayList lines = null; // ArrayList for RandomAccess ++ // Paper end + + public CraftSign(final Block block) { + super(block, TileEntitySign.class); +@@ -0,0 +0,0 @@ public class CraftSign extends CraftBlockEntityState implements + super(material, te); + } + ++ // Paper start + @Override +- public String[] getLines() { +- if (lines == null) { +- // Lazy initialization: +- TileEntitySign sign = this.getSnapshot(); +- lines = new String[sign.lines.length]; +- System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length); +- originalLines = new String[lines.length]; +- System.arraycopy(lines, 0, originalLines, 0, originalLines.length); ++ public java.util.List lines() { ++ this.loadLines(); ++ return this.lines; ++ } ++ ++ @Override ++ public net.kyori.adventure.text.Component line(int index) { ++ this.loadLines(); ++ return this.lines.get(index); ++ } ++ ++ @Override ++ public void line(int index, net.kyori.adventure.text.Component line) { ++ this.loadLines(); ++ this.lines.set(index, line); ++ } ++ ++ private void loadLines() { ++ if (lines != null) { ++ return; + } +- return lines; ++ ++ // Lazy initialization: ++ TileEntitySign sign = this.getSnapshot(); ++ lines = io.papermc.paper.adventure.PaperAdventure.asAdventure(com.google.common.collect.Lists.newArrayList(sign.lines)); ++ originalLines = new java.util.ArrayList<>(lines); ++ } ++ // Paper end ++ @Override ++ public String[] getLines() { ++ this.loadLines(); ++ return this.lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper + } + + @Override + public String getLine(int index) throws IndexOutOfBoundsException { +- return getLines()[index]; ++ this.loadLines(); ++ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.lines.get(index)); // Paper + } + + @Override + public void setLine(int index, String line) throws IndexOutOfBoundsException { +- getLines()[index] = line; ++ this.loadLines(); ++ this.lines.set(index, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line)); // Paper + } + + @Override +@@ -0,0 +0,0 @@ public class CraftSign extends CraftBlockEntityState implements + super.applyTo(sign); + + if (lines != null) { +- for (int i = 0; i < lines.length; i++) { +- String line = (lines[i] == null) ? "" : lines[i]; +- if (line.equals(originalLines[i])) { ++ // Paper start ++ for (int i = 0; i < this.lines.size(); ++i) { ++ net.kyori.adventure.text.Component component = this.lines.get(i); ++ net.kyori.adventure.text.Component origComp = this.lines.get(i); ++ if (component.equals(origComp)) { + continue; // The line contents are still the same, skip. + } +- sign.lines[i] = CraftChatMessage.fromString(line)[0]; ++ sign.lines[i] = io.papermc.paper.adventure.PaperAdventure.asVanilla(component); + } ++ // Paper end + } + } + ++ // Paper start ++ public static IChatBaseComponent[] sanitizeLines(java.util.List lines) { ++ IChatBaseComponent[] components = new IChatBaseComponent[4]; ++ for (int i = 0; i < 4; i++) { ++ if (i < lines.size() && lines.get(i) != null) { ++ components[i] = io.papermc.paper.adventure.PaperAdventure.asVanilla(lines.get(i)); ++ } else { ++ components[i] = new ChatComponentText(""); ++ } ++ } ++ return components; ++ } ++ // Paper end + public static IChatBaseComponent[] sanitizeLines(String[] lines) { + IChatBaseComponent[] components = new IChatBaseComponent[4]; + +diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java ++++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java +@@ -0,0 +0,0 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co + public boolean isConversing() { + return conversationTracker.isConversing(); + } ++ ++ // Paper start ++ @Override ++ public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { ++ this.sendRawMessage(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer.plain().serialize(message)); ++ } ++ // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java ++++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +@@ -0,0 +0,0 @@ public class CraftEnchantment extends Enchantment { + CraftEnchantment ench = (CraftEnchantment) other; + return !target.isCompatible(ench.target); + } ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component displayName(int level) { ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getTranslationComponentForLevel(level)); ++ } ++ // Paper end + + public net.minecraft.server.Enchantment getHandle() { + return target; +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +@@ -0,0 +0,0 @@ import net.minecraft.server.EntityZombieVillager; + import net.minecraft.server.IChatBaseComponent; + import net.minecraft.server.NBTBase; + import net.minecraft.server.NBTTagCompound; ++import net.minecraft.server.TileEntityEnchantTable; + import org.bukkit.Chunk; // Paper + import org.bukkit.EntityEffect; + import org.bukkit.Location; +@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { + return getHandle().getVehicle().getBukkitEntity(); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component customName() { ++ final IChatBaseComponent name = this.getHandle().getCustomName(); ++ return name != null ? io.papermc.paper.adventure.PaperAdventure.asAdventure(name) : null; ++ } ++ ++ @Override ++ public void customName(final net.kyori.adventure.text.Component customName) { ++ this.getHandle().setCustomName(customName != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(customName) : null); ++ } ++ // Paper end ++ + @Override + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +@@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { + container = CraftEventFactory.callInventoryOpenEvent(player, container); + if (container == null) return; + +- String title = container.getBukkitView().getTitle(); ++ //String title = container.getBukkitView().getTitle(); // Paper - comment ++ net.kyori.adventure.text.Component adventure$title = container.getBukkitView().title(); // Paper ++ if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper + +- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); ++ //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment ++ player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper + getHandle().activeContainer = container; + getHandle().activeContainer.addSlotListener(player); + } +@@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { + + // Now open the window + Containers windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory()); +- String title = inventory.getTitle(); +- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); ++ ++ //String title = inventory.getTitle(); // Paper - comment ++ net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper ++ if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper ++ //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment ++ player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper + player.activeContainer = container; + player.activeContainer.addSlotListener(player); + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -0,0 +0,0 @@ import org.bukkit.Particle; + import org.bukkit.Sound; + import org.bukkit.Statistic; + import org.bukkit.WeatherType; +-import org.bukkit.World; + import org.bukkit.block.data.BlockData; + import org.bukkit.configuration.serialization.DelegateDeserialization; + import org.bukkit.conversations.Conversation; +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + + @Override + public String getDisplayName() { ++ if(true) return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.getHandle().adventure$displayName); // Paper + return getHandle().displayName; + } + + @Override + public void setDisplayName(final String name) { ++ this.getHandle().adventure$displayName = name != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(name) : null; if (true) return; // Paper + getHandle().displayName = name == null ? getName() : name; + } + ++ // Paper start ++ @Override ++ public void playerListName(net.kyori.adventure.text.Component name) { ++ getHandle().listName = name == null ? null : io.papermc.paper.adventure.PaperAdventure.asVanilla(name); ++ for (EntityPlayer player : server.getHandle().players) { ++ if (player.getBukkitEntity().canSee(this)) { ++ player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); ++ } ++ } ++ } ++ @Override ++ public net.kyori.adventure.text.Component playerListName() { ++ return getHandle().listName == null ? net.kyori.adventure.text.Component.text(getName()) : io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().listName); ++ } ++ @Override ++ public net.kyori.adventure.text.Component playerListHeader() { ++ return playerListHeader; ++ } ++ @Override ++ public net.kyori.adventure.text.Component playerListFooter() { ++ return playerListFooter; ++ } ++ // Paper end + @Override + public String getPlayerListName() { + return getHandle().listName == null ? getName() : CraftChatMessage.fromComponent(getHandle().listName); +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + } + +- private IChatBaseComponent playerListHeader; +- private IChatBaseComponent playerListFooter; ++ private net.kyori.adventure.text.Component playerListHeader; // Paper - Adventure ++ private net.kyori.adventure.text.Component playerListFooter; // Paper - Adventure + + @Override + public String getPlayerListHeader() { +- return (playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader); ++ return (playerListHeader == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(playerListHeader); // Paper - Adventure + } + + @Override + public String getPlayerListFooter() { +- return (playerListFooter == null) ? null : CraftChatMessage.fromComponent(playerListFooter); ++ return (playerListFooter == null) ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(playerListFooter); // Paper - Adventure + } + + @Override + public void setPlayerListHeader(String header) { +- this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); ++ this.playerListHeader = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(header); // Paper - Adventure + updatePlayerListHeaderFooter(); + } + + @Override + public void setPlayerListFooter(String footer) { +- this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); ++ this.playerListFooter = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(footer); // Paper - Adventure + updatePlayerListHeaderFooter(); + } + + @Override + public void setPlayerListHeaderFooter(String header, String footer) { +- this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); +- this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); ++ this.playerListHeader = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(header); // Paper - Adventure ++ this.playerListFooter = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(footer); // Paper - Adventure + updatePlayerListHeaderFooter(); + } + +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + if (getHandle().playerConnection == null) return; + + PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); +- packet.header = (this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader; +- packet.footer = (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter; ++ packet.header = (this.playerListHeader == null) ? new ChatComponentText("") : io.papermc.paper.adventure.PaperAdventure.asVanilla(this.playerListHeader); // Paper - Adventure ++ packet.footer = (this.playerListFooter == null) ? new ChatComponentText("") : io.papermc.paper.adventure.PaperAdventure.asVanilla(this.playerListFooter); // Paper - Adventure + getHandle().playerConnection.sendPacket(packet); + } + +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + getHandle().playerConnection.disconnect(message == null ? "" : message); + } + ++ // Paper start ++ @Override ++ public void kick(final net.kyori.adventure.text.Component message) { ++ org.spigotmc.AsyncCatcher.catchOp("player kick"); ++ final PlayerConnection connection = this.getHandle().playerConnection; ++ if (connection != null) { ++ connection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla( ++ message == null ? net.kyori.adventure.text.Component.empty() : message ++ )); ++ } ++ } ++ // Paper end ++ + @Override + public void setCompassTarget(Location loc) { + if (getHandle().playerConnection == null) return; +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + getHandle().playerConnection.sendPacket(packet); + } + ++ // Paper start ++ @Override ++ public void sendSignChange(Location loc, List lines) { ++ this.sendSignChange(loc, lines, org.bukkit.DyeColor.BLACK); ++ } ++ @Override ++ public void sendSignChange(Location loc, List lines, DyeColor dyeColor) { ++ if (getHandle().playerConnection == null) { ++ return; ++ } ++ if (lines == null) { ++ lines = new java.util.ArrayList<>(4); ++ } ++ Validate.notNull(loc, "Location cannot be null"); ++ Validate.notNull(dyeColor, "DyeColor cannot be null"); ++ if (lines.size() < 4) { ++ throw new IllegalArgumentException("Must have at least 4 lines"); ++ } ++ IChatBaseComponent[] components = CraftSign.sanitizeLines(lines); ++ this.sendSignChange0(components, loc, dyeColor); ++ } ++ ++ private void sendSignChange0(IChatBaseComponent[] components, Location loc, DyeColor dyeColor) { ++ TileEntitySign sign = new TileEntitySign(); ++ sign.setPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); ++ sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData())); ++ System.arraycopy(components, 0, sign.lines, 0, sign.lines.length); ++ ++ getHandle().playerConnection.sendPacket(sign.getUpdatePacket()); ++ } ++ // Paper end + @Override + public void sendSignChange(Location loc, String[] lines) { + sendSignChange(loc, lines, DyeColor.BLACK); +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + + IChatBaseComponent[] components = CraftSign.sanitizeLines(lines); +- TileEntitySign sign = new TileEntitySign(); ++ /*TileEntitySign sign = new TileEntitySign(); // Paper + sign.setPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData())); + System.arraycopy(components, 0, sign.lines, 0, sign.lines.length); + +- getHandle().playerConnection.sendPacket(sign.getUpdatePacket()); ++ getHandle().playerConnection.sendPacket(sign.getUpdatePacket());*/ // Paper ++ this.sendSignChange0(components, loc, dyeColor); // Paper + } + + @Override +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + return (getHandle().clientViewDistance == null) ? Bukkit.getViewDistance() : getHandle().clientViewDistance; + } + ++ // Paper start ++ @Override ++ public java.util.Locale locale() { ++ return getHandle().adventure$locale; ++ } ++ // Paper end + @Override + public String getLocale() { + return getHandle().locale; +@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + getInventory().setItemInMainHand(hand); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component displayName() { ++ return this.getHandle().adventure$displayName; ++ } ++ ++ @Override ++ public void displayName(final net.kyori.adventure.text.Component displayName) { ++ this.getHandle().adventure$displayName = displayName; ++ } ++ ++ @Override ++ public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { ++ final PacketPlayOutChat packet = new PacketPlayOutChat(null, type == net.kyori.adventure.audience.MessageType.CHAT ? net.minecraft.server.ChatMessageType.CHAT : net.minecraft.server.ChatMessageType.SYSTEM, identity.uuid()); ++ packet.adventure$message = message; ++ this.getHandle().playerConnection.sendPacket(packet); ++ } ++ ++ @Override ++ public void sendActionBar(final net.kyori.adventure.text.Component message) { ++ final PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, null); ++ packet.adventure$text = message; ++ this.getHandle().playerConnection.sendPacket(packet); ++ } ++ ++ @Override ++ public void sendPlayerListHeader(final net.kyori.adventure.text.Component header) { ++ this.playerListHeader = header; ++ this.adventure$sendPlayerListHeaderAndFooter(); ++ } ++ ++ @Override ++ public void sendPlayerListFooter(final net.kyori.adventure.text.Component footer) { ++ this.playerListFooter = footer; ++ this.adventure$sendPlayerListHeaderAndFooter(); ++ } ++ ++ @Override ++ public void sendPlayerListHeaderAndFooter(final net.kyori.adventure.text.Component header, final net.kyori.adventure.text.Component footer) { ++ this.playerListHeader = header; ++ this.playerListFooter = footer; ++ this.adventure$sendPlayerListHeaderAndFooter(); ++ } ++ ++ private void adventure$sendPlayerListHeaderAndFooter() { ++ final PlayerConnection connection = this.getHandle().playerConnection; ++ if (connection == null) return; ++ final PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); ++ 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; ++ connection.sendPacket(packet); ++ } ++ ++ @Override ++ public void showTitle(final net.kyori.adventure.title.Title title) { ++ final PlayerConnection connection = this.getHandle().playerConnection; ++ final net.kyori.adventure.title.Title.Times times = title.times(); ++ if (times != null) { ++ connection.sendPacket(new PacketPlayOutTitle(ticks(times.fadeIn()), ticks(times.fadeOut()), ticks(times.stay()))); ++ } ++ final PacketPlayOutTitle sp = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, null); ++ sp.adventure$text = title.subtitle(); ++ connection.sendPacket(sp); ++ final PacketPlayOutTitle tp = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, null); ++ tp.adventure$text = title.title(); ++ connection.sendPacket(tp); ++ } ++ ++ private static int ticks(final java.time.Duration duration) { ++ if (duration == null) { ++ return -1; ++ } ++ return (int) (duration.toMillis() / 50L); ++ } ++ ++ @Override ++ public void clearTitle() { ++ this.getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, null)); ++ } ++ ++ // resetTitle implemented above ++ ++ @Override ++ public void showBossBar(final net.kyori.adventure.bossbar.BossBar bar) { ++ ((net.kyori.adventure.bossbar.HackyBossBarPlatformBridge) bar).paper$playerShow(this); ++ } ++ ++ @Override ++ public void hideBossBar(final net.kyori.adventure.bossbar.BossBar bar) { ++ ((net.kyori.adventure.bossbar.HackyBossBarPlatformBridge) bar).paper$playerHide(this); ++ } ++ ++ @Override ++ public void playSound(final net.kyori.adventure.sound.Sound sound) { ++ final Vec3D pos = this.getHandle().getPositionVector(); ++ this.playSound(sound, pos.x, pos.y, pos.z); ++ } ++ ++ @Override ++ public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) { ++ final MinecraftKey name = io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.name()); ++ final java.util.Optional event = net.minecraft.server.IRegistry.SOUND_EVENT.getOptional(name); ++ if (event.isPresent()) { ++ this.getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(event.get(), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), x, y, z, sound.volume(), sound.pitch())); ++ } else { ++ this.getHandle().playerConnection.sendPacket(new PacketPlayOutCustomSoundEffect(name, io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), new Vec3D(x, y, z), sound.volume(), sound.pitch())); ++ } ++ } ++ ++ @Override ++ public void stopSound(final net.kyori.adventure.sound.SoundStop stop) { ++ this.getHandle().playerConnection.sendPacket(new PacketPlayOutStopSound( ++ io.papermc.paper.adventure.PaperAdventure.asVanillaNullable(stop.sound()), ++ io.papermc.paper.adventure.PaperAdventure.asVanillaNullable(stop.source()) ++ )); ++ } ++ ++ @Override ++ public void openBook(final net.kyori.adventure.inventory.Book book) { ++ final java.util.Locale locale = this.getHandle().adventure$locale; ++ final net.minecraft.server.ItemStack item = io.papermc.paper.adventure.PaperAdventure.asItemStack(book, locale); ++ final EntityPlayer player = this.getHandle(); ++ final PlayerConnection connection = player.playerConnection; ++ final net.minecraft.server.PlayerInventory inventory = player.inventory; ++ final int slot = inventory.items.size() + inventory.itemInHandIndex; ++ connection.sendPacket(new net.minecraft.server.PacketPlayOutSetSlot(0, slot, item)); ++ connection.sendPacket(new net.minecraft.server.PacketPlayOutOpenBook(net.minecraft.server.EnumHand.MAIN_HAND)); ++ connection.sendPacket(new net.minecraft.server.PacketPlayOutSetSlot(0, slot, inventory.getItemInHand())); ++ } ++ // Paper end ++ + // Spigot start + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +@@ -0,0 +0,0 @@ public class CraftEventFactory { + return event; + } + +- public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List drops, String deathMessage, boolean keepInventory) { ++ public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List 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); +@@ -0,0 +0,0 @@ public class CraftEventFactory { + * Server methods + */ + public static ServerListPingEvent callServerListPingEvent(Server craftServer, InetAddress address, String motd, int numPlayers, int maxPlayers) { +- ServerListPingEvent event = new ServerListPingEvent(address, motd, numPlayers, maxPlayers); ++ ServerListPingEvent event = new ServerListPingEvent(address, craftServer.motd(), numPlayers, maxPlayers); // Paper - Adventure + craftServer.getPluginManager().callEvent(event); + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +@@ -0,0 +0,0 @@ public class CraftContainer extends Container { + + private final InventoryView view; + private InventoryType cachedType; ++ private net.kyori.adventure.text.Component adventure$title; // Paper + private String cachedTitle; + private Container delegate; + private final int cachedSize; +@@ -0,0 +0,0 @@ public class CraftContainer extends Container { + IInventory top = ((CraftInventory) view.getTopInventory()).getInventory(); + PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory(); + cachedType = view.getType(); +- cachedTitle = view.getTitle(); ++ this.adventure$title = view.title(); // Paper ++ if (this.adventure$title == null) this.adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(view.getTitle()); // Paper ++ //cachedTitle = view.getTitle(); // Paper - comment + cachedSize = getSize(); + setupSlots(top, bottom, player); + } +@@ -0,0 +0,0 @@ public class CraftContainer extends Container { + return inventory.getType(); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component title() { ++ return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).title() : net.kyori.adventure.text.Component.text(inventory.getType().getDefaultTitle()); ++ } ++ // Paper end ++ + @Override + public String getTitle() { + return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle(); +@@ -0,0 +0,0 @@ public class CraftContainer extends Container { + + @Override + public boolean c(EntityHuman entityhuman) { +- 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 +@@ -0,0 +0,0 @@ public class CraftContainer extends Container { + // 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 = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(view.getTitle()); // Paper ++ //cachedTitle = view.getTitle(); // Paper - comment + if (view.getPlayer() instanceof CraftPlayer) { + CraftPlayer player = (CraftPlayer) view.getPlayer(); + Containers type = getNotchInventoryType(view.getTopInventory()); +@@ -0,0 +0,0 @@ public class CraftContainer extends Container { + setupSlots(top, bottom, player.getHandle()); + } + int size = getSize(); +- player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle))); ++ player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, 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 + player.updateInventory(); + } + return true; +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +@@ -0,0 +0,0 @@ public class CraftInventoryCustom extends CraftInventory { + super(new MinecraftInventory(owner, type)); + } + ++ // Paper start ++ public CraftInventoryCustom(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ super(new MinecraftInventory(owner, type, title)); ++ } ++ // Paper end ++ + public CraftInventoryCustom(InventoryHolder owner, InventoryType type, String title) { + super(new MinecraftInventory(owner, type, title)); + } +@@ -0,0 +0,0 @@ public class CraftInventoryCustom extends CraftInventory { + super(new MinecraftInventory(owner, size)); + } + ++ // Paper start ++ public CraftInventoryCustom(InventoryHolder owner, int size, net.kyori.adventure.text.Component title) { ++ super(new MinecraftInventory(owner, size, title)); ++ } ++ // Paper end ++ + public CraftInventoryCustom(InventoryHolder owner, int size, String title) { + super(new MinecraftInventory(owner, size, title)); + } +@@ -0,0 +0,0 @@ public class CraftInventoryCustom extends CraftInventory { + private final NonNullList items; + private int maxStack = MAX_STACK; + private final List viewers; +- private final String title; ++ private final net.kyori.adventure.text.Component adventure$title; // Paper ++ private String title; // Paper - remove final + private InventoryType type; + private final InventoryHolder owner; + ++ // Paper start ++ public MinecraftInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ this(owner, type.getDefaultSize(), title); ++ this.type = type; ++ } ++ // Paper end ++ + public MinecraftInventory(InventoryHolder owner, InventoryType type) { + this(owner, type.getDefaultSize(), type.getDefaultTitle()); + this.type = type; +@@ -0,0 +0,0 @@ public class CraftInventoryCustom extends CraftInventory { + this(owner, size, "Chest"); + } + ++ // Paper start + public MinecraftInventory(InventoryHolder owner, int size, String title) { ++ this(owner, size, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(title)); ++ } ++ // Paper end ++ ++ public MinecraftInventory(InventoryHolder owner, int size, net.kyori.adventure.text.Component title) { // Paper - String -> net.kyori.adventure.text.Component + Validate.notNull(title, "Title cannot be null"); + this.items = NonNullList.a(size, ItemStack.b); +- this.title = title; ++ this.adventure$title = title; + this.viewers = new ArrayList(); + this.owner = owner; + this.type = InventoryType.CHEST; +@@ -0,0 +0,0 @@ public class CraftInventoryCustom extends CraftInventory { + return null; + } + ++ // Paper start ++ public net.kyori.adventure.text.Component title() { ++ return this.adventure$title; ++ } ++ // Paper end ++ + public String getTitle() { ++ // Paper start ++ if (this.title == null) { ++ this.title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.adventure$title); ++ } ++ // Paper end + return title; + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +@@ -0,0 +0,0 @@ public class CraftInventoryView extends InventoryView { + return CraftItemStack.asCraftMirror(container.getSlot(slot).getItem()); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component title() { ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.container.getTitle()); ++ } ++ // Paper end ++ + @Override + public String getTitle() { + return CraftChatMessage.fromComponent(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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { + public Material updateMaterial(ItemMeta meta, Material material) throws IllegalArgumentException { + return ((CraftMetaItem) meta).updateMaterial(material); + } ++ ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.event.HoverEvent asHoverEvent(final ItemStack item, final java.util.function.UnaryOperator op) { ++ final net.minecraft.server.NBTTagCompound tag = CraftItemStack.asNMSCopy(item).getTag(); ++ return net.kyori.adventure.text.event.HoverEvent.showItem(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowItem.of(item.getType().getKey(), item.getAmount(), io.papermc.paper.adventure.PaperAdventure.asBinaryTagHolder(tag)))); ++ } ++ // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +@@ -0,0 +0,0 @@ import org.apache.commons.lang.Validate; + + public class CraftMerchantCustom extends CraftMerchant { + ++ @Deprecated // Paper - Adventure + public CraftMerchantCustom(String title) { + super(new MinecraftMerchant(title)); + getMerchant().craftMerchant = this; + } ++ // Paper start ++ public CraftMerchantCustom(net.kyori.adventure.text.Component title) { ++ super(new MinecraftMerchant(title)); ++ getMerchant().craftMerchant = this; ++ } ++ // Paper end + + @Override + public String toString() { +@@ -0,0 +0,0 @@ public class CraftMerchantCustom extends CraftMerchant { + private World tradingWorld; + protected CraftMerchant craftMerchant; + ++ @Deprecated // Paper - Adventure + public MinecraftMerchant(String title) { + Validate.notNull(title, "Title cannot be null"); + this.title = new ChatComponentText(title); + } ++ // Paper start ++ public MinecraftMerchant(net.kyori.adventure.text.Component title) { ++ Validate.notNull(title, "Title cannot be null"); ++ this.title = io.papermc.paper.adventure.PaperAdventure.asVanilla(title); ++ } ++ // Paper end + + @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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +@@ -0,0 +0,0 @@ package org.bukkit.craftbukkit.inventory; + + import com.google.common.collect.ImmutableList; + import com.google.common.collect.Lists; +-import com.google.common.collect.ImmutableMap.Builder; ++ ++import com.google.common.collect.ImmutableMap; // Paper + import java.util.ArrayList; + import java.util.Arrays; + import java.util.List; + import java.util.Map; + import java.util.Objects; ++import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; ++import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; + import net.minecraft.server.IChatBaseComponent; + import net.minecraft.server.NBTTagCompound; + import net.minecraft.server.NBTTagList; +@@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { + this.generation = (generation == null) ? null : generation.ordinal(); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component title() { ++ return this.title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.title); ++ } ++ ++ @Override ++ public org.bukkit.inventory.meta.BookMeta title(net.kyori.adventure.text.Component title) { ++ this.setTitle(title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title)); ++ return this; ++ } ++ ++ @Override ++ public net.kyori.adventure.text.Component author() { ++ return this.author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.author); ++ } ++ ++ @Override ++ public org.bukkit.inventory.meta.BookMeta author(net.kyori.adventure.text.Component author) { ++ this.setAuthor(author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author)); ++ return this; ++ } ++ ++ @Override ++ public net.kyori.adventure.text.Component page(final int page) { ++ Validate.isTrue(isValidPage(page), "Invalid page number"); ++ return this instanceof CraftMetaBookSigned ? GsonComponentSerializer.gson().deserialize(pages.get(page - 1)) : LegacyComponentSerializer.legacySection().deserialize(pages.get(page - 1)); ++ } ++ ++ @Override ++ public void page(final int page, net.kyori.adventure.text.Component data) { ++ if (!isValidPage(page)) { ++ throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size()); ++ } ++ if (data == null) { ++ data = net.kyori.adventure.text.Component.empty(); ++ } ++ pages.set(page - 1, this instanceof CraftMetaBookSigned ? GsonComponentSerializer.gson().serialize(data) : LegacyComponentSerializer.legacySection().serialize(data)); ++ } ++ ++ @Override ++ public List pages() { ++ if (this.pages == null) return ImmutableList.of(); ++ if (this instanceof CraftMetaBookSigned) ++ return pages.stream().map(GsonComponentSerializer.gson()::deserialize).collect(ImmutableList.toImmutableList()); ++ else ++ return pages.stream().map(LegacyComponentSerializer.legacySection()::deserialize).collect(ImmutableList.toImmutableList()); ++ } ++ ++ @Override ++ public BookMeta pages(List pages) { ++ if (this.pages != null) this.pages.clear(); ++ for (net.kyori.adventure.text.Component page : pages) { ++ addPages(page); ++ } ++ return this; ++ } ++ ++ @Override ++ public BookMeta pages(net.kyori.adventure.text.Component... pages) { ++ if (this.pages != null) this.pages.clear(); ++ addPages(pages); ++ return this; ++ } ++ ++ @Override ++ public void addPages(net.kyori.adventure.text.Component... pages) { ++ if (this.pages == null) this.pages = new ArrayList<>(); ++ for (net.kyori.adventure.text.Component page : pages) { ++ if (this.pages.size() >= MAX_PAGES) { ++ return; ++ } ++ ++ if (page == null) { ++ page = net.kyori.adventure.text.Component.empty(); ++ } ++ ++ this.pages.add(this instanceof CraftMetaBookSigned ? GsonComponentSerializer.gson().serialize(page) : LegacyComponentSerializer.legacySection().serialize(page)); ++ } ++ } ++ ++ private CraftMetaBook(net.kyori.adventure.text.Component title, net.kyori.adventure.text.Component author, List pages) { ++ super((org.bukkit.craftbukkit.inventory.CraftMetaItem) org.bukkit.Bukkit.getItemFactory().getItemMeta(org.bukkit.Material.WRITABLE_BOOK)); ++ this.title = title == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(title); ++ this.author = author == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(author); ++ this.pages = pages.subList(0, Math.min(MAX_PAGES, pages.size())).stream().map(LegacyComponentSerializer.legacySection()::serialize).collect(java.util.stream.Collectors.toList()); ++ } ++ ++ static final class CraftMetaBookBuilder implements BookMetaBuilder { ++ private net.kyori.adventure.text.Component title = null; ++ private net.kyori.adventure.text.Component author = null; ++ private final List pages = new java.util.ArrayList<>(); ++ ++ @Override ++ public BookMetaBuilder title(net.kyori.adventure.text.Component title) { ++ this.title = title; ++ return this; ++ } ++ ++ @Override ++ public BookMetaBuilder author(net.kyori.adventure.text.Component author) { ++ this.author = author; ++ return this; ++ } ++ ++ @Override ++ public BookMetaBuilder addPage(net.kyori.adventure.text.Component page) { ++ this.pages.add(page); ++ return this; ++ } ++ ++ @Override ++ public BookMetaBuilder pages(net.kyori.adventure.text.Component... pages) { ++ java.util.Collections.addAll(this.pages, pages); ++ return this; ++ } ++ ++ @Override ++ public BookMetaBuilder pages(java.util.Collection pages) { ++ this.pages.addAll(pages); ++ return this; ++ } ++ ++ @Override ++ public BookMeta build() { ++ return new CraftMetaBook(title, author, pages); ++ } ++ } ++ // Paper end + @Override + public String getPage(final int page) { + Validate.isTrue(isValidPage(page), "Invalid page number"); +@@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { + } + + @Override +- Builder serialize(Builder builder) { ++ ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { + super.serialize(builder); + + if (hasTitle()) { +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java +@@ -0,0 +0,0 @@ + package org.bukkit.craftbukkit.inventory; + +-import com.google.common.collect.ImmutableMap.Builder; ++import com.google.common.collect.ImmutableMap; // Paper + import java.util.Map; + import net.minecraft.server.NBTTagCompound; + import org.bukkit.Material; +@@ -0,0 +0,0 @@ class CraftMetaBookSigned extends CraftMetaBook implements BookMeta { + } + + @Override +- Builder serialize(Builder builder) { ++ ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { + super.serialize(builder); + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +@@ -0,0 +0,0 @@ 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()); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component displayName() { ++ return displayName == null ? null : net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(displayName); ++ } ++ ++ @Override ++ public void displayName(final net.kyori.adventure.text.Component displayName) { ++ this.displayName = displayName == null ? null : net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().serialize(displayName); ++ } ++ // Paper end ++ + @Override + public String getDisplayName() { + return CraftChatMessage.fromJSONComponent(displayName); +@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { + return this.lore != null && !this.lore.isEmpty(); + } + ++ // Paper start ++ @Override ++ public List lore() { ++ return this.lore != null ? io.papermc.paper.adventure.PaperAdventure.asAdventureFromJson(this.lore) : null; ++ } ++ ++ @Override ++ public void lore(final List lore) { ++ this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asJson(lore) : null; ++ } ++ // Paper end ++ + @Override + public boolean hasRepairCost() { + return 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftCustomInventoryConverter.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftCustomInventoryConverter.java +@@ -0,0 +0,0 @@ public class CraftCustomInventoryConverter implements CraftInventoryCreator.Inve + return new CraftInventoryCustom(holder, type); + } + ++ // Paper start ++ @Override ++ public Inventory createInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ return new CraftInventoryCustom(owner, type, title); ++ } ++ // Paper end ++ + @Override + public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { + return new CraftInventoryCustom(owner, type, title); +@@ -0,0 +0,0 @@ public class CraftCustomInventoryConverter implements CraftInventoryCreator.Inve + return new CraftInventoryCustom(owner, size); + } + ++ // Paper start ++ public Inventory createInventory(InventoryHolder owner, int size, net.kyori.adventure.text.Component title) { ++ return new CraftInventoryCustom(owner, size, title); ++ } ++ // Paper end ++ + public Inventory createInventory(InventoryHolder owner, int size, String title) { + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java +@@ -0,0 +0,0 @@ public final class CraftInventoryCreator { + return converterMap.get(type).createInventory(holder, type); + } + ++ // Paper start ++ public Inventory createInventory(InventoryHolder holder, InventoryType type, net.kyori.adventure.text.Component title) { ++ // Paper start ++ if (holder != null) { ++ return DEFAULT_CONVERTER.createInventory(holder, type, title); ++ } ++ //noinspection ConstantConditions // Paper end ++ return converterMap.get(type).createInventory(holder, type, title); ++ } ++ // Paper end ++ + public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { + return converterMap.get(type).createInventory(holder, type, title); + } +@@ -0,0 +0,0 @@ public final class CraftInventoryCreator { + return DEFAULT_CONVERTER.createInventory(holder, size); + } + ++ // Paper start ++ public Inventory createInventory(InventoryHolder holder, int size, net.kyori.adventure.text.Component title) { ++ return DEFAULT_CONVERTER.createInventory(holder, size, title); ++ } ++ // Paper end ++ + public Inventory createInventory(InventoryHolder holder, int size, String title) { + return DEFAULT_CONVERTER.createInventory(holder, size, title); + } +@@ -0,0 +0,0 @@ public final class CraftInventoryCreator { + + Inventory createInventory(InventoryHolder holder, InventoryType type); + ++ // Paper start ++ Inventory createInventory(InventoryHolder holder, InventoryType type, net.kyori.adventure.text.Component title); ++ // Paper end ++ + Inventory createInventory(InventoryHolder holder, InventoryType type, String title); + } + } +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +@@ -0,0 +0,0 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat + return getInventory(getTileEntity()); + } + ++ // Paper start ++ @Override ++ public Inventory createInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ IInventory te = getTileEntity(); ++ if (te instanceof TileEntityLootable) { ++ ((TileEntityLootable) te).setCustomName(io.papermc.paper.adventure.PaperAdventure.asVanilla(title)); ++ } ++ ++ return getInventory(te); ++ } ++ // Paper end ++ + @Override + public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { + IInventory te = getTileEntity(); +@@ -0,0 +0,0 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat + return furnace; + } + ++ // Paper start ++ @Override ++ public Inventory createInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ IInventory tileEntity = getTileEntity(); ++ ((TileEntityFurnace) tileEntity).setCustomName(io.papermc.paper.adventure.PaperAdventure.asVanilla(title)); ++ return getInventory(tileEntity); ++ } ++ // Paper end ++ + @Override + public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { + IInventory tileEntity = getTileEntity(); +@@ -0,0 +0,0 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat + return new TileEntityBrewingStand(); + } + ++ // Paper start ++ @Override ++ public Inventory createInventory(InventoryHolder owner, InventoryType type, net.kyori.adventure.text.Component title) { ++ // BrewingStand does not extend TileEntityLootable ++ IInventory tileEntity = getTileEntity(); ++ if (tileEntity instanceof TileEntityBrewingStand) { ++ ((TileEntityBrewingStand) tileEntity).setCustomName(io.papermc.paper.adventure.PaperAdventure.asVanilla(title)); ++ } ++ return getInventory(tileEntity); ++ } ++ // Paper end ++ + @Override + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java +@@ -0,0 +0,0 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective + return objective.getName(); + } + ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component displayName() throws IllegalStateException { ++ CraftScoreboard scoreboard = checkState(); ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(objective.getDisplayName()); ++ } ++ @Override ++ public void displayName(net.kyori.adventure.text.Component displayName) throws IllegalStateException, IllegalArgumentException { ++ if (displayName == null) { ++ displayName = net.kyori.adventure.text.Component.empty(); ++ } ++ CraftScoreboard scoreboard = checkState(); ++ objective.setDisplayName(io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName)); ++ } ++ // Paper end + @Override + public String getDisplayName() throws IllegalStateException { + CraftScoreboard scoreboard = checkState(); +diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java +@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { + public CraftObjective registerNewObjective(String name, String criteria) throws IllegalArgumentException { + return registerNewObjective(name, criteria, name); + } ++ // Paper start ++ @Override ++ public CraftObjective registerNewObjective(String name, String criteria, net.kyori.adventure.text.Component displayName) { ++ return registerNewObjective(name, criteria, displayName, org.bukkit.scoreboard.RenderType.INTEGER); ++ } ++ @Override ++ public CraftObjective registerNewObjective(String name, String criteria, net.kyori.adventure.text.Component displayName, RenderType renderType) { ++ if (displayName == null) { ++ displayName = net.kyori.adventure.text.Component.empty(); ++ } ++ Validate.notNull(name, "Objective name cannot be null"); ++ Validate.notNull(criteria, "Criteria cannot be null"); ++ Validate.notNull(displayName, "Display name cannot be null"); ++ Validate.notNull(renderType, "RenderType cannot be null"); ++ 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); ++ ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); ++ return new CraftObjective(this, objective); ++ } ++ // Paper end + + @Override + public CraftObjective registerNewObjective(String name, String criteria, String displayName) throws IllegalArgumentException { +@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { + + @Override + public CraftObjective registerNewObjective(String name, String criteria, String displayName, RenderType renderType) throws IllegalArgumentException { +- Validate.notNull(name, "Objective name cannot be null"); ++ /*Validate.notNull(name, "Objective name cannot be null"); // Paper + Validate.notNull(criteria, "Criteria cannot be null"); + Validate.notNull(displayName, "Display name cannot be null"); + Validate.notNull(renderType, "RenderType cannot be null"); +@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { + + CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); + ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); +- return new CraftObjective(this, objective); ++ return new CraftObjective(this, objective);*/ // Paper ++ return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName)); // Paper + } + + @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +@@ -0,0 +0,0 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { + + return team.getName(); + } ++ // Paper start ++ @Override ++ public net.kyori.adventure.text.Component displayName() throws IllegalStateException { ++ CraftScoreboard scoreboard = checkState(); ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(team.getDisplayName()); ++ } ++ @Override ++ public void displayName(net.kyori.adventure.text.Component displayName) throws IllegalStateException, IllegalArgumentException { ++ if (displayName == null) displayName = net.kyori.adventure.text.Component.empty(); ++ CraftScoreboard scoreboard = checkState(); ++ team.setDisplayName(io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName)); ++ } ++ @Override ++ public net.kyori.adventure.text.Component prefix() throws IllegalStateException { ++ CraftScoreboard scoreboard = checkState(); ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(team.getPrefix()); ++ } ++ @Override ++ public void prefix(net.kyori.adventure.text.Component prefix) throws IllegalStateException, IllegalArgumentException { ++ if (prefix == null) prefix = net.kyori.adventure.text.Component.empty(); ++ CraftScoreboard scoreboard = checkState(); ++ team.setPrefix(io.papermc.paper.adventure.PaperAdventure.asVanilla(prefix)); ++ } ++ @Override ++ public net.kyori.adventure.text.Component suffix() throws IllegalStateException { ++ CraftScoreboard scoreboard = checkState(); ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(team.getSuffix()); ++ } ++ @Override ++ public void suffix(net.kyori.adventure.text.Component suffix) throws IllegalStateException, IllegalArgumentException { ++ if (suffix == null) suffix = net.kyori.adventure.text.Component.empty(); ++ CraftScoreboard scoreboard = checkState(); ++ team.setSuffix(io.papermc.paper.adventure.PaperAdventure.asVanilla(suffix)); ++ } ++ @Override ++ public net.kyori.adventure.text.format.TextColor color() throws IllegalStateException { ++ CraftScoreboard scoreboard = checkState(); ++ if (team.getColor().getHexValue() == null) throw new IllegalStateException("Team colors must have hex values"); ++ net.kyori.adventure.text.format.TextColor color = net.kyori.adventure.text.format.TextColor.color(team.getColor().getHexValue()); ++ if (!(color instanceof net.kyori.adventure.text.format.NamedTextColor)) throw new IllegalStateException("Team doesn't have a NamedTextColor"); ++ return (net.kyori.adventure.text.format.NamedTextColor) color; ++ } ++ @Override ++ public void color(net.kyori.adventure.text.format.NamedTextColor color) { ++ if (color == null) color = net.kyori.adventure.text.format.NamedTextColor.WHITE; ++ CraftScoreboard scoreboard = checkState(); ++ team.setColor(io.papermc.paper.adventure.PaperAdventure.asVanilla(color)); ++ } ++ // Paper end + + @Override + public String getDisplayName() throws IllegalStateException { diff --git a/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch b/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch index cb6c31f46b..a2c4d63f75 100644 --- a/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch +++ b/Spigot-Server-Patches/Allow-Reloading-of-Custom-Permissions.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return null; } + return this.adventure$audiences; } + + @Override diff --git a/Spigot-Server-Patches/Broadcast-join-message-to-console.patch b/Spigot-Server-Patches/Broadcast-join-message-to-console.patch index 58ea9674fd..3b5bd59202 100644 --- a/Spigot-Server-Patches/Broadcast-join-message-to-console.patch +++ b/Spigot-Server-Patches/Broadcast-join-message-to-console.patch @@ -9,14 +9,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - joinMessage = playerJoinEvent.getJoinMessage(); + joinMessage = PaperAdventure.asVanilla(playerJoinEvent.joinMessage()); // Paper - Adventure - if (joinMessage != null && joinMessage.length() > 0) { -- for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { -- server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b)); -- } + if (playerJoinEvent.joinMessage() != net.kyori.adventure.text.Component.empty()) { // Paper - Adventure +- server.getPlayerList().sendAll(new PacketPlayOutChat(joinMessage, ChatMessageType.SYSTEM, SystemUtils.b)); // Paper - Adventure + // Paper start - Removed sendAll for loop and broadcasted to console also -+ server.getPlayerList().sendMessage(CraftChatMessage.fromString(joinMessage)); ++ server.getPlayerList().sendMessage(joinMessage); // Paper - Adventure + // Paper end } // CraftBukkit end diff --git a/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch b/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch index 8a16518afa..9ad6a06d86 100644 --- a/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch +++ b/Spigot-Server-Patches/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/ChunkMapDistance.java +++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java @@ -0,0 +0,0 @@ public abstract class ChunkMapDistance { + long i = sectionposition.r().pair(); ObjectSet objectset = (ObjectSet) this.c.get(i); - if (objectset == null) return; // CraftBukkit - SPIGOT-6208 - objectset.remove(entityplayer); - if (objectset.isEmpty()) { diff --git a/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch b/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch index a60240fdf4..59ccc44c0f 100644 --- a/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch +++ b/Spigot-Server-Patches/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PacketPlayOutChat.java +++ b/src/main/java/net/minecraft/server/PacketPlayOutChat.java @@ -0,0 +0,0 @@ public class PacketPlayOutChat implements Packet { - public void b(PacketDataSerializer packetdataserializer) throws IOException { + // Paper end // Spigot start if (components != null) { - packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components)); diff --git a/Spigot-Server-Patches/Entity-Activation-Range-2.0.patch b/Spigot-Server-Patches/Entity-Activation-Range-2.0.patch index 09032c6bf5..a8cd8e38bb 100644 --- a/Spigot-Server-Patches/Entity-Activation-Range-2.0.patch +++ b/Spigot-Server-Patches/Entity-Activation-Range-2.0.patch @@ -443,10 +443,10 @@ diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -0,0 +0,0 @@ - package org.spigotmc; +@@ -0,0 +0,0 @@ package org.spigotmc; import java.util.Collection; + import java.util.List; + +import net.minecraft.server.Activity; import net.minecraft.server.AxisAlignedBB; @@ -634,7 +634,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ private static void activateChunkEntities(Chunk chunk) { -- for ( java.util.List slice : chunk.entitySlices ) +- for ( List slice : chunk.entitySlices ) - { - for ( Entity entity : (Collection) slice ) + // Paper start diff --git a/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch b/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch index d2dbeef458..f28846366f 100644 --- a/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch +++ b/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch @@ -21,10 +21,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - getInventory().setItemInMainHand(hand); + connection.sendPacket(new net.minecraft.server.PacketPlayOutOpenBook(net.minecraft.server.EnumHand.MAIN_HAND)); + connection.sendPacket(new net.minecraft.server.PacketPlayOutSetSlot(0, slot, inventory.getItemInHand())); } - -+ // Paper start ++ + public float getCooldownPeriod() { + return getHandle().getCooldownPeriod(); + } @@ -36,8 +36,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void resetCooldown() { + getHandle().resetAttackCooldown(); + } -+ // Paper end -+ + // Paper end + // Spigot start - private final Player.Spigot spigot = new Player.Spigot() - { diff --git a/Spigot-Server-Patches/Fix-CraftServer-isPrimaryThread-and-MinecraftServer-.patch b/Spigot-Server-Patches/Fix-CraftServer-isPrimaryThread-and-MinecraftServer-.patch index 73c15fe4cc..dad391c30d 100644 --- a/Spigot-Server-Patches/Fix-CraftServer-isPrimaryThread-and-MinecraftServer-.patch +++ b/Spigot-Server-Patches/Fix-CraftServer-isPrimaryThread-and-MinecraftServer-.patch @@ -40,4 +40,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return Thread.currentThread().equals(console.serverThread); // Paper - Fix issues with detecting main thread properly } - @Override + // Paper start diff --git a/Spigot-Server-Patches/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch b/Spigot-Server-Patches/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch index 0563a05afc..2579ce27b1 100644 --- a/Spigot-Server-Patches/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch +++ b/Spigot-Server-Patches/Fix-Longstanding-Broken-behavior-of-PlayerJoinEvent.patch @@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + mountSavedVehicle(entityplayer, worldserver1, nbttagcompound); + // Paper end // CraftBukkit start - PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage); + PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(cserver.getPlayer(entityplayer), PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure cserver.getPluginManager().callEvent(playerJoinEvent); @@ -0,0 +0,0 @@ public abstract class PlayerList { entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); diff --git a/Spigot-Server-Patches/Fix-exploit-that-allowed-colored-signs-to-be-created.patch b/Spigot-Server-Patches/Fix-exploit-that-allowed-colored-signs-to-be-created.patch index f1f7e769b1..a747273222 100644 --- a/Spigot-Server-Patches/Fix-exploit-that-allowed-colored-signs-to-be-created.patch +++ b/Spigot-Server-Patches/Fix-exploit-that-allowed-colored-signs-to-be-created.patch @@ -9,13 +9,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { - String[] lines = new String[4]; + List lines = new java.util.ArrayList<>(); for (int i = 0; i < list.size(); ++i) { -- lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a((String) list.get(i))).getString()); -+ lines[i] = SharedConstants.filterAllowedChatCharacters(list.get(i)); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. +- lines.add(net.kyori.adventure.text.Component.text(list.get(i))); ++ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(list.get(i)))); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. } - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); + SignChangeEvent event = new SignChangeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldserver, blockposition), this.getPlayer(), lines); this.server.getPluginManager().callEvent(event); diff --git a/src/main/java/net/minecraft/server/SharedConstants.java b/src/main/java/net/minecraft/server/SharedConstants.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/Spigot-Server-Patches/Fix-unregistering-entities-from-unloading-chunks.patch b/Spigot-Server-Patches/Fix-unregistering-entities-from-unloading-chunks.patch index 18e9b12652..e753c5fa81 100644 --- a/Spigot-Server-Patches/Fix-unregistering-entities-from-unloading-chunks.patch +++ b/Spigot-Server-Patches/Fix-unregistering-entities-from-unloading-chunks.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } private void removeEntityFromChunk(Entity entity) { -- IChunkAccess ichunkaccess = chunkProvider.getChunkUnchecked(entity.chunkX, entity.chunkZ); // CraftBukkit - SPIGOT-5228: getChunkAt won't find the entity's chunk if it has already been unloaded (i.e. if it switched to state INACCESSIBLE). +- IChunkAccess ichunkaccess = this.getChunkAt(entity.chunkX, entity.chunkZ, ChunkStatus.FULL, false); + Chunk ichunkaccess = entity.getCurrentChunk(); // Paper - getChunkAt(x,z,full,false) is broken by CraftBukkit as it won't return an unloading chunk. Use our current chunk reference as this points to what chunk they need to be removed from anyways - if (ichunkaccess instanceof Chunk) { diff --git a/Spigot-Server-Patches/Further-improve-server-tick-loop.patch b/Spigot-Server-Patches/Further-improve-server-tick-loop.patch index bd1cf11a9f..a353e25266 100644 --- a/Spigot-Server-Patches/Further-improve-server-tick-loop.patch +++ b/Spigot-Server-Patches/Further-improve-server-tick-loop.patch @@ -158,9 +158,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end + - // Spigot start private final Spigot spigot = new Spigot() { + diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java diff --git a/Spigot-Server-Patches/Implement-Player-Client-Options-API.patch b/Spigot-Server-Patches/Implement-Player-Client-Options-API.patch index 369df9816b..5c0ae0a90d 100644 --- a/Spigot-Server-Patches/Implement-Player-Client-Options-API.patch +++ b/Spigot-Server-Patches/Implement-Player-Client-Options-API.patch @@ -119,8 +119,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private Entity spectatedEntity; public boolean worldChangeInvuln; @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { - - public String locale = null; // CraftBukkit - lowercase // Paper - default to null + public String locale = null; // CraftBukkit - add, lowercase // Paper - default to null + public java.util.Locale adventure$locale = java.util.Locale.US; // Paper public void a(PacketPlayInSettings packetplayinsettings) { + new PlayerClientOptionsChangeEvent(getBukkitEntity(), packetplayinsettings.locale, packetplayinsettings.viewDistance, com.destroystokyo.paper.ClientOption.ChatVisibility.valueOf(packetplayinsettings.getChatVisibility().name()), packetplayinsettings.hasChatColorsEnabled(), new com.destroystokyo.paper.PaperSkinParts(packetplayinsettings.getSkinParts()), packetplayinsettings.getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT).callEvent(); // Paper - settings event // CraftBukkit start diff --git a/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch b/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch index d50a033311..180897ecb4 100644 --- a/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch +++ b/Spigot-Server-Patches/Implement-PlayerLocaleChangeEvent.patch @@ -13,10 +13,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - public String locale = "en_us"; // CraftBukkit - add, lowercase -+ public String locale = null; // CraftBukkit - lowercase // Paper - default to null ++ public String locale = null; // CraftBukkit - add, lowercase // Paper - default to null + public java.util.Locale adventure$locale = java.util.Locale.US; // Paper public void a(PacketPlayInSettings packetplayinsettings) { // CraftBukkit start - if (getMainHand() != packetplayinsettings.getMainHand()) { +@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); this.server.server.getPluginManager().callEvent(event); } @@ -27,13 +28,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packetplayinsettings.locale).callEvent(); // Paper } this.locale = packetplayinsettings.locale; - this.clientViewDistance = packetplayinsettings.viewDistance; + // Paper start diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - + // Paper end @Override public String getLocale() { - return getHandle().locale; diff --git a/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index a9636523c5..edfb7b9df4 100644 --- a/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -207,7 +207,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers() || hasPlaceableKeys() || hasDestroyableKeys()); // Paper - Implement an API for CanPlaceOn and CanDestroy NBT values } - @Override + // Paper start @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { && (this.hideFlag == that.hideFlag) && (this.isUnbreakable() == that.isUnbreakable()) diff --git a/Spigot-Server-Patches/Implement-ensureServerConversions-API.patch b/Spigot-Server-Patches/Implement-ensureServerConversions-API.patch index d5ca344c90..6e0e96ffeb 100644 --- a/Spigot-Server-Patches/Implement-ensureServerConversions-API.patch +++ b/Spigot-Server-Patches/Implement-ensureServerConversions-API.patch @@ -11,13 +11,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { - public Material updateMaterial(ItemMeta meta, Material material) throws IllegalArgumentException { - return ((CraftMetaItem) meta).updateMaterial(material); + final net.minecraft.server.NBTTagCompound tag = CraftItemStack.asNMSCopy(item).getTag(); + return net.kyori.adventure.text.event.HoverEvent.showItem(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowItem.of(item.getType().getKey(), item.getAmount(), io.papermc.paper.adventure.PaperAdventure.asBinaryTagHolder(tag)))); } ++ + // Paper start + @Override + public ItemStack ensureServerConversions(ItemStack item) { + return CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(item)); + } -+ // Paper end + // Paper end } diff --git a/Spigot-Server-Patches/Implemented-BlockFailedDispenseEvent.patch b/Spigot-Server-Patches/Implemented-BlockFailedDispenseEvent.patch index bcf7aab3f3..a41ecbfef3 100644 --- a/Spigot-Server-Patches/Implemented-BlockFailedDispenseEvent.patch +++ b/Spigot-Server-Patches/Implemented-BlockFailedDispenseEvent.patch @@ -40,6 +40,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.net.InetAddress; import java.util.ArrayList; import java.util.Collections; +@@ -0,0 +0,0 @@ import net.minecraft.server.EntityAnimal; + import net.minecraft.server.EntityAreaEffectCloud; + import net.minecraft.server.EntityDamageSource; + import net.minecraft.server.EntityDamageSourceIndirect; +-import net.minecraft.server.EntityEnderCrystal; + import net.minecraft.server.EntityEnderDragon; + import net.minecraft.server.EntityExperienceOrb; + import net.minecraft.server.EntityFireworks; +@@ -0,0 +0,0 @@ import net.minecraft.server.EntityVillager; + import net.minecraft.server.EntityWaterAnimal; + import net.minecraft.server.EnumDirection; + import net.minecraft.server.EnumHand; +-import net.minecraft.server.EnumItemSlot; + import net.minecraft.server.Explosion; + import net.minecraft.server.GeneratorAccess; + import net.minecraft.server.IBlockData; +-import net.minecraft.server.IChatBaseComponent; + import net.minecraft.server.IInventory; + import net.minecraft.server.IProjectile; + import net.minecraft.server.ItemActionContext; +@@ -0,0 +0,0 @@ import net.minecraft.server.Unit; + import net.minecraft.server.World; + import net.minecraft.server.WorldServer; + import org.bukkit.Bukkit; +-import org.bukkit.Location; + import org.bukkit.Material; + import org.bukkit.NamespacedKey; + import org.bukkit.Server; @@ -0,0 +0,0 @@ import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.Vehicle; import org.bukkit.entity.Villager; @@ -48,6 +76,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.Event.Result; +@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityDeathEvent; + import org.bukkit.event.entity.EntityEnterLoveModeEvent; + import org.bukkit.event.entity.EntityPickupItemEvent; + import org.bukkit.event.entity.EntityPlaceEvent; +-import org.bukkit.event.entity.EntityPortalEvent; + import org.bukkit.event.entity.EntityPotionEffectEvent; + import org.bukkit.event.entity.EntityShootBowEvent; + import org.bukkit.event.entity.EntitySpawnEvent; +@@ -0,0 +0,0 @@ import org.bukkit.inventory.EquipmentSlot; + import org.bukkit.inventory.InventoryView; + import org.bukkit.inventory.meta.BookMeta; + import org.bukkit.potion.PotionEffect; +-import org.bukkit.projectiles.ProjectileSource; + + import org.bukkit.event.entity.SpawnerSpawnEvent; // Spigot + @@ -0,0 +0,0 @@ public class CraftEventFactory { return event; diff --git a/Spigot-Server-Patches/Improve-death-events.patch b/Spigot-Server-Patches/Improve-death-events.patch index ff67e01844..94ca0c95d8 100644 --- a/Spigot-Server-Patches/Improve-death-events.patch +++ b/Spigot-Server-Patches/Improve-death-events.patch @@ -289,9 +289,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start public String displayName; @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + IChatBaseComponent defaultMessage = this.getCombatTracker().getDeathMessage(); - String deathmessage = defaultMessage.getString(); - 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 + // Paper start - cancellable death event + if (event.isCancelled()) { + // make compatible with plugins that might have already set the health in an event listener diff --git a/Spigot-Server-Patches/Improved-Watchdog-Support.patch b/Spigot-Server-Patches/Improved-Watchdog-Support.patch index 656166dd51..f42f1e2a26 100644 --- a/Spigot-Server-Patches/Improved-Watchdog-Support.patch +++ b/Spigot-Server-Patches/Improved-Watchdog-Support.patch @@ -356,7 +356,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return Thread.currentThread().equals(console.serverThread) || Thread.currentThread().equals(net.minecraft.server.MinecraftServer.getServer().shutdownThread); // Paper - Fix issues with detecting main thread properly, the only time Watchdog will be used is during a crash shutdown which is a "try our best" scenario } - @Override + // Paper start diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java diff --git a/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch b/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch index 126292acb4..c3b73e3f21 100644 --- a/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch +++ b/Spigot-Server-Patches/InventoryCloseEvent-Reason-API.patch @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DEATH); // Paper } - String deathMessage = event.getDeathMessage(); + net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { return OptionalInt.empty(); } else { @@ -128,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entityplayer.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper } - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " 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)); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java diff --git a/Spigot-Server-Patches/Lazily-track-plugin-scoreboards-by-default.patch b/Spigot-Server-Patches/Lazily-track-plugin-scoreboards-by-default.patch index b17680a4cb..6bd13878fb 100644 --- a/Spigot-Server-Patches/Lazily-track-plugin-scoreboards-by-default.patch +++ b/Spigot-Server-Patches/Lazily-track-plugin-scoreboards-by-default.patch @@ -50,8 +50,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); - return new CraftObjective(this, objective); - } + return new CraftObjective(this, objective);*/ // Paper + return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName)); // Paper diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java diff --git a/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch b/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch index ac59e4aa83..9fb3467d31 100644 --- a/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch +++ b/Spigot-Server-Patches/Limit-Client-Sign-length-more.patch @@ -34,10 +34,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { - String[] lines = new String[4]; + List lines = new java.util.ArrayList<>(); for (int i = 0; i < list.size(); ++i) { -- lines[i] = SharedConstants.filterAllowedChatCharacters(list.get(i)); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. +- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(list.get(i)))); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. + // Paper start - cap line length - modified clients can send longer data than normal + String currentLine = list.get(i); + if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.length() > MAX_SIGN_LINE_LENGTH) { @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + // Paper end -+ lines[i] = SharedConstants.filterAllowedChatCharacters(currentLine); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. ++ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(currentLine))); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. } - SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); + SignChangeEvent event = new SignChangeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldserver, blockposition), this.getPlayer(), lines); this.server.getPluginManager().callEvent(event); diff --git a/Spigot-Server-Patches/Limit-recipe-packets.patch b/Spigot-Server-Patches/Limit-recipe-packets.patch index fb48547777..d497287268 100644 --- a/Spigot-Server-Patches/Limit-recipe-packets.patch +++ b/Spigot-Server-Patches/Limit-recipe-packets.patch @@ -42,8 +42,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger; - // CraftBukkit start +@@ -0,0 +0,0 @@ import io.papermc.paper.adventure.PaperAdventure; // Paper + import io.papermc.paper.adventure.VanillaChatMessageLogic; // Paper import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; + diff --git a/Spigot-Server-Patches/Load-Chunks-for-Login-Asynchronously.patch b/Spigot-Server-Patches/Load-Chunks-for-Login-Asynchronously.patch index 869544eec8..5d911f93b3 100644 --- a/Spigot-Server-Patches/Load-Chunks-for-Login-Asynchronously.patch +++ b/Spigot-Server-Patches/Load-Chunks-for-Login-Asynchronously.patch @@ -211,7 +211,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class PlayerList { } - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " 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)); - cserver.getPluginManager().callEvent(playerQuitEvent); + if (entityplayer.didPlayerJoinEvent) cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); @@ -235,8 +235,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); // CraftBukkit end -- return playerQuitEvent.getQuitMessage(); // CraftBukkit -+ return entityplayer.didPlayerJoinEvent ? playerQuitEvent.getQuitMessage() : null; // CraftBukkit // Paper - don't print quit if we never printed join +- return playerQuitEvent.quitMessage(); // Paper - Adventure ++ return entityplayer.didPlayerJoinEvent ? playerQuitEvent.quitMessage() : null; // CraftBukkit // Paper - Adventure // Paper - don't print quit if we never printed join } // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer diff --git a/Spigot-Server-Patches/MC-Utils.patch b/Spigot-Server-Patches/MC-Utils.patch index 1a91cb496d..0ff68181ac 100644 --- a/Spigot-Server-Patches/MC-Utils.patch +++ b/Spigot-Server-Patches/MC-Utils.patch @@ -3993,25 +3993,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + public final boolean isEntityTickingReady() { + return this.isEntityTickingReady; -+ } -+ + } + + public final boolean isTickingReady() { + return this.isTickingReady; + } + + public final boolean isFullChunkReady() { + return this.isFullChunkReady; - } ++ } + // Paper end - ++ // CraftBukkit start - public Chunk getFullChunk() { + public final Chunk getFullChunk() { // Paper - final for inline if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks - return this.getFullChunkUnchecked(); - } -@@ -0,0 +0,0 @@ public class PlayerChunk { - return (either == null) ? null : (Chunk) either.left().orElse(null); + CompletableFuture> statusFuture = this.getStatusFutureUnchecked(ChunkStatus.FULL); + Either either = (Either) statusFuture.getNow(null); + return either == null ? null : (Chunk) either.left().orElse(null); } // CraftBukkit end + // Paper start - "real" get full chunk immediately diff --git a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch index ac69b62521..4644f19281 100644 --- a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch +++ b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch @@ -25,25 +25,51 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + useVanillaScoreboardColoring = getBoolean("use-vanilla-world-scoreboard-name-coloring", false); + } } +diff --git a/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java b/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java ++++ b/src/main/java/io/papermc/paper/adventure/VanillaChatMessageLogic.java +@@ -0,0 +0,0 @@ import java.util.regex.MatchResult; + import net.kyori.adventure.text.Component; + import net.kyori.adventure.text.ComponentLike; + import net.kyori.adventure.text.TextComponent; ++import net.kyori.adventure.text.format.NamedTextColor; ++import net.kyori.adventure.text.format.Style; + import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; ++import net.minecraft.server.IChatBaseComponent; ++import net.minecraft.server.ScoreboardTeam; ++import org.bukkit.craftbukkit.CraftWorld; + import org.bukkit.craftbukkit.entity.CraftPlayer; + + public class VanillaChatMessageLogic { + public static Component displayNameForChat(final CraftPlayer player) { ++ if (((CraftWorld) player.getWorld()).getHandle().paperConfig.useVanillaScoreboardColoring) { ++ IChatBaseComponent nameFromTeam = ScoreboardTeam.a(player.getHandle().getScoreboardTeam(), player.getHandle().getDisplayName()); ++ // Explicitly add a RESET here, vanilla uses components for this now... ++ return PaperAdventure.asAdventure(nameFromTeam); ++ } + return player.displayName(); + } + diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { - return; - } + } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { + // Do nothing, this is coming from a plugin + } else { +- Player player = this.getPlayer(); ++ CraftPlayer player = this.getPlayer(); // Paper + AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(minecraftServer)); + this.server.getPluginManager().callEvent(event); -- s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); -+ // Paper Start - (Meh) Support for vanilla world scoreboard name coloring -+ String displayName = event.getPlayer().getDisplayName(); -+ if (this.player.getWorld().paperConfig.useVanillaScoreboardColoring) { -+ IChatBaseComponent nameFromTeam = ScoreboardTeam.a(this.player.getScoreboardTeam(), ((CraftPlayer) player).getHandle().getDisplayName()); -+ // Explicitly add a RESET here, vanilla uses components for this now... -+ displayName = new net.md_5.bungee.api.chat.TextComponent(net.md_5.bungee.chat.ComponentSerializer.parse(IChatBaseComponent.ChatSerializer.componentToJson(nameFromTeam))).toLegacyText() + org.bukkit.ChatColor.RESET; -+ } -+ -+ s = String.format(event.getFormat(), displayName, event.getMessage()); -+ // Paper end - minecraftServer.console.sendMessage(s); - if (((LazyPlayerSet) event.getRecipients()).isLazy()) { - for (Object recipient : minecraftServer.getPlayerList().players) { +@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { + return null; + } + +- final net.kyori.adventure.text.Component adventure$msg = VanillaChatMessageLogic.formatChat(VanillaChatMessageLogic.displayNameForChat((CraftPlayer) player), queueEvent.getFormat(), queueEvent.getMessage()); // Paper ++ final net.kyori.adventure.text.Component adventure$msg = VanillaChatMessageLogic.formatChat(VanillaChatMessageLogic.displayNameForChat(player), queueEvent.getFormat(), queueEvent.getMessage()); // Paper + //String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); // Paper - comment + //PlayerConnection.this.minecraftServer.console.sendMessage(message); // Paper - comment + PlayerConnection.this.minecraftServer.console.sendMessage(adventure$msg); // Paper diff --git a/Spigot-Server-Patches/Paper-config-files.patch b/Spigot-Server-Patches/Paper-config-files.patch index afef859a46..6439e257d5 100644 --- a/Spigot-Server-Patches/Paper-config-files.patch +++ b/Spigot-Server-Patches/Paper-config-files.patch @@ -687,9 +687,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ignoreVanillaPermissions = commandsConfiguration.getBoolean("ignore-vanilla-permissions"); @@ -0,0 +0,0 @@ public final class CraftServer implements Server { + { return spigot; } - // Spigot end + + // Paper start + @SuppressWarnings({"rawtypes", "unchecked"}) diff --git a/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch b/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch index 86887d4ed2..e3352250f9 100644 --- a/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch +++ b/Spigot-Server-Patches/Player-Tab-List-and-Title-APIs.patch @@ -38,19 +38,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void b(PacketDataSerializer packetdataserializer) throws IOException { - packetdataserializer.a((Enum) this.a); - if (this.a == PacketPlayOutTitle.EnumTitleAction.TITLE || this.a == PacketPlayOutTitle.EnumTitleAction.SUBTITLE || this.a == PacketPlayOutTitle.EnumTitleAction.ACTIONBAR) { -- packetdataserializer.a(this.b); -+ // Paper start -+ if (this.components != null) { -+ packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components)); -+ } else { -+ packetdataserializer.a(this.b); -+ } -+ // Paper end - } - - if (this.a == PacketPlayOutTitle.EnumTitleAction.TIMES) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -71,15 +58,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) { + if (header != null) { + String headerJson = net.md_5.bungee.chat.ComponentSerializer.toString(header); -+ playerListHeader = net.minecraft.server.ChatBaseComponent.ChatSerializer.jsonToComponent(headerJson); ++ playerListHeader = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(headerJson); + } else { + playerListHeader = null; + } + + if (footer != null) { + String footerJson = net.md_5.bungee.chat.ComponentSerializer.toString(footer); -+ playerListFooter = net.minecraft.server.ChatBaseComponent.ChatSerializer.jsonToComponent(footerJson); -+ } else { ++ playerListFooter = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(footerJson); ++ } else { + playerListFooter = null; + } + @@ -158,4 +145,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public String getDisplayName() { - return getHandle().displayName; + if(true) return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.getHandle().adventure$displayName); // Paper diff --git a/Spigot-Server-Patches/Player-affects-spawning-API.patch b/Spigot-Server-Patches/Player-affects-spawning-API.patch index d212c1e2fd..4080986137 100644 --- a/Spigot-Server-Patches/Player-affects-spawning-API.patch +++ b/Spigot-Server-Patches/Player-affects-spawning-API.patch @@ -144,13 +144,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + public void setAffectsSpawning(boolean affects) { + this.getHandle().affectsSpawning = affects; -+ } -+ + } + + @Override + public boolean getAffectsSpawning() { + return this.getHandle().affectsSpawning; - } ++ } + // Paper end - ++ @Override public void updateCommands() { + if (getHandle().playerConnection == null) return; diff --git a/Spigot-Server-Patches/Prevent-opening-inventories-when-frozen.patch b/Spigot-Server-Patches/Prevent-opening-inventories-when-frozen.patch index aaf34a5dd0..0927e97ac6 100644 --- a/Spigot-Server-Patches/Prevent-opening-inventories-when-frozen.patch +++ b/Spigot-Server-Patches/Prevent-opening-inventories-when-frozen.patch @@ -40,20 +40,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { + if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper - String title = container.getBukkitView().getTitle(); - -- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); -+ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper + //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment +- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper ++ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper getHandle().activeContainer = container; getHandle().activeContainer.addSlotListener(player); } @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { - // Now open the window - Containers windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory()); - String title = inventory.getTitle(); -- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); -+ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper + net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper + if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper + //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment +- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper ++ if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper player.activeContainer = container; player.activeContainer.addSlotListener(player); } diff --git a/Spigot-Server-Patches/Prevent-tile-entity-and-entity-crashes.patch b/Spigot-Server-Patches/Prevent-tile-entity-and-entity-crashes.patch index 5a70440870..d00326ee00 100644 --- a/Spigot-Server-Patches/Prevent-tile-entity-and-entity-crashes.patch +++ b/Spigot-Server-Patches/Prevent-tile-entity-and-entity-crashes.patch @@ -42,9 +42,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.tileEntityListTick.remove(tileTickPosition--); + continue; + // Paper end - // Spigot start - } finally { - tileentity.tickTimer.stopTiming(); + } + // Spigot start + finally { @@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable { try { consumer.accept(entity); diff --git a/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch b/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch index 4078820694..b3f513077d 100644 --- a/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch +++ b/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch @@ -11,11 +11,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class PlayerList { // return chatmessage; - if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); // Spigot + if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Spigot // Paper - Adventure - } else if (!this.isWhitelisted(gameprofile)) { +- chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); +- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage)); // Spigot // Paper - Adventure + } else if (!this.isWhitelisted(gameprofile, event)) { // Paper - chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); -- event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot ++ //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper + //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { IpBanEntry ipbanentry = this.l.get(socketaddress); @@ -37,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + event.callEvent(); + if (!event.isWhitelisted()) { + if (loginEvent != null) { -+ loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, event.getKickMessage() == null ? org.spigotmc.SpigotConfig.whitelistMessage : event.getKickMessage()); ++ loginEvent.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(event.getKickMessage() == null ? org.spigotmc.SpigotConfig.whitelistMessage : event.getKickMessage())); + } + return false; + } diff --git a/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch b/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch index d0781edc3b..61d21e3c18 100644 --- a/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch +++ b/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch @@ -88,11 +88,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void shutdown(boolean isRestarting) { // CraftBukkit start - disconnect safely for (EntityPlayer player : this.players) { -- player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message -+ player.playerConnection.disconnect(!isRestarting ? this.server.server.getShutdownMessage() : org.spigotmc.SpigotConfig.restartMessage); // CraftBukkit - add custom shutdown message // Paper - add isRestarting flag ++ if (isRestarting) player.playerConnection.disconnect(org.spigotmc.SpigotConfig.restartMessage); else // Paper + player.playerConnection.disconnect(PaperAdventure.asVanilla(this.server.server.shutdownMessage())); // CraftBukkit - add custom shutdown message // Paper - Adventure } // CraftBukkit end - @@ -0,0 +0,0 @@ public abstract class PlayerList { } // Paper end @@ -135,7 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } - // Kick all players -- for ( EntityPlayer p : (List) MinecraftServer.getServer().getPlayerList().players ) +- for ( EntityPlayer p : (List< EntityPlayer>) MinecraftServer.getServer().getPlayerList().players ) - { - p.playerConnection.disconnect(SpigotConfig.restartMessage); - } diff --git a/Spigot-Server-Patches/Restore-custom-InventoryHolder-support.patch b/Spigot-Server-Patches/Restore-custom-InventoryHolder-support.patch index 9103a01a54..d5c9bd78b9 100644 --- a/Spigot-Server-Patches/Restore-custom-InventoryHolder-support.patch +++ b/Spigot-Server-Patches/Restore-custom-InventoryHolder-support.patch @@ -32,6 +32,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return converterMap.get(type).createInventory(holder, type); } +@@ -0,0 +0,0 @@ public final class CraftInventoryCreator { + // Paper end + public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { + // Paper start + if (holder != null) { diff --git a/Spigot-Server-Patches/Support-components-in-ItemMeta.patch b/Spigot-Server-Patches/Support-components-in-ItemMeta.patch index 23fe226d4b..49e2500685 100644 --- a/Spigot-Server-Patches/Support-components-in-ItemMeta.patch +++ b/Spigot-Server-Patches/Support-components-in-ItemMeta.patch @@ -4,18 +4,6 @@ Date: Sat, 6 Jun 2020 18:13:42 +0200 Subject: [PATCH] Support components in ItemMeta -diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/IChatBaseComponent.java -+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java -@@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, IChatFormatted, Iterable 0) { -- name += "(interval:" + period + ")"; +- name += "(interval:" + period +")"; - } else { - name += "(Single)"; - } @@ -2120,13 +2120,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + +import co.aikar.timings.NullTimingHandler; import org.bukkit.Bukkit; +-import org.bukkit.craftbukkit.SpigotTimings; // Spigot +-import org.spigotmc.CustomTimingsHandler; // Spigot +import co.aikar.timings.MinecraftTimings; // Paper +import co.aikar.timings.Timing; // Paper import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitTask; --import org.bukkit.craftbukkit.SpigotTimings; // Spigot - import org.spigotmc.CustomTimingsHandler; // Spigot - @@ -0,0 +0,0 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot */ diff --git a/Spigot-Server-Patches/Tracking-Range-Improvements.patch b/Spigot-Server-Patches/Tracking-Range-Improvements.patch index 035839bf0f..f181870a56 100644 --- a/Spigot-Server-Patches/Tracking-Range-Improvements.patch +++ b/Spigot-Server-Patches/Tracking-Range-Improvements.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if ( entity instanceof EntityPlayer ) { return config.playerTrackingRange; -- } else if ( entity.activationType == ActivationRange.ActivationType.MONSTER || entity.activationType == ActivationRange.ActivationType.RAIDER ) +- } else if ( entity.activationType == ActivationRange.ActivationType.MONSTER || entity.activationType == ActivationRange.ActivationType.RAIDER ) - { - return config.monsterTrackingRange; - } else if ( entity instanceof EntityGhast ) diff --git a/Spigot-Server-Patches/Update-itemstack-legacy-name-and-lore.patch b/Spigot-Server-Patches/Update-itemstack-legacy-name-and-lore.patch index c21c341007..d592999de6 100644 --- a/Spigot-Server-Patches/Update-itemstack-legacy-name-and-lore.patch +++ b/Spigot-Server-Patches/Update-itemstack-legacy-name-and-lore.patch @@ -69,15 +69,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public NBTTagCompound b(String s) { return this.tag != null && this.tag.hasKeyOfType(s, 10) ? this.tag.getCompound(s) : null; -diff --git a/src/main/java/net/minecraft/server/NBTTagString.java b/src/main/java/net/minecraft/server/NBTTagString.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/NBTTagString.java -+++ b/src/main/java/net/minecraft/server/NBTTagString.java -@@ -0,0 +0,0 @@ public class NBTTagString implements NBTBase { - this.data = s; - } - -+ public static NBTTagString create(String s) { return a(s); } // Paper - OBFHELPER - public static NBTTagString a(String s) { - return s.isEmpty() ? NBTTagString.b : new NBTTagString(s); - } diff --git a/Spigot-Server-Patches/Use-ConcurrentHashMap-in-JsonList.patch b/Spigot-Server-Patches/Use-ConcurrentHashMap-in-JsonList.patch index 24eca627b3..7d2076d980 100644 --- a/Spigot-Server-Patches/Use-ConcurrentHashMap-in-JsonList.patch +++ b/Spigot-Server-Patches/Use-ConcurrentHashMap-in-JsonList.patch @@ -127,7 +127,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { } else if (!this.isWhitelisted(gameprofile, event)) { // Paper - chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); + //chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper //event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted - } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { + } else if (getIPBans().isBanned(socketaddress) && getIPBans().get(socketaddress) != null && !getIPBans().get(socketaddress).hasExpired()) { // Paper - fix NPE with temp ip bans diff --git a/Spigot-Server-Patches/Use-proper-max-length-when-serialising-BungeeCord-te.patch b/Spigot-Server-Patches/Use-proper-max-length-when-serialising-BungeeCord-te.patch index a65ad8efad..bef5706a12 100644 --- a/Spigot-Server-Patches/Use-proper-max-length-when-serialising-BungeeCord-te.patch +++ b/Spigot-Server-Patches/Use-proper-max-length-when-serialising-BungeeCord-te.patch @@ -16,8 +16,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - + private static final int MAX_LENGTH = Short.MAX_VALUE * 8 + 8; // Paper private IChatBaseComponent a; + public net.kyori.adventure.text.Component adventure$message; // Paper public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot - private ChatMessageType b; @@ -0,0 +0,0 @@ public class PacketPlayOutChat implements Packet { //packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components)); // Paper - comment, replaced with below // Paper start - don't nest if we don't need to so that we can preserve formatting diff --git a/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch b/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch index 918dd87622..8e2a20a8c7 100644 --- a/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch +++ b/Spigot-Server-Patches/implement-optional-per-player-mob-spawns.patch @@ -589,7 +589,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start public String displayName; @@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting { - this.displayName = this.getName(); + this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getName()); // Paper this.canPickUpLoot = true; this.maxHealthCache = this.getMaxHealth(); + this.cachedSingleMobDistanceMap = new com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper diff --git a/work/Bukkit b/work/Bukkit index 1e843b72bb..1b5ad2af5d 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 1e843b72bbd67b7b5ec785eae260fb00a5b64292 +Subproject commit 1b5ad2af5decf1d2cd276ae391d75a8ab1167b15 diff --git a/work/CraftBukkit b/work/CraftBukkit index b7eed25467..8049146227 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit b7eed25467eb583d77cda6a042387dc48fe14f97 +Subproject commit 8049146227e4f8e44013f6b825ee91bdc7e3290f diff --git a/work/Spigot b/work/Spigot index 73fb6094f4..89d6047d1a 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 73fb6094f4fa318955bb5bb11a1ec1af12cf90a1 +Subproject commit 89d6047d1aea78b9011ba38681663780a63233c9