Update block signs; resolves #333 (for now)

This commit is contained in:
Daniel Saukel 2018-05-31 20:39:43 +02:00
parent 7e65ff1ebc
commit 3d14c0ba24
2 changed files with 13 additions and 22 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.erethon</groupId> <groupId>de.erethon</groupId>
<artifactId>dungeonsxl</artifactId> <artifactId>dungeonsxl</artifactId>
<version>0.16-SNAPSHOT</version> <version>0.16</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>DungeonsXL</name> <name>DungeonsXL</name>
<url>https://dre2n.github.io</url> <url>https://dre2n.github.io</url>

View File

@ -16,9 +16,10 @@
*/ */
package de.erethon.dungeonsxl.sign; package de.erethon.dungeonsxl.sign;
import de.erethon.caliburn.item.ExItem;
import de.erethon.caliburn.item.VanillaItem;
import de.erethon.commons.misc.NumberUtil; import de.erethon.commons.misc.NumberUtil;
import de.erethon.dungeonsxl.world.DGameWorld; import de.erethon.dungeonsxl.world.DGameWorld;
import org.bukkit.Material;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
/** /**
@ -31,8 +32,8 @@ public class BlockSign extends DSign {
// Variables // Variables
private boolean initialized; private boolean initialized;
private boolean active; private boolean active;
private int offBlockId = 0; private ExItem offBlock = VanillaItem.AIR;
private int onBlockId = 0; private ExItem onBlock = VanillaItem.AIR;
private byte offBlockData = 0x0; private byte offBlockData = 0x0;
private byte onBlockData = 0x0; private byte onBlockData = 0x0;
@ -49,12 +50,7 @@ public class BlockSign extends DSign {
public void onInit() { public void onInit() {
if (!lines[1].isEmpty()) { if (!lines[1].isEmpty()) {
String line1[] = lines[1].split(","); String line1[] = lines[1].split(",");
Material offBlock = Material.matchMaterial(line1[0]); offBlock = plugin.getCaliburn().getExItem(line1[0]);
if (offBlock != null) {
offBlockId = offBlock.getId();
} else {
offBlockId = NumberUtil.parseInt(line1[0]);
}
if (line1.length > 1) { if (line1.length > 1) {
offBlockData = (byte) NumberUtil.parseInt(line1[1]); offBlockData = (byte) NumberUtil.parseInt(line1[1]);
} }
@ -62,28 +58,22 @@ public class BlockSign extends DSign {
if (!lines[2].isEmpty()) { if (!lines[2].isEmpty()) {
String line2[] = lines[2].split(","); String line2[] = lines[2].split(",");
Material onBlock = Material.matchMaterial(line2[0]); onBlock = plugin.getCaliburn().getExItem(line2[0]);
if (onBlock != null) {
onBlockId = onBlock.getId();
} else {
onBlockId = NumberUtil.parseInt(line2[0]);
}
if (line2.length > 1) { if (line2.length > 1) {
onBlockData = (byte) NumberUtil.parseInt(line2[1]); onBlockData = (byte) NumberUtil.parseInt(line2[1]);
} }
} }
getSign().getBlock().setTypeIdAndData(offBlockId, offBlockData, true); getSign().getBlock().setType(offBlock.getMaterial());
getSign().getBlock().setData(offBlockData);
initialized = true; initialized = true;
} }
@Override @Override
public void onTrigger() { public void onTrigger() {
if (initialized && !active) { if (initialized && !active) {
getSign().getBlock().setTypeIdAndData(onBlockId, onBlockData, true); getSign().getBlock().setType(onBlock.getMaterial());
getSign().getBlock().setData(onBlockData);
active = true; active = true;
} }
} }
@ -91,7 +81,8 @@ public class BlockSign extends DSign {
@Override @Override
public void onDisable() { public void onDisable() {
if (initialized && active) { if (initialized && active) {
getSign().getBlock().setTypeIdAndData(offBlockId, offBlockData, true); getSign().getBlock().setType(offBlock.getMaterial());
getSign().getBlock().setData(offBlockData);
active = false; active = false;
} }
} }