mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-25 03:55:22 +01:00
#411 More block sign error handling
This commit is contained in:
parent
186dd1192b
commit
d1654670ab
@ -50,32 +50,41 @@ public class BlockSign extends DSign {
|
|||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (lines[1].isEmpty()) {
|
if (lines[1].isEmpty()) {
|
||||||
offBlock = VanillaItem.AIR;
|
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;
|
onBlock = VanillaItem.AIR;
|
||||||
}
|
|
||||||
|
|
||||||
String[] line1 = lines[1].split(",");
|
} else {
|
||||||
offBlock = plugin.getCaliburn().getExItem(line1[0]);
|
String[] line2 = lines[2].split(",");
|
||||||
if (offBlock == null) {
|
onBlock = plugin.getCaliburn().getExItem(line2[0]);
|
||||||
markAsErroneous("Could not recognize offBlock, input: " + lines[1]);
|
if (onBlock == null) {
|
||||||
return;
|
markAsErroneous("Could not recognize onBlock, input: " + lines[2]);
|
||||||
}
|
return;
|
||||||
if (line1.length > 1) {
|
}
|
||||||
offBlockData = (byte) NumberUtil.parseInt(line1[1]);
|
if (line2.length > 1) {
|
||||||
}
|
onBlockData = (byte) NumberUtil.parseInt(line2[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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSign().getBlock().setType(offBlock.getMaterial());
|
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;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +92,12 @@ public class BlockSign extends DSign {
|
|||||||
public void onTrigger() {
|
public void onTrigger() {
|
||||||
if (initialized && !active) {
|
if (initialized && !active) {
|
||||||
getSign().getBlock().setType(onBlock.getMaterial());
|
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;
|
active = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user