Fixes a potential exception when a gate's open-block or closed-block is not a block

This commit is contained in:
Kristian Knarvik 2021-11-25 03:25:22 +01:00
parent 0740cd0a66
commit 4b34ea3cf5

View File

@ -188,14 +188,25 @@ public class GateHandler {
* @return <p>True if the gate is valid. False otherwise</p> * @return <p>True if the gate is valid. False otherwise</p>
*/ */
private static boolean validateGate(Gate gate, String fileName) { private static boolean validateGate(Gate gate, String fileName) {
String failString = String.format("Could not load Gate %s", fileName) + " - %s";
if (gate.getLayout().getControls().length != 2) { if (gate.getLayout().getControls().length != 2) {
Stargate.logSevere(String.format("Could not load Gate %s - Gates must have exactly 2 control points.", Stargate.logSevere(String.format(failString, "Gates must have exactly 2 control points."));
fileName));
return false; return false;
} }
if (!MaterialHelper.isButtonCompatible(gate.getPortalButton())) { if (!MaterialHelper.isButtonCompatible(gate.getPortalButton())) {
Stargate.logSevere(String.format("Could not load Gate %s - Gate button must be a type of button.", fileName)); Stargate.logSevere(String.format(failString, "Gate button must be a type of button."));
return false;
}
if (!gate.getPortalOpenBlock().isBlock()) {
Stargate.logSevere(String.format(failString, "Gate open block must be a type of block."));
return false;
}
if (!gate.getPortalClosedBlock().isBlock()) {
Stargate.logSevere(String.format(failString, "Gate closed block must be a type of block."));
return false; return false;
} }
return true; return true;