mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 15:17:17 +01:00
readd old UUID format patch
This commit is contained in:
parent
ba8512a0d8
commit
f1fc1b30be
1 changed files with 17 additions and 20 deletions
|
@ -8,7 +8,7 @@ We have stored UUID in plenty of places that did not get DFU'd
|
||||||
So just look for old format and load it if it exists.
|
So just look for old format and load it if it exists.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||||
index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c9555921290d875 100644
|
index df246d69591e1a5822a0109c99b0f67996da71fa..4e005b7b062e3231f564d284887ea1c2783a4e7d 100644
|
||||||
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
|
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||||
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||||
@@ -232,6 +232,12 @@ public class CompoundTag implements Tag {
|
@@ -232,6 +232,12 @@ public class CompoundTag implements Tag {
|
||||||
|
@ -45,22 +45,19 @@ index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c955592
|
||||||
Tag tag = this.get(key);
|
Tag tag = this.get(key);
|
||||||
return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
|
return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
diff --git a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
index 3e395d575fab2348cd30a88511a194aba2d8e4ba..f3b11b08358fdd93464cd19b05047e10727a5799 100644
|
index d8ed3404e8c3c61b2daff110ef32ef890a77a461..f5f1156744b45da3873f68c080ba2a55cbaec506 100644
|
||||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
+++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||||
@@ -65,6 +65,14 @@ public final class NbtUtils {
|
@@ -20,9 +20,10 @@ public record ResolvableProfile(Optional<String> name, Optional<UUID> id, Proper
|
||||||
@Nullable
|
instance -> instance.group(
|
||||||
public static GameProfile readGameProfile(CompoundTag nbt) {
|
ExtraCodecs.PLAYER_NAME.optionalFieldOf("name").forGetter(ResolvableProfile::name),
|
||||||
UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID;
|
UUIDUtil.CODEC.optionalFieldOf("id").forGetter(ResolvableProfile::id),
|
||||||
+ // Paper start - Support old UUID format
|
+ UUIDUtil.STRING_CODEC.lenientOptionalFieldOf("Id").forGetter($ -> Optional.empty()), // Paper
|
||||||
+ if (nbt.contains("Id", Tag.TAG_STRING)) {
|
ExtraCodecs.PROPERTY_MAP.optionalFieldOf("properties", new PropertyMap()).forGetter(ResolvableProfile::properties)
|
||||||
+ try {
|
)
|
||||||
+ uUID = UUID.fromString(nbt.getString("Id"));
|
- .apply(instance, ResolvableProfile::new)
|
||||||
+ } catch (IllegalArgumentException ignored){
|
+ .apply(instance, (s, uuid, uuid2, propertyMap) -> new ResolvableProfile(s, uuid2.or(() -> uuid), propertyMap)) // Paper
|
||||||
+ }
|
);
|
||||||
+ }
|
public static final Codec<ResolvableProfile> CODEC = Codec.withAlternative(
|
||||||
+ // Paper end - Support old UUID format
|
FULL_CODEC, ExtraCodecs.PLAYER_NAME, name -> new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())
|
||||||
String string = nbt.getString("Name");
|
|
||||||
|
|
||||||
try {
|
|
Loading…
Reference in a new issue