Paper/patches/server/1070-Expanded-Art-API.patch

54 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kokiriglade <60290002+celerry@users.noreply.github.com>
Date: Sat, 23 Nov 2024 18:58:49 +0000
Subject: [PATCH] Expanded Art API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/src/main/java/org/bukkit/craftbukkit/CraftArt.java
index 40af940193d0df66bbcdcf5f46132e304016a4d7..932118f5e5bfc765c852acaf21f9721d8fa5fb6a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftArt.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftArt.java
@@ -42,6 +42,9 @@ public class CraftArt implements Art, Handleable<PaintingVariant> {
private final NamespacedKey key;
private final PaintingVariant paintingVariant;
+ private final net.kyori.adventure.text.@org.jspecify.annotations.Nullable Component adventureTitle; // Paper - name and author components, assetId key
+ private final net.kyori.adventure.text.@org.jspecify.annotations.Nullable Component adventureAuthor; // Paper - name and author components, assetId key
+ private final net.kyori.adventure.key.@org.jspecify.annotations.NonNull Key adventureAssetId; // Paper - name and author components, assetId key
private final String name;
private final int ordinal;
@@ -58,6 +61,9 @@ public class CraftArt implements Art, Handleable<PaintingVariant> {
this.name = key.toString();
}
this.ordinal = CraftArt.count++;
+ this.adventureTitle = paintingVariant.title().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).orElse(null); // Paper - name and author components, assetId key
+ this.adventureAuthor = paintingVariant.author().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).orElse(null); // Paper - name and author components, assetId key
+ this.adventureAssetId = io.papermc.paper.adventure.PaperAdventure.asAdventure(paintingVariant.assetId()); // Paper - name and author components, assetId key
}
@Override
@@ -75,6 +81,22 @@ public class CraftArt implements Art, Handleable<PaintingVariant> {
return this.paintingVariant.height();
}
+ // Paper start - name and author components, assetId key
+ @Override
+ public net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component title() {
+ return this.adventureTitle;
+ }
+
+ @Override
+ public net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component author() {
+ return this.adventureAuthor;
+ }
+
+ public net.kyori.adventure.key.@org.jspecify.annotations.NonNull Key assetId() {
+ return this.adventureAssetId;
+ }
+ // Paper end - name and author components, assetId key
+
@Override
public int getId() {
return CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).getId(this.paintingVariant);