2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2023-03-23 17:49:24 +01:00
From: Riley Park <rileysebastianpark@gmail.com>
2021-06-11 14:02:28 +02:00
Date: Fri, 29 Jan 2021 17:21:55 +0100
Subject: [PATCH] Adventure
Co-authored-by: zml <zml@stellardrift.ca>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
2021-06-12 00:37:16 +02:00
diff --git a/build.gradle.kts b/build.gradle.kts
2023-06-18 13:03:18 +02:00
index 3dec6ab39000edd3e90d1bf734d24cc779ce0e3b..cbab63d2f3b045f6193f5a3422ae4b5509d3003b 100644
2021-06-12 00:37:16 +02:00
--- a/build.gradle.kts
+++ b/build.gradle.kts
2023-06-07 18:24:39 +02:00
@@ -8,13 +8,26 @@ java {
2021-07-06 05:25:23 +02:00
withJavadocJar()
}
2023-06-09 02:22:51 +02:00
+val adventureVersion = "4.14.0"
2021-10-27 04:45:45 +02:00
+val apiAndDocs: Configuration by configurations.creating {
2021-08-14 06:11:12 +02:00
+ attributes {
+ attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
+ attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
+ attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
+ attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
+ }
+}
+configurations.api {
+ extendsFrom(apiAndDocs)
+}
2021-07-06 05:25:23 +02:00
+
2023-06-07 18:24:39 +02:00
val annotationsVersion = "24.0.1"
2021-07-06 05:25:23 +02:00
dependencies {
// api dependencies are listed transitively to API consumers
2022-12-07 17:46:46 +01:00
api("com.google.guava:guava:31.1-jre")
api("com.google.code.gson:gson:2.10")
2022-03-04 21:53:36 +01:00
- api("net.md-5:bungeecord-chat:1.16-R0.4")
2023-03-14 19:59:28 +01:00
+ api("net.md-5:bungeecord-chat:1.16-R0.4-deprecated+build.9") // Paper
2023-06-08 15:25:35 +02:00
api("org.yaml:snakeyaml:2.0")
2023-03-14 18:21:11 +01:00
api("org.joml:joml:1.10.5")
2022-03-04 21:53:36 +01:00
// Paper start
2023-06-07 18:24:39 +02:00
@@ -22,6 +35,13 @@ dependencies {
2021-11-27 07:54:18 +01:00
isTransitive = false // includes junit
}
2021-11-23 09:57:41 +01:00
api("it.unimi.dsi:fastutil:8.5.6")
2021-08-14 06:11:12 +02:00
+ apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion"))
+ apiAndDocs("net.kyori:adventure-api")
2022-02-28 22:38:23 +01:00
+ apiAndDocs("net.kyori:adventure-text-minimessage")
2021-08-14 06:11:12 +02:00
+ apiAndDocs("net.kyori:adventure-text-serializer-gson")
+ apiAndDocs("net.kyori:adventure-text-serializer-legacy")
+ apiAndDocs("net.kyori:adventure-text-serializer-plain")
2022-06-12 23:07:40 +02:00
+ apiAndDocs("net.kyori:adventure-text-logger-slf4j")
2021-11-27 07:54:18 +01:00
// Paper end
2021-06-12 00:37:16 +02:00
2023-06-18 13:03:18 +02:00
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
2023-06-16 17:34:49 +02:00
@@ -82,10 +102,26 @@ tasks.withType<Javadoc> {
2023-04-07 20:39:13 +02:00
"https://guava.dev/releases/31.1-jre/api/docs/",
2023-06-08 15:25:35 +02:00
"https://javadoc.io/doc/org.yaml/snakeyaml/2.0/",
2023-06-07 18:24:39 +02:00
"https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/", // Paper - we don't want Java 5 annotations
2022-03-04 21:53:36 +01:00
- "https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/",
2021-11-22 10:35:00 +01:00
+ // Paper start
2022-03-04 21:53:36 +01:00
+ //"https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/", // don't link to bungee chat
2023-02-23 17:55:36 +01:00
+ "https://jd.advntr.dev/api/$adventureVersion/",
+ "https://jd.advntr.dev/text-minimessage/$adventureVersion/",
+ "https://jd.advntr.dev/text-serializer-gson/$adventureVersion/",
+ "https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/",
+ "https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
2023-06-16 17:34:49 +02:00
+ "https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/"
2021-11-22 10:35:00 +01:00
+ // Paper end
)
2023-04-09 02:00:50 +02:00
options.tags("apiNote:a:API Note:")
2022-03-01 05:38:49 +01:00
+ inputs.files(apiAndDocs).ignoreEmptyDirectories().withPropertyName(apiAndDocs.name + "-configuration")
+ doFirst {
+ options.addStringOption(
+ "sourcepath",
+ apiAndDocs.resolvedConfiguration.files.joinToString(separator = File.pathSeparator, transform = File::getPath)
+ )
+ }
+
// workaround for https://github.com/gradle/gradle/issues/4046
inputs.dir("src/main/javadoc").withPropertyName("javadoc-sourceset")
doLast {
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/io/papermc/paper/chat/ChatRenderer.java b/src/main/java/io/papermc/paper/chat/ChatRenderer.java
new file mode 100644
2022-08-01 21:34:55 +02:00
index 0000000000000000000000000000000000000000..ffe0a921cc1ebbb95104f22b57e0e3af85e287a6
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/chat/ChatRenderer.java
2022-08-01 21:34:55 +02:00
@@ -0,0 +1,71 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.chat;
+
+import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
2022-02-18 02:10:46 +01:00
+import org.jetbrains.annotations.ApiStatus;
2021-06-11 14:02:28 +02:00
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * A chat renderer is responsible for rendering chat messages sent by {@link Player}s to the server.
+ */
+@FunctionalInterface
+public interface ChatRenderer {
+ /**
+ * Renders a chat message. This will be called once for each receiving {@link Audience}.
+ *
+ * @param source the message source
+ * @param sourceDisplayName the display name of the source player
+ * @param message the chat message
+ * @param viewer the receiving {@link Audience}
+ * @return a rendered chat message
+ */
2022-02-18 02:10:46 +01:00
+ @ApiStatus.OverrideOnly
2021-06-11 14:02:28 +02:00
+ @NotNull
+ Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer);
+
+ /**
+ * Create a new instance of the default {@link ChatRenderer}.
+ *
+ * @return a new {@link ChatRenderer}
+ */
+ @NotNull
+ static ChatRenderer defaultRenderer() {
2022-08-01 21:34:55 +02:00
+ return new ViewerUnawareImpl.Default((source, sourceDisplayName, message) -> Component.translatable("chat.type.text", sourceDisplayName, message));
+ }
+
+ @ApiStatus.Internal
+ sealed interface Default extends ChatRenderer, ViewerUnaware permits ViewerUnawareImpl.Default {
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Creates a new viewer-unaware {@link ChatRenderer}, which will render the chat message a single time,
+ * displaying the same rendered message to every viewing {@link Audience}.
+ *
+ * @param renderer the viewer unaware renderer
+ * @return a new {@link ChatRenderer}
+ */
+ @NotNull
+ static ChatRenderer viewerUnaware(final @NotNull ViewerUnaware renderer) {
2022-08-01 21:34:55 +02:00
+ return new ViewerUnawareImpl(renderer);
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Similar to {@link ChatRenderer}, but without knowledge of the message viewer.
+ *
+ * @see ChatRenderer#viewerUnaware(ViewerUnaware)
+ */
+ interface ViewerUnaware {
+ /**
+ * Renders a chat message.
+ *
+ * @param source the message source
+ * @param sourceDisplayName the display name of the source player
+ * @param message the chat message
+ * @return a rendered chat message
+ */
2022-02-18 02:10:46 +01:00
+ @ApiStatus.OverrideOnly
2021-06-11 14:02:28 +02:00
+ @NotNull
+ Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message);
+ }
+}
2022-08-01 21:34:55 +02:00
diff --git a/src/main/java/io/papermc/paper/chat/ViewerUnawareImpl.java b/src/main/java/io/papermc/paper/chat/ViewerUnawareImpl.java
new file mode 100644
2023-03-23 17:49:24 +01:00
index 0000000000000000000000000000000000000000..2ad76b1751ba707f7ae0d283aa1cbaf6c9619da9
2022-08-01 21:34:55 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/chat/ViewerUnawareImpl.java
2023-03-23 17:49:24 +01:00
@@ -0,0 +1,35 @@
2022-08-01 21:34:55 +02:00
+package io.papermc.paper.chat;
+
+import net.kyori.adventure.audience.Audience;
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
2023-03-23 17:49:24 +01:00
+import org.jetbrains.annotations.Nullable;
2022-08-01 21:34:55 +02:00
+
+sealed class ViewerUnawareImpl implements ChatRenderer, ChatRenderer.ViewerUnaware permits ViewerUnawareImpl.Default {
+ private final ViewerUnaware unaware;
2023-03-23 17:49:24 +01:00
+ private @Nullable Component message;
2022-08-01 21:34:55 +02:00
+
+ ViewerUnawareImpl(final ViewerUnaware unaware) {
+ this.unaware = unaware;
+ }
+
+ @Override
+ public @NotNull Component render(final @NotNull Player source, final @NotNull Component sourceDisplayName, final @NotNull Component message, final @NotNull Audience viewer) {
+ return this.render(source, sourceDisplayName, message);
+ }
+
+ @Override
+ public @NotNull Component render(final @NotNull Player source, final @NotNull Component sourceDisplayName, final @NotNull Component message) {
+ if (this.message == null) {
+ this.message = this.unaware.render(source, sourceDisplayName, message);
+ }
+ return this.message;
+ }
+
+ static final class Default extends ViewerUnawareImpl implements ChatRenderer.Default {
+ Default(final ViewerUnaware unaware) {
+ super(unaware);
+ }
+ }
+}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java b/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java
new file mode 100644
2022-12-23 16:54:04 +01:00
index 0000000000000000000000000000000000000000..e7e13011c76285681ad420e6f356f6b83045d31a
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java
2022-12-23 16:54:04 +01:00
@@ -0,0 +1,128 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.event.player;
+
+import io.papermc.paper.chat.ChatRenderer;
+import net.kyori.adventure.audience.Audience;
2022-12-23 16:54:04 +01:00
+import net.kyori.adventure.chat.SignedMessage;
2021-06-11 14:02:28 +02:00
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.NotNull;
+
2022-12-23 16:54:04 +01:00
+import java.util.Set;
+
2021-06-11 14:02:28 +02:00
+import static java.util.Objects.requireNonNull;
+
+/**
+ * An abstract implementation of a chat event, handling shared logic.
+ */
+public abstract class AbstractChatEvent extends PlayerEvent implements Cancellable {
+ private final Set<Audience> viewers;
+ private final Component originalMessage;
2022-12-23 16:54:04 +01:00
+ private final SignedMessage signedMessage;
2021-06-19 00:47:40 +02:00
+ private ChatRenderer renderer;
2021-06-11 14:02:28 +02:00
+ private Component message;
2021-06-19 00:47:40 +02:00
+ private boolean cancelled = false;
2021-06-11 14:02:28 +02:00
+
2022-12-23 16:54:04 +01:00
+ AbstractChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) {
2021-06-11 14:02:28 +02:00
+ super(player, async);
+ this.viewers = viewers;
+ this.renderer = renderer;
+ this.message = message;
+ this.originalMessage = originalMessage;
2022-12-23 16:54:04 +01:00
+ this.signedMessage = signedMessage;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Gets a set of {@link Audience audiences} that this chat message will be displayed to.
+ *
+ * <p>The set returned is not guaranteed to be mutable and may auto-populate
+ * on access. Any listener accessing the returned set should be aware that
+ * it may reduce performance for a lazy set implementation.</p>
+ *
+ * <p>Listeners should be aware that modifying the list may throw {@link
+ * UnsupportedOperationException} if the event caller provides an
+ * unmodifiable set.</p>
+ *
+ * @return a set of {@link Audience audiences} who will receive the chat message
+ */
+ @NotNull
+ public final Set<Audience> viewers() {
+ return this.viewers;
+ }
+
+ /**
+ * Sets the chat renderer.
+ *
+ * @param renderer the chat renderer
+ * @throws NullPointerException if {@code renderer} is {@code null}
+ */
+ public final void renderer(final @NotNull ChatRenderer renderer) {
+ this.renderer = requireNonNull(renderer, "renderer");
+ }
+
+ /**
+ * Gets the chat renderer.
+ *
+ * @return the chat renderer
+ */
+ @NotNull
+ public final ChatRenderer renderer() {
+ return this.renderer;
+ }
+
+ /**
+ * Gets the user-supplied message.
+ * The return value will reflect changes made using {@link #message(Component)}.
+ *
+ * @return the user-supplied message
+ */
+ @NotNull
+ public final Component message() {
+ return this.message;
+ }
+
+ /**
+ * Sets the user-supplied message.
+ *
+ * @param message the user-supplied message
+ * @throws NullPointerException if {@code message} is {@code null}
+ */
+ public final void message(final @NotNull Component message) {
+ this.message = requireNonNull(message, "message");
+ }
+
+ /**
+ * Gets the original and unmodified user-supplied message.
+ * The return value will <b>not</b> reflect changes made using
+ * {@link #message(Component)}.
+ *
+ * @return the original user-supplied message
+ */
+ @NotNull
+ public final Component originalMessage() {
+ return this.originalMessage;
+ }
+
2022-12-23 16:54:04 +01:00
+ /**
+ * Gets the signed message.
+ * Changes made in this event will <b>not</b> update
+ * the signed message.
+ *
+ * @return the signed message
+ */
+ @NotNull
+ public final SignedMessage signedMessage() {
+ return this.signedMessage;
+ }
+
2021-06-11 14:02:28 +02:00
+ @Override
+ public final boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public final void setCancelled(final boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+}
2022-08-01 21:34:55 +02:00
diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java
new file mode 100644
2022-12-11 18:55:39 +01:00
index 0000000000000000000000000000000000000000..feece00981ebf932e64760e7a10a04ad080d0228
2022-08-01 21:34:55 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AsyncChatCommandDecorateEvent.java
2022-12-11 18:55:39 +01:00
@@ -0,0 +1,28 @@
2022-08-01 21:34:55 +02:00
+package io.papermc.paper.event.player;
+
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+@ApiStatus.Experimental
+public class AsyncChatCommandDecorateEvent extends AsyncChatDecorateEvent {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
2022-12-11 18:55:39 +01:00
+ @ApiStatus.Internal
+ public AsyncChatCommandDecorateEvent(boolean async, @Nullable Player player, @NotNull Component originalMessage, @NotNull Component result) {
+ super(async, player, originalMessage, result);
2022-08-01 21:34:55 +02:00
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static @NotNull HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java
new file mode 100644
2023-06-07 15:47:32 +02:00
index 0000000000000000000000000000000000000000..667bfa6afc35f8a8f475431171ee474af4e10afd
2022-08-01 21:34:55 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java
2023-06-07 15:47:32 +02:00
@@ -0,0 +1,117 @@
2022-08-01 21:34:55 +02:00
+package io.papermc.paper.event.player;
+
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.server.ServerEvent;
+import org.jetbrains.annotations.ApiStatus;
2022-12-11 18:55:39 +01:00
+import org.jetbrains.annotations.Contract;
2022-08-01 21:34:55 +02:00
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
2022-12-11 18:55:39 +01:00
+ * This event is fired when the server decorates a component for chat purposes. This is called
+ * before {@link AsyncChatEvent} and the other chat events. It is recommended that you modify the
+ * message here, and use the chat events for modifying receivers and later the chat type. If you
+ * want to keep the message as "signed" for the clients who get it, be sure to include the entire
+ * original message somewhere in the final message.
2022-08-01 21:34:55 +02:00
+ * @see AsyncChatCommandDecorateEvent for the decoration of messages sent via commands
+ */
+@ApiStatus.Experimental
+public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final Player player;
+ private final Component originalMessage;
+ private Component result;
+ private boolean cancelled;
+
+ @ApiStatus.Internal
2022-12-11 18:55:39 +01:00
+ public AsyncChatDecorateEvent(final boolean async, final @Nullable Player player, final @NotNull Component originalMessage, final @NotNull Component result) {
2022-08-01 21:34:55 +02:00
+ super(async);
+ this.player = player;
+ this.originalMessage = originalMessage;
+ this.result = result;
+ }
+
+ /**
+ * Gets the player (if available) associated with this event.
+ * <p>
+ * Certain commands request decorations without a player context
+ * which is why this is possibly null.
+ *
+ * @return the player or null
+ */
+ public @Nullable Player player() {
+ return this.player;
+ }
+
+ /**
+ * Gets the original decoration input
+ *
+ * @return the input
+ */
+ public @NotNull Component originalMessage() {
+ return this.originalMessage;
+ }
+
+ /**
+ * Gets the decoration result. This may already be different from
+ * {@link #originalMessage()} if some other listener to this event
+ * <b>OR</b> the legacy preview event ({@link org.bukkit.event.player.AsyncPlayerChatPreviewEvent}
+ * changed the result.
+ *
+ * @return the result
+ */
+ public @NotNull Component result() {
+ return this.result;
+ }
+
+ /**
+ * Sets the resulting decorated component.
+ *
+ * @param result the result
+ */
+ public void result(@NotNull Component result) {
+ this.result = result;
+ }
+
+ /**
+ * If this decorating is part of a preview request/response.
+ *
+ * @return true if part of previewing
2022-12-11 19:34:31 +01:00
+ * @deprecated chat preview was removed in 1.19.3
2022-08-01 21:34:55 +02:00
+ */
2022-12-11 18:55:39 +01:00
+ @Deprecated(forRemoval = true)
2023-06-07 15:47:32 +02:00
+ @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
2022-12-11 18:55:39 +01:00
+ @Contract(value = "-> false", pure = true)
2022-08-01 21:34:55 +02:00
+ public boolean isPreview() {
2022-12-11 18:55:39 +01:00
+ return false;
2022-08-01 21:34:55 +02:00
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ /**
+ * A cancelled decorating event means that no changes to the result component
+ * will have any effect. The decorated component will be equal to the original
+ * component.
+ */
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ public static @NotNull HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java
new file mode 100644
2022-12-23 16:54:04 +01:00
index 0000000000000000000000000000000000000000..975a767313247d3b1c2a6cfd42c7fa6cd1525c53
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/AsyncChatEvent.java
2022-12-23 16:54:04 +01:00
@@ -0,0 +1,32 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.event.player;
+
+import java.util.Set;
+import io.papermc.paper.chat.ChatRenderer;
+import net.kyori.adventure.audience.Audience;
2022-12-23 16:54:04 +01:00
+import net.kyori.adventure.chat.SignedMessage;
2021-06-11 14:02:28 +02:00
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * An event fired when a {@link Player} sends a chat message to the server.
+ */
+public final class AsyncChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+
2022-12-23 16:54:04 +01:00
+ public AsyncChatEvent(final boolean async, final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) {
+ super(async, player, viewers, renderer, message, originalMessage, signedMessage);
2021-06-11 14:02:28 +02:00
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/event/player/ChatEvent.java b/src/main/java/io/papermc/paper/event/player/ChatEvent.java
new file mode 100644
2022-12-23 16:54:04 +01:00
index 0000000000000000000000000000000000000000..46c209f61135c7d37ccfbbc7bb1d74e608fac9d3
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/ChatEvent.java
2022-12-23 16:54:04 +01:00
@@ -0,0 +1,37 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.event.player;
+
+import java.util.Set;
+import io.papermc.paper.chat.ChatRenderer;
+import net.kyori.adventure.audience.Audience;
2022-12-23 16:54:04 +01:00
+import net.kyori.adventure.chat.SignedMessage;
2021-06-11 14:02:28 +02:00
+import net.kyori.adventure.text.Component;
+import org.bukkit.Warning;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * An event fired when a {@link Player} sends a chat message to the server.
+ *
+ * @deprecated Listening to this event forces chat to wait for the main thread, delaying chat messages. It is recommended to use {@link AsyncChatEvent} instead, wherever possible.
+ */
+@Deprecated
+@Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.")
+public final class ChatEvent extends AbstractChatEvent {
+ private static final HandlerList HANDLERS = new HandlerList();
+
2022-12-23 16:54:04 +01:00
+ public ChatEvent(final @NotNull Player player, final @NotNull Set<Audience> viewers, final @NotNull ChatRenderer renderer, final @NotNull Component message, final @NotNull Component originalMessage, final @NotNull SignedMessage signedMessage) {
+ super(false, player, viewers, renderer, message, originalMessage, signedMessage);
2021-06-11 14:02:28 +02:00
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+}
diff --git a/src/main/java/io/papermc/paper/text/PaperComponents.java b/src/main/java/io/papermc/paper/text/PaperComponents.java
new file mode 100644
2022-11-23 05:53:50 +01:00
index 0000000000000000000000000000000000000000..6e94562d79206d88b74b53814f9423f12a2e6e06
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/text/PaperComponents.java
2022-11-23 05:53:50 +01:00
@@ -0,0 +1,177 @@
2021-06-11 14:02:28 +02:00
+package io.papermc.paper.text;
+
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.flattener.ComponentFlattener;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
2021-12-22 23:56:37 +01:00
+import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
2021-12-22 08:07:17 +01:00
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
2021-06-11 14:02:28 +02:00
+import org.bukkit.Bukkit;
2022-11-23 05:53:50 +01:00
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Entity;
2021-12-22 08:07:17 +01:00
+import org.jetbrains.annotations.NotNull;
2022-11-23 05:53:50 +01:00
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
2021-06-11 14:02:28 +02:00
+
+/**
+ * Paper API-specific methods for working with {@link Component}s and related.
+ */
+public final class PaperComponents {
+ private PaperComponents() {
+ throw new RuntimeException("PaperComponents is not to be instantiated!");
+ }
+
+ /**
2022-11-23 05:53:50 +01:00
+ * Resolves a component with a specific command sender and subject.
+ * <p>
+ * Note that in Vanilla, elevated permissions are usually required to use
+ * '@' selectors in various component types, but this method should not
+ * check such permissions from the sender.
+ * <p>
+ * A {@link CommandSender} argument is required to resolve:
+ * <ul>
+ * <li>{@link net.kyori.adventure.text.NBTComponent}</li>
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
+ * <li>{@link net.kyori.adventure.text.SelectorComponent}</li>
+ * </ul>
+ * A {@link Entity} argument is optional to help resolve:
+ * <ul>
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
+ * </ul>
+ * {@link net.kyori.adventure.text.TranslatableComponent}s don't require any extra arguments.
+ *
+ * @param input the component to resolve
+ * @param context the command sender to resolve with
+ * @param scoreboardSubject the scoreboard subject to use (for use with {@link net.kyori.adventure.text.ScoreComponent}s)
+ * @return the resolved component
+ * @throws IOException if a syntax error tripped during resolving
+ */
+ public static @NotNull Component resolveWithContext(@NotNull Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject) throws IOException {
+ return resolveWithContext(input, context, scoreboardSubject, true);
+ }
+
+ /**
+ * Resolves a component with a specific command sender and subject.
+ * <p>
+ * Note that in Vanilla, elevated permissions are required to use
+ * '@' selectors in various component types. If the boolean {@code bypassPermissions}
+ * argument is {@code false}, the {@link CommandSender} argument will be used to query
+ * those permissions.
+ * <p>
+ * A {@link CommandSender} argument is required to resolve:
+ * <ul>
+ * <li>{@link net.kyori.adventure.text.NBTComponent}</li>
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
+ * <li>{@link net.kyori.adventure.text.SelectorComponent}</li>
+ * </ul>
+ * A {@link Entity} argument is optional to help resolve:
+ * <ul>
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
+ * </ul>
+ * {@link net.kyori.adventure.text.TranslatableComponent}s don't require any extra arguments.
+ *
+ * @param input the component to resolve
+ * @param context the command sender to resolve with
+ * @param scoreboardSubject the scoreboard subject to use (for use with {@link net.kyori.adventure.text.ScoreComponent}s)
+ * @param bypassPermissions true to bypass permissions checks for resolving components
+ * @return the resolved component
+ * @throws IOException if a syntax error tripped during resolving
+ */
+ public static @NotNull Component resolveWithContext(@NotNull Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject, boolean bypassPermissions) throws IOException {
+ return Bukkit.getUnsafe().resolveWithContext(input, context, scoreboardSubject, bypassPermissions);
+ }
+
+ /**
2021-06-11 14:02:28 +02:00
+ * Return a component flattener that can use game data to resolve extra information about components.
+ *
+ * @return a component flattener
+ */
2021-12-22 08:07:17 +01:00
+ public static @NotNull ComponentFlattener flattener() {
2021-06-11 14:02:28 +02:00
+ return Bukkit.getUnsafe().componentFlattener();
+ }
+
+ /**
+ * Get a serializer for {@link Component}s that will convert components to
+ * a plain-text string.
+ *
+ * <p>Implementations may provide a serializer capable of processing any
+ * information that requires access to implementation details.</p>
+ *
+ * @return a serializer to plain text
2022-05-26 21:12:14 +02:00
+ * @deprecated will be removed in adventure 5.0.0, use {@link PlainTextComponentSerializer#plainText()}
2021-06-11 14:02:28 +02:00
+ */
2022-05-26 21:12:14 +02:00
+ @Deprecated(forRemoval = true)
2021-12-22 23:56:37 +01:00
+ public static @NotNull PlainComponentSerializer plainSerializer() {
2021-06-11 14:02:28 +02:00
+ return Bukkit.getUnsafe().plainComponentSerializer();
+ }
+
+ /**
2021-12-22 23:56:37 +01:00
+ * Get a serializer for {@link Component}s that will convert components to
+ * a plain-text string.
+ *
+ * <p>Implementations may provide a serializer capable of processing any
+ * information that requires access to implementation details.</p>
+ *
+ * @return a serializer to plain text
2022-05-26 21:12:14 +02:00
+ * @deprecated use {@link PlainTextComponentSerializer#plainText()}
2021-12-22 23:56:37 +01:00
+ */
2022-05-26 21:12:14 +02:00
+ @Deprecated(forRemoval = true)
2021-12-22 23:56:37 +01:00
+ public static @NotNull PlainTextComponentSerializer plainTextSerializer() {
+ return Bukkit.getUnsafe().plainTextSerializer();
+ }
+
+ /**
2021-06-11 14:02:28 +02:00
+ * Get a serializer for {@link Component}s that will convert to and from the
+ * standard JSON serialization format using Gson.
+ *
+ * <p>Implementations may provide a serializer capable of processing any
+ * information that requires implementation details, such as legacy
+ * (pre-1.16) hover events.</p>
+ *
+ * @return a json component serializer
2022-05-26 21:12:14 +02:00
+ * @deprecated use {@link GsonComponentSerializer#gson()}
2021-06-11 14:02:28 +02:00
+ */
2022-05-26 21:12:14 +02:00
+ @Deprecated(forRemoval = true)
2021-12-22 08:07:17 +01:00
+ public static @NotNull GsonComponentSerializer gsonSerializer() {
2021-06-11 14:02:28 +02:00
+ return Bukkit.getUnsafe().gsonComponentSerializer();
+ }
+
+ /**
+ * Get a serializer for {@link Component}s that will convert to and from the
+ * standard JSON serialization format using Gson, downsampling any RGB colors
+ * to their nearest {@link NamedTextColor} counterpart.
+ *
+ * <p>Implementations may provide a serializer capable of processing any
+ * information that requires implementation details, such as legacy
+ * (pre-1.16) hover events.</p>
+ *
+ * @return a json component serializer
2022-05-26 21:12:14 +02:00
+ * @deprecated use {@link GsonComponentSerializer#colorDownsamplingGson()}
2021-06-11 14:02:28 +02:00
+ */
2022-05-26 21:12:14 +02:00
+ @Deprecated(forRemoval = true)
2021-12-22 08:07:17 +01:00
+ public static @NotNull GsonComponentSerializer colorDownsamplingGsonSerializer() {
2021-06-11 14:02:28 +02:00
+ return Bukkit.getUnsafe().colorDownsamplingGsonComponentSerializer();
+ }
+
+ /**
+ * Get a serializer for {@link Component}s that will convert to and from the
+ * legacy component format used by Bukkit. This serializer uses the
+ * {@link LegacyComponentSerializer.Builder#useUnusualXRepeatedCharacterHexFormat()}
+ * option to match upstream behavior.
+ *
+ * <p>This legacy serializer uses the standard section symbol to mark
+ * formatting characters.</p>
+ *
+ * <p>Implementations may provide a serializer capable of processing any
+ * information that requires access to implementation details.</p>
+ *
+ * @return a section serializer
2022-05-26 21:12:14 +02:00
+ * @deprecated use {@link LegacyComponentSerializer#legacySection()}
2021-06-11 14:02:28 +02:00
+ */
2022-05-26 21:12:14 +02:00
+ @Deprecated(forRemoval = true)
2021-12-22 08:07:17 +01:00
+ public static @NotNull LegacyComponentSerializer legacySectionSerializer() {
2021-06-11 14:02:28 +02:00
+ return Bukkit.getUnsafe().legacyComponentSerializer();
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
2023-07-04 10:22:56 +02:00
index ffb6ff5793f8702f6974ff53b53380e00d2d4057..b7bc68c5d0dbb41c089f59b7db51342d45d1fc74 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
2023-07-04 10:22:56 +02:00
@@ -389,7 +389,9 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
*
* @param message the message
* @return the number of players
+ * @deprecated in favour of {@link Server#broadcast(net.kyori.adventure.text.Component)}
*/
+ @Deprecated // Paper
public static int broadcastMessage(@NotNull String message) {
return server.broadcastMessage(message);
}
2023-07-04 10:22:56 +02:00
@@ -1105,6 +1107,19 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
server.shutdown();
}
+ // Paper start
+ /**
+ * Broadcast a message to all players.
+ * <p>
+ * This is the same as calling {@link #broadcast(net.kyori.adventure.text.Component,
+ * java.lang.String)} with the {@link Server#BROADCAST_CHANNEL_USERS} permission.
+ *
+ * @param message the message
+ * @return the number of players
+ */
2023-03-23 17:49:24 +01:00
+ public static int broadcast(net.kyori.adventure.text.@NotNull Component message) {
2021-06-11 14:02:28 +02:00
+ return server.broadcast(message);
+ }
/**
* Broadcasts the specified message to every user with the given
* permission name.
2023-07-04 10:22:56 +02:00
@@ -1114,6 +1129,21 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
* permissibles} must have to receive the broadcast
* @return number of message recipients
*/
2023-03-23 17:49:24 +01:00
+ public static int broadcast(net.kyori.adventure.text.@NotNull Component message, @NotNull String permission) {
2021-06-11 14:02:28 +02:00
+ 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);
}
2023-07-04 10:22:56 +02:00
@@ -1375,6 +1405,7 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
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;
2023-07-04 10:22:56 +02:00
@@ -1400,6 +1431,38 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
* @see InventoryType#isCreatable()
*/
@NotNull
2023-03-23 17:49:24 +01:00
+ public static Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, net.kyori.adventure.text.@NotNull Component title) {
2021-06-11 14:02:28 +02:00
+ 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.<br>
+ * It should be noted that some inventory types do not support titles and
+ * may not render with said titles on the Minecraft client.
+ * <br>
+ * {@link InventoryType#WORKBENCH} will not process crafting recipes if
+ * created with this method. Use
+ * {@link Player#openWorkbench(Location, boolean)} instead.
+ * <br>
+ * {@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);
}
2023-07-04 10:22:56 +02:00
@@ -1418,6 +1481,7 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
return server.createInventory(owner, size);
}
+ // Paper start
/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size and title.
2023-07-04 10:22:56 +02:00
@@ -1430,10 +1494,30 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
* @throws IllegalArgumentException if the size is not a multiple of 9
*/
@NotNull
2023-03-23 17:49:24 +01:00
+ public static Inventory createInventory(@Nullable InventoryHolder owner, int size, net.kyori.adventure.text.@NotNull Component title) throws IllegalArgumentException {
2021-06-11 14:02:28 +02:00
+ 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.
*
2023-07-04 10:22:56 +02:00
@@ -1441,7 +1525,20 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
* when the merchant inventory is viewed
* @return a new merchant
*/
2023-03-23 17:49:24 +01:00
+ public static @NotNull Merchant createMerchant(net.kyori.adventure.text.@Nullable Component title) {
2021-06-11 14:02:28 +02:00
+ 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);
}
2023-07-04 10:22:56 +02:00
@@ -1558,12 +1655,43 @@ public final class Bukkit {
2021-06-11 14:02:28 +02:00
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();
+ }
2023-06-13 01:51:45 +02:00
+
+ /**
+ * Set the message that is displayed on the server list.
+ *
+ * @param motd The message to be displayed
+ */
+ public static void motd(final net.kyori.adventure.text.@NotNull Component motd) {
+ server.motd(motd);
+ }
+
+ /**
+ * Gets the default message that is displayed when the server is stopped.
+ *
+ * @return the shutdown message
+ */
+ public static net.kyori.adventure.text.@Nullable Component shutdownMessage() {
+ return server.shutdownMessage();
+ }
2021-06-11 14:02:28 +02:00
+ // 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();
}
2023-07-04 10:22:56 +02:00
@@ -1572,7 +1700,9 @@ public final class Bukkit {
2023-06-13 01:51:45 +02:00
* Set the message that is displayed on the server list.
*
* @param motd The message to be displayed
+ * @deprecated in favour of {@link #motd(net.kyori.adventure.text.Component)}
*/
+ @Deprecated // Paper
public static void setMotd(@NotNull String motd) {
server.setMotd(motd);
}
2023-07-04 10:22:56 +02:00
@@ -1581,8 +1711,10 @@ public final class Bukkit {
2023-03-23 22:57:03 +01:00
* Gets the default message that is displayed when the server is stopped.
*
* @return the shutdown message
+ * @deprecated in favour of {@link #shutdownMessage()}
*/
2021-06-11 14:02:28 +02:00
@Nullable
+ @Deprecated // Paper
public static String getShutdownMessage() {
return server.getShutdownMessage();
}
2023-04-02 20:53:29 +02:00
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
2023-06-14 05:48:41 +02:00
index e3f185dc982d1c38195a4e01ddd485c13ffa58c0..918a045165cdcde264bc24082b7afebb407271de 100644
2023-04-02 20:53:29 +02:00
--- a/src/main/java/org/bukkit/ChatColor.java
+++ b/src/main/java/org/bukkit/ChatColor.java
2023-06-14 05:48:41 +02:00
@@ -10,7 +10,9 @@ import org.jetbrains.annotations.Nullable;
2023-04-02 20:53:29 +02:00
/**
* All supported color values for chat
2023-06-14 05:48:41 +02:00
+ * @deprecated ChatColor has been deprecated in favor of <a href="https://docs.advntr.dev/text.html">Adventure</a> API. See {@link net.kyori.adventure.text.format.NamedTextColor} for the adventure equivalent of pre-defined text colors
2023-04-02 20:53:29 +02:00
*/
+@Deprecated // Paper
public enum ChatColor {
/**
* Represents black
2021-12-13 05:26:19 +01:00
diff --git a/src/main/java/org/bukkit/Keyed.java b/src/main/java/org/bukkit/Keyed.java
index 32c92621c2c15eec14c50965f5ecda00c46e6c80..e076d447da62445764a9776ee2554c077637d270 100644
--- a/src/main/java/org/bukkit/Keyed.java
+++ b/src/main/java/org/bukkit/Keyed.java
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents an object which has a {@link NamespacedKey} attached to it.
*/
-public interface Keyed {
+public interface Keyed extends net.kyori.adventure.key.Keyed { // Paper -- extend Adventure Keyed
/**
* Return the namespaced identifier for this object.
@@ -14,4 +14,16 @@ public interface Keyed {
*/
@NotNull
NamespacedKey getKey();
+
+ // Paper start
+ /**
+ * Returns the unique identifier for this object.
+ *
+ * @return this object's key
+ */
+ @Override
+ default net.kyori.adventure.key.@NotNull Key key() {
+ return this.getKey();
+ }
+ // Paper end
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/Nameable.java b/src/main/java/org/bukkit/Nameable.java
2023-05-12 13:10:08 +02:00
index b79daa857fc686f00ac06b8851e0ab68d83ae949..45d996878ba8d314a47078589b6da59dc84d589e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Nameable.java
+++ b/src/main/java/org/bukkit/Nameable.java
2023-05-12 13:10:08 +02:00
@@ -7,6 +7,30 @@ import org.jetbrains.annotations.Nullable;
*/
2021-06-11 14:02:28 +02:00
public interface Nameable {
+ // Paper start
+ /**
+ * Gets the custom name.
+ *
+ * <p>This value has no effect on players, they will always use their real name.</p>
+ *
+ * @return the custom name
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@Nullable Component customName();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the custom name.
+ *
+ * <p>This name will be used in death messages and can be sent to the client as a nameplate over the mob.</p>
+ *
+ * <p>Setting the name to {@code null} will clear it.</p>
+ *
+ * <p>This value has no effect on players, they will always use their real name.</p>
+ *
+ * @param customName the custom name to set
+ */
2023-03-23 17:49:24 +01:00
+ void customName(final net.kyori.adventure.text.@Nullable Component customName);
2021-06-11 14:02:28 +02:00
+ // Paper end
+
/**
* Gets the custom name on a mob or block. If there is no name this method
* will return null.
2023-05-12 13:10:08 +02:00
@@ -14,8 +38,10 @@ public interface Nameable {
2022-02-23 03:11:52 +01:00
* This value has no effect on players, they will always use their real
* name.
*
+ * @deprecated in favour of {@link #customName()}
* @return name of the mob/block or null
*/
+ @Deprecated // Paper
@Nullable
public String getCustomName();
2023-05-12 13:10:08 +02:00
@@ -28,7 +54,9 @@ public interface Nameable {
2022-02-23 03:11:52 +01:00
* This value has no effect on players, they will always use their real
* name.
*
+ * @deprecated in favour of {@link #customName(net.kyori.adventure.text.Component)}
* @param name the name to set
*/
+ @Deprecated // Paper
public void setCustomName(@Nullable String name);
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/NamespacedKey.java b/src/main/java/org/bukkit/NamespacedKey.java
2023-02-26 15:59:52 +01:00
index c559f38fdb92cfee9f2e0ffb7088d1cf74a7f73d..a42f1d53340e4073038d46b7fabf5d44248d5b32 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/NamespacedKey.java
+++ b/src/main/java/org/bukkit/NamespacedKey.java
2023-02-07 16:55:53 +01:00
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
* 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.
2023-02-26 15:59:52 +01:00
@@ -129,10 +129,11 @@ public final class NamespacedKey {
@Override
public int hashCode() {
- int hash = 5;
- hash = 47 * hash + this.namespace.hashCode();
- hash = 47 * hash + this.key.hashCode();
- return hash;
+ // Paper start
+ int result = this.namespace.hashCode();
+ result = (31 * result) + this.key.hashCode();
+ return result;
+ // Paper end
}
@Override
@@ -140,11 +141,10 @@ public final class NamespacedKey {
if (obj == null) {
return false;
}
- if (getClass() != obj.getClass()) {
- return false;
- }
- final NamespacedKey other = (NamespacedKey) obj;
- return this.namespace.equals(other.namespace) && this.key.equals(other.key);
+ // Paper start
+ if (!(obj instanceof net.kyori.adventure.key.Key key)) return false;
+ return this.namespace.equals(key.namespace()) && this.key.equals(key.value());
+ // Paper end
}
@Override
2023-02-07 16:55:53 +01:00
@@ -246,4 +246,24 @@ public final class NamespacedKey {
2021-06-11 14:02:28 +02:00
public static NamespacedKey fromString(@NotNull String key) {
return fromString(key, null);
}
+
+ // 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
2023-07-04 10:22:56 +02:00
index 8263a17a46c2aa7f976b37b80933acd850b9434a..e3602c6703b29ffec17ef7806c9deb3eead8a112 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
2023-07-04 10:22:56 +02:00
@@ -61,13 +61,13 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
/**
* 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
* command.
* <p>
- * For use in {@link #broadcast(java.lang.String, java.lang.String)}.
+ * For use in {@link #broadcast(net.kyori.adventure.text.Component, java.lang.String)}.
*/
public static final String BROADCAST_CHANNEL_ADMINISTRATIVE = "bukkit.broadcast.admin";
2023-07-04 10:22:56 +02:00
@@ -75,7 +75,7 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
* Used for all announcement messages, such as informing users that a
* player has joined.
* <p>
- * For use in {@link #broadcast(java.lang.String, java.lang.String)}.
+ * For use in {@link #broadcast(net.kyori.adventure.text.Component, java.lang.String)}.
*/
public static final String BROADCAST_CHANNEL_USERS = "bukkit.broadcast.user";
2023-07-04 10:22:56 +02:00
@@ -328,7 +328,9 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
*
* @param message the message
* @return the number of players
+ * @deprecated use {@link #broadcast(net.kyori.adventure.text.Component)}
*/
+ @Deprecated // Paper
public int broadcastMessage(@NotNull String message);
/**
2023-07-04 10:22:56 +02:00
@@ -946,8 +948,33 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
* @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
+ /**
+ * Broadcast a message to all players.
+ * <p>
+ * This is the same as calling {@link #broadcast(net.kyori.adventure.text.Component,
+ * java.lang.String)} with the {@link #BROADCAST_CHANNEL_USERS} permission.
+ *
+ * @param message the message
+ * @return the number of players
+ */
2023-03-23 17:49:24 +01:00
+ int broadcast(net.kyori.adventure.text.@NotNull Component message);
2021-06-11 14:02:28 +02:00
+
+ /**
+ * 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
+ */
2023-03-23 17:49:24 +01:00
+ int broadcast(net.kyori.adventure.text.@NotNull Component message, @NotNull String permission);
2021-06-11 14:02:28 +02:00
+ // Paper end
/**
* Gets the player by the given name, regardless if they are offline or
2023-07-04 10:22:56 +02:00
@@ -1164,6 +1191,35 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
@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;
+ * otherwise the new inventory has the normal size for its type.<br>
+ * It should be noted that some inventory types do not support titles and
+ * may not render with said titles on the Minecraft client.
+ * <br>
+ * {@link InventoryType#WORKBENCH} will not process crafting recipes if
+ * created with this method. Use
+ * {@link Player#openWorkbench(Location, boolean)} instead.
+ * <br>
+ * {@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.
+ *
+ * @see InventoryType#isCreatable()
+ */
+ @NotNull
2023-06-13 01:51:45 +02:00
+ Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, net.kyori.adventure.text.@NotNull 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;
2023-07-04 10:22:56 +02:00
@@ -1185,9 +1241,11 @@ public interface Server extends PluginMessageRecipient {
2023-06-13 01:51:45 +02:00
* @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
2021-06-11 14:02:28 +02:00
Inventory createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull String title);
2023-07-04 10:22:56 +02:00
@@ -1203,6 +1261,22 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
@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
2023-03-23 17:49:24 +01:00
+ */
+ @NotNull
2023-03-23 22:57:03 +01:00
+ Inventory createInventory(@Nullable InventoryHolder owner, int size, net.kyori.adventure.text.@NotNull Component title) throws IllegalArgumentException;
+ // Paper end
+
/**
* Creates an empty inventory of type {@link InventoryType#CHEST} with the
* specified size and title.
2023-07-04 10:22:56 +02:00
@@ -1213,18 +1287,32 @@ public interface Server extends PluginMessageRecipient {
2023-03-23 22:57:03 +01:00
* 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
2021-06-11 14:02:28 +02:00
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
+ */
2023-06-13 01:51:45 +02:00
+ @NotNull Merchant createMerchant(net.kyori.adventure.text.@Nullable 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)}
*/
2021-06-11 14:02:28 +02:00
@NotNull
+ @Deprecated // Paper
Merchant createMerchant(@Nullable String title);
/**
2023-07-04 10:22:56 +02:00
@@ -1320,27 +1408,56 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
*/
boolean isPrimaryThread();
+ // Paper start
+ /**
+ * Gets the message that is displayed on the server list.
+ *
+ * @return the server's MOTD
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component motd();
2023-06-13 01:51:45 +02:00
+
+ /**
+ * Set the message that is displayed on the server list.
+ *
+ * @param motd The message to be displayed
+ */
+ void motd(final net.kyori.adventure.text.@NotNull Component motd);
+
+ /**
+ * Gets the default message that is displayed when the server is stopped.
+ *
+ * @return the shutdown message
+ */
+ net.kyori.adventure.text.@Nullable Component shutdownMessage();
2021-06-11 14:02:28 +02:00
+ // 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();
2023-06-13 01:51:45 +02:00
/**
* Set the message that is displayed on the server list.
*
* @param motd The message to be displayed
+ * @deprecated in favour of {@link #motd(net.kyori.adventure.text.Component)}
*/
+ @Deprecated // Paper
void setMotd(@NotNull String motd);
2023-03-23 22:57:03 +01:00
/**
* Gets the default message that is displayed when the server is stopped.
*
* @return the shutdown message
+ * @deprecated in favour of {@link #shutdownMessage()}
*/
2021-06-11 14:02:28 +02:00
@Nullable
+ @Deprecated // Paper
String getShutdownMessage();
/**
2023-07-04 10:22:56 +02:00
@@ -1722,7 +1839,9 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
* Sends the component to the player
*
* @param component the components to send
+ * @deprecated use {@link #broadcast(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.");
}
2023-07-04 10:22:56 +02:00
@@ -1731,7 +1850,9 @@ public interface Server extends PluginMessageRecipient {
2021-06-11 14:02:28 +02:00
* Sends an array of components as a single message to the player
*
* @param components the components to send
+ * @deprecated use {@link #broadcast(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/Sound.java b/src/main/java/org/bukkit/Sound.java
2023-06-07 18:24:39 +02:00
index 4cbc963f268753316327e38b6e1e42cffb486b54..6e8d2b35d8f33827396dbcfa817cd9c2f8ad83a6 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/Sound.java
+++ b/src/main/java/org/bukkit/Sound.java
2023-06-07 18:24:39 +02:00
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
2021-06-11 14:02:28 +02:00
* guarantee values will not be removed from this Enum. As such, you should not
* depend on the ordinal values of this class.
*/
-public enum Sound implements Keyed {
+public enum Sound implements Keyed, net.kyori.adventure.sound.Sound.Type { // Paper - implement Sound.Type
AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"),
AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"),
2023-06-07 18:24:39 +02:00
@@ -1498,4 +1498,11 @@ public enum Sound implements Keyed {
2021-06-11 14:02:28 +02:00
public NamespacedKey getKey() {
return key;
}
+
+ // Paper start
+ @Override
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.key.@NotNull Key key() {
2021-06-11 14:02:28 +02:00
+ return this.key;
+ }
2021-06-28 15:07:19 +02:00
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/SoundCategory.java b/src/main/java/org/bukkit/SoundCategory.java
index ac5e263d737973af077e3406a84a84baca4370db..2d91924b7f5ef16a91d40cdc1bfc3d68e0fda38d 100644
--- a/src/main/java/org/bukkit/SoundCategory.java
+++ b/src/main/java/org/bukkit/SoundCategory.java
@@ -3,7 +3,7 @@ package org.bukkit;
/**
* An Enum of categories for sounds.
*/
-public enum SoundCategory {
+public enum SoundCategory implements net.kyori.adventure.sound.Sound.Source.Provider { // Paper - implement Sound.Source.Provider
MASTER,
MUSIC,
@@ -15,4 +15,22 @@ public enum SoundCategory {
PLAYERS,
AMBIENT,
VOICE;
+
+ // Paper start - implement Sound.Source.Provider
+ @Override
+ public net.kyori.adventure.sound.Sound.@org.jetbrains.annotations.NotNull Source soundSource() {
+ return switch (this) {
+ case MASTER -> net.kyori.adventure.sound.Sound.Source.MASTER;
+ case MUSIC -> net.kyori.adventure.sound.Sound.Source.MUSIC;
+ case RECORDS -> net.kyori.adventure.sound.Sound.Source.RECORD;
+ case WEATHER -> net.kyori.adventure.sound.Sound.Source.WEATHER;
+ case BLOCKS -> net.kyori.adventure.sound.Sound.Source.BLOCK;
+ case HOSTILE -> net.kyori.adventure.sound.Sound.Source.HOSTILE;
+ case NEUTRAL -> net.kyori.adventure.sound.Sound.Source.NEUTRAL;
+ case PLAYERS -> net.kyori.adventure.sound.Sound.Source.PLAYER;
+ case AMBIENT -> net.kyori.adventure.sound.Sound.Source.AMBIENT;
+ case VOICE -> net.kyori.adventure.sound.Sound.Source.VOICE;
+ };
+ }
2021-06-11 14:02:28 +02:00
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
2023-06-06 11:09:19 +02:00
index 650adcecdca839518e0b57bc47935d010ca0f64f..fd0ae07b8a19f6b628601a487329a929f3a26c91 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
2023-06-06 11:09:19 +02:00
@@ -25,6 +25,15 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
*/
@Deprecated
public interface UnsafeValues {
+ // Paper start
+ net.kyori.adventure.text.flattener.ComponentFlattener componentFlattener();
2022-05-26 21:12:14 +02:00
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainComponentSerializer plainComponentSerializer();
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer plainTextSerializer();
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer();
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer();
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer();
2022-11-23 05:53:50 +01:00
+ net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component component, org.bukkit.command.CommandSender context, org.bukkit.entity.Entity scoreboardSubject, boolean bypassPermissions) throws java.io.IOException;
2021-06-11 14:02:28 +02:00
+ // Paper end
Material toLegacy(Material material);
2022-03-04 22:19:57 +01:00
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/Warning.java b/src/main/java/org/bukkit/Warning.java
index efb97712cc9dc7c1e12a59f5b94e4f2ad7c6b7d8..3024468af4c073324e536c1cb26beffb1e09f3f4 100644
--- a/src/main/java/org/bukkit/Warning.java
+++ b/src/main/java/org/bukkit/Warning.java
@@ -67,6 +67,7 @@ public @interface Warning {
* </ul>
*/
public boolean printFor(@Nullable Warning warning) {
+ if (Boolean.getBoolean("paper.alwaysPrintWarningState")) return true; // Paper
if (this == DEFAULT) {
return warning == null || warning.value();
}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
2023-06-06 11:09:19 +02:00
index c4d2a13d62059ca1f148a9af909f424b745bc8df..5357291ff0f2f20bd87ab9f6e57f6a4f6ff65226 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
2023-06-06 11:09:19 +02:00
@@ -44,7 +44,7 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
/**
* Represents a world, which may contain entities, chunks and blocks
*/
2022-05-09 11:03:07 +02:00
-public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient, Metadatable, PersistentDataHolder, Keyed {
+public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient, Metadatable, PersistentDataHolder, Keyed, net.kyori.adventure.audience.ForwardingAudience { // Paper
2021-06-11 14:02:28 +02:00
/**
* Gets the {@link Block} at the given coordinates
2023-06-06 11:09:19 +02:00
@@ -605,6 +605,14 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
2021-06-11 14:02:28 +02:00
@NotNull
public List<Player> getPlayers();
+ // Paper start
+ @NotNull
+ @Override
+ default Iterable<? extends net.kyori.adventure.audience.Audience> audiences() {
+ return this.getPlayers();
+ }
+ // Paper end
+
/**
* Returns a list of entities within a bounding box centered around a
* Location.
2021-09-30 23:28:02 +02:00
diff --git a/src/main/java/org/bukkit/block/CommandBlock.java b/src/main/java/org/bukkit/block/CommandBlock.java
2023-03-23 17:49:24 +01:00
index 372c0bd5a4d7800a11c24c95e39fe376a96232bf..9c88be68b4f403d0500cb607394b3a1646675ef7 100644
2021-09-30 23:28:02 +02:00
--- a/src/main/java/org/bukkit/block/CommandBlock.java
+++ b/src/main/java/org/bukkit/block/CommandBlock.java
@@ -33,7 +33,9 @@ public interface CommandBlock extends TileState {
* by default is "@".
*
* @return Name of this CommandBlock.
+ * @deprecated in favour of {@link #name()}
*/
+ @Deprecated // Paper
@NotNull
public String getName();
@@ -43,6 +45,28 @@ public interface CommandBlock extends TileState {
* same as setting it to "@".
*
* @param name New name for this CommandBlock.
+ * @deprecated in favour of {@link #name(net.kyori.adventure.text.Component)}
*/
+ @Deprecated // Paper
public void setName(@Nullable String name);
+
+ // Paper start
+ /**
+ * Gets the name of this CommandBlock. The name is used with commands
+ * that this CommandBlock executes. This name will never be null, and
+ * by default is a {@link net.kyori.adventure.text.TextComponent} containing {@code @}.
+ *
+ * @return Name of this CommandBlock.
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component name();
2021-09-30 23:28:02 +02:00
+
+ /**
+ * Sets the name of this CommandBlock. The name is used with commands
+ * that this CommandBlock executes. Setting the name to null is the
+ * same as setting it to a {@link net.kyori.adventure.text.TextComponent} containing {@code @}.
+ *
+ * @param name New name for this CommandBlock.
+ */
2023-03-23 17:49:24 +01:00
+ public void name(net.kyori.adventure.text.@Nullable Component name);
2021-09-30 23:28:02 +02:00
+ // Paper end
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java
2023-07-04 10:22:56 +02:00
index 5fc1c759e6e8f3fd43a5fa5c6e3f777efa16b1ec..e6b87ad5b2099800a61e7f585a5404e9e672228a 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/block/Sign.java
+++ b/src/main/java/org/bukkit/block/Sign.java
2023-06-07 18:24:39 +02:00
@@ -10,12 +10,50 @@ import org.jetbrains.annotations.NotNull;
2021-06-11 14:02:28 +02:00
* Represents a captured state of either a SignPost or a WallSign.
*/
public interface Sign extends TileState, Colorable {
+ // Paper start
+ /**
2023-06-01 01:36:57 +02:00
+ * Gets all the lines of text currently on the {@link Side#FRONT} of this sign.
2021-06-11 14:02:28 +02:00
+ *
2023-06-01 01:36:57 +02:00
+ * @return List of components containing each line of text
2023-06-07 18:24:39 +02:00
+ * @deprecated A sign may have multiple writable sides now. Use {@link Sign#getSide(Side)} and {@link SignSide#lines()}.
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2023-03-23 22:57:03 +01:00
+ public java.util.List<net.kyori.adventure.text.Component> lines();
2021-06-11 14:02:28 +02:00
+
+ /**
2023-06-01 01:36:57 +02:00
+ * Gets the line of text at the specified index on the {@link Side#FRONT}.
2021-06-11 14:02:28 +02:00
+ * <p>
+ * For example, getLine(0) will return the first line of text.
+ *
+ * @param index Line number to get the text from, starting at 0
2023-03-23 17:49:24 +01:00
+ * @throws IndexOutOfBoundsException Thrown when the line does not exist
2023-03-23 22:57:03 +01:00
+ * @return Text on the given line
2023-06-07 18:24:39 +02:00
+ * @deprecated A sign may have multiple writable sides now. Use {@link #getSide(Side)} and {@link SignSide#line(int)}.
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2023-06-07 18:24:39 +02:00
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ public net.kyori.adventure.text.Component line(int index) throws IndexOutOfBoundsException;
2021-06-11 14:02:28 +02:00
+
+ /**
2023-06-01 01:36:57 +02:00
+ * Sets the line of text at the specified index on the {@link Side#FRONT}.
2021-06-11 14:02:28 +02:00
+ * <p>
+ * 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
2023-06-07 18:24:39 +02:00
+ * @deprecated A sign may have multiple writable sides now. Use {@link #getSide(Side)} and {@link SignSide#line(int, net.kyori.adventure.text.Component)}.
2023-03-23 17:49:24 +01:00
+ */
2023-06-07 18:24:39 +02:00
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ public void line(int index, net.kyori.adventure.text.@NotNull Component line) throws IndexOutOfBoundsException;
+ // Paper end
/**
2023-06-01 01:36:57 +02:00
* Gets all the lines of text currently on the {@link Side#FRONT} of this sign.
2023-06-07 18:24:39 +02:00
*
* @return Array of Strings containing each line of text
- * @deprecated A sign may have multiple writable sides now. Use {@link Sign#getSide(Side)} and {@link SignSide#getLines()}.
+ * @deprecated A sign may have multiple writable sides now. Use {@link Sign#getSide(Side)} and {@link SignSide#lines()}.
2023-03-23 22:57:03 +01:00
*/
2023-06-07 18:24:39 +02:00
@Deprecated
2023-03-23 22:57:03 +01:00
@NotNull
2023-06-07 18:24:39 +02:00
@@ -29,7 +67,7 @@ public interface Sign extends TileState, Colorable {
* @param index Line number to get the text from, starting at 0
2023-03-23 22:57:03 +01:00
* @return Text on the given line
* @throws IndexOutOfBoundsException Thrown when the line does not exist
2023-06-07 18:24:39 +02:00
- * @deprecated A sign may have multiple writable sides now. Use {@link #getSide(Side)} and {@link SignSide#getLine(int)}.
+ * @deprecated A sign may have multiple writable sides now. Use {@link #getSide(Side)} and {@link SignSide#line(int)}.
2023-03-23 22:57:03 +01:00
*/
2023-06-07 18:24:39 +02:00
@Deprecated
2023-03-23 22:57:03 +01:00
@NotNull
2023-06-07 18:24:39 +02:00
@@ -44,7 +82,7 @@ public interface Sign extends TileState, Colorable {
* @param index Line number to set the text at, starting from 0
2023-03-23 22:57:03 +01:00
* @param line New text to set at the specified index
* @throws IndexOutOfBoundsException If the index is out of the range 0..3
2023-06-07 18:24:39 +02:00
- * @deprecated A sign may have multiple writable sides now. Use {@link #getSide(Side)} and {@link SignSide#setLine(int, String)}.
+ * @deprecated A sign may have multiple writable sides now. Use {@link #getSide(Side)} and {@link SignSide#line(int, net.kyori.adventure.text.Component)}.
2023-03-23 22:57:03 +01:00
*/
2023-06-07 18:24:39 +02:00
@Deprecated
2021-06-11 14:02:28 +02:00
public void setLine(int index, @NotNull String line) throws IndexOutOfBoundsException;
2023-06-01 01:36:57 +02:00
diff --git a/src/main/java/org/bukkit/block/sign/SignSide.java b/src/main/java/org/bukkit/block/sign/SignSide.java
2023-07-11 18:58:08 +02:00
index 0f4ae7bd2ad379b5edb40f49f93de9e18c38f415..575e545a69b5279b90067d7ebee08b7b59288496 100644
2023-06-01 01:36:57 +02:00
--- a/src/main/java/org/bukkit/block/sign/SignSide.java
+++ b/src/main/java/org/bukkit/block/sign/SignSide.java
2023-07-11 18:58:08 +02:00
@@ -7,13 +7,48 @@ import org.jetbrains.annotations.NotNull;
2023-06-07 18:24:39 +02:00
* Represents a side of a sign.
2023-06-01 01:36:57 +02:00
*/
public interface SignSide extends Colorable {
+ // Paper start
+ /**
+ * Gets all the lines of text currently on the sign.
+ *
+ * @return List of components containing each line of text
+ */
+ @NotNull
+ public java.util.List<net.kyori.adventure.text.Component> lines();
+
+ /**
+ * Gets the line of text at the specified index.
+ * <p>
+ * 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.
+ * <p>
+ * 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, net.kyori.adventure.text.@NotNull Component line) throws IndexOutOfBoundsException;
+ // Paper end
/**
* Gets all the lines of text currently on this side of the sign.
2023-07-11 18:58:08 +02:00
*
* @return Array of Strings containing each line of text
+ * @deprecated in favour of {@link #lines()}
*/
@NotNull
+ @Deprecated // Paper
public String[] getLines();
/**
@@ -24,8 +59,10 @@ public interface SignSide extends Colorable {
* @param index Line number to get the text from, starting at 0
* @return Text on the given line
* @throws IndexOutOfBoundsException Thrown when the line does not exist
+ * @deprecated in favour of {@link #line(int)}
*/
@NotNull
+ @Deprecated // Paper
public String getLine(int index) throws IndexOutOfBoundsException;
/**
@@ -37,7 +74,9 @@ public interface SignSide extends 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;
/**
2021-10-05 22:52:03 +02:00
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
2023-03-23 17:49:24 +01:00
index 80209bb88a0294d4eedc78509533a6257315d856..75759131bd94b672bec4cd8e271ebff1ad391cba 100644
2021-10-05 22:52:03 +02:00
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
2023-02-19 15:57:10 +01:00
@@ -32,7 +32,7 @@ public abstract class Command {
2021-10-05 22:52:03 +02:00
protected String description;
protected String usageMessage;
private String permission;
- private String permissionMessage;
+ private net.kyori.adventure.text.Component permissionMessage; // Paper
2023-02-19 15:57:10 +01:00
public org.spigotmc.CustomTimingsHandler timings; // Spigot
2021-10-05 22:52:03 +02:00
2022-03-04 22:19:57 +01:00
protected Command(@NotNull String name) {
2023-02-19 15:57:10 +01:00
@@ -186,10 +186,10 @@ public abstract class Command {
2021-10-05 22:52:03 +02:00
if (permissionMessage == null) {
target.sendMessage(ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is a mistake.");
- } else if (permissionMessage.length() != 0) {
- for (String line : permissionMessage.replace("<permission>", permission).split("\n")) {
- target.sendMessage(line);
- }
+ // Paper start - use components for permissionMessage
+ } else if (!permissionMessage.equals(net.kyori.adventure.text.Component.empty())) {
+ target.sendMessage(permissionMessage.replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<permission>").replacement(permission).build()));
+ // Paper end
}
return false;
2023-02-19 15:57:10 +01:00
@@ -317,10 +317,12 @@ public abstract class Command {
2021-10-05 22:52:03 +02:00
* command
*
* @return Permission check failed message
+ * @deprecated use {@link #permissionMessage()}
*/
@Nullable
+ @Deprecated // Paper
public String getPermissionMessage() {
- return permissionMessage;
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serializeOrNull(permissionMessage); // Paper
2021-10-05 22:52:03 +02:00
}
/**
2023-02-19 15:57:10 +01:00
@@ -381,10 +383,12 @@ public abstract class Command {
2021-10-05 22:52:03 +02:00
* @param permissionMessage new permission message, null to indicate
* default message, or an empty string to indicate no message
* @return this command object, for chaining
+ * @deprecated use {@link #permissionMessage(net.kyori.adventure.text.Component)}
*/
@NotNull
+ @Deprecated // Paper
public Command setPermissionMessage(@Nullable String permissionMessage) {
- this.permissionMessage = permissionMessage;
2022-05-26 21:12:14 +02:00
+ this.permissionMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(permissionMessage); // Paper
2021-10-05 22:52:03 +02:00
return this;
}
2023-02-19 15:57:10 +01:00
@@ -399,13 +403,47 @@ public abstract class Command {
2021-10-05 22:52:03 +02:00
this.usageMessage = (usage == null) ? "" : usage;
return this;
}
+ // Paper start
2021-10-06 10:05:39 +02:00
+ /**
+ * Gets the permission message.
+ *
+ * @return the permission message
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@Nullable Component permissionMessage() {
2021-10-05 22:52:03 +02:00
+ return this.permissionMessage;
+ }
+
2021-10-06 10:05:39 +02:00
+ /**
+ * Sets the permission message.
+ *
+ * @param permissionMessage the permission message
+ */
2023-03-23 17:49:24 +01:00
+ public void permissionMessage(net.kyori.adventure.text.@Nullable Component permissionMessage) {
2021-10-05 22:52:03 +02:00
+ this.permissionMessage = permissionMessage;
+ }
+ // Paper end
public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message) {
broadcastCommandMessage(source, message, true);
2022-06-03 06:26:56 +02:00
}
public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message, boolean sendToSource) {
- String result = source.getName() + ": " + message;
+ // Paper start
+ broadcastCommandMessage(source, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message), sendToSource);
+ }
+
2023-03-23 17:49:24 +01:00
+ public static void broadcastCommandMessage(@NotNull CommandSender source, net.kyori.adventure.text.@NotNull Component message) {
2022-06-03 06:26:56 +02:00
+ broadcastCommandMessage(source, message, true);
+ }
+
2023-03-23 17:49:24 +01:00
+ public static void broadcastCommandMessage(@NotNull CommandSender source, net.kyori.adventure.text.@NotNull Component message, boolean sendToSource) {
2022-06-03 06:26:56 +02:00
+ net.kyori.adventure.text.TextComponent.Builder result = net.kyori.adventure.text.Component.text()
+ .color(net.kyori.adventure.text.format.NamedTextColor.WHITE)
+ .decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false)
+ .append(source.name())
+ .append(net.kyori.adventure.text.Component.text(": "))
+ .append(message);
+ // Paper end
if (source instanceof BlockCommandSender) {
BlockCommandSender blockCommandSender = (BlockCommandSender) source;
2023-02-19 15:57:10 +01:00
@@ -424,7 +462,12 @@ public abstract class Command {
2022-06-03 06:26:56 +02:00
}
Set<Permissible> users = Bukkit.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
- String colored = ChatColor.GRAY + "" + ChatColor.ITALIC + "[" + result + ChatColor.GRAY + ChatColor.ITALIC + "]";
+ // Paper start
+ net.kyori.adventure.text.TextComponent.Builder colored = net.kyori.adventure.text.Component.text()
+ .color(net.kyori.adventure.text.format.NamedTextColor.GRAY)
+ .decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC)
+ .append(net.kyori.adventure.text.Component.text("["), result, net.kyori.adventure.text.Component.text("]"));
+ // Paper end
if (sendToSource && !(source instanceof ConsoleCommandSender)) {
source.sendMessage(message);
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
2023-04-02 20:53:29 +02:00
index 284be63a125624a8ae43d2c164aede810ce6bfe5..4e440880bd82f3cd8b267f00b2fcd725b49ce981 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/command/CommandSender.java
+++ b/src/main/java/org/bukkit/command/CommandSender.java
2023-04-02 20:53:29 +02:00
@@ -6,20 +6,28 @@ import org.bukkit.permissions.Permissible;
2021-06-11 14:02:28 +02:00
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)
2023-04-02 20:53:29 +02:00
+ * @see #sendPlainMessage(String)
+ * @see #sendRichMessage(String)
2021-06-11 14:02:28 +02:00
*/
2023-04-02 20:53:29 +02:00
+ @org.jetbrains.annotations.ApiStatus.Obsolete // Paper
2021-06-11 14:02:28 +02:00
public void sendMessage(@NotNull String message);
2023-04-02 20:53:29 +02:00
/**
2021-06-11 14:02:28 +02:00
* Sends this sender multiple messages
*
* @param messages An array of messages to be displayed
+ * @see #sendMessage(net.kyori.adventure.text.Component)
2023-04-02 20:53:29 +02:00
+ * @see #sendPlainMessage(String)
+ * @see #sendRichMessage(String)
2021-06-11 14:02:28 +02:00
*/
2023-04-02 20:53:29 +02:00
+ @org.jetbrains.annotations.ApiStatus.Obsolete // Paper
2021-07-22 20:11:56 +02:00
public void sendMessage(@NotNull String... messages);
2021-06-11 14:02:28 +02:00
2023-04-02 20:53:29 +02:00
/**
@@ -27,7 +35,10 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
*
* @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)
2023-04-02 20:53:29 +02:00
+ * @deprecated sender UUID is ignored
2021-06-11 14:02:28 +02:00
*/
2023-04-02 20:53:29 +02:00
+ @Deprecated // Paper
2021-06-11 14:02:28 +02:00
public void sendMessage(@Nullable UUID sender, @NotNull String message);
2023-04-02 20:53:29 +02:00
/**
@@ -35,7 +46,10 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
*
* @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)
2023-04-02 20:53:29 +02:00
+ * @deprecated sender UUID is ignored
2021-06-11 14:02:28 +02:00
*/
2023-04-02 20:53:29 +02:00
+ @Deprecated // Paper
2021-07-22 20:11:56 +02:00
public void sendMessage(@Nullable UUID sender, @NotNull String... messages);
2021-06-11 14:02:28 +02:00
2023-04-02 20:53:29 +02:00
/**
@@ -61,7 +75,9 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
* 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.");
}
2023-04-02 20:53:29 +02:00
@@ -70,7 +86,9 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
* 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.");
}
2023-04-02 20:53:29 +02:00
@@ -80,7 +98,9 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
*
* @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.");
}
2023-04-02 20:53:29 +02:00
@@ -90,7 +110,9 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
*
* @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.");
}
2023-04-02 20:53:29 +02:00
@@ -99,4 +121,39 @@ public interface CommandSender extends Permissible {
2021-06-11 14:02:28 +02:00
@NotNull
Spigot spigot();
// Spigot end
+
+ // Paper start
2021-09-22 20:34:40 +02:00
+ /**
+ * Gets the name of this command sender
+ *
+ * @return Name of the sender
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component name();
2021-09-22 20:34:40 +02:00
+
2021-06-11 14:02:28 +02:00
+ @Override
2023-03-23 17:49:24 +01:00
+ default void sendMessage(final net.kyori.adventure.identity.@NotNull Identity identity, final net.kyori.adventure.text.@NotNull Component message, final net.kyori.adventure.audience.@NotNull MessageType type) {
2022-05-26 21:12:14 +02:00
+ this.sendMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(message));
2021-06-11 14:02:28 +02:00
+ }
2022-06-09 23:34:06 +02:00
+
+ /**
+ * Sends a message with the MiniMessage format to the command sender.
+ * <p>
2023-02-26 17:00:55 +01:00
+ * See <a href="https://docs.advntr.dev/minimessage/">MiniMessage docs</a>
2022-06-09 23:34:06 +02:00
+ * for more information on the format.
+ *
+ * @param message MiniMessage content
+ */
+ default void sendRichMessage(final @NotNull String message) {
+ this.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(message));
+ }
+
+ /**
+ * Sends a plain message to the command sender.
+ *
+ * @param message plain message
+ */
+ default void sendPlainMessage(final @NotNull String message) {
+ this.sendMessage(net.kyori.adventure.text.Component.text(message));
+ }
2021-06-11 14:02:28 +02:00
+ // Paper end
}
2021-10-05 22:52:03 +02:00
diff --git a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
2022-05-26 21:12:14 +02:00
index a542c4bb3c973bbe4b976642feccde6a4d90cb7b..ef870b864c1e36032b54b31f3f85707edc06d764 100644
2021-10-05 22:52:03 +02:00
--- a/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
+++ b/src/main/java/org/bukkit/command/PluginCommandYamlParser.java
@@ -67,7 +67,7 @@ public class PluginCommandYamlParser {
}
if (permissionMessage != null) {
- newCmd.setPermissionMessage(permissionMessage.toString());
2022-05-26 21:12:14 +02:00
+ newCmd.permissionMessage(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(permissionMessage.toString())); // Paper
2021-10-05 22:52:03 +02:00
}
pluginCmds.add(newCmd);
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/command/ProxiedCommandSender.java b/src/main/java/org/bukkit/command/ProxiedCommandSender.java
2023-03-23 17:49:24 +01:00
index fcc34b640265f4dccb46b9f09466ab8e1d96043e..5c813ac024f675951159a59d88d8baa0d49840e9 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/command/ProxiedCommandSender.java
+++ b/src/main/java/org/bukkit/command/ProxiedCommandSender.java
@@ -3,7 +3,7 @@ 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
@@ -21,4 +21,16 @@ public interface ProxiedCommandSender extends CommandSender {
@NotNull
CommandSender getCallee();
+ // Paper start
+ @Override
2023-03-23 17:49:24 +01:00
+ default void sendMessage(final net.kyori.adventure.identity.@NotNull Identity source, final net.kyori.adventure.text.@NotNull Component message, final net.kyori.adventure.audience.@NotNull MessageType type) {
2021-06-11 14:02:28 +02:00
+ 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
}
2023-04-02 20:53:29 +02:00
diff --git a/src/main/java/org/bukkit/conversations/Conversable.java b/src/main/java/org/bukkit/conversations/Conversable.java
index b7d8dd30360a38dbdc7bbce40c8e6ced7261f833..0817f2395c2b18828565435568ce651f5ba99a99 100644
--- a/src/main/java/org/bukkit/conversations/Conversable.java
+++ b/src/main/java/org/bukkit/conversations/Conversable.java
@@ -55,6 +55,7 @@ public interface Conversable {
*
* @param message Message to be displayed
*/
+ @org.jetbrains.annotations.ApiStatus.Obsolete // Paper
public void sendRawMessage(@NotNull String message);
/**
@@ -62,6 +63,8 @@ public interface Conversable {
*
* @param message Message to be displayed
* @param sender The sender of this message
+ * @deprecated sender UUID is ignored
*/
+ @Deprecated // Paper
public void sendRawMessage(@Nullable UUID sender, @NotNull String message);
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
2023-03-23 17:49:24 +01:00
index e2800dc97af5bbb02c555069285a0fa155a9799d..2dc749936df6168073a5bb9f9051d55f8589ac62 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
2022-06-07 19:20:30 +02:00
@@ -299,6 +299,19 @@ public abstract class Enchantment implements Keyed {
2021-06-11 14:02:28 +02:00
* @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.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @param level the level of the enchantment to show
+ * @return the name of the enchantment with {@code level} applied
+ */
2023-03-23 17:49:24 +01:00
+ public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
2021-06-11 14:02:28 +02:00
+ // 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 9566e4306ada5e82dede0f002aa06da12c44996b..4d5f0837bd0e02a30c943d8969fb6b13452322e0 100644
--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
+++ b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
@@ -63,4 +63,11 @@ 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
2023-04-09 02:00:50 +02:00
index f3afe67f0832cb828d25be3654518ff73a80b0e1..598abaa82c634178043a29f6caa6ac5221659d06 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
2023-04-09 02:00:50 +02:00
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
/**
* Represents a base entity in the world
*/
-public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder {
2021-11-13 00:58:46 +01:00
+public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowEntity>, net.kyori.adventure.sound.Sound.Emitter { // Paper
2021-06-11 14:02:28 +02:00
/**
* Gets the entity's current position
2023-04-09 02:00:50 +02:00
@@ -710,4 +710,20 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
2021-06-11 14:02:28 +02:00
@Override
Spigot spigot();
// Spigot end
+
+ // Paper start
2021-09-22 20:34:40 +02:00
+ /**
+ * Gets the entity's display name formatted with their team prefix/suffix and
+ * the entity's default hover/click events.
+ *
+ * @return the team display name
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component teamDisplayName();
2021-09-22 20:34:40 +02:00
+
2021-06-11 14:02:28 +02:00
+ @NotNull
+ @Override
+ default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> 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
2023-07-22 21:38:40 +02:00
index 7591d6de16694467b0fa5ab7ee746f3efdafad82..513e48de04a78268d16c924717d64896a23b437f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
2023-07-04 10:22:56 +02:00
@@ -49,7 +49,41 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
/**
* Represents a player, connected or not
*/
-public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient {
2023-06-12 23:43:39 +02:00
+public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer { // Paper
2021-06-11 14:02:28 +02:00
+
+ // Paper start
+ @Override
2023-03-23 17:49:24 +01:00
+ default net.kyori.adventure.identity.@NotNull Identity identity() {
2021-06-11 14:02:28 +02:00
+ return net.kyori.adventure.identity.Identity.identity(this.getUniqueId());
+ }
+
+ /**
2023-06-12 23:43:39 +02:00
+ * Gets an unmodifiable view of all known currently active bossbars.
+ * <p>
+ * <b>This currently only returns bossbars shown to the player via
+ * {@link #showBossBar(net.kyori.adventure.bossbar.BossBar)} and does not contain bukkit
+ * {@link org.bukkit.boss.BossBar} instances shown to the player.</b>
+ *
+ * @return an unmodifiable view of all known currently active bossbars
+ * @since 4.14.0
+ */
+ @Override
+ @org.jetbrains.annotations.UnmodifiableView @NotNull Iterable<? extends net.kyori.adventure.bossbar.BossBar> activeBossBars();
+
+ /**
2021-06-11 14:02:28 +02:00
+ * Gets the "friendly" name to display of this player.
+ *
+ * @return the display name
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component displayName();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the "friendly" name to display of this player.
+ *
+ * @param displayName the display name to set
+ */
2023-03-23 17:49:24 +01:00
+ void displayName(final net.kyori.adventure.text.@Nullable Component displayName);
2021-06-11 14:02:28 +02:00
+ // Paper end
/**
2022-07-27 20:52:03 +02:00
* {@inheritDoc}
2023-07-04 10:22:56 +02:00
@@ -66,7 +100,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* places defined by plugins.
*
* @return the friendly name
+ * @deprecated in favour of {@link #displayName()}
*/
+ @Deprecated // Paper
@NotNull
public String getDisplayName();
2023-07-04 10:22:56 +02:00
@@ -78,15 +114,50 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* 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.
+ * <p>
+ * If the value is null, the name will be identical to {@link #getName()}.
+ *
+ * @param name new player list name
+ */
2023-03-23 17:49:24 +01:00
+ void playerListName(net.kyori.adventure.text.@Nullable Component name);
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Gets the name that is shown on the in-game player list.
+ *
+ * @return the player list name
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component playerListName();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Gets the currently displayed player list header for this player.
+ *
+ * @return player list header or null
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@Nullable Component playerListHeader();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Gets the currently displayed player list footer for this player.
+ *
+ * @return player list footer or null
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@Nullable Component playerListFooter();
2021-06-11 14:02:28 +02:00
+ // 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();
/**
2023-07-04 10:22:56 +02:00
@@ -95,14 +166,18 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* 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();
2023-07-04 10:22:56 +02:00
@@ -110,7 +185,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* 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();
2023-07-04 10:22:56 +02:00
@@ -118,14 +195,18 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* 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);
/**
2023-07-04 10:22:56 +02:00
@@ -134,7 +215,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
*
* @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);
/**
2023-07-04 10:22:56 +02:00
@@ -172,9 +255,25 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* 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
+ /**
2022-06-01 08:20:12 +02:00
+ * Kicks the player with the default kick message.
2023-03-10 21:18:50 +01:00
+ * @see #kick(net.kyori.adventure.text.Component)
2022-06-01 08:20:12 +02:00
+ */
+ void kick();
+ /**
2021-06-11 14:02:28 +02:00
+ * Kicks player with custom kick message.
+ *
+ * @param message kick message
+ */
2023-03-23 17:49:24 +01:00
+ void kick(final net.kyori.adventure.text.@Nullable Component message);
2021-06-11 14:02:28 +02:00
+ // Paper end
+
/**
2023-07-04 10:22:56 +02:00
* Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will
* update the entry.
2023-07-22 21:38:40 +02:00
@@ -671,6 +770,106 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-11-22 06:21:37 +01:00
*/
2023-03-10 21:18:50 +01:00
public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull Map<EquipmentSlot, ItemStack> items);
2021-06-11 14:02:28 +02:00
2021-11-22 10:35:00 +01:00
+ // Paper start
2021-08-05 21:53:50 +02:00
+ /**
+ * 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)}.
+ * <p>
+ * 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
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2021-08-05 21:53:50 +02:00
+ */
2023-07-22 21:38:40 +02:00
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List<? extends net.kyori.adventure.text.Component> lines) throws IllegalArgumentException {
+ this.sendSignChange(loc, lines, DyeColor.BLACK);
2021-11-22 10:35:00 +01:00
+ }
2021-08-05 21:53:50 +02:00
+
2021-06-11 14:02:28 +02:00
+ /**
+ * 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)}.
+ * <p>
+ * 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
2021-12-22 08:07:17 +01:00
+ * @param dyeColor the color of the sign
2021-06-11 14:02:28 +02:00
+ * @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
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2021-06-11 14:02:28 +02:00
+ */
2023-07-22 21:38:40 +02:00
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List<? extends net.kyori.adventure.text.Component> lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException {
+ this.sendSignChange(loc, lines, dyeColor, false);
+ }
2021-08-05 21:53:50 +02:00
+
+ /**
+ * 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)}.
+ * <p>
+ * 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
2023-03-23 22:57:03 +01:00
+ * @param hasGlowingText whether the text of the sign should glow as if dyed with a glowing ink sac
2021-08-05 21:53:50 +02:00
+ * @throws IllegalArgumentException if location is null
2023-03-23 22:57:03 +01:00
+ * @throws IllegalArgumentException if dyeColor is null
2021-08-05 21:53:50 +02:00
+ * @throws IllegalArgumentException if lines is non-null and has a length less than 4
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2021-08-05 21:53:50 +02:00
+ */
2023-07-22 21:38:40 +02:00
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ default void sendSignChange(@NotNull Location loc, @Nullable java.util.List<? extends net.kyori.adventure.text.Component> lines, boolean hasGlowingText) throws IllegalArgumentException {
+ this.sendSignChange(loc, lines, DyeColor.BLACK, hasGlowingText);
+ }
2021-08-05 21:53:50 +02:00
+
2021-11-22 10:35:00 +01:00
+ /**
+ * 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)}.
+ * <p>
+ * 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
2021-12-22 08:07:17 +01:00
+ * @param dyeColor the color of the sign
2023-03-23 22:57:03 +01:00
+ * @param hasGlowingText whether the text of the sign should glow as if dyed with a glowing ink sac
2021-11-22 10:35:00 +01:00
+ * @throws IllegalArgumentException if location is null
2021-12-22 08:07:17 +01:00
+ * @throws IllegalArgumentException if dyeColor is null
2021-11-22 10:35:00 +01:00
+ * @throws IllegalArgumentException if lines is non-null and has a length less than 4
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2023-03-23 17:49:24 +01:00
+ */
2023-07-22 21:38:40 +02:00
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ void sendSignChange(@NotNull Location loc, @Nullable java.util.List<? extends net.kyori.adventure.text.Component> lines, @NotNull DyeColor dyeColor, boolean hasGlowingText)
+ 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.
2023-07-22 21:38:40 +02:00
@@ -688,7 +887,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2023-03-23 22:57:03 +01:00
* @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
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2023-03-23 22:57:03 +01:00
*/
+ @Deprecated // Paper
public void sendSignChange(@NotNull Location loc, @Nullable String[] lines) throws IllegalArgumentException;
/**
2023-07-22 21:38:40 +02:00
@@ -710,7 +913,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2023-03-23 22:57:03 +01:00
* @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
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException;
/**
2023-07-22 21:38:40 +02:00
@@ -733,7 +940,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-08-05 21:53:50 +02:00
* @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
2023-07-22 21:38:40 +02:00
+ * @deprecated Use {@link #sendBlockUpdate(Location, TileState)} by creating a new virtual
+ * {@link org.bukkit.block.Sign} block state via {@link BlockData#createBlockState()}
+ * (constructed e.g. via {@link Material#createBlockData()})
2021-08-05 21:53:50 +02:00
*/
+ @Deprecated // Paper
public void sendSignChange(@NotNull Location loc, @Nullable String[] lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException;
/**
2023-07-22 21:38:40 +02:00
@@ -1249,6 +1460,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2022-02-23 03:11:52 +01:00
* pack correctly.
* </ul>
*
+ * @deprecated in favour of {@link #setResourcePack(String, byte[], Component)}
* @param url The URL from which the client will download the resource
* pack. The string must contain only US-ASCII characters and should
* be encoded as per RFC 1738.
2023-07-22 21:38:40 +02:00
@@ -1305,8 +1517,57 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2022-02-23 03:11:52 +01:00
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
* long.
2021-12-22 08:07:17 +01:00
*/
2022-02-23 03:11:52 +01:00
+ @Deprecated // Paper
2021-12-22 08:07:17 +01:00
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt);
+ // Paper start
+ /**
+ * Request that the player's client download and switch resource packs.
+ * <p>
+ * The player's client will download the new resource pack asynchronously
+ * in the background, and will automatically switch to it once the
+ * download is complete. If the client has downloaded and cached a
+ * resource pack with the same hash in the past it will not download but
+ * directly apply the cached pack. If the hash is null and the client has
+ * downloaded and cached the same resource pack in the past, it will
+ * perform a file size check against the response content to determine if
+ * the resource pack has changed and needs to be downloaded again. When
+ * this request is sent for the very first time from a given server, the
+ * client will first display a confirmation GUI to the player before
+ * proceeding with the download.
+ * <p>
+ * Notes:
+ * <ul>
+ * <li>Players can disable server resources on their client, in which
+ * case this method will have no affect on them. Use the
+ * {@link PlayerResourcePackStatusEvent} to figure out whether or not
+ * the player loaded the pack!
+ * <li>There is no concept of resetting resource packs back to default
+ * within Minecraft, so players will have to relog to do so or you
+ * have to send an empty pack.
+ * <li>The request is sent with empty string as the hash when the hash is
+ * not provided. This might result in newer versions not loading the
+ * pack correctly.
+ * </ul>
+ *
+ * @param url The URL from which the client will download the resource
+ * pack. The string must contain only US-ASCII characters and should
+ * be encoded as per RFC 1738.
+ * @param hash The sha1 hash sum of the resource pack file which is used
+ * to apply a cached version of the pack directly without downloading
+ * if it is available. Hast to be 20 bytes long!
2023-06-12 23:43:39 +02:00
+ * @param prompt The optional custom prompt message to be shown to client.
+ * @throws IllegalArgumentException Thrown if the URL is null.
+ * @throws IllegalArgumentException Thrown if the URL is too long. The
+ * length restriction is an implementation specific arbitrary value.
+ * @throws IllegalArgumentException Thrown if the hash is not 20 bytes
+ * long.
+ */
+ default void setResourcePack(@NotNull String url, byte @Nullable [] hash, net.kyori.adventure.text.@Nullable Component prompt) {
+ this.setResourcePack(url, hash, prompt, false);
+ }
+ // Paper end
+
/**
* Request that the player's client download and switch resource packs.
* <p>
2023-07-22 21:38:40 +02:00
@@ -1336,6 +1597,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2023-06-12 23:43:39 +02:00
* pack correctly.
* </ul>
*
+ * @deprecated in favour of {@link #setResourcePack(String, byte[], Component, boolean)}
* @param url The URL from which the client will download the resource
* pack. The string must contain only US-ASCII characters and should
* be encoded as per RFC 1738.
2023-07-22 21:38:40 +02:00
@@ -1396,8 +1658,57 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2022-02-23 03:11:52 +01:00
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
* long.
2021-12-22 08:07:17 +01:00
*/
2022-02-23 03:11:52 +01:00
+ @Deprecated // Paper
2021-12-22 08:07:17 +01:00
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force);
2022-02-23 03:11:52 +01:00
+ // Paper start
2021-12-22 08:07:17 +01:00
+ /**
+ * Request that the player's client download and switch resource packs.
+ * <p>
+ * The player's client will download the new resource pack asynchronously
+ * in the background, and will automatically switch to it once the
+ * download is complete. If the client has downloaded and cached a
+ * resource pack with the same hash in the past it will not download but
+ * directly apply the cached pack. If the hash is null and the client has
+ * downloaded and cached the same resource pack in the past, it will
+ * perform a file size check against the response content to determine if
+ * the resource pack has changed and needs to be downloaded again. When
+ * this request is sent for the very first time from a given server, the
+ * client will first display a confirmation GUI to the player before
+ * proceeding with the download.
+ * <p>
+ * Notes:
+ * <ul>
+ * <li>Players can disable server resources on their client, in which
+ * case this method will have no affect on them. Use the
+ * {@link PlayerResourcePackStatusEvent} to figure out whether or not
+ * the player loaded the pack!
+ * <li>There is no concept of resetting resource packs back to default
+ * within Minecraft, so players will have to relog to do so or you
+ * have to send an empty pack.
+ * <li>The request is sent with empty string as the hash when the hash is
+ * not provided. This might result in newer versions not loading the
+ * pack correctly.
+ * </ul>
+ *
+ * @param url The URL from which the client will download the resource
+ * pack. The string must contain only US-ASCII characters and should
+ * be encoded as per RFC 1738.
+ * @param hash The sha1 hash sum of the resource pack file which is used
+ * to apply a cached version of the pack directly without downloading
+ * if it is available. Hast to be 20 bytes long!
+ * @param prompt The optional custom prompt message to be shown to client.
+ * @param force If true, the client will be disconnected from the server
+ * when it declines to use the resource pack.
+ * @throws IllegalArgumentException Thrown if the URL is null.
+ * @throws IllegalArgumentException Thrown if the URL is too long. The
+ * length restriction is an implementation specific arbitrary value.
+ * @throws IllegalArgumentException Thrown if the hash is not 20 bytes
+ * long.
+ */
+ public void setResourcePack(@NotNull String url, byte @Nullable [] hash, net.kyori.adventure.text.@Nullable Component prompt, boolean force);
+ // Paper end
+
/**
* Gets the Scoreboard displayed to this player
*
2023-07-22 21:38:40 +02:00
@@ -1532,7 +1843,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-09-23 23:07:44 +02:00
*
* @param title Title text
* @param subtitle Subtitle text
- * @deprecated API behavior subject to change
+ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} or {@link #sendTitlePart(net.kyori.adventure.title.TitlePart, Object)}
*/
@Deprecated
public void sendTitle(@Nullable String title, @Nullable String subtitle);
2023-07-22 21:38:40 +02:00
@@ -1551,7 +1862,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-09-23 23:07:44 +02:00
* @param fadeIn time in ticks for titles to fade in. Defaults to 10.
* @param stay time in ticks for titles to stay. Defaults to 70.
* @param fadeOut time in ticks for titles to fade out. Defaults to 20.
+ * @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} or {@link #sendTitlePart(net.kyori.adventure.title.TitlePart, Object)}
*/
+ @Deprecated // Paper - Adventure
public void sendTitle(@Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut);
/**
2023-07-22 21:38:40 +02:00
@@ -1778,6 +2091,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
*/
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 estimated ping in milliseconds.
*
2023-07-22 21:38:40 +02:00
@@ -1803,8 +2124,10 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* they wish.
*
* @return the player's locale
+ * @deprecated in favour of {@link #locale()}
*/
@NotNull
+ @Deprecated // Paper
public String getLocale();
/**
2023-07-22 21:38:40 +02:00
@@ -1856,6 +2179,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
*/
2021-11-23 06:49:33 +01:00
public boolean isAllowingServerListings();
2021-06-11 14:02:28 +02:00
+ // Paper start
+ @NotNull
+ @Override
+ default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> 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.displayName())));
+ }
+ // Paper end
+
// Spigot start
public class Spigot extends Entity.Spigot {
2023-07-22 21:38:40 +02:00
@@ -1887,11 +2218,13 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
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.");
2023-07-22 21:38:40 +02:00
@@ -1902,7 +2235,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
*
* @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.");
}
2023-07-22 21:38:40 +02:00
@@ -1912,7 +2247,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
*
* @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.");
}
2023-07-22 21:38:40 +02:00
@@ -1923,7 +2260,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* @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
2023-03-10 21:18:50 +01:00
public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable java.util.UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent component) {
2021-06-11 14:02:28 +02:00
throw new UnsupportedOperationException("Not supported yet.");
}
2023-07-22 21:38:40 +02:00
@@ -1934,7 +2273,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
2021-06-11 14:02:28 +02:00
* @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
2023-03-10 21:18:50 +01:00
public void sendMessage(@NotNull net.md_5.bungee.api.ChatMessageType position, @Nullable java.util.UUID sender, @NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
2021-06-11 14:02:28 +02:00
throw new UnsupportedOperationException("Not supported yet.");
2022-03-04 22:19:57 +01:00
}
2023-03-15 00:52:28 +01:00
diff --git a/src/main/java/org/bukkit/entity/TextDisplay.java b/src/main/java/org/bukkit/entity/TextDisplay.java
2023-05-12 13:10:08 +02:00
index d6d7ada3d3ff9a033ce3f780b104ef3e176f9083..f101ffde9e7b3f6c3ab6f1cffb8d6f4e720634b2 100644
2023-03-15 00:52:28 +01:00
--- a/src/main/java/org/bukkit/entity/TextDisplay.java
+++ b/src/main/java/org/bukkit/entity/TextDisplay.java
@@ -13,17 +13,37 @@ public interface TextDisplay extends Display {
* Gets the displayed text.
*
* @return the displayed text.
+ * @deprecated in favour of {@link #text()}
*/
@Nullable
+ @Deprecated // Paper
String getText();
/**
* Sets the displayed text.
*
* @param text the new text
+ * @deprecated in favour of {@link #text(net.kyori.adventure.text.Component)}
*/
+ @Deprecated // Paper
void setText(@Nullable String text);
+ // Paper start
+ /**
+ * Gets the displayed text.
+ *
+ * @return the displayed text
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component text();
2023-03-15 00:52:28 +01:00
+
+ /**
+ * Sets the displayed text.
+ *
+ * @param text the new text
+ */
2023-03-23 17:49:24 +01:00
+ void text(net.kyori.adventure.text.@Nullable Component text);
2023-03-15 00:52:28 +01:00
+ // Paper end
+
/**
* Gets the maximum line width before wrapping.
*
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java b/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java
index 63c80b4ee1f7adc8a9efc3b607993104b1991f90..91cab8b13d5bba34007f124838b32a1df58c5ac7 100644
--- a/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java
+++ b/src/main/java/org/bukkit/entity/minecart/CommandMinecart.java
@@ -32,7 +32,9 @@ 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
2023-06-01 01:36:57 +02:00
index f4ac033ff8794a61c82a49dc6c3f863f3291455d..d944d67f544494355f03c5bc9afd8ea7726e6412 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/block/SignChangeEvent.java
+++ b/src/main/java/org/bukkit/event/block/SignChangeEvent.java
2023-06-01 01:36:57 +02:00
@@ -17,18 +17,38 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
2021-06-11 14:02:28 +02:00
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private final Player player;
- private final String[] lines;
2023-06-01 01:36:57 +02:00
+ private final java.util.List<net.kyori.adventure.text.Component> adventure$lines; // Paper
private final Side side;
2021-06-11 14:02:28 +02:00
2023-06-01 01:36:57 +02:00
+ // Paper start
+ public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List<net.kyori.adventure.text.Component> adventure$lines, @NotNull Side side) {
2021-06-11 14:02:28 +02:00
+ super(theBlock);
+ this.player = player;
+ this.adventure$lines = adventure$lines;
2023-06-01 01:36:57 +02:00
+ this.side = side;
2021-06-11 14:02:28 +02:00
+ }
+
2023-06-01 01:36:57 +02:00
+ @Deprecated
+ public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List<net.kyori.adventure.text.Component> adventure$lines) {
+ this(theBlock, player, adventure$lines, Side.FRONT);
+ }
+ // Paper end
+
@Deprecated
2021-06-11 14:02:28 +02:00
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines) {
2023-06-01 01:36:57 +02:00
this(theBlock, thePlayer, theLines, Side.FRONT);
}
+ @Deprecated // Paper
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines, @NotNull Side side) {
2021-06-11 14:02:28 +02:00
super(theBlock);
this.player = thePlayer;
- this.lines = theLines;
+ // Paper start
+ this.adventure$lines = new java.util.ArrayList<>();
+ for (String theLine : theLines) {
2022-05-26 21:12:14 +02:00
+ this.adventure$lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(theLine));
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
2023-06-01 01:36:57 +02:00
this.side = side;
2021-06-11 14:02:28 +02:00
}
2023-06-01 01:36:57 +02:00
@@ -42,14 +62,52 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
2021-06-11 14:02:28 +02:00
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
+ */
2023-03-23 22:57:03 +01:00
+ public @NotNull java.util.List<net.kyori.adventure.text.Component> lines() {
+ return this.adventure$lines;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * 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}
+ */
2023-03-23 22:57:03 +01:00
+ public net.kyori.adventure.text.@Nullable Component line(int index) throws IndexOutOfBoundsException {
+ return this.adventure$lines.get(index);
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * 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}
+ */
2023-03-23 22:57:03 +01:00
+ public void line(int index, net.kyori.adventure.text.@Nullable 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
}
/**
2023-06-01 01:36:57 +02:00
@@ -60,10 +118,12 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
2023-03-23 22:57:03 +01:00
* 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
}
/**
2023-06-01 01:36:57 +02:00
@@ -73,9 +133,11 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
2023-03-23 22:57:03 +01:00
* @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
2021-06-11 14:02:28 +02:00
public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException {
- lines[index] = line;
2022-05-26 21:12:14 +02:00
+ adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper
2021-06-11 14:02:28 +02:00
}
2023-06-01 01:36:57 +02:00
/**
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
2023-03-23 17:49:24 +01:00
index 3c2ea8fec3a748cab7f5ad9100d12bd8213ec6c9..a803bfea5400b3578bb4cf3261874e873b6467d9 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -12,25 +12,48 @@ import org.jetbrains.annotations.Nullable;
public class PlayerDeathEvent extends EntityDeathEvent {
private int newExp = 0;
private String deathMessage = "";
+ private net.kyori.adventure.text.Component adventure$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<ItemStack> drops, final int droppedExp, @Nullable final net.kyori.adventure.text.Component adventure$deathMessage) {
+ this(player, drops, droppedExp, 0, adventure$deathMessage, null);
+ }
2023-03-23 22:57:03 +01:00
+
2021-06-11 14:02:28 +02:00
+ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, @Nullable final net.kyori.adventure.text.Component adventure$deathMessage, @Nullable String deathMessage) {
+ this(player, drops, droppedExp, newExp, 0, 0, adventure$deathMessage, deathMessage);
+ }
2023-03-23 22:57:03 +01:00
2021-06-11 14:02:28 +02:00
+ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final net.kyori.adventure.text.Component adventure$deathMessage, @Nullable String deathMessage) {
+ super(player, drops, droppedExp);
+ this.newExp = newExp;
+ this.newTotalExp = newTotalExp;
+ this.newLevel = newLevel;
+ this.deathMessage = deathMessage;
+ this.adventure$deathMessage = adventure$deathMessage;
+ }
+ // Paper end
+
+ @Deprecated // Paper
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> 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<ItemStack> 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<ItemStack> 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;
2022-12-13 13:24:59 +01:00
+ this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : null; // Paper
2021-06-11 14:02:28 +02:00
}
@NotNull
2023-03-23 22:57:03 +01:00
@@ -39,25 +62,55 @@ public class PlayerDeathEvent extends EntityDeathEvent {
2021-06-11 14:02:28 +02:00
return (Player) entity;
}
+ // Paper start
2023-03-23 22:57:03 +01:00
+ /**
+ * Set the death message that will appear to everyone on the server.
+ *
+ * @param deathMessage Message to appear to other players on the server.
+ */
2023-03-23 17:49:24 +01:00
+ public void deathMessage(net.kyori.adventure.text.@Nullable Component deathMessage) {
2021-06-11 14:02:28 +02:00
+ this.deathMessage = null;
+ this.adventure$deathMessage = deathMessage;
2023-03-23 22:57:03 +01:00
+ }
+
+ /**
+ * Get the death message that will appear to everyone on the server.
+ *
+ * @return Message to appear to other players on the server.
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@Nullable Component deathMessage() {
2021-06-11 14:02:28 +02:00
+ return this.adventure$deathMessage;
+ }
+ // Paper end
+
2023-03-23 22:57:03 +01:00
/**
* Set the death message that will appear to everyone on the server.
*
* @param deathMessage Message to appear to other players on the server.
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #deathMessage(net.kyori.adventure.text.Component)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
public void setDeathMessage(@Nullable String deathMessage) {
this.deathMessage = deathMessage;
2022-12-13 13:24:59 +01:00
+ this.adventure$deathMessage = deathMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(deathMessage) : null; // Paper
2021-06-11 14:02:28 +02:00
}
2023-03-23 22:57:03 +01:00
/**
* Get the death message that will appear to everyone on the server.
*
* @return Message to appear to other players on the server.
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #deathMessage()}
2023-03-23 22:57:03 +01:00
*/
@Nullable
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
public String getDeathMessage() {
- return deathMessage;
2021-06-11 14:02:28 +02:00
+ return this.deathMessage != null ? this.deathMessage : (this.adventure$deathMessage != null ? getDeathMessageString(this.adventure$deathMessage) : null); // Paper
2023-03-23 22:57:03 +01:00
}
-
2021-06-11 14:02:28 +02:00
+ // Paper start //TODO: add translation API to drop String deathMessage in favor of just Adventure
+ private static String getDeathMessageString(net.kyori.adventure.text.Component component) {
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(component);
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
/**
* Gets how much EXP the Player should have at respawn.
* <p>
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java
2023-07-04 10:22:56 +02:00
index ec9f58ea221bfcde706d2454483888c54d44023a..19ba2d948ad83baab2a14ae6f7b3ce43c3d4971f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/inventory/InventoryType.java
+++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java
2023-07-04 10:22:56 +02:00
@@ -155,6 +155,18 @@ public enum InventoryType {
2021-06-11 14:02:28 +02:00
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
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component defaultTitle() {
2021-06-11 14:02:28 +02:00
+ return defaultTitleComponent;
+ }
+ // Paper end
private InventoryType(int defaultSize, /*@NotNull*/ String defaultTitle) {
this(defaultSize, defaultTitle, true);
}
2023-07-04 10:22:56 +02:00
@@ -163,6 +175,7 @@ public enum InventoryType {
2021-06-11 14:02:28 +02:00
size = defaultSize;
title = defaultTitle;
this.isCreatable = isCreatable;
+ this.defaultTitleComponent = net.kyori.adventure.text.Component.text(defaultTitle); // Paper - Adventure
}
public int getDefaultSize() {
2023-07-04 10:22:56 +02:00
@@ -170,6 +183,7 @@ public enum InventoryType {
2021-06-11 14:02:28 +02:00
}
@NotNull
+ @Deprecated // Paper
public String getDefaultTitle() {
return title;
}
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java
index 9c68c3f2d61500479f48b80264f625aaae2f3204..399afcd19fcb6acd24857ed6ab48cf0d105a01a3 100644
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java
@@ -22,7 +22,11 @@ import org.jetbrains.annotations.NotNull;
* <p>
* Care should be taken to check {@link #isAsynchronous()} and treat the event
* appropriately.
+ *
+ * @deprecated use {@link io.papermc.paper.event.player.AsyncChatEvent} instead
*/
+@Deprecated // Paper
+@org.bukkit.Warning(value = false, reason = "Don't nag on old event yet") // Paper
public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
2022-05-26 21:12:14 +02:00
index 9866c07c999f46cb585709804aaad710c3031d5a..c7c45e2de8cca1bf8b8e12752e08db62403efa6a 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
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;
@@ -27,7 +27,7 @@ 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;
@@ -79,6 +79,7 @@ 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
@@ -86,7 +87,7 @@ public class AsyncPlayerPreLoginEvent extends Event {
* @return Current kick message
*/
@NotNull
- public String getKickMessage() {
+ public net.kyori.adventure.text.Component kickMessage() {
return message;
}
2023-03-23 22:57:03 +01:00
@@ -95,16 +96,66 @@ public class AsyncPlayerPreLoginEvent extends Event {
2021-06-11 14:02:28 +02:00
*
* @param message New kick message
*/
- public void setKickMessage(@NotNull final String message) {
+ public void kickMessage(@NotNull final net.kyori.adventure.text.Component message) {
2023-03-23 22:57:03 +01:00
+ 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
+ */
2021-06-11 14:02:28 +02:00
+ public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) {
2023-03-23 22:57:03 +01:00
+ this.result = result;
2021-06-11 14:02:28 +02:00
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() {
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * 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) {
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2021-06-11 14:02:28 +02:00
+ }
+
2023-03-23 22:57:03 +01:00
/**
* Allows the player to log in
*/
public void allow() {
result = Result.ALLOWED;
- message = "";
2021-06-11 14:02:28 +02:00
+ message = net.kyori.adventure.text.Component.empty(); // Paper
2023-03-23 22:57:03 +01:00
}
/**
@@ -112,10 +163,12 @@ public class AsyncPlayerPreLoginEvent extends Event {
*
* @param result New result for disallowing the player
* @param message Kick message to display to the user
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #disallow(org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result, net.kyori.adventure.text.Component)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result;
- this.message = message;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2023-03-23 22:57:03 +01:00
}
2021-06-11 14:02:28 +02:00
/**
@@ -130,7 +183,7 @@ 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;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2021-06-11 14:02:28 +02:00
}
/**
diff --git a/src/main/java/org/bukkit/event/player/PlayerChatEvent.java b/src/main/java/org/bukkit/event/player/PlayerChatEvent.java
2022-06-07 19:20:30 +02:00
index a1f4261eaa1497554f1e51d1d5a072c2eb9226df..3a1da86e3dbf18c6e1040086c1df4b8976bc2b9d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerChatEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerChatEvent.java
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
* Listening to this event forces chat to wait for the main thread which
* causes delays for chat. {@link AsyncPlayerChatEvent} is the encouraged
* alternative for thread safe implementations.
+ * @deprecated use {@link io.papermc.paper.event.player.ChatEvent} instead
*/
@Deprecated
@Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.")
diff --git a/src/main/java/org/bukkit/event/player/PlayerEvent.java b/src/main/java/org/bukkit/event/player/PlayerEvent.java
index 793b661b6d2d05de3d7f4fc26a4c018a2af58e62..f6d3b817de3001f04ea4554c7c39a1290af3fd6d 100644
--- a/src/main/java/org/bukkit/event/player/PlayerEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerEvent.java
@@ -14,7 +14,7 @@ public abstract class PlayerEvent extends Event {
player = who;
}
- PlayerEvent(@NotNull final Player who, boolean async) {
+ public PlayerEvent(@NotNull final Player who, boolean async) { // Paper - public
super(async);
player = who;
diff --git a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
2023-03-23 17:49:24 +01:00
index d06684aba7688ce06777dbd837a46856a9d7767f..3e1e7cd0415509da4dd887db59efa55011b1dab4 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java
2023-03-23 22:57:03 +01:00
@@ -10,30 +10,60 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
*/
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) {
2023-03-23 22:57:03 +01:00
+ super(playerJoined);
+ this.joinMessage = joinMessage;
+ }
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper end
2023-03-23 22:57:03 +01:00
public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) {
super(playerJoined);
2022-05-26 21:12:14 +02:00
+ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper end
2021-06-11 14:02:28 +02:00
+ }
+
+ // Paper start
2023-03-23 17:49:24 +01:00
+ /**
+ * Gets the join message to send to all online players
+ *
+ * @return string join message. Can be null
+ */
2023-03-23 22:57:03 +01:00
+ public net.kyori.adventure.text.@Nullable Component joinMessage() {
+ return this.joinMessage;
2023-03-23 17:49:24 +01:00
+ }
+
+ /**
+ * Sets the join message to send to all online players
+ *
+ * @param joinMessage join message. If null, no message will be sent
+ */
2023-03-23 22:57:03 +01:00
+ public void joinMessage(net.kyori.adventure.text.@Nullable 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)}
*/
2023-03-23 17:49:24 +01:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
public void setJoinMessage(@Nullable String joinMessage) {
- this.joinMessage = joinMessage;
2022-05-26 21:12:14 +02:00
+ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper
2023-03-23 22:57:03 +01:00
}
2021-06-11 14:02:28 +02:00
@NotNull
diff --git a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
2023-03-23 17:49:24 +01:00
index 2f6ca42330675733b2b4132cbb66e433788d05d5..997b06c19a5277656521e0e298f2958c209f1da1 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerKickEvent.java
@@ -10,35 +10,84 @@ import org.jetbrains.annotations.NotNull;
*/
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
2022-06-05 10:43:06 +02:00
private boolean cancel;
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) {
+ super(playerKicked);
2022-05-26 21:12:14 +02:00
+ 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
2021-06-11 14:02:28 +02:00
+ 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
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component leaveMessage() {
2021-06-11 14:02:28 +02:00
+ return this.leaveMessage;
+ }
+
+ /**
+ * Sets the leave message send to all online players
+ *
+ * @param leaveMessage leave message
+ */
2023-03-23 17:49:24 +01:00
+ public void leaveMessage(net.kyori.adventure.text.@NotNull Component leaveMessage) {
2021-06-11 14:02:28 +02:00
+ this.leaveMessage = leaveMessage;
+ }
+
/**
* Gets the reason why the player is getting kicked
*
* @return string kick reason
*/
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component reason() {
2021-06-11 14:02:28 +02:00
+ return this.kickReason;
+ }
+
+ /**
+ * Sets the reason why the player is getting kicked
+ *
+ * @param kickReason kick reason
+ */
2023-03-23 17:49:24 +01:00
+ public void reason(net.kyori.adventure.text.@NotNull Component kickReason) {
2021-06-11 14:02:28 +02:00
+ 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;
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.kickReason); // Paper
2021-06-11 14:02:28 +02:00
}
/**
* 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;
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.leaveMessage); // Paper
2021-06-11 14:02:28 +02:00
}
@Override
@@ -55,18 +104,22 @@ 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;
2022-05-26 21:12:14 +02:00
+ this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper
2021-06-11 14:02:28 +02:00
}
/**
* 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;
2022-05-26 21:12:14 +02:00
+ this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper
2021-06-11 14:02:28 +02:00
}
@NotNull
diff --git a/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java b/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java
2023-04-16 03:13:59 +02:00
index 36b436e145a7215682b692a87ab894df25752c1d..c5e8bffef736365881953161ff812c98adf93a80 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java
2021-07-07 08:52:40 +02:00
@@ -12,17 +12,31 @@ public class PlayerLocaleChangeEvent extends PlayerEvent {
2021-06-11 14:02:28 +02:00
private static final HandlerList handlers = new HandlerList();
//
private final String locale;
+ // Paper start
+ private final java.util.Locale adventure$locale;
+ /**
2023-04-16 03:13:59 +02:00
+ * @see Player#locale()
2021-06-11 14:02:28 +02:00
+ *
+ * @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
}
/**
* @return the player's new locale
2021-07-07 08:52:40 +02:00
* @see Player#getLocale()
2021-06-11 14:02:28 +02:00
+ * @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
2023-03-23 17:49:24 +01:00
index 084ca8cfcb7381bfa4fa6280748cf9b81210a9c1..62fb782baad5c80a3daaa557c0faa674c58a98cf 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
@@ -17,7 +17,7 @@ public class PlayerLoginEvent extends PlayerEvent {
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
/**
2023-03-23 22:57:03 +01:00
@@ -53,12 +53,52 @@ public class PlayerLoginEvent extends PlayerEvent {
2021-06-11 14:02:28 +02:00
* @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
2023-03-23 22:57:03 +01:00
this(player, hostname, address, realAddress); // Spigot
this.result = result;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2021-06-11 14:02:28 +02:00
+ }
+
+ // 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
2023-03-23 22:57:03 +01:00
+ this(player, hostname, address, realAddress); // Spigot
+ this.result = result;
+ this.message = message;
+ }
+
2021-06-11 14:02:28 +02:00
+ /**
+ * Gets the current kick message that will be used if getResult() !=
+ * Result.ALLOWED
+ *
+ * @return Current kick message
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component kickMessage() {
2021-06-11 14:02:28 +02:00
+ return this.message;
+ }
+
+ /**
+ * Sets the kick message to display if getResult() != Result.ALLOWED
+ *
+ * @param message New kick message
+ */
2023-03-23 17:49:24 +01:00
+ public void kickMessage(net.kyori.adventure.text.@NotNull Component message) {
2023-03-23 22:57:03 +01:00
this.message = message;
}
2021-06-11 14:02:28 +02:00
+ // Paper end
2023-03-23 22:57:03 +01:00
2021-06-11 14:02:28 +02:00
// Spigot start
/**
@@ -96,19 +136,23 @@ 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;
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
2021-06-11 14:02:28 +02:00
}
/**
* 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;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2021-06-11 14:02:28 +02:00
}
/**
@@ -127,7 +171,7 @@ public class PlayerLoginEvent extends PlayerEvent {
*/
public void allow() {
result = Result.ALLOWED;
- message = "";
+ message = net.kyori.adventure.text.Component.empty(); // Paper
}
/**
@@ -135,8 +179,21 @@ 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;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message);
2021-06-11 14:02:28 +02:00
+ }
+ /**
+ * 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
2022-05-26 21:12:14 +02:00
index fb066251f793ec3b41bfc075b9478901b15ee549..6800132c6288b4588fd02b08d26f016c38f27129 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull;
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;
@@ -31,7 +31,7 @@ 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;
@@ -56,6 +56,7 @@ public class PlayerPreLoginEvent extends Event {
this.result = result;
}
+ // Paper start
/**
* Gets the current kick message that will be used if getResult() !=
* Result.ALLOWED
@@ -63,7 +64,7 @@ public class PlayerPreLoginEvent extends Event {
* @return Current kick message
*/
@NotNull
- public String getKickMessage() {
+ public net.kyori.adventure.text.Component kickMessage() {
return message;
}
2023-03-23 22:57:03 +01:00
@@ -72,16 +73,51 @@ public class PlayerPreLoginEvent extends Event {
2021-06-11 14:02:28 +02:00
*
* @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;
}
2023-03-23 22:57:03 +01:00
+ /**
+ * 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
+ */
2021-06-11 14:02:28 +02:00
+ public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) {
2023-03-23 22:57:03 +01:00
+ this.result = result;
+ this.message = message;
+ }
2021-06-11 14:02:28 +02:00
+ // 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() {
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * 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) {
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2021-06-11 14:02:28 +02:00
+ }
+
2023-03-23 22:57:03 +01:00
/**
* Allows the player to log in
*/
public void allow() {
result = Result.ALLOWED;
- message = "";
2021-06-11 14:02:28 +02:00
+ message = net.kyori.adventure.text.Component.empty(); // Paper
2023-03-23 22:57:03 +01:00
}
/**
@@ -89,10 +125,12 @@ public class PlayerPreLoginEvent extends Event {
*
* @param result New result for disallowing the player
* @param message Kick message to display to the user
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #disallow(org.bukkit.event.player.PlayerPreLoginEvent.Result, net.kyori.adventure.text.Component)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
public void disallow(@NotNull final Result result, @NotNull final String message) {
this.result = result;
- this.message = message;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2023-03-23 22:57:03 +01:00
}
2021-06-11 14:02:28 +02:00
/**
diff --git a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
2023-03-23 17:49:24 +01:00
index d70c25f404e994766a9ebce89a917c8d0719777c..14b27eaaf744736b3e56bb1383481df98a218c43 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java
2023-03-23 22:57:03 +01:00
@@ -10,30 +10,59 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
*/
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) {
2023-03-23 22:57:03 +01:00
super(who);
2022-05-26 21:12:14 +02:00
+ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
2021-06-11 14:02:28 +02:00
+ }
+ // Paper start
+ public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) {
2023-03-23 22:57:03 +01:00
+ super(who);
+ this.quitMessage = quitMessage;
+ }
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Gets the quit message to send to all online players
+ *
+ * @return string quit message
+ */
2023-03-23 22:57:03 +01:00
+ public net.kyori.adventure.text.@Nullable Component quitMessage() {
+ return quitMessage;
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Sets the quit message to send to all online players
+ *
+ * @param quitMessage quit message
2023-03-23 22:57:03 +01:00
+ */
+ public void quitMessage(net.kyori.adventure.text.@Nullable 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
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #quitMessage(net.kyori.adventure.text.Component)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
public void setQuitMessage(@Nullable String quitMessage) {
- this.quitMessage = quitMessage;
2022-05-26 21:12:14 +02:00
+ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
2023-03-23 22:57:03 +01:00
}
2021-06-11 14:02:28 +02:00
@NotNull
diff --git a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java
2023-04-16 03:13:59 +02:00
index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..25c0fe98489d903fdf77cbdd181c95593bd7f727 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java
+++ b/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java
2023-04-16 03:13:59 +02:00
@@ -9,16 +9,16 @@ import org.jetbrains.annotations.NotNull;
/**
* Event triggered for server broadcast messages such as from
- * {@link org.bukkit.Server#broadcast(String, String)}.
+ * {@link org.bukkit.Server#broadcast(net.kyori.adventure.text.Component)} (String, String)}.
*
- * <b>This event behaves similarly to {@link AsyncPlayerChatEvent} in that it
+ * <b>This event behaves similarly to {@link io.papermc.paper.event.player.AsyncChatEvent} in that it
* should be async if fired from an async thread. Please see that event for
* further information.</b>
*/
2021-06-11 14:02:28 +02:00
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<CommandSender> recipients;
private boolean cancelled = false;
@@ -27,29 +27,66 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable {
this(false, message, recipients);
}
+ @Deprecated // Paper
public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set<CommandSender> recipients) {
+ // Paper start
+ super(isAsync);
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message);
2021-06-11 14:02:28 +02:00
+ this.recipients = recipients;
+ }
+
+ @Deprecated
2023-03-23 17:49:24 +01:00
+ public BroadcastMessageEvent(net.kyori.adventure.text.@NotNull Component message, @NotNull Set<CommandSender> recipients) {
2021-06-11 14:02:28 +02:00
+ this(false, message, recipients);
+ }
+
2023-03-23 17:49:24 +01:00
+ public BroadcastMessageEvent(boolean isAsync, net.kyori.adventure.text.@NotNull Component message, @NotNull Set<CommandSender> recipients) {
2021-06-11 14:02:28 +02:00
+ // Paper end
super(isAsync);
this.message = message;
this.recipients = recipients;
}
+ // Paper start
+ /**
+ * Get the broadcast message.
+ *
+ * @return Message to broadcast
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component message() {
2021-06-11 14:02:28 +02:00
+ return this.message;
+ }
+
+ /**
+ * Set the broadcast message.
+ *
+ * @param message New message to broadcast
+ */
2023-03-23 17:49:24 +01:00
+ public void message(net.kyori.adventure.text.@NotNull Component message) {
2021-06-11 14:02:28 +02:00
+ 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;
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper
2021-06-11 14:02:28 +02:00
}
/**
* 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;
2022-05-26 21:12:14 +02:00
+ this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper
2021-06-11 14:02:28 +02:00
}
/**
diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
2023-03-23 17:49:24 +01:00
index 5adbe0514129abf3cfbc4b29a213f522359fe2e1..72ebc29db42d08d1d0361dba462fc8a573fbf918 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
+++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
2022-12-07 17:46:46 +01:00
@@ -22,7 +22,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
private static final HandlerList handlers = new HandlerList();
2022-10-31 03:44:25 +01:00
private final String hostname;
2021-06-11 14:02:28 +02:00
private final InetAddress address;
- private String motd;
+ private net.kyori.adventure.text.Component motd; // Paper
private final int numPlayers;
private int maxPlayers;
2022-12-07 17:46:46 +01:00
@@ -31,7 +31,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
2022-06-07 19:20:30 +02:00
Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
2022-10-31 03:44:25 +01:00
this.hostname = hostname;
2021-06-11 14:02:28 +02:00
this.address = address;
- this.motd = motd;
2022-05-26 21:12:14 +02:00
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
2021-06-11 14:02:28 +02:00
this.numPlayers = numPlayers;
this.maxPlayers = maxPlayers;
2022-12-07 17:46:46 +01:00
}
@@ -45,15 +45,80 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
* @param address the address of the pinger
2021-06-11 14:02:28 +02:00
* @param motd the message of the day
* @param maxPlayers the max number of players
2022-12-07 17:46:46 +01:00
+ * @deprecated in favour of {@link #ServerListPingEvent(String, java.net.InetAddress, net.kyori.adventure.text.Component, int)}
2021-06-11 14:02:28 +02:00
*/
+ @Deprecated // Paper
2023-03-23 17:49:24 +01:00
protected ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) {
super(true);
2023-03-23 22:57:03 +01:00
this.numPlayers = MAGIC_PLAYER_COUNT;
this.hostname = hostname;
this.address = address;
2022-05-26 21:12:14 +02:00
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
2021-06-11 14:02:28 +02:00
+ this.maxPlayers = maxPlayers;
+ }
+ // Paper start
2022-10-31 03:44:25 +01:00
+ @Deprecated
2022-12-07 17:46:46 +01:00
+ public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int numPlayers, final int maxPlayers) {
+ this("", address, motd, numPlayers, maxPlayers);
2022-10-31 03:44:25 +01:00
+ }
2022-12-07 17:46:46 +01:00
+ public ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int numPlayers, final int maxPlayers) {
2021-06-11 14:02:28 +02:00
+ super(true);
2022-06-07 22:31:10 +02:00
+ Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online (%s)", numPlayers);
2022-10-31 03:44:25 +01:00
+ this.hostname = hostname;
2021-06-11 14:02:28 +02:00
+ this.address = address;
2023-03-23 22:57:03 +01:00
this.motd = motd;
2021-06-11 14:02:28 +02:00
+ this.numPlayers = numPlayers;
2023-03-23 22:57:03 +01:00
this.maxPlayers = maxPlayers;
}
2021-06-11 14:02:28 +02:00
+ /**
+ * 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
2022-12-07 17:46:46 +01:00
+ * @deprecated in favour of {@link #ServerListPingEvent(String, java.net.InetAddress, net.kyori.adventure.text.Component, int)}
2021-06-11 14:02:28 +02:00
+ */
2022-10-31 03:44:25 +01:00
+ @Deprecated
2022-12-07 17:46:46 +01:00
+ protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int maxPlayers) {
+ this("", address, motd, maxPlayers);
2022-10-31 03:44:25 +01:00
+ }
+
+ /**
+ * This constructor is intended for implementations that provide the
+ * {@link #iterator()} method, thus provided the {@link #getNumPlayers()}
+ * count.
+ *
+ * @param hostname The hostname that was used to connect to the server
+ * @param address the address of the pinger
+ * @param motd the message of the day
+ * @param maxPlayers the max number of players
+ */
2023-03-23 17:49:24 +01:00
+ protected ServerListPingEvent(final @NotNull String hostname, final @NotNull InetAddress address, final net.kyori.adventure.text.@NotNull Component motd, final int maxPlayers) {
2023-03-23 22:57:03 +01:00
+ this.numPlayers = MAGIC_PLAYER_COUNT;
+ this.hostname = hostname;
+ this.address = address;
+ this.motd = motd;
+ this.maxPlayers = maxPlayers;
+ }
2021-06-11 14:02:28 +02:00
+ /**
+ * Get the message of the day message.
+ *
+ * @return the message of the day
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component motd() {
2021-06-11 14:02:28 +02:00
+ return motd;
+ }
+ /**
+ * Change the message of the day message.
+ *
+ * @param motd the message of the day
+ */
2023-03-23 17:49:24 +01:00
+ public void motd(net.kyori.adventure.text.@NotNull Component motd) {
2021-06-11 14:02:28 +02:00
+ this.motd = motd;
+ }
+ // Paper end
/**
2022-10-31 03:44:25 +01:00
* Gets the hostname that the player used to connect to the server, or
2022-12-07 17:46:46 +01:00
@@ -80,19 +145,23 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
2021-06-11 14:02:28 +02:00
* 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;
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.motd); // Paper
2021-06-11 14:02:28 +02:00
}
/**
* 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;
2022-05-26 21:12:14 +02:00
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
2021-06-11 14:02:28 +02:00
}
/**
diff --git a/src/main/java/org/bukkit/inventory/InventoryView.java b/src/main/java/org/bukkit/inventory/InventoryView.java
2023-05-12 13:10:08 +02:00
index e12996492c1558fed9fab30de9f8018e0ed7fac3..002acfbdce1db10f7ba1b6a013e678f504ac6e69 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/InventoryView.java
+++ b/src/main/java/org/bukkit/inventory/InventoryView.java
2023-05-12 13:10:08 +02:00
@@ -447,12 +447,26 @@ public abstract class InventoryView {
2021-06-11 14:02:28 +02:00
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() {
2022-05-26 21:12:14 +02:00
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.getTitle());
2021-06-11 14:02:28 +02:00
+ }
+ // 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();
2023-05-12 13:10:08 +02:00
/**
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
2022-04-16 10:29:50 +02:00
index f89d71b77d1200314df6ca23614d5ca6fb15ceb3..af4a7ce37eb10bab06eadb6583c7894b3ec55ae6 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
2022-04-16 10:29:50 +02:00
@@ -159,4 +159,24 @@ public interface ItemFactory {
2021-06-11 14:02:28 +02:00
@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<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op);
+
+ /**
+ * Get the formatted display name of the {@link ItemStack}.
+ *
+ * @param itemStack the {@link ItemStack}
+ * @return display name of the {@link ItemStack}
+ */
+ @NotNull
+ net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack);
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
2023-03-23 17:49:24 +01:00
index d80b0a52968920b990a75cff85e436a16d782500..9d327f0832c40d4a8d212346284274f6cf78834f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
2023-02-15 23:10:14 +01:00
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
* use this class to encapsulate Materials for which {@link Material#isItem()}
* returns false.</b>
*/
2023-02-15 23:10:14 +01:00
-public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable {
+public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable, net.kyori.adventure.text.event.HoverEventSource<net.kyori.adventure.text.event.HoverEvent.ShowItem> { // Paper
2021-06-11 14:02:28 +02:00
private Material type = Material.AIR;
private int amount = 0;
private MaterialData data = null;
2023-02-15 23:10:14 +01:00
@@ -602,4 +602,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
public String getTranslationKey() {
return Bukkit.getUnsafe().getTranslationKey(this);
2021-06-11 14:02:28 +02:00
}
+
+ // Paper start
+ @NotNull
+ @Override
+ public net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowItem> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowItem> op) {
+ return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op);
+ }
+
+ /**
+ * Get the formatted display name of the {@link ItemStack}.
+ *
+ * @return display name of the {@link ItemStack}
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@NotNull Component displayName() {
2021-06-11 14:02:28 +02:00
+ return Bukkit.getServer().getItemFactory().displayName(this);
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/inventory/meta/BookMeta.java b/src/main/java/org/bukkit/inventory/meta/BookMeta.java
2023-03-23 17:49:24 +01:00
index 94852d50e88d0594b84b581cd627174043629995..be7c2cfc757e4dd15927be850739d401958fb227 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/meta/BookMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/BookMeta.java
2022-02-23 03:11:52 +01:00
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
2021-06-11 14:02:28 +02:00
* 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
2023-03-23 22:57:03 +01:00
@@ -119,6 +119,109 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
*/
boolean hasPages();
+ // Paper start
2023-03-23 22:57:03 +01:00
+ /**
2021-06-11 14:02:28 +02:00
+ * Gets the title of the book.
+ * <p>
+ * Plugins should check that hasTitle() returns true before calling this
+ * method.
+ *
+ * @return the title of the book
+ */
+ @Override
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@Nullable Component title();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the title of the book.
+ * <p>
+ * Limited to 32 characters. Removes title when given null.
+ *
+ * @param title the title to set
+ * @return the same {@link BookMeta} instance
+ */
2023-03-23 17:49:24 +01:00
+ @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false)
2021-06-11 14:02:28 +02:00
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMeta title(net.kyori.adventure.text.@Nullable Component title);
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Gets the author of the book.
+ * <p>
+ * Plugins should check that hasAuthor() returns true before calling this
+ * method.
+ *
+ * @return the author of the book
+ */
+ @Override
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@Nullable Component author();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the author of the book. Removes author when given null.
+ *
+ * @param author the author to set
+ * @return the same {@link BookMeta} instance
+ */
2023-03-23 17:49:24 +01:00
+ @org.jetbrains.annotations.Contract(value = "_ -> this", pure = false)
2021-06-11 14:02:28 +02:00
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMeta author(net.kyori.adventure.text.@Nullable Component author);
2022-02-23 03:11:52 +01:00
+
2021-06-11 14:02:28 +02:00
+ /**
+ * Gets the specified page in the book. The page must exist.
2023-03-23 22:57:03 +01:00
+ * <p>
+ * Pages are 1-indexed.
+ *
+ * @param page the page number to get, in range [1, getPageCount()]
+ * @return the page from the book
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component page(int page);
2023-03-23 22:57:03 +01:00
+
+ /**
+ * Sets the specified page in the book. Pages of the book must be
+ * contiguous.
+ * <p>
+ * The data can be up to 256 characters in length, additional characters
+ * are truncated.
+ * <p>
+ * Pages are 1-indexed.
+ *
+ * @param page the page number to set, in range [1, getPageCount()]
+ * @param data the data to set for that page
+ */
2023-03-23 17:49:24 +01:00
+ void page(int page, net.kyori.adventure.text.@NotNull Component data);
2023-03-23 22:57:03 +01:00
+
+ /**
+ * 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
+ */
2023-03-23 17:49:24 +01:00
+ void addPages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages);
2021-06-11 14:02:28 +02:00
+
+ interface BookMetaBuilder extends Builder {
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMetaBuilder title(net.kyori.adventure.text.@Nullable Component title);
2021-06-11 14:02:28 +02:00
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMetaBuilder author(net.kyori.adventure.text.@Nullable Component author);
2021-06-11 14:02:28 +02:00
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMetaBuilder addPage(net.kyori.adventure.text.@NotNull Component page);
2021-06-11 14:02:28 +02:00
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMetaBuilder pages(net.kyori.adventure.text.@NotNull Component @NotNull ... pages);
2021-06-11 14:02:28 +02:00
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMetaBuilder pages(java.util.@NotNull Collection<net.kyori.adventure.text.Component> pages);
2021-06-11 14:02:28 +02:00
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMeta build();
2021-06-11 14:02:28 +02:00
+ }
+
+ @Override
2023-03-23 17:49:24 +01:00
+ @NotNull BookMetaBuilder toBuilder();
2021-06-11 14:02:28 +02:00
+
+ // Paper end
+
2023-03-23 22:57:03 +01:00
/**
* Gets the specified page in the book. The given page must exist.
* <p>
@@ -126,8 +229,10 @@ public interface BookMeta extends ItemMeta {
*
* @param page the page number to get, in range [1, getPageCount()]
* @return the page from the book
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #page(int)}
2023-03-23 22:57:03 +01:00
*/
@NotNull
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
String getPage(int page);
/**
@@ -141,15 +246,19 @@ 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
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #page(int, net.kyori.adventure.text.Component)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
void setPage(int page, @NotNull String data);
/**
* Gets all the pages in the book.
*
* @return list of all the pages in the book
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #pages()}
2023-03-23 22:57:03 +01:00
*/
@NotNull
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
List<String> getPages();
/**
@@ -157,7 +266,9 @@ 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
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #pages(List)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
void setPages(@NotNull List<String> pages);
/**
@@ -165,7 +276,9 @@ public interface BookMeta extends ItemMeta {
* pages. Maximum 50 pages with 256 characters per page.
*
* @param pages A list of strings, each being a page
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #pages(net.kyori.adventure.text.Component...)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
2023-03-23 22:57:03 +01:00
void setPages(@NotNull String... pages);
/**
@@ -173,7 +286,9 @@ public interface BookMeta extends ItemMeta {
* 256 characters per page.
*
* @param pages A list of strings, each being a page
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #addPages(net.kyori.adventure.text.Component...)}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
+ @Deprecated // Paper
void addPage(@NotNull String... pages);
/**
2023-03-23 17:49:24 +01:00
@@ -195,8 +310,10 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
*
* @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.");
}
2023-03-23 17:49:24 +01:00
@@ -210,7 +327,9 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
*
* @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.");
}
2023-03-23 17:49:24 +01:00
@@ -219,8 +338,10 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
* 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<BaseComponent[]> getPages() {
throw new UnsupportedOperationException("Not supported yet.");
}
2023-03-23 17:49:24 +01:00
@@ -230,7 +351,9 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
* 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<BaseComponent[]> pages) {
throw new UnsupportedOperationException("Not supported yet.");
}
2023-03-23 17:49:24 +01:00
@@ -240,7 +363,9 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
* 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.");
}
2023-03-23 17:49:24 +01:00
@@ -250,7 +375,9 @@ public interface BookMeta extends ItemMeta {
2021-06-11 14:02:28 +02:00
* 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
2023-03-23 17:49:24 +01:00
index 2fbb0b7640dd9b9b0e70d4bc60fbb0310d5ec250..049c70c935fd7a781280d223f74bbbf87223f505 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -31,6 +31,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasDisplayName();
+ // Paper start
+ /**
+ * Gets the display name.
+ *
+ * <p>Plugins should check that {@link #hasDisplayName()} returns <code>true</code> before calling this method.</p>
+ *
+ * @return the display name
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@Nullable Component displayName();
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the display name.
+ *
+ * @param displayName the display name to set
+ */
2023-03-23 17:49:24 +01:00
+ void displayName(final net.kyori.adventure.text.@Nullable Component displayName);
2021-06-11 14:02:28 +02:00
+ // Paper end
+
/**
* Gets the display name that is set.
* <p>
@@ -38,7 +56,9 @@ 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();
@@ -46,7 +66,9 @@ 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);
/**
@@ -81,6 +103,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasLore();
+ // Paper start
+ /**
+ * Gets the lore.
+ *
+ * <p>Plugins should check that {@link #hasLore()} returns <code>true</code> before calling this method.</p>
+ *
2022-06-24 18:39:44 +02:00
+ * @return the lore
2021-06-11 14:02:28 +02:00
+ */
+ @Nullable List<net.kyori.adventure.text.Component> lore();
+
+ /**
+ * Sets the lore.
+ *
+ * @param lore the lore to set
+ */
2023-03-20 09:18:06 +01:00
+ void lore(final @Nullable List<? extends net.kyori.adventure.text.Component> lore);
2021-06-11 14:02:28 +02:00
+ // Paper end
+
/**
* Gets the lore that is set.
* <p>
@@ -88,7 +128,9 @@ 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<String> getLore();
@@ -97,7 +139,9 @@ 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<String> lore);
/**
diff --git a/src/main/java/org/bukkit/map/MapCursor.java b/src/main/java/org/bukkit/map/MapCursor.java
2023-03-23 17:49:24 +01:00
index 83354b2a38b6261b172b91c1008dcf3313cc4a8f..762d8a53bbfa82edcd725a52d630b61c40503d67 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/map/MapCursor.java
+++ b/src/main/java/org/bukkit/map/MapCursor.java
@@ -10,7 +10,7 @@ public final class MapCursor {
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.
@@ -24,7 +24,7 @@ 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
}
/**
2023-03-23 22:57:03 +01:00
@@ -37,7 +37,7 @@ public final class MapCursor {
2021-06-11 14:02:28 +02:00
* @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
}
2023-03-23 22:57:03 +01:00
/**
@@ -49,7 +49,7 @@ 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) {
@@ -58,8 +58,42 @@ 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
2021-06-11 14:02:28 +02:00
+ /**
+ * 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
2023-03-23 22:57:03 +01:00
+ * @deprecated Magic value
2021-06-11 14:02:28 +02:00
+ */
+ @Deprecated
2023-03-23 22:57:03 +01:00
+ public MapCursor(byte x, byte y, byte direction, byte type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
+ this.x = x; this.y = y; this.visible = visible; this.caption = caption;
2021-06-11 14:02:28 +02:00
+ 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
+ */
2023-03-23 17:49:24 +01:00
+ public MapCursor(byte x, byte y, byte direction, @NotNull Type type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
2021-06-11 14:02:28 +02:00
+ this.x = x; this.y = y; this.visible = visible; this.caption = caption;
+ setDirection(direction);
+ setType(type);
+ }
+ // Paper end
/**
* Initialize the map cursor.
@@ -77,7 +111,7 @@ public final class MapCursor {
setDirection(direction);
setType(type);
this.visible = visible;
- this.caption = caption;
2022-05-26 21:12:14 +02:00
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
2021-06-11 14:02:28 +02:00
}
/**
@@ -200,23 +234,45 @@ public final class MapCursor {
this.visible = visible;
}
+ // Paper start
2023-03-23 22:57:03 +01:00
+ /**
+ * Gets the caption on this cursor.
+ *
+ * @return caption
+ */
2023-03-23 17:49:24 +01:00
+ public net.kyori.adventure.text.@Nullable Component caption() {
2021-06-11 14:02:28 +02:00
+ return this.caption;
+ }
+ /**
+ * Sets the caption on this cursor.
+ *
+ * @param caption new caption
+ */
2023-03-23 17:49:24 +01:00
+ public void caption(net.kyori.adventure.text.@Nullable Component caption) {
2021-06-11 14:02:28 +02:00
+ this.caption = caption;
+ }
+ // Paper end
2023-03-23 22:57:03 +01:00
/**
* Gets the caption on this cursor.
*
* @return caption
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #caption()}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
@Nullable
+ @Deprecated // Paper
public String getCaption() {
- return caption;
2022-05-26 21:12:14 +02:00
+ return this.caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.caption); // Paper
2021-06-11 14:02:28 +02:00
}
/**
* 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;
2022-05-26 21:12:14 +02:00
+ this.caption = caption == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(caption); // Paper
2021-06-11 14:02:28 +02:00
}
/**
diff --git a/src/main/java/org/bukkit/map/MapCursorCollection.java b/src/main/java/org/bukkit/map/MapCursorCollection.java
2023-03-23 17:49:24 +01:00
index 4dba721aefe4fc6699b3b4bfa7ecb0b19c2a2a1a..6bc28d000f538ecbf249467ff3e87e3f4fea963e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/map/MapCursorCollection.java
+++ b/src/main/java/org/bukkit/map/MapCursorCollection.java
@@ -117,4 +117,22 @@ 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
2023-03-23 17:49:24 +01:00
+ public @NotNull MapCursor addCursor(int x, int y, byte direction, byte type, boolean visible, net.kyori.adventure.text.@Nullable Component caption) {
2021-06-11 14:02:28 +02:00
+ return addCursor(new MapCursor((byte) x, (byte) y, direction, type, visible, caption));
+ }
2021-09-23 23:07:44 +02:00
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/permissions/Permissible.java b/src/main/java/org/bukkit/permissions/Permissible.java
index 228421154913116069c20323afb519bdde2134df..26791db3c267670d5782f1d2b67ff7d5b55b9dac 100644
--- a/src/main/java/org/bukkit/permissions/Permissible.java
+++ b/src/main/java/org/bukkit/permissions/Permissible.java
@@ -126,4 +126,34 @@ public interface Permissible extends ServerOperator {
*/
@NotNull
public Set<PermissionAttachmentInfo> getEffectivePermissions();
+
+ // Paper start - add TriState permission checks
+ /**
+ * Checks if this object has a permission set and, if it is set, the value of the permission.
+ *
+ * @param permission the permission to check
+ * @return a tri-state of if the permission is set and, if it is set, it's value
+ */
+ default net.kyori.adventure.util.@NotNull TriState permissionValue(final @NotNull Permission permission) {
+ if (this.isPermissionSet(permission)) {
+ return net.kyori.adventure.util.TriState.byBoolean(this.hasPermission(permission));
+ } else {
+ return net.kyori.adventure.util.TriState.NOT_SET;
+ }
+ }
+
+ /**
+ * Checks if this object has a permission set and, if it is set, the value of the permission.
+ *
+ * @param permission the permission to check
+ * @return a tri-state of if the permission is set and, if it is set, it's value
+ */
+ default net.kyori.adventure.util.@NotNull TriState permissionValue(final @NotNull String permission) {
+ if (this.isPermissionSet(permission)) {
+ return net.kyori.adventure.util.TriState.byBoolean(this.hasPermission(permission));
+ } else {
+ return net.kyori.adventure.util.TriState.NOT_SET;
+ }
+ }
2021-06-11 14:02:28 +02:00
+ // Paper end
}
2022-06-12 23:07:40 +02:00
diff --git a/src/main/java/org/bukkit/plugin/Plugin.java b/src/main/java/org/bukkit/plugin/Plugin.java
index 03ca87a1cbace2459174bb7bb8847bda766e80c5..b37938745f916b5f0111b07b1a1c97527f026e9d 100644
--- a/src/main/java/org/bukkit/plugin/Plugin.java
+++ b/src/main/java/org/bukkit/plugin/Plugin.java
@@ -179,6 +179,13 @@ public interface Plugin extends TabExecutor {
@NotNull
public Logger getLogger();
+ // Paper start - Adventure component logger
+ @NotNull
+ default net.kyori.adventure.text.logger.slf4j.ComponentLogger getComponentLogger() {
+ return net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(getLogger().getName());
+ }
+ // Paper end
+
/**
* Returns the name of the plugin.
* <p>
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java
2023-03-23 17:49:24 +01:00
index 2ff3a11f1f9c115722ea224873e7eb6dc6dc63e6..86a0a6f9e8487d6dfaf60876ace3dcc9b4722826 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/scoreboard/Objective.java
+++ b/src/main/java/org/bukkit/scoreboard/Objective.java
@@ -19,14 +19,35 @@ public interface Objective {
*/
@NotNull
String getName() throws IllegalStateException;
+ // Paper start
2023-03-23 22:57:03 +01:00
+ /**
+ * Gets the name displayed to players for this objective
+ *
+ * @return this objective's display name
+ * @throws IllegalStateException if this objective has been unregistered
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component displayName() throws IllegalStateException;
2021-06-11 14:02:28 +02:00
+ /**
+ * 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.
+ */
2023-03-23 17:49:24 +01:00
+ void displayName(net.kyori.adventure.text.@Nullable Component displayName) throws IllegalStateException, IllegalArgumentException;
2021-06-11 14:02:28 +02:00
+ // Paper end
2023-03-23 22:57:03 +01:00
/**
* Gets the name displayed to players for this objective
*
* @return this objective's display name
* @throws IllegalStateException if this objective has been unregistered
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #displayName()}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
@NotNull
+ @Deprecated // Paper
String getDisplayName() throws IllegalStateException;
/**
@@ -37,7 +58,9 @@ 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
2023-03-23 17:49:24 +01:00
index a15183f302de42956d8965efe5f0585fc2cd030e..ebb72912c1f8431606162b0643f6289203331253 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java
+++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
2022-08-09 09:18:08 +02:00
@@ -27,6 +27,92 @@ public interface Scoreboard {
2021-06-11 14:02:28 +02:00
@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
2022-03-06 16:32:33 +01:00
+ * @throws IllegalArgumentException if name is longer than 32767
2021-06-11 14:02:28 +02:00
+ * 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
2022-08-09 09:18:08 +02:00
+ * @deprecated use {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component)}
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2022-08-09 09:18:08 +02:00
+ @Deprecated
2023-03-23 17:49:24 +01:00
+ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, net.kyori.adventure.text.@Nullable Component displayName) throws IllegalArgumentException;
2021-06-11 14:02:28 +02:00
+ /**
+ * 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
2022-03-06 16:32:33 +01:00
+ * @throws IllegalArgumentException if name is longer than 32767
2021-06-11 14:02:28 +02:00
+ * 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
2022-08-09 09:18:08 +02:00
+ * @deprecated use {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component, RenderType)}
2021-06-11 14:02:28 +02:00
+ */
+ @NotNull
2022-08-09 09:18:08 +02:00
+ @Deprecated
2023-03-23 17:49:24 +01:00
+ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, net.kyori.adventure.text.@Nullable Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
2022-08-09 09:18:08 +02:00
+ /**
+ * 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 32767
+ * 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
2023-03-23 17:49:24 +01:00
+ Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, net.kyori.adventure.text.@Nullable Component displayName) throws IllegalArgumentException;
2022-08-09 09:18:08 +02:00
+ /**
+ * 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 32767
+ * 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
2023-03-23 17:49:24 +01:00
+ Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, net.kyori.adventure.text.@Nullable Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
2021-06-11 14:02:28 +02:00
+ // Paper end
/**
* Registers an Objective on this Scoreboard
2022-08-09 09:18:08 +02:00
@@ -47,6 +133,7 @@ public interface Scoreboard {
* @deprecated use {@link #registerNewObjective(String, Criteria, String)}
*/
@NotNull
+ @Deprecated // Paper
Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName) throws IllegalArgumentException;
/**
@@ -70,6 +157,7 @@ public interface Scoreboard {
* @deprecated use {@link #registerNewObjective(String, Criteria, String, RenderType)}
*/
@NotNull
+ @Deprecated // Paper
Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
/**
@@ -88,8 +176,10 @@ public interface Scoreboard {
2021-06-11 14:02:28 +02:00
* characters.
* @throws IllegalArgumentException if an objective by that name already
* exists
2022-08-09 09:18:08 +02:00
+ * @deprecated in favour of {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component)}
2021-06-11 14:02:28 +02:00
*/
@NotNull
+ @Deprecated // Paper
2022-08-09 09:18:08 +02:00
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName) throws IllegalArgumentException;
2021-06-11 14:02:28 +02:00
/**
2022-08-09 09:18:08 +02:00
@@ -110,8 +200,10 @@ public interface Scoreboard {
2021-06-11 14:02:28 +02:00
* @throws IllegalArgumentException if renderType is null
* @throws IllegalArgumentException if an objective by that name already
* exists
2022-08-09 09:18:08 +02:00
+ * @deprecated in favour of {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component, RenderType)}
2021-06-11 14:02:28 +02:00
*/
@NotNull
+ @Deprecated // Paper
2022-08-09 09:18:08 +02:00
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
2021-06-11 14:02:28 +02:00
/**
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
2023-03-23 17:49:24 +01:00
index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..4d625f79ba2e3fe074feade98f7c1bc2798cb82e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
2022-06-03 07:05:42 +02:00
@@ -22,14 +22,100 @@ public interface Team {
2021-06-11 14:02:28 +02:00
*/
@NotNull
String getName() throws IllegalStateException;
+ // Paper start
2023-03-23 22:57:03 +01:00
+ /**
+ * Gets the name displayed to entries for this team
+ *
+ * @return Team display name
+ * @throws IllegalStateException if this team has been unregistered
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component displayName() throws IllegalStateException;
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the name displayed to entries for this team
+ *
+ * @param displayName New display name
+ * @throws IllegalStateException if this team has been unregistered
+ */
2023-03-23 17:49:24 +01:00
+ void displayName(net.kyori.adventure.text.@Nullable Component displayName) throws IllegalStateException, IllegalArgumentException;
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Gets the prefix prepended to the display of entries on this team.
+ *
+ * @return Team prefix
+ * @throws IllegalStateException if this team has been unregistered
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component prefix() throws IllegalStateException;
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the prefix prepended to the display of entries on this team.
+ *
+ * @param prefix New prefix
+ * @throws IllegalArgumentException if prefix is null
+ * characters
+ * @throws IllegalStateException if this team has been unregistered
+ */
2023-03-23 17:49:24 +01:00
+ void prefix(net.kyori.adventure.text.@Nullable Component prefix) throws IllegalStateException, IllegalArgumentException;
2021-06-11 14:02:28 +02:00
+
+ /**
+ * 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
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.@NotNull Component suffix() throws IllegalStateException;
2021-06-11 14:02:28 +02:00
+
+ /**
+ * 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
+ * characters
+ * @throws IllegalStateException if this team has been unregistered
+ */
2023-03-23 17:49:24 +01:00
+ void suffix(net.kyori.adventure.text.@Nullable Component suffix) throws IllegalStateException, IllegalArgumentException;
2021-06-11 14:02:28 +02:00
+
+ /**
2022-04-24 03:37:10 +02:00
+ * Checks if the team has a color specified
+ *
+ * @return true if it has a <b>color</b>
+ * @throws IllegalStateException if this team has been unregistered
+ */
+ boolean hasColor();
+
+ /**
2021-06-11 14:02:28 +02:00
+ * Gets the color of the team.
+ * <br>
+ * This only sets the team outline, other occurrences of colors such as in
+ * names are handled by prefixes / suffixes.
+ *
2022-04-24 03:37:10 +02:00
+ * @return team color
2021-06-11 14:02:28 +02:00
+ * @throws IllegalStateException if this team has been unregistered
2022-04-24 03:37:10 +02:00
+ * @throws IllegalStateException if the team doesn't have a color
+ * @see #hasColor()
2021-06-11 14:02:28 +02:00
+ */
2023-03-23 17:49:24 +01:00
+ net.kyori.adventure.text.format.@NotNull TextColor color() throws IllegalStateException;
2021-06-11 14:02:28 +02:00
+
+ /**
+ * Sets the color of the team.
+ * <br>
+ * This only sets the team outline, other occurrences of colors such as in
+ * names are handled by prefixes / suffixes.
+ *
2022-04-24 03:37:10 +02:00
+ * @param color new color, null for no color
2021-06-11 14:02:28 +02:00
+ */
2023-03-23 17:49:24 +01:00
+ void color(net.kyori.adventure.text.format.@Nullable NamedTextColor color);
2021-06-11 14:02:28 +02:00
+ // Paper end
2023-03-23 22:57:03 +01:00
/**
* Gets the name displayed to entries for this team
*
* @return Team display name
* @throws IllegalStateException if this team has been unregistered
2021-06-11 14:02:28 +02:00
+ * @deprecated in favour of {@link #displayName()}
2023-03-23 22:57:03 +01:00
*/
2021-06-11 14:02:28 +02:00
@NotNull
+ @Deprecated // Paper
String getDisplayName() throws IllegalStateException;
/**
2022-06-03 07:05:42 +02:00
@@ -39,7 +125,9 @@ public interface Team {
2021-06-11 14:02:28 +02:00
* @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;
/**
2022-06-03 07:05:42 +02:00
@@ -47,8 +135,10 @@ public interface Team {
2021-06-11 14:02:28 +02:00
*
* @return Team prefix
* @throws IllegalStateException if this team has been unregistered
+ * @deprecated in favour of {@link #prefix()}
*/
@NotNull
+ @Deprecated // Paper
String getPrefix() throws IllegalStateException;
/**
2022-06-03 07:05:42 +02:00
@@ -59,7 +149,9 @@ public interface Team {
2021-06-11 14:02:28 +02:00
* @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;
/**
2022-06-03 07:05:42 +02:00
@@ -67,8 +159,10 @@ public interface Team {
2021-06-11 14:02:28 +02:00
*
* @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;
/**
2022-06-03 07:05:42 +02:00
@@ -79,7 +173,9 @@ public interface Team {
2021-06-11 14:02:28 +02:00
* @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;
/**
2022-06-03 07:05:42 +02:00
@@ -90,8 +186,10 @@ public interface Team {
2021-06-11 14:02:28 +02:00
*
* @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;
/**
2022-06-03 07:05:42 +02:00
@@ -102,7 +200,9 @@ public interface Team {
2021-06-11 14:02:28 +02:00
*
* @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);
/**
2023-02-26 15:59:52 +01:00
diff --git a/src/test/java/io/papermc/paper/adventure/KeyTest.java b/src/test/java/io/papermc/paper/adventure/KeyTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..70c575077d204e4b36d07559f6a8d952b84af1cf
--- /dev/null
+++ b/src/test/java/io/papermc/paper/adventure/KeyTest.java
@@ -0,0 +1,31 @@
+package io.papermc.paper.adventure;
+
+import java.util.HashSet;
+import java.util.Set;
+import net.kyori.adventure.key.Key;
+import org.bukkit.NamespacedKey;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class KeyTest {
+
+ @Test
+ public void equalsTest() {
+ Key key = new NamespacedKey("test", "key");
+ Key key1 = Key.key("test", "key");
+ assertEquals(key, key1);
+ assertEquals(key1, key);
+ }
+
+ @Test
+ public void setTest() {
+ Key key = new NamespacedKey("test", "key");
+ Key key1 = Key.key("test", "key");
+ Set<Key> set = new HashSet<>(Set.of(key));
+ Set<Key> set1 = new HashSet<>(Set.of(key1));
+ assertTrue(set.contains(key1));
+ assertTrue(set1.contains(key));
+ }
+}