From 79906fae0ad21558e03a74559a5cb3647c2c65c3 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sat, 4 Apr 2020 02:45:51 -0500 Subject: [PATCH] Fix NPE if banner had no patterns --- .../block/entity/BannerBlockEntityTranslator.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java index a5ed59947..d0d431071 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BannerBlockEntityTranslator.java @@ -41,13 +41,14 @@ public class BannerBlockEntityTranslator extends BlockEntityTranslator { List> tags = new ArrayList<>(); ListTag patterns = tag.get("Patterns"); List tagsList = new ArrayList<>(); - for (com.github.steveice10.opennbt.tag.builtin.Tag patternTag : patterns.getValue()) { - tagsList.add(getPattern((CompoundTag) patternTag)); + if (tag.contains("Patterns")) { + for (com.github.steveice10.opennbt.tag.builtin.Tag patternTag : patterns.getValue()) { + tagsList.add(getPattern((CompoundTag) patternTag)); + } + com.nukkitx.nbt.tag.ListTag bedrockPatterns = + new com.nukkitx.nbt.tag.ListTag<>("Patterns", com.nukkitx.nbt.tag.CompoundTag.class, tagsList); + tags.add(bedrockPatterns); } - com.nukkitx.nbt.tag.ListTag bedrockPatterns = - new com.nukkitx.nbt.tag.ListTag<>("Patterns", com.nukkitx.nbt.tag.CompoundTag.class, tagsList); - tags.add(bedrockPatterns); - if (tag.contains("CustomName")) { tags.add(new StringTag("CustomName", (String) tag.get("CustomName").getValue())); }