Splits the portal class into Portal, PortalActivator, PortalOpener and PortalStructure
PortalStructure now contains information about the gate's physical structure, such as the location of border blocks, the location of entrances, the gate type and the button location. PortalActivator is responsible for activating/de-activating portals, destination toggling and getting information about available destinations. PortalOpener is responsible for opening/closing a portal. It's also the place to go for checking if the portal is open for a given player. Comments of the Portal class have been improved, but the comments of the three new classes need fixing.
This commit is contained in:
@ -35,7 +35,7 @@ public final class EconomyHelper {
|
||||
// Insufficient Funds
|
||||
if (!success) {
|
||||
sendInsufficientFundsMessage(entrancePortal.getName(), player, cost);
|
||||
entrancePortal.close(false);
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public final class PermissionHelper {
|
||||
* @param portal <p>The portal to open</p>
|
||||
*/
|
||||
public static void openPortal(Player player, Portal portal) {
|
||||
Portal destination = portal.getDestination();
|
||||
Portal destination = portal.getPortalActivator().getDestination();
|
||||
|
||||
//Always-open gate -- Do nothing
|
||||
if (portal.getOptions().isAlwaysOn()) {
|
||||
@ -46,13 +46,14 @@ public final class PermissionHelper {
|
||||
if (portal.isOpen()) {
|
||||
// Close if this player opened the gate
|
||||
if (portal.getActivePlayer() == player) {
|
||||
portal.close(false);
|
||||
portal.getPortalOpener().closePortal(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//Gate that someone else is using -- Deny access
|
||||
if ((!portal.getOptions().isFixed()) && portal.isActive() && (portal.getActivePlayer() != player)) {
|
||||
if ((!portal.getOptions().isFixed()) && portal.getPortalActivator().isActive() &&
|
||||
(portal.getActivePlayer() != player)) {
|
||||
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
return;
|
||||
}
|
||||
@ -70,7 +71,7 @@ public final class PermissionHelper {
|
||||
}
|
||||
|
||||
//Open gate
|
||||
portal.open(player, false);
|
||||
portal.getPortalOpener().openPortal(player, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -388,7 +389,7 @@ public final class PermissionHelper {
|
||||
}
|
||||
|
||||
// Not open for this player
|
||||
if (!entrancePortal.isOpenFor(player)) {
|
||||
if (!entrancePortal.getPortalOpener().isOpenFor(player)) {
|
||||
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
|
||||
return true;
|
||||
@ -403,7 +404,7 @@ public final class PermissionHelper {
|
||||
if (PermissionHelper.cannotAccessPortal(player, entrancePortal, destination)) {
|
||||
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||
new PlayerTeleporter(entrancePortal, player).teleport(entrancePortal, event);
|
||||
entrancePortal.close(false);
|
||||
entrancePortal.getPortalOpener().closePortal(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user