From b63faca10981c7a02981e123dde675efc0dad73a Mon Sep 17 00:00:00 2001 From: Steven Scott Date: Wed, 14 Mar 2012 23:24:34 -0700 Subject: [PATCH] More API changes for StargateCommand --- src/net/TheDgtl/Stargate/Portal.java | 12 ++++++++---- src/net/TheDgtl/Stargate/Stargate.java | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/net/TheDgtl/Stargate/Portal.java b/src/net/TheDgtl/Stargate/Portal.java index 86d524e..bdc9cd8 100644 --- a/src/net/TheDgtl/Stargate/Portal.java +++ b/src/net/TheDgtl/Stargate/Portal.java @@ -337,6 +337,7 @@ public class Portal { Portal end = getDestination(); // Only open dest if it's not-fixed or points at this gate if (end != null && (!end.isFixed() || end.getDestinationName().equalsIgnoreCase(getName())) && !end.isOpen()) { + Stargate.debug("portal::open", "Ver: " + end.isVerified()); end.open(openFor, false); end.setDestination(this); if (end.isVerified()) end.drawSign(); @@ -523,7 +524,7 @@ public class Portal { return gate.matches(topLeft, modX, modZ); } - public void activate(Player player) { + public boolean activate(Player player) { destinations.clear(); destination = ""; Stargate.activeList.add(this); @@ -555,11 +556,12 @@ public class Portal { Stargate.server.getPluginManager().callEvent(event); if (event.isCancelled()) { Stargate.activeList.remove(this); - return; + return false; } destination = event.getDestination(); destinations = event.getDestinations(); drawSign(); + return true; } public void deactivate() { @@ -588,7 +590,10 @@ public class Portal { public void cycleDestination(Player player, int dir) { Boolean activate = false; if (!isActive() || getActivePlayer() != player) { - activate(player); + // If the event is cancelled, return + if (!activate(player)) { + return; + } Stargate.debug("cycleDestination", "Network Size: " + allPortalsNet.get(network.toLowerCase()).size()); Stargate.debug("cycleDestination", "Player has access to: " + destinations.size()); activate = true; @@ -646,7 +651,6 @@ public class Portal { } } else { int index = destinations.indexOf(destination); - if ((index == max) && (max > 1) && (++done <= 3)) { if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) { Portal dest = Portal.getByName(destinations.get(index - 2), network); diff --git a/src/net/TheDgtl/Stargate/Stargate.java b/src/net/TheDgtl/Stargate/Stargate.java index f9a2c86..b794456 100644 --- a/src/net/TheDgtl/Stargate/Stargate.java +++ b/src/net/TheDgtl/Stargate/Stargate.java @@ -275,7 +275,7 @@ public class Stargate extends JavaPlugin { return lang.getString(name); } - private void onButtonPressed(Player player, Portal portal) { + public static void openPortal(Player player, Portal portal) { Portal destination = portal.getDestination(); // Always-open gate -- Do nothing @@ -811,7 +811,7 @@ public class Stargate extends JavaPlugin { Stargate.sendMessage(player, Stargate.getString("denyMsg")); return; } - onButtonPressed(player, portal); + openPortal(player, portal); } return; } @@ -864,7 +864,7 @@ public class Stargate extends JavaPlugin { Stargate.sendMessage(player, Stargate.getString("denyMsg")); return; } - onButtonPressed(player, portal); + openPortal(player, portal); } } }