diff --git a/README.md b/README.md index 094abcb..fe1feda 100644 --- a/README.md +++ b/README.md @@ -395,6 +395,7 @@ portalInfoServer=Server: %server% players accidentally losing the creatures during teleportation - Fixes a potential exception when a gate's open-block or closed-block is set to a material which isn't a block - Fixes a potential exception when a portal without a sign has an invalid gate type +- Prevents loading of gate files using non-blocks as part of the border #### \[Version 0.9.2.1] EpicKnarvik97 fork diff --git a/src/main/java/net/knarcraft/stargate/portal/property/gate/Gate.java b/src/main/java/net/knarcraft/stargate/portal/property/gate/Gate.java index 18cbf12..684b6d2 100644 --- a/src/main/java/net/knarcraft/stargate/portal/property/gate/Gate.java +++ b/src/main/java/net/knarcraft/stargate/portal/property/gate/Gate.java @@ -69,6 +69,15 @@ public class Gate { return layout; } + /** + * Gets a copy of the character to material mapping for this gate + * + * @return

The character to material map

+ */ + public Map getCharacterMaterialMap() { + return new HashMap<>(characterMaterialMap); + } + /** * Gets the material type used for this gate's control blocks * diff --git a/src/main/java/net/knarcraft/stargate/portal/property/gate/GateHandler.java b/src/main/java/net/knarcraft/stargate/portal/property/gate/GateHandler.java index 0596ed1..9558175 100644 --- a/src/main/java/net/knarcraft/stargate/portal/property/gate/GateHandler.java +++ b/src/main/java/net/knarcraft/stargate/portal/property/gate/GateHandler.java @@ -189,7 +189,7 @@ public class GateHandler { */ 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) { Stargate.logSevere(String.format(failString, "Gates must have exactly 2 control points.")); return false; @@ -199,16 +199,24 @@ public class GateHandler { 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; } + + for (Material material : gate.getCharacterMaterialMap().values()) { + if (!material.isBlock()) { + Stargate.logSevere(String.format(failString, "Every gate border block must be a type of block.")); + return false; + } + } + return true; }