diff --git a/src/main/java/net/knarcraft/stargate/portal/Gate.java b/src/main/java/net/knarcraft/stargate/portal/Gate.java index 1a7b6d6..9fdc3d8 100644 --- a/src/main/java/net/knarcraft/stargate/portal/Gate.java +++ b/src/main/java/net/knarcraft/stargate/portal/Gate.java @@ -265,7 +265,7 @@ public class Gate { bufferedWriter.newLine(); //Save the gate layout - layout.save(bufferedWriter); + layout.saveLayout(bufferedWriter); bufferedWriter.close(); } catch (IOException ex) { diff --git a/src/main/java/net/knarcraft/stargate/portal/GateLayout.java b/src/main/java/net/knarcraft/stargate/portal/GateLayout.java index 38e121a..00d3278 100644 --- a/src/main/java/net/knarcraft/stargate/portal/GateLayout.java +++ b/src/main/java/net/knarcraft/stargate/portal/GateLayout.java @@ -5,6 +5,7 @@ import net.knarcraft.stargate.container.RelativeBlockVector; import java.io.BufferedWriter; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -12,7 +13,7 @@ import java.util.List; * *
The gate layout parses a layout described by a Character matrix and stores the different parts of the gate as * relative block vectors. All relative vectors has an origin in the top-left block when looking at the gate's front - * (the side with the sign)
+ * (the side with the sign). The origin of the relative vectors can also be seen as 0,0 in the character matrix. */ public class GateLayout { @@ -26,7 +27,7 @@ public class GateLayout { /** * Instantiates a new gate layout * - * @param layoutA character array describing the layout
+ * @param layoutA character matrix describing the layout
*/ public GateLayout(Character[][] layout) { this.layout = layout; @@ -43,7 +44,9 @@ public class GateLayout { } /** - * Gets the locations of entrances for this gate + * Gets the locations of all entrances for this gate + * + *Entrances contain both the portal entrance blocks and the portal exit blocks.
* * @returnThe locations of entrances for this gate
*/ @@ -73,9 +76,12 @@ public class GateLayout { } /** - * Gets other possible exits of the gate + * Gets all possible exit locations defined in the layout * - * @returnOther possible gate exits
+ *This returns all blocks usable as exits. This basically means it returns the lowest block in each opening of + * the gate layout.
+ * + * @returnAll possible exits
*/ public ListThe control blocks are the blocks where a sign can be placed to create a portal.
+ *The control blocks are the blocks where a sign can be placed to create a portal. The control block without a + * sign will be used for the button if necessary. There will always be exactly two control blocks.
* * @returnThe locations of the control blocks for this gate
*/ @@ -98,44 +105,24 @@ public class GateLayout { * @param bufferedWriterThe buffered writer to write to
* @throws IOExceptionIf unable to write to the buffered writer
*/ - public void save(BufferedWriter bufferedWriter) throws IOException { + public void saveLayout(BufferedWriter bufferedWriter) throws IOException { for (Character[] line : this.layout) { - for (Character symbol : line) { - bufferedWriter.append(symbol); - } + bufferedWriter.append(Arrays.toString(line)); bufferedWriter.newLine(); } } /** - * Reads the gate layout to relative block vectors + * Reads the layout and stores key information + * + *This methods reads the layout and stores exits, entrances, border blocks and control blocks.
*/ private void readLayout() { ListThe list of control blocks to save to
* @param entranceListThe list of entrances to save to
* @param borderListThe list of border blocks to save to
- * @returnA list of depths of possible extra exits
*/ - private int[] readLayout(ListThe character read
- * @param rowIndexThe row of the read character
- * @param lineIndexThe line of the read character
+ * @param keyThe read character
+ * @param columnIndexThe column containing the read character
+ * @param rowIndexThe row containing the read character
* @param exitDepthsThe list of exit depths to save to
* @param controlListThe list of control blocks to save to
* @param entranceListThe list of entrances to save to
* @param borderListThe list of border blocks to save to
*/ - private void parseLayoutCharacter(Character key, int rowIndex, int lineIndex, int[] exitDepths, + private void parseLayoutCharacter(Character key, int columnIndex, int rowIndex, int[] exitDepths, ListThe character to check
+ * @returnTrue if the character represents an opening
+ */ + private boolean isOpening(Character character) { + return character.equals(GateHandler.getEntranceCharacter()) || character.equals(GateHandler.getExitCharacter()); + } + }