diff --git a/src/net/TheDgtl/Stargate/Gate.java b/src/net/TheDgtl/Stargate/Gate.java index 088182e..31bb93f 100644 --- a/src/net/TheDgtl/Stargate/Gate.java +++ b/src/net/TheDgtl/Stargate/Gate.java @@ -13,6 +13,7 @@ import java.util.Scanner; import java.util.logging.Level; import org.bukkit.Material; +import org.bukkit.Tag; import org.bukkit.block.Block; /** @@ -53,6 +54,7 @@ public class Gate { private final HashMap exits = new HashMap<>(); private Material portalBlockOpen = Material.NETHER_PORTAL; private Material portalBlockClosed = Material.AIR; + private Material button = Material.STONE_BUTTON; // Economy information private int useCost = -1; @@ -120,6 +122,7 @@ public class Gate { writeConfig(bw, "portal-open", portalBlockOpen.name()); writeConfig(bw, "portal-closed", portalBlockClosed.name()); + writeConfig(bw, "button", button.name()); if (useCost != -1) writeConfig(bw, "usecost", useCost); if (createCost != -1) @@ -224,7 +227,11 @@ public class Gate { public void setPortalBlockClosed(Material type) { portalBlockClosed = type; } - + + public Material getButton() { + return button; + } + public int getUseCost() { if (useCost < 0) return EconomyHandler.useCost; return useCost; @@ -379,6 +386,7 @@ public class Gate { gate.portalBlockOpen = readConfig(config, gate, file, "portal-open", gate.portalBlockOpen); gate.portalBlockClosed = readConfig(config, gate, file, "portal-closed", gate.portalBlockClosed); + gate.button = readConfig(config, gate, file, "button", gate.button); gate.useCost = readConfig(config, gate, file, "usecost", -1); gate.destroyCost = readConfig(config, gate, file, "destroycost", -1); gate.createCost = readConfig(config, gate, file, "createcost", -1); @@ -388,6 +396,11 @@ public class Gate { Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gates must have exactly 2 control points."); return null; } + + if (!Tag.BUTTONS.isTagged(gate.button)) { + Stargate.log.log(Level.SEVERE, "Could not load Gate " + file.getName() + " - Gate button must be a type of button."); + return null; + } // Merge frame types, add open mat to list frameBlocks.addAll(frameTypes); diff --git a/src/net/TheDgtl/Stargate/Portal.java b/src/net/TheDgtl/Stargate/Portal.java index 737dde1..2a74f76 100644 --- a/src/net/TheDgtl/Stargate/Portal.java +++ b/src/net/TheDgtl/Stargate/Portal.java @@ -1154,8 +1154,7 @@ public class Portal { // No button on an always-open gate. if (!alwaysOn) { button = topleft.modRelative(buttonVector.getRight(), buttonVector.getDepth(), buttonVector.getDistance() + 1, modX, 1, modZ); - button.setType(Material.STONE_BUTTON); - Directional buttondata = (Directional) button.getBlock().getBlockData(); + Directional buttondata = (Directional) Bukkit.createBlockData(gate.getButton()); buttondata.setFacing(buttonfacing); button.getBlock().setBlockData(buttondata); portal.setButton(button); diff --git a/src/net/TheDgtl/Stargate/Stargate.java b/src/net/TheDgtl/Stargate/Stargate.java index b365e0c..2b995c5 100644 --- a/src/net/TheDgtl/Stargate/Stargate.java +++ b/src/net/TheDgtl/Stargate/Stargate.java @@ -24,6 +24,7 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; 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; @@ -926,7 +927,7 @@ public class Stargate extends JavaPlugin { } // Implement right-click to toggle a stargate, gets around spawn protection problem. - if ((block.getType() == Material.STONE_BUTTON)) { + if (Tag.BUTTONS.isTagged(block.getType())) { Portal portal = Portal.getByBlock(block); if (portal == null) return; @@ -1072,7 +1073,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 (block.getType() == Material.STONE_BUTTON) { + } else if (Tag.BUTTONS.isTagged(block.getType())) { portal = Portal.getByControl(block); } if (portal != null) event.setCancelled(true);