mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 08:20:51 +01:00
e035fd7034
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: cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities f23325b6 Add API for per-world simulation distances 26e1774e Add API for per-world view distances 0b541e60 Add PlayerLoginEvent#getRealAddress 5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types CraftBukkit Changes: bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs 7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst 752aac669 Implement APIs for per world view and simulation distances 57d7ef433 Preserve empty enchantment tags for glow effect 465ec3fb4 Remove connected check on setScoreboard f90ce621e Use one PermissibleBase for all command blocks 5876cca44 SPIGOT-7550: Fix creation of Arrow instances f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition 9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item Spigot Changes: ed9ba9a4 Drop no longer required patch ignoring -o option 86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message aa7cde7a Remove obsolete APIs for per world view and simulation distances 6dff577e Remove obsolete patch preserving empty `ench` tags a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress 1b02f5d6 Remove obsolete connected check on setScoreboard patch acf717eb Remove obsolete command block PermissibleBase patch 053fa2a9 Remove redundant patch dealing with null tile entities
84 lines
3.5 KiB
Diff
84 lines
3.5 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 7cd7e275c997bbf0ad7aab87aabc27aa722b915c..b9eca4b39cc265cb2d9b9f20ee6f803bea748c7d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
@@ -878,11 +878,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
return CraftChatMessage.fromJSONComponent(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(displayName);
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public final void setDisplayName(String name) {
|
|
this.displayName = CraftChatMessage.fromStringOrNullToJSON(name);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public void setDisplayNameComponent(net.md_5.bungee.api.chat.BaseComponent[] component) {
|
|
+ this.displayName = net.md_5.bungee.chat.ComponentSerializer.toString(component);
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public boolean hasDisplayName() {
|
|
return this.displayName != null;
|
|
@@ -1023,6 +1035,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromJSONComponent));
|
|
}
|
|
|
|
+ // 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(entry)
|
|
+ ).collect(java.util.stream.Collectors.toList()));
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public void setLore(List<String> lore) {
|
|
if (lore == null || lore.isEmpty()) {
|
|
@@ -1037,6 +1057,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;
|
|
@@ -1505,6 +1540,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[]) {
|
|
+ addTo.add(net.md_5.bungee.chat.ComponentSerializer.toString((net.md_5.bungee.api.chat.BaseComponent[]) object));
|
|
+ } else
|
|
+ // Paper end
|
|
if (!(object instanceof String)) {
|
|
if (object != null) {
|
|
// SPIGOT-7399: Null check via if is important,
|