mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
#411 More block sign error handling
This commit is contained in:
parent
186dd1192b
commit
d1654670ab
@ -50,10 +50,8 @@ public class BlockSign extends DSign {
|
||||
public void onInit() {
|
||||
if (lines[1].isEmpty()) {
|
||||
offBlock = VanillaItem.AIR;
|
||||
} else if (lines[2].isEmpty()) {
|
||||
onBlock = VanillaItem.AIR;
|
||||
}
|
||||
|
||||
} else {
|
||||
String[] line1 = lines[1].split(",");
|
||||
offBlock = plugin.getCaliburn().getExItem(line1[0]);
|
||||
if (offBlock == null) {
|
||||
@ -63,7 +61,12 @@ public class BlockSign extends DSign {
|
||||
if (line1.length > 1) {
|
||||
offBlockData = (byte) NumberUtil.parseInt(line1[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (lines[2].isEmpty()) {
|
||||
onBlock = VanillaItem.AIR;
|
||||
|
||||
} else {
|
||||
String[] line2 = lines[2].split(",");
|
||||
onBlock = plugin.getCaliburn().getExItem(line2[0]);
|
||||
if (onBlock == null) {
|
||||
@ -73,9 +76,15 @@ public class BlockSign extends DSign {
|
||||
if (line2.length > 1) {
|
||||
onBlockData = (byte) NumberUtil.parseInt(line2[1]);
|
||||
}
|
||||
}
|
||||
|
||||
getSign().getBlock().setType(offBlock.getMaterial());
|
||||
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());
|
||||
try {
|
||||
getSign().getBlock().setData(onBlockData);
|
||||
} catch (IllegalArgumentException exception) {
|
||||
markAsErroneous("onBlock data value " + onBlockData + " cannot be applied to given type " + onBlock.getId());
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user