mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-15 23:25:32 +01:00
Fix NPE when reading skull-owner uuidInts
This commit is contained in:
parent
cca1fbc826
commit
7895222816
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.world.block.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -31,6 +32,7 @@
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class SkullBlockEntity extends BlockEntity {
|
||||
private final @Nullable String noteBlockSound;
|
||||
private final @Nullable String extraType;
|
||||
@ -47,18 +49,6 @@ protected SkullBlockEntity(Map<String, Object> data) {
|
||||
this.skullOwner = ownerData != null ? new SkullOwner(ownerData) : null;
|
||||
}
|
||||
|
||||
public @Nullable String getNoteBlockSound() {
|
||||
return noteBlockSound;
|
||||
}
|
||||
|
||||
public @Nullable String getExtraType() {
|
||||
return extraType;
|
||||
}
|
||||
|
||||
public SkullOwner getSkullOwner() {
|
||||
return skullOwner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SkullBlockEntity{" +
|
||||
@ -68,6 +58,7 @@ public String toString() {
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class SkullOwner {
|
||||
private final @Nullable UUID id;
|
||||
private final @Nullable String name;
|
||||
@ -75,8 +66,14 @@ public static class SkullOwner {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private SkullOwner(Map<String, Object> data) {
|
||||
int[] uuidInts = (int[]) data.get("Id");
|
||||
this.id = new UUID((long) uuidInts[0] << 32 | uuidInts[1], (long) uuidInts[2] << 32 | uuidInts[3]);
|
||||
int @Nullable [] uuidInts = (int[]) data.get("Id");
|
||||
|
||||
if (uuidInts == null || uuidInts.length != 4) {
|
||||
this.id = null;
|
||||
} else {
|
||||
this.id = new UUID((long) uuidInts[0] << 32 | uuidInts[1], (long) uuidInts[2] << 32 | uuidInts[3]);
|
||||
}
|
||||
|
||||
this.name = (String) data.get("Name");
|
||||
|
||||
Map<String, Object> properties = (Map<String, Object>) data.getOrDefault("Properties", Map.of());
|
||||
@ -87,18 +84,6 @@ private SkullOwner(Map<String, Object> data) {
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<Texture> getTextures() {
|
||||
return textures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SkullOwner{" +
|
||||
@ -109,6 +94,7 @@ public String toString() {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class Texture {
|
||||
private final @Nullable String signature;
|
||||
private final String value;
|
||||
@ -118,14 +104,6 @@ private Texture(Map<String, Object> data) {
|
||||
this.value = (String) data.getOrDefault("value", "");
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Texture{" +
|
||||
|
Loading…
Reference in New Issue
Block a user