From e11560e965ca4b429e833b37243a20722073f591 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 31 Dec 2020 20:03:19 -0800 Subject: [PATCH] Updated Upstream (CraftBukkit/Spigot) (#4972) 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 CraftBukkit Changes: 560b65c4 #707, SPIGOT-5063, SPIGOT-5304, SPIGOT-5656, SPIGOT-3206, SPIGOT-5350, SPIGOT-5980, SPIGOT-4672: Persist the exact internal text representation where possible. Spigot Changes: ff439d1e Rebuild patches --- ...property-to-disable-book-size-limits.patch | 37 ++++++++----------- .../Handle-Item-Meta-Inconsistencies.patch | 6 +-- ...-for-CanPlaceOn-and-CanDestroy-NBT-v.patch | 12 +++--- .../Support-components-in-ItemMeta.patch | 24 ++++++------ work/CraftBukkit | 2 +- work/Spigot | 2 +- 6 files changed, 38 insertions(+), 45 deletions(-) diff --git a/Spigot-Server-Patches/Add-system-property-to-disable-book-size-limits.patch b/Spigot-Server-Patches/Add-system-property-to-disable-book-size-limits.patch index e63bec8826..9ace767d1f 100644 --- a/Spigot-Server-Patches/Add-system-property-to-disable-book-size-limits.patch +++ b/Spigot-Server-Patches/Add-system-property-to-disable-book-size-limits.patch @@ -32,27 +32,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } @@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { - throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size()); + String validatePage(String page) { + if (page == null) { + page = ""; +- } else if (page.length() > MAX_PAGE_LENGTH) { ++ } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override + page = page.substring(0, MAX_PAGE_LENGTH); } - -- String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH ? text.substring(0, MAX_PAGE_LENGTH) : text; -+ String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS ? text.substring(0, MAX_PAGE_LENGTH) : text; - pages.set(page - 1, CraftChatMessage.fromString(newText, true)[0]); - } - + return page; @@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { - @Override - public void addPage(final String... pages) { - for (String page : pages) { -- if (this.pages.size() >= MAX_PAGES) { -+ if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) { - return; - } - - if (page == null) { - page = ""; -- } else if (page.length() > MAX_PAGE_LENGTH) { -+ } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override - page = page.substring(0, MAX_PAGE_LENGTH); - } - + // asserted: page != null + if (this.pages == null) { + this.pages = new ArrayList(); +- } else if (this.pages.size() >= MAX_PAGES) { ++ } else if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) {// Paper - Add override + return; + } + this.pages.add(page); diff --git a/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch b/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch index 9af29f576d..ff6d4260a4 100644 --- a/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch +++ b/Spigot-Server-Patches/Handle-Item-Meta-Inconsistencies.patch @@ -213,16 +213,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import java.util.EnumSet; import java.util.HashMap; import java.util.Iterator; -@@ -0,0 +0,0 @@ import java.util.Locale; - import java.util.Map; +@@ -0,0 +0,0 @@ import java.util.Map; import java.util.NoSuchElementException; + import java.util.Objects; import java.util.Set; +import java.util.TreeMap; // Paper import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nonnull; @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - private List lore; + private List lore; // null and empty are two different states internally private Integer customModelData; private NBTTagCompound blockData; - private Map enchantments; diff --git a/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index 016b529a69..7cfdda308f 100644 --- a/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/Spigot-Server-Patches/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -57,8 +57,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + static final ItemMetaKey CAN_PLACE_ON = new ItemMetaKey("CanPlaceOn"); + // Paper end - private IChatBaseComponent displayName; - private IChatBaseComponent locName; + // We store the raw original JSON representation of all text data. See SPIGOT-5063, SPIGOT-5656, SPIGOT-5304 + private String displayName; @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { private int hideFlag; private boolean unbreakable; @@ -196,15 +196,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end + - NBTTagList createStringList(List list) { - if (list == null || list.isEmpty()) { + NBTTagList createStringList(List list) { + if (list == null) { return null; @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @Overridden boolean isEmpty() { -- return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers()); -+ return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers() || hasPlaceableKeys() || hasDestroyableKeys()); // Paper - Implement an API for CanPlaceOn and CanDestroy NBT values +- return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers()); ++ return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers() || hasPlaceableKeys() || hasDestroyableKeys()); // Paper - Implement an API for CanPlaceOn and CanDestroy NBT values } @Override diff --git a/Spigot-Server-Patches/Support-components-in-ItemMeta.patch b/Spigot-Server-Patches/Support-components-in-ItemMeta.patch index a56ef76629..1b6bcdc138 100644 --- a/Spigot-Server-Patches/Support-components-in-ItemMeta.patch +++ b/Spigot-Server-Patches/Support-components-in-ItemMeta.patch @@ -21,44 +21,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - return CraftChatMessage.fromComponent(displayName); + return CraftChatMessage.fromJSONComponent(displayName); } + // Paper start + @Override + public net.md_5.bungee.api.chat.BaseComponent[] getDisplayNameComponent() { -+ return net.md_5.bungee.chat.ComponentSerializer.parse(IChatBaseComponent.ChatSerializer.componentToJson(displayName)); ++ return net.md_5.bungee.chat.ComponentSerializer.parse(displayName); + } + // Paper end @Override public final void setDisplayName(String name) { - this.displayName = CraftChatMessage.fromStringOrNull(name); + this.displayName = CraftChatMessage.fromStringOrNullToJSON(name); } + // Paper start + @Override + public void setDisplayNameComponent(net.md_5.bungee.api.chat.BaseComponent[] component) { -+ this.displayName = IChatBaseComponent.ChatSerializer.jsonToComponent(net.md_5.bungee.chat.ComponentSerializer.toString(component)); ++ this.displayName = net.md_5.bungee.chat.ComponentSerializer.toString(component); + } + // Paper end @Override public boolean hasDisplayName() { return displayName != null; @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - return this.lore == null ? null : new ArrayList(Lists.transform(this.lore, CraftChatMessage::fromComponent)); + return this.lore == null ? null : new ArrayList(Lists.transform(this.lore, CraftChatMessage::fromJSONComponent)); } + // Paper start + @Override + public List getLoreComponents() { + return this.lore == null ? null : new ArrayList<>(this.lore.stream().map(entry -> -+ net.md_5.bungee.chat.ComponentSerializer.parse(IChatBaseComponent.ChatSerializer.componentToJson(entry) -+ )).collect(java.util.stream.Collectors.toList())); ++ net.md_5.bungee.chat.ComponentSerializer.parse(entry) ++ ).collect(java.util.stream.Collectors.toList())); + } + // Paper end @Override - public void setLore(List lore) { // too tired to think if .clone is better - if (lore == null) { + public void setLore(List lore) { + if (lore == null || lore.isEmpty()) { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { } } @@ -70,10 +70,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.lore = null; + } else { + if (this.lore == null) { -+ safelyAdd(lore, this.lore = new ArrayList<>(lore.size()), Integer.MAX_VALUE); ++ safelyAdd(lore, this.lore = new ArrayList<>(lore.size()), false); + } else { + this.lore.clear(); -+ safelyAdd(lore, this.lore, Integer.MAX_VALUE); ++ safelyAdd(lore, this.lore, false); + } + } + } @@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for (Object object : addFrom) { + // Paper start - support components + if(object instanceof net.md_5.bungee.api.chat.BaseComponent[]) { -+ addTo.add(IChatBaseComponent.ChatSerializer.jsonToComponent(net.md_5.bungee.chat.ComponentSerializer.toString((net.md_5.bungee.api.chat.BaseComponent[]) object))); ++ addTo.add(net.md_5.bungee.chat.ComponentSerializer.toString((net.md_5.bungee.api.chat.BaseComponent[]) object)); + } else + // Paper end if (!(object instanceof String)) { diff --git a/work/CraftBukkit b/work/CraftBukkit index b5e5adc428..560b65c4f8 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit b5e5adc428e622c6575b407a9c33b13fcc2d7d9b +Subproject commit 560b65c4f8a15619aaa4a1737c7040f21e725cce diff --git a/work/Spigot b/work/Spigot index 628435a80b..ff439d1e51 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 628435a80b4e69e07735824489f15c9689a411d7 +Subproject commit ff439d1e51cd390669f197e432a1dd578f05858b