Skip to content

Commit

Permalink
NPE fix for EntityHuman NPCs that are already saved (CloudburstMC#1353
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Sleepybear authored Apr 16, 2020
1 parent 9ef9e12 commit e69ac84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/cn/nukkit/entity/EntityHuman.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,17 @@ protected void initEntity() {
}
if (skinTag.contains("PieceTintColors")) {
ListTag<CompoundTag> tintColors = skinTag.getList("PieceTintColors", CompoundTag.class);
for (CompoundTag tintColor: tintColors.getAll()) {
for (CompoundTag tintColor : tintColors.getAll()) {
newSkin.getTintColors().add(new PersonaPieceTint(
tintColor.getString("PieceType"),
tintColor.getList("Colors", StringTag.class).getAll().stream()
.map(stringTag -> stringTag.data).collect(Collectors.toList())
));
}
}
newSkin.setTrusted(skinTag.getBoolean("IsTrustedSkin"));
if (skinTag.contains("IsTrustedSkin")) {
newSkin.setTrusted(skinTag.getBoolean("IsTrustedSkin"));
}
this.setSkin(newSkin);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/entity/data/Skin.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Skin {
private String capeId;
private String skinColor = "#0";
private String armSize = "wide";
private boolean trusted;
private boolean trusted = false;

public boolean isValid() {
return isValidSkin() && isValidResourcePatch();
Expand Down

0 comments on commit e69ac84

Please sign in to comment.