Skip to content

Commit

Permalink
Properly write properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed May 9, 2024
1 parent 91193cf commit fd43ca5
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,25 @@ private void updateProfileTag(final CompoundTag tag, final CompoundTag profileTa
skullOwnerTag.put("Id", idTag);
}

final Tag propertiesListTag = profileTag.remove("properties");
if (!(propertiesListTag instanceof ListTag<?>)) {
final ListTag<CompoundTag> propertiesListTag = profileTag.getListTag("properties", CompoundTag.class);
if (propertiesListTag == null) {
return;
}

final CompoundTag propertiesTag = new CompoundTag();
for (final Tag propertyTag : ((ListTag<?>) propertiesListTag)) {
if (!(propertyTag instanceof CompoundTag)) {
continue;
}

final CompoundTag propertyCompoundTag = (CompoundTag) propertyTag;
final String property = propertyCompoundTag.getString("name", "");
final String value = propertyCompoundTag.getString("value", "");
final String signature = propertyCompoundTag.getString("signature");
for (final CompoundTag propertyTag : propertiesListTag) {
final String property = propertyTag.getString("name", "");
final String value = propertyTag.getString("value", "");
final String signature = propertyTag.getString("signature");

final ListTag<CompoundTag> list = new ListTag<>(CompoundTag.class);
final CompoundTag updatedPropertyTag = new CompoundTag();
updatedPropertyTag.putString("Value", value);
if (signature != null) {
updatedPropertyTag.putString("Signature", signature);
}
propertiesTag.put(property, updatedPropertyTag);
list.add(updatedPropertyTag);
propertiesTag.put(property, list);
}
skullOwnerTag.put("Properties", propertiesTag);
}
Expand Down

0 comments on commit fd43ca5

Please sign in to comment.