diff --git a/README b/README index 6e235af..779a308 100644 --- a/README +++ b/README @@ -202,6 +202,8 @@ createConflict=Gate conflicts with existing gate ============= Changes ============= +[Version 0.7.6.1] + - API update to support StargateCommand [Version 0.7.6] - Moved gate opening/closing to a Queue/Runnable system to resolve server lag issues with very large gates [Version 0.7.5.11] diff --git a/src/net/TheDgtl/Stargate/Gate.java b/src/net/TheDgtl/Stargate/Gate.java index e9e275e..4b37f55 100644 --- a/src/net/TheDgtl/Stargate/Gate.java +++ b/src/net/TheDgtl/Stargate/Gate.java @@ -61,7 +61,7 @@ public class Gate { private int destroyCost = -1; private boolean toOwner = false; - private Gate(String filename, Character[][] layout, HashMap types, HashMap metadata) { + public Gate(String filename, Character[][] layout, HashMap types, HashMap metadata) { this.filename = filename; this.layout = layout; this.metadata = metadata; @@ -175,6 +175,14 @@ public class Gate { public Character[][] getLayout() { return layout; } + + public HashMap getTypes() { + return types; + } + + public HashMap getMetaData() { + return metadata; + } public RelativeBlockVector[] getEntrances() { return entrances; @@ -206,11 +214,19 @@ public class Gate { public int getPortalBlockOpen() { return portalBlockOpen; } + + public void setPortalBlockOpen(int type) { + portalBlockOpen = type; + } public int getPortalBlockClosed() { return portalBlockClosed; } + public void setPortalBlockClosed(int type) { + portalBlockClosed = type; + } + public int getUseCost() { if (useCost < 0) return iConomyHandler.useCost; return useCost; @@ -281,7 +297,7 @@ public class Gate { return true; } - private static void registerGate(Gate gate) { + public static void registerGate(Gate gate) { gates.put(gate.getFilename(), gate); int blockID = gate.getControlBlock(); @@ -293,7 +309,7 @@ public class Gate { controlBlocks.get(blockID).add(gate); } - private static Gate loadGate(File file) { + public static Gate loadGate(File file) { Scanner scanner = null; boolean designing = false; ArrayList> design = new ArrayList>(); diff --git a/src/net/TheDgtl/Stargate/Portal.java b/src/net/TheDgtl/Stargate/Portal.java index 69411ca..86d524e 100644 --- a/src/net/TheDgtl/Stargate/Portal.java +++ b/src/net/TheDgtl/Stargate/Portal.java @@ -524,10 +524,6 @@ public class Portal { } public void activate(Player player) { - StargateActivateEvent event = new StargateActivateEvent(this, player); - Stargate.server.getPluginManager().callEvent(event); - if (event.isCancelled()) return; - destinations.clear(); destination = ""; Stargate.activeList.add(this); @@ -554,6 +550,15 @@ public class Portal { if (Stargate.destMemory && !lastDest.isEmpty() && destinations.contains(lastDest)) { destination = lastDest; } + + StargateActivateEvent event = new StargateActivateEvent(this, player, destinations, destination); + Stargate.server.getPluginManager().callEvent(event); + if (event.isCancelled()) { + Stargate.activeList.remove(this); + return; + } + destination = event.getDestination(); + destinations = event.getDestinations(); drawSign(); } diff --git a/src/net/TheDgtl/Stargate/Stargate.java b/src/net/TheDgtl/Stargate/Stargate.java index 1ea174f..f9a2c86 100644 --- a/src/net/TheDgtl/Stargate/Stargate.java +++ b/src/net/TheDgtl/Stargate/Stargate.java @@ -262,6 +262,10 @@ public class Stargate extends JavaPlugin { public static String getSaveLocation() { return portalFolder; } + + public static String getGateFolder() { + return gateFolder; + } public static String getDefaultNetwork() { return defNetwork; diff --git a/src/net/TheDgtl/Stargate/event/StargateActivateEvent.java b/src/net/TheDgtl/Stargate/event/StargateActivateEvent.java index c6175cb..ae82405 100644 --- a/src/net/TheDgtl/Stargate/event/StargateActivateEvent.java +++ b/src/net/TheDgtl/Stargate/event/StargateActivateEvent.java @@ -1,5 +1,7 @@ package net.TheDgtl.Stargate.event; +import java.util.ArrayList; + import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; @@ -24,7 +26,9 @@ import net.TheDgtl.Stargate.Portal; */ public class StargateActivateEvent extends StargateEvent { - Player player; + private Player player; + private ArrayList destinations; + private String destination; private static final HandlerList handlers = new HandlerList(); @@ -35,13 +39,31 @@ public class StargateActivateEvent extends StargateEvent { public static HandlerList getHandlerList() { return handlers; } - public StargateActivateEvent(Portal portal, Player player) { + public StargateActivateEvent(Portal portal, Player player, ArrayList destinations, String destination) { super("StargatActivateEvent", portal); this.player = player; + this.destinations = destinations; + this.destination = destination; } public Player getPlayer() { return player; } + + public ArrayList getDestinations() { + return destinations; + } + + public void setDestinations(ArrayList destinations) { + this.destinations = destinations; + } + + public String getDestination() { + return destination; + } + + public void setDestination(String destination) { + this.destination = destination; + } } diff --git a/src/plugin.yml b/src/plugin.yml index 620ec77..698e806 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: Stargate main: net.TheDgtl.Stargate.Stargate -version: 0.7.6.0 +version: 0.7.6.1 description: Stargate mod for Bukkit author: Drakia website: http://www.thedgtl.net