diff --git a/src/com/dre/dungeonsxl/signs/SIGNBlock.java b/src/com/dre/dungeonsxl/signs/SIGNBlock.java index 33e81b80..bd8ee7da 100644 --- a/src/com/dre/dungeonsxl/signs/SIGNBlock.java +++ b/src/com/dre/dungeonsxl/signs/SIGNBlock.java @@ -1,6 +1,7 @@ package com.dre.dungeonsxl.signs; import org.bukkit.block.Sign; +import org.bukkit.Material; import com.dre.dungeonsxl.game.GameWorld; public class SIGNBlock extends DSign { @@ -14,6 +15,8 @@ public class SIGNBlock extends DSign { private boolean active; private int offBlockId = 0; private int onBlockId = 0; + private byte offBlockData = 0x0; + private byte onBlockData = 0x0; public SIGNBlock(Sign sign, GameWorld gworld) { super(sign, gworld); @@ -29,16 +32,40 @@ public class SIGNBlock extends DSign { @Override public void onInit() { String lines[] = sign.getLines(); - offBlockId = p.parseInt(lines[1]); - onBlockId = p.parseInt(lines[2]); - sign.getBlock().setTypeId(offBlockId); + if (!lines[1].equals("")) { + String line1[] = lines[1].split(","); + Material offBlock = Material.matchMaterial(line1[0]); + if (offBlock != null) { + offBlockId = offBlock.getId(); + } else { + offBlockId = p.parseInt(line1[0]); + } + if (line1.length > 1) { + offBlockData = (byte) p.parseInt(line1[1]); + } + } + + if (!lines[2].equals("")) { + String line2[] = lines[2].split(","); + Material onBlock = Material.matchMaterial(line2[0]); + if (onBlock != null) { + onBlockId = onBlock.getId(); + } else { + onBlockId = p.parseInt(line2[0]); + } + if (line2.length > 1) { + onBlockData = (byte) p.parseInt(line2[1]); + } + } + + sign.getBlock().setTypeIdAndData(offBlockId, offBlockData, true); initialized = true; } @Override public void onTrigger() { if (initialized && !active) { - sign.getBlock().setTypeId(onBlockId); + sign.getBlock().setTypeIdAndData(onBlockId, onBlockData, true); active = true; } } @@ -46,7 +73,7 @@ public class SIGNBlock extends DSign { @Override public void onDisable() { if (initialized && active) { - sign.getBlock().setTypeId(offBlockId); + sign.getBlock().setTypeIdAndData(offBlockId, offBlockData, true); active = false; } }