From 9cbf8178eab0a329ae40bae3d47084ea814d4754 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 29 Jun 2019 11:11:22 -0400 Subject: [PATCH] Fix setting player heads with owner name. --- .../com/sk89q/worldedit/blocks/SkullBlock.java | 17 +++++++++-------- .../factory/parser/DefaultBlockParser.java | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java index e65ab3ec1..944b4ab42 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java @@ -83,14 +83,15 @@ public class SkullBlock extends BaseBlock { @Override public String getNbtId() { - return "Skull"; + return "skull"; } @Override public CompoundTag getNbtData() { Map values = new HashMap<>(); - if (owner == null) owner = ""; - values.put("ExtraType", new StringTag(owner)); + Map inner = new HashMap<>(); + inner.put("Name", new StringTag(owner)); + values.put("Owner", new CompoundTag(inner)); return new CompoundTag(values); } @@ -105,13 +106,13 @@ public class SkullBlock extends BaseBlock { Tag t; t = values.get("id"); - if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Skull")) { - throw new RuntimeException("'Skull' tile entity expected"); + if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals(getNbtId())) { + throw new RuntimeException(String.format("'%s' tile entity expected", getNbtId())); } - t = values.get("ExtraType"); - if (t instanceof StringTag) { - owner = ((StringTag) t).getValue(); + t = values.get("Owner"); + if (t instanceof CompoundTag) { + setOwner(((CompoundTag) t).getValue().get("Name").getValue().toString()); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 32736265c..5ef91a497 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -42,7 +42,6 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockCategories; -import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes;