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 {
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<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.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<IChatBaseComponent> lore;
private List<String> lore; // null and empty are two different states internally
private Integer customModelData;
private NBTTagCompound blockData;
- private Map<Enchantment, Integer> enchantments;

View file

@ -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<IChatBaseComponent> list) {
if (list == null || list.isEmpty()) {
NBTTagList createStringList(List<String> 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

View file

@ -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<String>(Lists.transform(this.lore, CraftChatMessage::fromComponent));
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(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<String> lore) { // too tired to think if .clone is better
if (lore == null) {
public void setLore(List<String> 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)) {

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

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