diff --git a/src/main/java/de/erethon/dungeonsxl/sign/BlockSign.java b/src/main/java/de/erethon/dungeonsxl/sign/BlockSign.java index f665f16a..7279fb5e 100644 --- a/src/main/java/de/erethon/dungeonsxl/sign/BlockSign.java +++ b/src/main/java/de/erethon/dungeonsxl/sign/BlockSign.java @@ -50,32 +50,41 @@ public class BlockSign extends DSign { public void onInit() { if (lines[1].isEmpty()) { offBlock = VanillaItem.AIR; - } else if (lines[2].isEmpty()) { + + } else { + String[] line1 = lines[1].split(","); + offBlock = plugin.getCaliburn().getExItem(line1[0]); + if (offBlock == null) { + markAsErroneous("Could not recognize offBlock, input: " + lines[1]); + return; + } + if (line1.length > 1) { + offBlockData = (byte) NumberUtil.parseInt(line1[1]); + } + } + + if (lines[2].isEmpty()) { onBlock = VanillaItem.AIR; - } - String[] line1 = lines[1].split(","); - offBlock = plugin.getCaliburn().getExItem(line1[0]); - if (offBlock == null) { - markAsErroneous("Could not recognize offBlock, input: " + lines[1]); - return; - } - if (line1.length > 1) { - offBlockData = (byte) NumberUtil.parseInt(line1[1]); - } - - String[] line2 = lines[2].split(","); - onBlock = plugin.getCaliburn().getExItem(line2[0]); - if (onBlock == null) { - markAsErroneous("Could not recognize onBlock, input: " + lines[2]); - return; - } - if (line2.length > 1) { - onBlockData = (byte) NumberUtil.parseInt(line2[1]); + } else { + String[] line2 = lines[2].split(","); + onBlock = plugin.getCaliburn().getExItem(line2[0]); + if (onBlock == null) { + markAsErroneous("Could not recognize onBlock, input: " + lines[2]); + return; + } + if (line2.length > 1) { + onBlockData = (byte) NumberUtil.parseInt(line2[1]); + } } getSign().getBlock().setType(offBlock.getMaterial()); - getSign().getBlock().setData(offBlockData); + try { + getSign().getBlock().setData(offBlockData); + } catch (IllegalArgumentException exception) { + markAsErroneous("offBlock data value " + offBlockData + " cannot be applied to given type " + offBlock.getId()); + return; + } initialized = true; } @@ -83,7 +92,12 @@ public class BlockSign extends DSign { public void onTrigger() { if (initialized && !active) { getSign().getBlock().setType(onBlock.getMaterial()); - getSign().getBlock().setData(onBlockData); + try { + getSign().getBlock().setData(onBlockData); + } catch (IllegalArgumentException exception) { + markAsErroneous("onBlock data value " + onBlockData + " cannot be applied to given type " + onBlock.getId()); + return; + } active = true; } }