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 e63bec882..9ace767d1 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 9af29f576..ff6d4260a 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 016b529a6..7cfdda308 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 a56ef7662..1b6bcdc13 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 b5e5adc42..560b65c4f 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit b5e5adc428e622c6575b407a9c33b13fcc2d7d9b +Subproject commit 560b65c4f8a15619aaa4a1737c7040f21e725cce diff --git a/work/Spigot b/work/Spigot index 628435a80..ff439d1e5 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 628435a80b4e69e07735824489f15c9689a411d7 +Subproject commit ff439d1e51cd390669f197e432a1dd578f05858b