aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJakub Zacek <[email protected]>2024-06-16 13:54:38 +0200
committerGitHub <[email protected]>2024-06-16 13:54:38 +0200
commitd8c298007faeac56cac92ed16e39e55d39f6880a (patch)
tree4282497ee1a69278d82f63c2e7c9267445e94207
parentc84a3b541c8fda6fe57fae028bbb94d8fbd38cfd (diff)
downloadPaper-d8c298007faeac56cac92ed16e39e55d39f6880a.tar.gz
Paper-d8c298007faeac56cac92ed16e39e55d39f6880a.zip
Add Adventure API to ServerLinks (#10891)
-rw-r--r--patches/api/0006-Adventure.patch56
-rw-r--r--patches/server/0010-Adventure.patch38
2 files changed, 94 insertions, 0 deletions
diff --git a/patches/api/0006-Adventure.patch b/patches/api/0006-Adventure.patch
index f52397b4f8..3826a48b3e 100644
--- a/patches/api/0006-Adventure.patch
+++ b/patches/api/0006-Adventure.patch
@@ -1417,6 +1417,62 @@ index 7ffbf7e72275b3111ecb87824fa68f44d4300799..ddbaa7fb174e05533023a2523d67c3d3
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/ServerLinks.java b/src/main/java/org/bukkit/ServerLinks.java
+index 18a53194483410c4d5ad35f901c90d44efaeef60..aff43d77f31d81b82e5fc5fea6272dda24506562 100644
+--- a/src/main/java/org/bukkit/ServerLinks.java
++++ b/src/main/java/org/bukkit/ServerLinks.java
+@@ -50,13 +50,27 @@ public interface ServerLinks {
+ @NotNull
+ ServerLink addLink(@NotNull Type type, @NotNull URI url);
+
++ // Paper start - Adventure
++ /**
++ * Adds the given link to the list of links.
++ *
++ * @param displayName link name / display text Component
++ * @param url link url
++ * @return the added link
++ */
++ @NotNull
++ ServerLink addLink(@NotNull net.kyori.adventure.text.Component displayName, @NotNull URI url);
++ // Paper end - Adventure
++
+ /**
+ * Adds the given link to the list of links.
+ *
+ * @param displayName link name / display text
+ * @param url link url
+ * @return the added link
++ * @deprecated in favour of {@link ServerLinks#addLink(net.kyori.adventure.text.Component, URI)}
+ */
++ @Deprecated // Paper - Adventure
+ @NotNull
+ ServerLink addLink(@NotNull String displayName, @NotNull URI url);
+
+@@ -89,11 +103,23 @@ public interface ServerLinks {
+ @Nullable
+ Type getType();
+
++ // Paper start - Adventure
++ /**
++ * Gets the display name/text Component of this link.
++ *
++ * @return display name Component
++ */
++ @NotNull
++ net.kyori.adventure.text.Component displayName();
++ // Paper end - Adventure
++
+ /**
+ * Gets the display name/text of this link.
+ *
+ * @return display name
++ * @deprecated in favour of {@link ServerLink#displayName()}
+ */
++ @Deprecated // Paper - Adventure
+ @NotNull
+ String getDisplayName();
+
diff --git a/src/main/java/org/bukkit/Sound.java b/src/main/java/org/bukkit/Sound.java
index f4d7efee38c3b1381fdbcd47ab1f59fb02728cf2..b2ff1da3386223a544ab5fc363a90c66c8869242 100644
--- a/src/main/java/org/bukkit/Sound.java
diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch
index de30f92944..3e68c1f4f1 100644
--- a/patches/server/0010-Adventure.patch
+++ b/patches/server/0010-Adventure.patch
@@ -3492,6 +3492,44 @@ index 9babfd8e6c847ea26863be6243f17fc252dc9e1d..0e3ff653211b0210f8679b475d5f62ee
+ }
+ // Paper end
}
+diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java b/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java
+index cbdb1a56a97150c164515a4ce6d3ba06428bf321..b214e7b302abbfe1641485a05f1371ac65ffb517 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServerLinks.java
+@@ -61,6 +61,19 @@ public class CraftServerLinks implements ServerLinks {
+ return link;
+ }
+
++ // Paper start - Adventure
++ @Override
++ public ServerLink addLink(net.kyori.adventure.text.Component displayName, URI url) {
++ Preconditions.checkArgument(displayName != null, "displayName cannot be null");
++ Preconditions.checkArgument(url != null, "url cannot be null");
++
++ CraftServerLink link = new CraftServerLink(net.minecraft.server.ServerLinks.Entry.custom(io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), url));
++ this.addLink(link);
++
++ return link;
++ }
++ // Paper end - Adventure
++
+ @Override
+ public ServerLink addLink(String displayName, URI url) {
+ Preconditions.checkArgument(displayName != null, "displayName cannot be null");
+@@ -134,6 +147,13 @@ public class CraftServerLinks implements ServerLinks {
+ return CraftChatMessage.fromComponent(this.handle.displayName());
+ }
+
++ // Paper start - Adventure
++ @Override
++ public net.kyori.adventure.text.Component displayName() {
++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.displayName());
++ }
++ // Paper end - Adventure
++
+ @Override
+ public URI getUrl() {
+ return this.handle.link();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index a59eebb89d11788b999d1e5cb4fd2f4e55e023ab..1e8d93d81b7a391bbd1e9926ff35a68d4c563f0f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java