Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
4bc15f13aa
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e2160a18 Make MapCursor#type not depends on deprecated values CraftBukkit Changes: 6ce172642 SPIGOT-7761: Ender pearl does not damage or spawn endermites f5a63f734 SPIGOT-7759: Chunk not there when requested in ChunkUnloadEvent 28287259c Remove unused import eb9a7dde0 SPIGOT-7757: Cannot set item in Stonecutter Inventory f8be9d752 Move deserialized removed unhandled tags to dedicated removedTags a7e576186 Fix potential mutability issue with CraftMetaItem copy constructor 995885452 SPIGOT-7741: Vanilla ItemComponent in commands can't remove components 9ef69aa0b PR-1284: Move ItemType <-> ItemMeta linking to a centralized place 3e82eafbe PR-1420: Fix DirectEntity and CausingEntity Damager for Creepers ignited by Player c23daa71f SPIGOT-7751: Fix crash caused by arrows from trial spawners Make MapCursor#type not depends on deprecated values SPIGOT-7761: Ender pearl does not damage or spawn endermites
84 Zeilen
3.6 KiB
Diff
84 Zeilen
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MiniDigger <admin@benndorf.dev>
|
|
Date: Sat, 6 Jun 2020 18:13:42 +0200
|
|
Subject: [PATCH] Support components in ItemMeta
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
index 9ecbdd50aa2eb7851ce1716946fa31e5db8765b4..f13c703a0acafec7e6772f83ae4f5fda988cd15f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
@@ -969,11 +969,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
return CraftChatMessage.fromComponent(this.displayName);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] getDisplayNameComponent() {
|
|
+ return displayName == null ? new net.md_5.bungee.api.chat.BaseComponent[0] : net.md_5.bungee.chat.ComponentSerializer.parse(CraftChatMessage.toJSON(displayName));
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public final void setDisplayName(String name) {
|
|
this.displayName = CraftChatMessage.fromStringOrNull(name);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public void setDisplayNameComponent(net.md_5.bungee.api.chat.BaseComponent[] component) {
|
|
+ this.displayName = CraftChatMessage.fromJSON(net.md_5.bungee.chat.ComponentSerializer.toString(component));
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public boolean hasDisplayName() {
|
|
return this.displayName != null;
|
|
@@ -1147,6 +1159,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromComponent));
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public List<net.md_5.bungee.api.chat.BaseComponent[]> getLoreComponents() {
|
|
+ return this.lore == null ? null : new ArrayList<>(this.lore.stream().map(entry ->
|
|
+ net.md_5.bungee.chat.ComponentSerializer.parse(CraftChatMessage.toJSON(entry))
|
|
+ ).collect(java.util.stream.Collectors.toList()));
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public void setLore(List<String> lore) {
|
|
if (lore == null || lore.isEmpty()) {
|
|
@@ -1161,6 +1181,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
}
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public void setLoreComponents(List<net.md_5.bungee.api.chat.BaseComponent[]> lore) {
|
|
+ if (lore == null) {
|
|
+ this.lore = null;
|
|
+ } else {
|
|
+ if (this.lore == null) {
|
|
+ safelyAdd(lore, this.lore = new ArrayList<>(lore.size()), false);
|
|
+ } else {
|
|
+ this.lore.clear();
|
|
+ safelyAdd(lore, this.lore, false);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public boolean hasCustomModelData() {
|
|
return this.customModelData != null;
|
|
@@ -1873,6 +1908,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
}
|
|
|
|
for (Object object : addFrom) {
|
|
+ // Paper start - support components
|
|
+ if(object instanceof net.md_5.bungee.api.chat.BaseComponent[] baseComponentArr) {
|
|
+ addTo.add(CraftChatMessage.fromJSON(net.md_5.bungee.chat.ComponentSerializer.toString(baseComponentArr)));
|
|
+ } else
|
|
+ // Paper end
|
|
if (!(object instanceof String)) {
|
|
if (object != null) {
|
|
// SPIGOT-7399: Null check via if is important,
|