diff --git a/README.md b/README.md index 546f3cc..210888a 100644 --- a/README.md +++ b/README.md @@ -138,11 +138,21 @@ X*.X XX ``` The keys `portal-open` and `portal-closed` are used to define the material in the gate when it is open or closed. -The key `button` is used to define the type of button that is generated for this gate. It must be a button material. +The key `button` is used to define the type of button that is generated for this gate. It can be a button (of any type), +a type of wall coral (dead or alive), a type of shulker box or a chest. `X` and `-` are used to define block types for the layout (Any single-character can be used, such as `#`). In the gate format, you can see we use `X` to show where obsidian must be, `-` where the controls (Button/sign) are. You will also notice a `*` in the gate layout, this is the "exit point" of the gate, the block at which the player will teleport in front of. +# Underwater Portals +You can add a custom portal which will work underwater. You need to use `WATER`, not `AIR`, for the `portal-closed` material. + +The button must be a type of wall coral, like `BRAIN_CORAL_WALL_FAN` or `DEAD_BRAIN_CORAL_WALL_FAN`. + +Using `KELP_PLANT` as `portal-open` looks the part, but there are no particular restrictions. + +Any solid block can be used for the frame. + # Configuration ``` default-gate-network - The default gate network @@ -228,6 +238,7 @@ bungeeSign=Teleport to - Uses text from the language files in more places - Changes how backup language works, causing english strings to be shown if not available from the chosen language - Removes some pre-UUID code + - Adds underwater portals #### \[Version 0.8.0.3] PseudoKnight fork - Fix economy - Add custom buttons diff --git a/src/main/java/net/knarcraft/stargate/Gate.java b/src/main/java/net/knarcraft/stargate/Gate.java index 4a41ae5..8ca6ddd 100644 --- a/src/main/java/net/knarcraft/stargate/Gate.java +++ b/src/main/java/net/knarcraft/stargate/Gate.java @@ -1,7 +1,6 @@ package net.knarcraft.stargate; import org.bukkit.Material; -import org.bukkit.Tag; import org.bukkit.block.Block; import java.io.BufferedWriter; @@ -399,7 +398,7 @@ public class Gate { return null; } - if (!Tag.BUTTONS.isTagged(gate.button) && !MaterialHelper.isWallCoral(gate.button)) { + if (!MaterialHelper.isButtonCompatible(gate.button)) { Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gate button must be a type of button."); return null; } diff --git a/src/main/java/net/knarcraft/stargate/MaterialHelper.java b/src/main/java/net/knarcraft/stargate/MaterialHelper.java index 808c774..8a2e149 100644 --- a/src/main/java/net/knarcraft/stargate/MaterialHelper.java +++ b/src/main/java/net/knarcraft/stargate/MaterialHelper.java @@ -22,4 +22,14 @@ public class MaterialHelper { material.equals(Material.DEAD_TUBE_CORAL_WALL_FAN); } + /** + * Checks whether the given material can be used as a button + * @param material

The material to check

+ * @return

True if the material can be used as a button

+ */ + public static boolean isButtonCompatible(Material material) { + return Tag.BUTTONS.isTagged(material) || isWallCoral(material) || Tag.SHULKER_BOXES.isTagged(material) || + material == Material.CHEST; + } + } diff --git a/src/main/java/net/knarcraft/stargate/PlayerEventsListener.java b/src/main/java/net/knarcraft/stargate/PlayerEventsListener.java index 8360047..44216b5 100644 --- a/src/main/java/net/knarcraft/stargate/PlayerEventsListener.java +++ b/src/main/java/net/knarcraft/stargate/PlayerEventsListener.java @@ -1,7 +1,6 @@ package net.knarcraft.stargate; import org.bukkit.GameMode; -import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.data.type.WallSign; @@ -230,7 +229,7 @@ public class PlayerEventsListener implements Listener { } // Implement right-click to toggle a stargate, gets around spawn protection problem. - if (Tag.BUTTONS.isTagged(block.getType()) || MaterialHelper.isWallCoral(block.getType())) { + if (MaterialHelper.isButtonCompatible(block.getType())) { if (MaterialHelper.isWallCoral(block.getType())) { if (previousEvent != null && diff --git a/src/main/java/net/knarcraft/stargate/Stargate.java b/src/main/java/net/knarcraft/stargate/Stargate.java index 68c98ca..01ceb9e 100644 --- a/src/main/java/net/knarcraft/stargate/Stargate.java +++ b/src/main/java/net/knarcraft/stargate/Stargate.java @@ -6,7 +6,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Server; -import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.EndGateway; @@ -846,7 +845,7 @@ public class Stargate extends JavaPlugin { // Handle keeping portal material and buttons around if (block.getType() == Material.NETHER_PORTAL) { portal = Portal.getByEntrance(block); - } else if (Tag.BUTTONS.isTagged(block.getType()) || MaterialHelper.isWallCoral(block.getType())) { + } else if (MaterialHelper.isButtonCompatible(block.getType())) { portal = Portal.getByControl(block); } if (portal != null) event.setCancelled(true);