mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-03 02:20:51 +02:00
If a playerdata doesn't contain a valid, loaded world, reset to the main world spawn point
62 lines
3.7 KiB
Diff
62 lines
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: SoSeDiK <mrsosedik@gmail.com>
|
|
Date: Thu, 26 May 2022 03:30:05 +0300
|
|
Subject: [PATCH] Deep clone unhandled nbt tags
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
index 2510297df2f6ca80672c1dcbd35c0b1e0ce18ccb..9105c420c0c8d2285f5f45c184d54e9a5c5fbc57 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
|
@@ -304,7 +304,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
|
|
|
private CompoundTag internalTag;
|
|
- final Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper
|
|
+ Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper // Paper - remove final
|
|
private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftMetaItem.DATA_TYPE_REGISTRY);
|
|
|
|
private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only
|
|
@@ -345,8 +345,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
this.destroyableKeys = new java.util.HashSet<>(meta.destroyableKeys);
|
|
}
|
|
// Paper end
|
|
- this.unhandledTags.putAll(meta.unhandledTags);
|
|
- this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
|
|
+ // Paper start - Deep clone unhandled nbt tags
|
|
+ meta.unhandledTags.forEach((key, tag) -> this.unhandledTags.put(key, tag.copy()));
|
|
+ this.persistentDataContainer.putAll(meta.persistentDataContainer.getTagsCloned());
|
|
+ // Paper end
|
|
|
|
this.internalTag = meta.internalTag;
|
|
if (this.internalTag != null) {
|
|
@@ -1394,7 +1396,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
|
if (this.hasAttributeModifiers()) {
|
|
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
|
|
}
|
|
- clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getRaw(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
|
+ // Paper start - Deep clone unhandled nbt tags
|
|
+ clone.persistentDataContainer = new CraftPersistentDataContainer(this.persistentDataContainer.getTagsCloned(), CraftMetaItem.DATA_TYPE_REGISTRY);
|
|
+ clone.unhandledTags = new TreeMap<>(this.unhandledTags);
|
|
+ clone.unhandledTags.replaceAll((key, tag) -> tag.copy());
|
|
+ // Paper end - Deep clone unhandled nbt tags
|
|
clone.hideFlag = this.hideFlag;
|
|
clone.unbreakable = this.unbreakable;
|
|
clone.damage = this.damage;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
|
index 3351962e85438ed05215ce0d159799ed4707afde..8d5789cc6001fdf68c2d3f7ee3dd8fcafb9c831f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java
|
|
@@ -189,5 +189,11 @@ public class CraftPersistentDataContainer implements PersistentDataContainer {
|
|
this.putAll(compound);
|
|
}
|
|
}
|
|
+
|
|
+ public Map<String, Tag> getTagsCloned() {
|
|
+ final Map<String, Tag> tags = new HashMap<>();
|
|
+ this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy()));
|
|
+ return tags;
|
|
+ }
|
|
// Paper end
|
|
}
|