mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 06:25:15 +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.
|
||||
|
||||
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
|
||||
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
@@ -232,6 +232,12 @@ public class CompoundTag implements Tag {
|
||||
|
@ -45,22 +45,19 @@ index c7945686a4ee50d7a9d5f1173aa90e456f68b410..23916b011ed0645ab284fb080c955592
|
|||
Tag tag = this.get(key);
|
||||
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
|
||||
index 3e395d575fab2348cd30a88511a194aba2d8e4ba..f3b11b08358fdd93464cd19b05047e10727a5799 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -65,6 +65,14 @@ public final class NbtUtils {
|
||||
@Nullable
|
||||
public static GameProfile readGameProfile(CompoundTag nbt) {
|
||||
UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID;
|
||||
+ // Paper start - Support old UUID format
|
||||
+ if (nbt.contains("Id", Tag.TAG_STRING)) {
|
||||
+ try {
|
||||
+ uUID = UUID.fromString(nbt.getString("Id"));
|
||||
+ } catch (IllegalArgumentException ignored){
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Support old UUID format
|
||||
String string = nbt.getString("Name");
|
||||
|
||||
try {
|
||||
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 d8ed3404e8c3c61b2daff110ef32ef890a77a461..f5f1156744b45da3873f68c080ba2a55cbaec506 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/component/ResolvableProfile.java
|
||||
@@ -20,9 +20,10 @@ public record ResolvableProfile(Optional<String> name, Optional<UUID> id, Proper
|
||||
instance -> instance.group(
|
||||
ExtraCodecs.PLAYER_NAME.optionalFieldOf("name").forGetter(ResolvableProfile::name),
|
||||
UUIDUtil.CODEC.optionalFieldOf("id").forGetter(ResolvableProfile::id),
|
||||
+ UUIDUtil.STRING_CODEC.lenientOptionalFieldOf("Id").forGetter($ -> Optional.empty()), // Paper
|
||||
ExtraCodecs.PROPERTY_MAP.optionalFieldOf("properties", new PropertyMap()).forGetter(ResolvableProfile::properties)
|
||||
)
|
||||
- .apply(instance, ResolvableProfile::new)
|
||||
+ .apply(instance, (s, uuid, uuid2, propertyMap) -> new ResolvableProfile(s, uuid2.or(() -> uuid), propertyMap)) // Paper
|
||||
);
|
||||
public static final Codec<ResolvableProfile> CODEC = Codec.withAlternative(
|
||||
FULL_CODEC, ExtraCodecs.PLAYER_NAME, name -> new ResolvableProfile(Optional.of(name), Optional.empty(), new PropertyMap())
|
Loading…
Reference in a new issue