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
This commit is contained in:
Jake Potrebic 2020-12-31 20:03:19 -08:00
parent b1d8fe74c4
commit e11560e965
6 changed files with 38 additions and 45 deletions

View file

@ -32,27 +32,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
@@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { @@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size()); String validatePage(String page) {
}
- 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]);
}
@@ -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) { if (page == null) {
page = ""; page = "";
- } else if (page.length() > MAX_PAGE_LENGTH) { - } else if (page.length() > MAX_PAGE_LENGTH) {
+ } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override + } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
page = page.substring(0, MAX_PAGE_LENGTH); page = page.substring(0, MAX_PAGE_LENGTH);
} }
return page;
@@ -0,0 +0,0 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
// asserted: page != null
if (this.pages == null) {
this.pages = new ArrayList<String>();
- } else if (this.pages.size() >= MAX_PAGES) {
+ } else if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) {// Paper - Add override
return;
}
this.pages.add(page);

View file

@ -213,16 +213,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@@ -0,0 +0,0 @@ import java.util.Locale; @@ -0,0 +0,0 @@ import java.util.Map;
import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set; import java.util.Set;
+import java.util.TreeMap; // Paper +import java.util.TreeMap; // Paper
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
private List<IChatBaseComponent> lore; private List<String> lore; // null and empty are two different states internally
private Integer customModelData; private Integer customModelData;
private NBTTagCompound blockData; private NBTTagCompound blockData;
- private Map<Enchantment, Integer> enchantments; - private Map<Enchantment, Integer> enchantments;

View file

@ -57,8 +57,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ static final ItemMetaKey CAN_PLACE_ON = new ItemMetaKey("CanPlaceOn"); + static final ItemMetaKey CAN_PLACE_ON = new ItemMetaKey("CanPlaceOn");
+ // Paper end + // Paper end
private IChatBaseComponent displayName; // We store the raw original JSON representation of all text data. See SPIGOT-5063, SPIGOT-5656, SPIGOT-5304
private IChatBaseComponent locName; private String displayName;
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
private int hideFlag; private int hideFlag;
private boolean unbreakable; private boolean unbreakable;
@ -196,15 +196,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
+ +
NBTTagList createStringList(List<IChatBaseComponent> list) { NBTTagList createStringList(List<String> list) {
if (list == null || list.isEmpty()) { if (list == null) {
return null; return null;
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Overridden @Overridden
boolean isEmpty() { boolean isEmpty() {
- return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || 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());
+ 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() || hasPlaceableKeys() || hasDestroyableKeys()); // Paper - Implement an API for CanPlaceOn and CanDestroy NBT values
} }
@Override @Override

View file

@ -21,44 +21,44 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/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 { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return CraftChatMessage.fromComponent(displayName); return CraftChatMessage.fromJSONComponent(displayName);
} }
+ // Paper start + // Paper start
+ @Override + @Override
+ public net.md_5.bungee.api.chat.BaseComponent[] getDisplayNameComponent() { + 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 + // Paper end
@Override @Override
public final void setDisplayName(String name) { public final void setDisplayName(String name) {
this.displayName = CraftChatMessage.fromStringOrNull(name); this.displayName = CraftChatMessage.fromStringOrNullToJSON(name);
} }
+ // Paper start + // Paper start
+ @Override + @Override
+ public void setDisplayNameComponent(net.md_5.bungee.api.chat.BaseComponent[] component) { + 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 + // Paper end
@Override @Override
public boolean hasDisplayName() { public boolean hasDisplayName() {
return displayName != null; return displayName != null;
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromComponent)); return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromJSONComponent));
} }
+ // Paper start + // Paper start
+ @Override + @Override
+ public List<net.md_5.bungee.api.chat.BaseComponent[]> getLoreComponents() { + public List<net.md_5.bungee.api.chat.BaseComponent[]> getLoreComponents() {
+ return this.lore == null ? null : new ArrayList<>(this.lore.stream().map(entry -> + return this.lore == null ? null : new ArrayList<>(this.lore.stream().map(entry ->
+ net.md_5.bungee.chat.ComponentSerializer.parse(IChatBaseComponent.ChatSerializer.componentToJson(entry) + net.md_5.bungee.chat.ComponentSerializer.parse(entry)
+ )).collect(java.util.stream.Collectors.toList())); + ).collect(java.util.stream.Collectors.toList()));
+ } + }
+ // Paper end + // Paper end
@Override @Override
public void setLore(List<String> lore) { // too tired to think if .clone is better public void setLore(List<String> lore) {
if (lore == null) { if (lore == null || lore.isEmpty()) {
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
} }
} }
@ -70,10 +70,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.lore = null; + this.lore = null;
+ } else { + } else {
+ if (this.lore == null) { + 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 { + } else {
+ this.lore.clear(); + 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) { for (Object object : addFrom) {
+ // Paper start - support components + // Paper start - support components
+ if(object instanceof net.md_5.bungee.api.chat.BaseComponent[]) { + 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 + } else
+ // Paper end + // Paper end
if (!(object instanceof String)) { if (!(object instanceof String)) {

@ -1 +1 @@
Subproject commit b5e5adc428e622c6575b407a9c33b13fcc2d7d9b Subproject commit 560b65c4f8a15619aaa4a1737c7040f21e725cce

@ -1 +1 @@
Subproject commit 628435a80b4e69e07735824489f15c9689a411d7 Subproject commit ff439d1e51cd390669f197e432a1dd578f05858b