Moves functionality to the PortalOptions and PortalLocation classes
This commit is contained in:
parent
60c543e52a
commit
e7fc1daafe
@ -155,7 +155,7 @@ public class PlayerEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Decide if the user should be teleported to another bungee server
|
//Decide if the user should be teleported to another bungee server
|
||||||
if (entrancePortal.isBungee()) {
|
if (entrancePortal.getOptions().isBungee()) {
|
||||||
if (bungeeTeleport(player, entrancePortal, event)) {
|
if (bungeeTeleport(player, entrancePortal, event)) {
|
||||||
Stargate.sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
Stargate.sendSuccessMessage(player, Stargate.getString("teleportMsg"));
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ public class PlayerEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//No destination
|
//No destination
|
||||||
if (!entrancePortal.isBungee() && destination == null) {
|
if (!entrancePortal.getOptions().isBungee() && destination == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class VehicleEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Return if the portal cannot be teleported through
|
//Return if the portal cannot be teleported through
|
||||||
if (entrancePortal == null || !entrancePortal.isOpen() || entrancePortal.isBungee()) {
|
if (entrancePortal == null || !entrancePortal.isOpen() || entrancePortal.getOptions().isBungee()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public class VehicleEventListener implements Listener {
|
|||||||
Stargate.logger.warning(Stargate.getString("prefox") + "Unable to find portal destination");
|
Stargate.logger.warning(Stargate.getString("prefox") + "Unable to find portal destination");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Stargate.debug("vehicleTeleport", destinationPortal.getWorld() + " " + destinationPortal.getId());
|
Stargate.debug("vehicleTeleport", destinationPortal.getWorld() + " " + destinationPortal.getSignLocation());
|
||||||
destinationPortal.teleport(vehicle, entrancePortal);
|
destinationPortal.teleport(vehicle, entrancePortal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,17 +46,10 @@ import java.util.logging.Level;
|
|||||||
public class Portal {
|
public class Portal {
|
||||||
|
|
||||||
// Gate location block info
|
// Gate location block info
|
||||||
private final BlockLocation topLeft;
|
private final PortalLocation location;
|
||||||
private final int modX;
|
|
||||||
private final int modZ;
|
|
||||||
private final float yaw;
|
|
||||||
//The rotation axis is the axis along which the gate is placed. It's the cross axis of the button's axis
|
|
||||||
private final Axis rotationAxis;
|
|
||||||
|
|
||||||
// Block references
|
// Block references
|
||||||
private final BlockLocation id;
|
|
||||||
private final Gate gate;
|
private final Gate gate;
|
||||||
private final World world;
|
|
||||||
private BlockLocation button;
|
private BlockLocation button;
|
||||||
private BlockLocation[] frame;
|
private BlockLocation[] frame;
|
||||||
private BlockLocation[] entrances;
|
private BlockLocation[] entrances;
|
||||||
@ -69,8 +62,7 @@ public class Portal {
|
|||||||
private final String ownerName;
|
private final String ownerName;
|
||||||
private UUID ownerUUID;
|
private UUID ownerUUID;
|
||||||
private boolean verified;
|
private boolean verified;
|
||||||
private boolean fixed;
|
private final PortalOptions options;
|
||||||
private final Map<PortalOption, Boolean> options;
|
|
||||||
|
|
||||||
// In-use information
|
// In-use information
|
||||||
private Player player;
|
private Player player;
|
||||||
@ -83,25 +75,20 @@ public class Portal {
|
|||||||
* Instantiates a new portal
|
* Instantiates a new portal
|
||||||
*
|
*
|
||||||
* @param portalLocation <p>Object containing locations of all relevant blocks</p>
|
* @param portalLocation <p>Object containing locations of all relevant blocks</p>
|
||||||
* @param button <p>The location of the portal's open button</p>
|
* @param button <p>The location of the portal's open button</p>
|
||||||
* @param destination <p>The destination defined on the sign's destination line</p>
|
* @param destination <p>The destination defined on the sign's destination line</p>
|
||||||
* @param name <p>The name of the portal defined on the sign's first line</p>
|
* @param name <p>The name of the portal defined on the sign's first line</p>
|
||||||
* @param verified <p>Whether the portal's gate has been verified to match its template</p>
|
* @param verified <p>Whether the portal's gate has been verified to match its template</p>
|
||||||
* @param network <p>The network the portal belongs to, defined on the sign's network line</p>
|
* @param network <p>The network the portal belongs to, defined on the sign's network line</p>
|
||||||
* @param gate <p>The gate template this portal uses</p>
|
* @param gate <p>The gate template this portal uses</p>
|
||||||
* @param ownerUUID <p>The UUID of the gate's owner</p>
|
* @param ownerUUID <p>The UUID of the gate's owner</p>
|
||||||
* @param ownerName <p>The name of the gate's owner</p>
|
* @param ownerName <p>The name of the gate's owner</p>
|
||||||
* @param options <p>A map containing all possible portal options</p>
|
* @param options <p>A map containing all possible portal options</p>
|
||||||
*/
|
*/
|
||||||
Portal(PortalLocation portalLocation, BlockLocation button,
|
Portal(PortalLocation portalLocation, BlockLocation button,
|
||||||
String destination, String name, boolean verified, String network, Gate gate, UUID ownerUUID,
|
String destination, String name, boolean verified, String network, Gate gate, UUID ownerUUID,
|
||||||
String ownerName, Map<PortalOption, Boolean> options) {
|
String ownerName, Map<PortalOption, Boolean> options) {
|
||||||
this.topLeft = portalLocation.getTopLeft();
|
this.location = portalLocation;
|
||||||
this.modX = portalLocation.getModX();
|
|
||||||
this.modZ = portalLocation.getModZ();
|
|
||||||
this.yaw = portalLocation.getYaw();
|
|
||||||
this.rotationAxis = yaw == 0.0F || yaw == 180.0F ? Axis.X : Axis.Z;
|
|
||||||
this.id = portalLocation.getSignLocation();
|
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.button = button;
|
this.button = button;
|
||||||
this.verified = verified;
|
this.verified = verified;
|
||||||
@ -110,124 +97,29 @@ public class Portal {
|
|||||||
this.gate = gate;
|
this.gate = gate;
|
||||||
this.ownerUUID = ownerUUID;
|
this.ownerUUID = ownerUUID;
|
||||||
this.ownerName = ownerName;
|
this.ownerName = ownerName;
|
||||||
this.options = options;
|
this.options = new PortalOptions(options, destination.length() > 0);
|
||||||
this.world = topLeft.getWorld();
|
|
||||||
this.fixed = destination.length() > 0 || this.isRandom() || this.isBungee();
|
|
||||||
|
|
||||||
if (this.isAlwaysOn() && !this.isFixed()) {
|
|
||||||
this.options.put(PortalOption.ALWAYS_ON, false);
|
|
||||||
Stargate.debug("Portal", "Can not create a non-fixed always-on gate. Setting AlwaysOn = false");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isRandom() && !this.isAlwaysOn()) {
|
|
||||||
this.options.put(PortalOption.ALWAYS_ON, true);
|
|
||||||
Stargate.debug("Portal", "Gate marked as random, set to always-on");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verified) {
|
if (verified) {
|
||||||
this.drawSign();
|
this.drawSign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the portal options for this portal
|
||||||
|
*
|
||||||
|
* @return <p>This portal's portal options</p>
|
||||||
|
*/
|
||||||
|
public PortalOptions getOptions() {
|
||||||
|
return this.options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether this portal is currently open
|
* Gets whether this portal is currently open
|
||||||
*
|
*
|
||||||
* @return <p>Whether this portal is open</p>
|
* @return <p>Whether this portal is open</p>
|
||||||
*/
|
*/
|
||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return isOpen || isAlwaysOn();
|
return isOpen || options.isAlwaysOn();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is always on
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal is always on</p>
|
|
||||||
*/
|
|
||||||
public boolean isAlwaysOn() {
|
|
||||||
return this.options.get(PortalOption.ALWAYS_ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is hidden
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal is hidden</p>
|
|
||||||
*/
|
|
||||||
public boolean isHidden() {
|
|
||||||
return this.options.get(PortalOption.HIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is private
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal is private</p>
|
|
||||||
*/
|
|
||||||
public boolean isPrivate() {
|
|
||||||
return this.options.get(PortalOption.PRIVATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is free
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal is free</p>
|
|
||||||
*/
|
|
||||||
public boolean isFree() {
|
|
||||||
return this.options.get(PortalOption.FREE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is backwards
|
|
||||||
*
|
|
||||||
* <p>A backwards portal is one where players exit through the back.</p>
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal is backwards</p>
|
|
||||||
*/
|
|
||||||
public boolean isBackwards() {
|
|
||||||
return this.options.get(PortalOption.BACKWARDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is shown on the network even if it's always on
|
|
||||||
*
|
|
||||||
* @return <p>Whether portal gate is shown</p>
|
|
||||||
*/
|
|
||||||
public boolean isShown() {
|
|
||||||
return this.options.get(PortalOption.SHOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal shows no network
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal shows no network/p>
|
|
||||||
*/
|
|
||||||
public boolean isNoNetwork() {
|
|
||||||
return this.options.get(PortalOption.NO_NETWORK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal goes to a random location on the network
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal goes to a random location</p>
|
|
||||||
*/
|
|
||||||
public boolean isRandom() {
|
|
||||||
return this.options.get(PortalOption.RANDOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this portal is a bungee portal
|
|
||||||
*
|
|
||||||
* @return <p>Whether this portal is a bungee portal</p>
|
|
||||||
*/
|
|
||||||
public boolean isBungee() {
|
|
||||||
return this.options.get(PortalOption.BUNGEE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the rotation of the portal in degrees
|
|
||||||
*
|
|
||||||
* @return <p>The rotation of the portal</p>
|
|
||||||
*/
|
|
||||||
public float getRotation() {
|
|
||||||
return yaw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,7 +193,7 @@ public class Portal {
|
|||||||
* @return <p>The destination portal the player should teleport to</p>
|
* @return <p>The destination portal the player should teleport to</p>
|
||||||
*/
|
*/
|
||||||
public Portal getDestination(Player player) {
|
public Portal getDestination(Player player) {
|
||||||
if (isRandom()) {
|
if (options.isRandom()) {
|
||||||
destinations = PortalHandler.getDestinations(this, player, getNetwork());
|
destinations = PortalHandler.getDestinations(this, player, getNetwork());
|
||||||
if (destinations.size() == 0) {
|
if (destinations.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
@ -426,22 +318,13 @@ public class Portal {
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the location of this portal's sign
|
|
||||||
*
|
|
||||||
* @return <p>The location of this portal's sign</p>
|
|
||||||
*/
|
|
||||||
public BlockLocation getSign() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the world this portal belongs to
|
* Gets the world this portal belongs to
|
||||||
*
|
*
|
||||||
* @return <p>The world this portal belongs to</p>
|
* @return <p>The world this portal belongs to</p>
|
||||||
*/
|
*/
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
return world;
|
return location.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -488,7 +371,7 @@ public class Portal {
|
|||||||
|
|
||||||
//Change the opening blocks to the correct type
|
//Change the opening blocks to the correct type
|
||||||
Material openType = gate.getPortalOpenBlock();
|
Material openType = gate.getPortalOpenBlock();
|
||||||
Axis axis = (openType.createBlockData() instanceof Orientable) ? rotationAxis : null;
|
Axis axis = (openType.createBlockData() instanceof Orientable) ? location.getRotationAxis() : null;
|
||||||
for (BlockLocation inside : getEntrances()) {
|
for (BlockLocation inside : getEntrances()) {
|
||||||
Stargate.blockChangeRequestQueue.add(new BlockChangeRequest(inside, openType, axis));
|
Stargate.blockChangeRequestQueue.add(new BlockChangeRequest(inside, openType, axis));
|
||||||
}
|
}
|
||||||
@ -510,12 +393,12 @@ public class Portal {
|
|||||||
Stargate.activePortalsQueue.remove(this);
|
Stargate.activePortalsQueue.remove(this);
|
||||||
|
|
||||||
//Open remote portal
|
//Open remote portal
|
||||||
if (!isAlwaysOn()) {
|
if (!options.isAlwaysOn()) {
|
||||||
player = openFor;
|
player = openFor;
|
||||||
|
|
||||||
Portal destination = getDestination();
|
Portal destination = getDestination();
|
||||||
// Only open destination if it's not-fixed or points at this portal
|
// Only open destination if it's not-fixed or points at this portal
|
||||||
if (!isRandom() && destination != null && (!destination.isFixed() ||
|
if (!options.isRandom() && destination != null && (!destination.isFixed() ||
|
||||||
destination.getDestinationName().equalsIgnoreCase(getName())) && !destination.isOpen()) {
|
destination.getDestinationName().equalsIgnoreCase(getName())) && !destination.isOpen()) {
|
||||||
destination.open(openFor, false);
|
destination.open(openFor, false);
|
||||||
destination.setDestination(this);
|
destination.setDestination(this);
|
||||||
@ -537,7 +420,7 @@ public class Portal {
|
|||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
force = event.getForce();
|
force = event.getForce();
|
||||||
|
|
||||||
if (isAlwaysOn() && !force) return; // Only close always-open if forced
|
if (options.isAlwaysOn() && !force) return; // Only close always-open if forced
|
||||||
|
|
||||||
// Close this gate, then the dest gate.
|
// Close this gate, then the dest gate.
|
||||||
Material closedType = gate.getPortalClosedBlock();
|
Material closedType = gate.getPortalClosedBlock();
|
||||||
@ -560,7 +443,7 @@ public class Portal {
|
|||||||
Stargate.activePortalsQueue.remove(this);
|
Stargate.activePortalsQueue.remove(this);
|
||||||
|
|
||||||
//Close remote portal
|
//Close remote portal
|
||||||
if (!isAlwaysOn()) {
|
if (!options.isAlwaysOn()) {
|
||||||
Portal end = getDestination();
|
Portal end = getDestination();
|
||||||
|
|
||||||
if (end != null && end.isOpen()) {
|
if (end != null && end.isOpen()) {
|
||||||
@ -581,7 +464,7 @@ public class Portal {
|
|||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isAlwaysOn() || this.player == null) {
|
if (options.isAlwaysOn() || this.player == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return player != null && player.getName().equalsIgnoreCase(this.player.getName());
|
return player != null && player.getName().equalsIgnoreCase(this.player.getName());
|
||||||
@ -595,7 +478,7 @@ public class Portal {
|
|||||||
* @return <p>True if this portal points to a fixed exit portal</p>
|
* @return <p>True if this portal points to a fixed exit portal</p>
|
||||||
*/
|
*/
|
||||||
public boolean isFixed() {
|
public boolean isFixed() {
|
||||||
return fixed;
|
return options.isFixed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -606,7 +489,7 @@ public class Portal {
|
|||||||
* @param fixed <p>True if this portal points to a fixed exit portal</p>
|
* @param fixed <p>True if this portal points to a fixed exit portal</p>
|
||||||
*/
|
*/
|
||||||
public void setFixed(boolean fixed) {
|
public void setFixed(boolean fixed) {
|
||||||
this.fixed = fixed;
|
options.setFixed(fixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -655,10 +538,10 @@ public class Portal {
|
|||||||
*/
|
*/
|
||||||
private void adjustRotation(Location exit, Portal origin) {
|
private void adjustRotation(Location exit, Portal origin) {
|
||||||
int adjust = 0;
|
int adjust = 0;
|
||||||
if (isBackwards() != origin.isBackwards()) {
|
if (options.isBackwards() != origin.options.isBackwards()) {
|
||||||
adjust = 180;
|
adjust = 180;
|
||||||
}
|
}
|
||||||
float newYaw = (this.getRotation() + adjust) % 360;
|
float newYaw = (this.getYaw() + adjust) % 360;
|
||||||
Stargate.debug("Portal::adjustRotation", "Setting exit yaw to " + newYaw);
|
Stargate.debug("Portal::adjustRotation", "Setting exit yaw to " + newYaw);
|
||||||
exit.setYaw(newYaw);
|
exit.setYaw(newYaw);
|
||||||
}
|
}
|
||||||
@ -679,7 +562,7 @@ public class Portal {
|
|||||||
vehicle.setVelocity(new Vector());
|
vehicle.setVelocity(new Vector());
|
||||||
|
|
||||||
//Get new velocity
|
//Get new velocity
|
||||||
Vector newVelocityDirection = DirectionHelper.getDirectionVectorFromYaw(this.getRotation());
|
Vector newVelocityDirection = DirectionHelper.getDirectionVectorFromYaw(this.getYaw());
|
||||||
Vector newVelocity = newVelocityDirection.multiply(velocity);
|
Vector newVelocity = newVelocityDirection.multiply(velocity);
|
||||||
adjustRotation(exit, origin);
|
adjustRotation(exit, origin);
|
||||||
|
|
||||||
@ -769,9 +652,9 @@ public class Portal {
|
|||||||
RelativeBlockVector relativeExit = gate.getLayout().getExit();
|
RelativeBlockVector relativeExit = gate.getLayout().getExit();
|
||||||
if (relativeExit != null) {
|
if (relativeExit != null) {
|
||||||
BlockLocation exit = getBlockAt(relativeExit);
|
BlockLocation exit = getBlockAt(relativeExit);
|
||||||
int back = (isBackwards()) ? -1 : 1;
|
int back = (options.isBackwards()) ? -1 : 1;
|
||||||
exitLocation = exit.modRelativeLoc(0D, 0D, 1, traveller.getYaw(),
|
exitLocation = exit.modRelativeLoc(0D, 0D, 1, traveller.getYaw(),
|
||||||
traveller.getPitch(), modX * back, 1, modZ * back);
|
traveller.getPitch(), getModX() * back, 1, getModZ() * back);
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
double entitySize = EntityHelper.getEntityMaxSize(entity);
|
double entitySize = EntityHelper.getEntityMaxSize(entity);
|
||||||
@ -810,20 +693,22 @@ public class Portal {
|
|||||||
if (openingWidth > 1) {
|
if (openingWidth > 1) {
|
||||||
newOffset -= 0.5;
|
newOffset -= 0.5;
|
||||||
}
|
}
|
||||||
exitLocation = DirectionHelper.adjustLocation(exitLocation, newOffset, 0, 0, modX, modZ);
|
exitLocation = DirectionHelper.adjustLocation(exitLocation, newOffset, 0, 0, getModX(), getModZ());
|
||||||
|
|
||||||
//Move large entities further from the portal, especially if this portal will teleport them at once
|
//Move large entities further from the portal, especially if this portal will teleport them at once
|
||||||
double entitySize = EntityHelper.getEntityMaxSize(entity);
|
double entitySize = EntityHelper.getEntityMaxSize(entity);
|
||||||
int entityBoxSize = EntityHelper.getEntityMaxSizeInt(entity);
|
int entityBoxSize = EntityHelper.getEntityMaxSizeInt(entity);
|
||||||
if (entitySize > 1) {
|
if (entitySize > 1) {
|
||||||
if (isAlwaysOn()) {
|
if (options.isAlwaysOn()) {
|
||||||
exitLocation = DirectionHelper.adjustLocation(exitLocation, 0, 0, (entityBoxSize / 2D), modX, modZ);
|
exitLocation = DirectionHelper.adjustLocation(exitLocation, 0, 0, (entityBoxSize / 2D),
|
||||||
|
getModX(), getModZ());
|
||||||
} else {
|
} else {
|
||||||
exitLocation = DirectionHelper.adjustLocation(exitLocation, 0, 0, (entitySize / 2D) - 1, modX, modZ);
|
exitLocation = DirectionHelper.adjustLocation(exitLocation, 0, 0,
|
||||||
|
(entitySize / 2D) - 1, getModX(), getModZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity instanceof AbstractHorse) {
|
if (entity instanceof AbstractHorse) {
|
||||||
exitLocation = DirectionHelper.adjustLocation(exitLocation, 0, 0, 1, modX, modZ);
|
exitLocation = DirectionHelper.adjustLocation(exitLocation, 0, 0, 1, getModX(), getModZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
return exitLocation;
|
return exitLocation;
|
||||||
@ -886,8 +771,9 @@ public class Portal {
|
|||||||
|
|
||||||
//Get the chunk in front of the gate corner
|
//Get the chunk in front of the gate corner
|
||||||
Location cornerLocation = getBlockAt(vector).getLocation();
|
Location cornerLocation = getBlockAt(vector).getLocation();
|
||||||
int blockOffset = this.isBackwards() ? -5 : 5;
|
int blockOffset = options.isBackwards() ? -5 : 5;
|
||||||
Location fiveBlocksForward = DirectionHelper.adjustLocation(cornerLocation, 0, 0, blockOffset, modX, modZ);
|
Location fiveBlocksForward = DirectionHelper.adjustLocation(cornerLocation, 0, 0, blockOffset,
|
||||||
|
getModX(), getModZ());
|
||||||
Chunk forwardChunk = fiveBlocksForward.getChunk();
|
Chunk forwardChunk = fiveBlocksForward.getChunk();
|
||||||
|
|
||||||
//Load the chunks
|
//Load the chunks
|
||||||
@ -914,8 +800,8 @@ public class Portal {
|
|||||||
*
|
*
|
||||||
* @return <p>The identity location of the portal</p>
|
* @return <p>The identity location of the portal</p>
|
||||||
*/
|
*/
|
||||||
public BlockLocation getId() {
|
public BlockLocation getSignLocation() {
|
||||||
return this.id;
|
return this.location.getSignLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -924,7 +810,7 @@ public class Portal {
|
|||||||
* @return <p>The x modifier used by this portal</p>
|
* @return <p>The x modifier used by this portal</p>
|
||||||
*/
|
*/
|
||||||
public int getModX() {
|
public int getModX() {
|
||||||
return this.modX;
|
return this.location.getModX();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -933,7 +819,7 @@ public class Portal {
|
|||||||
* @return <p>The z modifier used by this portal</p>
|
* @return <p>The z modifier used by this portal</p>
|
||||||
*/
|
*/
|
||||||
public int getModZ() {
|
public int getModZ() {
|
||||||
return this.modZ;
|
return this.location.getModZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -942,7 +828,7 @@ public class Portal {
|
|||||||
* @return <p>The rotation of this portal</p>
|
* @return <p>The rotation of this portal</p>
|
||||||
*/
|
*/
|
||||||
public float getYaw() {
|
public float getYaw() {
|
||||||
return this.yaw;
|
return this.location.getYaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -951,7 +837,7 @@ public class Portal {
|
|||||||
* @return <p>The location of the top-left portal block</p>
|
* @return <p>The location of the top-left portal block</p>
|
||||||
*/
|
*/
|
||||||
public BlockLocation getTopLeft() {
|
public BlockLocation getTopLeft() {
|
||||||
return this.topLeft;
|
return this.location.getTopLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -991,7 +877,7 @@ public class Portal {
|
|||||||
if (!Stargate.verifyPortals) {
|
if (!Stargate.verifyPortals) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return gate.matches(topLeft, modX, modZ);
|
return gate.matches(getTopLeft(), getModX(), getModZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1122,10 +1008,11 @@ public class Portal {
|
|||||||
* Draws the sign on this portal
|
* Draws the sign on this portal
|
||||||
*/
|
*/
|
||||||
public final void drawSign() {
|
public final void drawSign() {
|
||||||
BlockState state = id.getBlock().getState();
|
BlockState state = getSignLocation().getBlock().getState();
|
||||||
if (!(state instanceof Sign)) {
|
if (!(state instanceof Sign)) {
|
||||||
Stargate.logger.warning(Stargate.getString("prefix") + "Sign block is not a Sign object");
|
Stargate.logger.warning(Stargate.getString("prefix") + "Sign block is not a Sign object");
|
||||||
Stargate.debug("Portal::drawSign", "Block: " + id.getBlock().getType() + " @ " + id.getBlock().getLocation());
|
Stargate.debug("Portal::drawSign", "Block: " + getSignLocation().getBlock().getType() + " @ "
|
||||||
|
+ getSignLocation().getBlock().getLocation());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,7 +1027,7 @@ public class Portal {
|
|||||||
* @return <p>The block at the given relative position</p>
|
* @return <p>The block at the given relative position</p>
|
||||||
*/
|
*/
|
||||||
public BlockLocation getBlockAt(RelativeBlockVector vector) {
|
public BlockLocation getBlockAt(RelativeBlockVector vector) {
|
||||||
return DirectionHelper.getBlockAt(topLeft, vector, modX, modZ);
|
return DirectionHelper.getBlockAt(getTopLeft(), vector, getModX(), getModZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1174,7 +1061,8 @@ public class Portal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Portal [id=%s, network=%s name=%s, type=%s]", id, network, name, gate.getFilename());
|
return String.format("Portal [id=%s, network=%s name=%s, type=%s]", getSignLocation(), network, name,
|
||||||
|
gate.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,11 +73,11 @@ public class PortalHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Check if destination is a random portal
|
//Check if destination is a random portal
|
||||||
if (portal.isRandom()) {
|
if (portal.getOptions().isRandom()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Check if destination is always open (Don't show if so)
|
//Check if destination is always open (Don't show if so)
|
||||||
if (portal.isAlwaysOn() && !portal.isShown()) {
|
if (portal.getOptions().isAlwaysOn() && !portal.getOptions().isShown()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Check if destination is this portal
|
//Check if destination is this portal
|
||||||
@ -125,8 +125,8 @@ public class PortalHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Remove registered info about the lookup controls and blocks
|
//Remove registered info about the lookup controls and blocks
|
||||||
lookupBlocks.remove(portal.getId());
|
lookupBlocks.remove(portal.getSignLocation());
|
||||||
lookupControls.remove(portal.getId());
|
lookupControls.remove(portal.getSignLocation());
|
||||||
if (portal.getButton() != null) {
|
if (portal.getButton() != null) {
|
||||||
lookupBlocks.remove(portal.getButton());
|
lookupBlocks.remove(portal.getButton());
|
||||||
lookupControls.remove(portal.getButton());
|
lookupControls.remove(portal.getButton());
|
||||||
@ -142,7 +142,7 @@ public class PortalHandler {
|
|||||||
allPortals.remove(portal);
|
allPortals.remove(portal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (portal.isBungee()) {
|
if (portal.getOptions().isBungee()) {
|
||||||
//Remove the bungee listing
|
//Remove the bungee listing
|
||||||
bungeePortals.remove(portalName);
|
bungeePortals.remove(portalName);
|
||||||
} else {
|
} else {
|
||||||
@ -161,15 +161,15 @@ public class PortalHandler {
|
|||||||
origin.drawSign();
|
origin.drawSign();
|
||||||
}
|
}
|
||||||
//Close portal without destination
|
//Close portal without destination
|
||||||
if (origin.isAlwaysOn()) {
|
if (origin.getOptions().isAlwaysOn()) {
|
||||||
origin.close(true);
|
origin.close(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear sign data
|
//Clear sign data
|
||||||
if (portal.getId().getBlock().getBlockData() instanceof WallSign) {
|
if (portal.getSignLocation().getBlock().getBlockData() instanceof WallSign) {
|
||||||
Sign sign = (Sign) portal.getId().getBlock().getState();
|
Sign sign = (Sign) portal.getSignLocation().getBlock().getState();
|
||||||
sign.setLine(0, portal.getName());
|
sign.setLine(0, portal.getName());
|
||||||
sign.setLine(1, "");
|
sign.setLine(1, "");
|
||||||
sign.setLine(2, "");
|
sign.setLine(2, "");
|
||||||
@ -186,13 +186,13 @@ public class PortalHandler {
|
|||||||
* @param portal <p>The portal to register</p>
|
* @param portal <p>The portal to register</p>
|
||||||
*/
|
*/
|
||||||
private static void registerPortal(Portal portal) {
|
private static void registerPortal(Portal portal) {
|
||||||
portal.setFixed(portal.getDestinationName().length() > 0 || portal.isRandom() || portal.isBungee());
|
portal.setFixed(portal.getDestinationName().length() > 0 || portal.getOptions().isRandom() || portal.getOptions().isBungee());
|
||||||
|
|
||||||
String portalName = portal.getName().toLowerCase();
|
String portalName = portal.getName().toLowerCase();
|
||||||
String networkName = portal.getNetwork().toLowerCase();
|
String networkName = portal.getNetwork().toLowerCase();
|
||||||
|
|
||||||
//Bungee portals are stored in their own list
|
//Bungee portals are stored in their own list
|
||||||
if (portal.isBungee()) {
|
if (portal.getOptions().isBungee()) {
|
||||||
bungeePortals.put(portalName, portal);
|
bungeePortals.put(portalName, portal);
|
||||||
} else {
|
} else {
|
||||||
//Check if network exists in the lookup list. If not, register the new network
|
//Check if network exists in the lookup list. If not, register the new network
|
||||||
@ -216,8 +216,8 @@ public class PortalHandler {
|
|||||||
lookupBlocks.put(block, portal);
|
lookupBlocks.put(block, portal);
|
||||||
}
|
}
|
||||||
//Register the sign and button to the lookup lists
|
//Register the sign and button to the lookup lists
|
||||||
lookupBlocks.put(portal.getId(), portal);
|
lookupBlocks.put(portal.getSignLocation(), portal);
|
||||||
lookupControls.put(portal.getId(), portal);
|
lookupControls.put(portal.getSignLocation(), portal);
|
||||||
if (portal.getButton() != null) {
|
if (portal.getButton() != null) {
|
||||||
lookupBlocks.put(portal.getButton(), portal);
|
lookupBlocks.put(portal.getButton(), portal);
|
||||||
lookupControls.put(portal.getButton(), portal);
|
lookupControls.put(portal.getButton(), portal);
|
||||||
@ -353,10 +353,11 @@ public class PortalHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the new portal is a valid bungee portal
|
* Checks if the new portal is a valid bungee portal
|
||||||
* @param portalOptions <p>The enabled portal options</p>
|
*
|
||||||
* @param player <p>The player trying to create the new portal</p>
|
* @param portalOptions <p>The enabled portal options</p>
|
||||||
|
* @param player <p>The player trying to create the new portal</p>
|
||||||
* @param destinationName <p>The name of the portal's destination</p>
|
* @param destinationName <p>The name of the portal's destination</p>
|
||||||
* @param network <p>The name of the portal's network</p>
|
* @param network <p>The name of the portal's network</p>
|
||||||
* @return <p>False if the portal is an invalid bungee portal. True otherwise</p>
|
* @return <p>False if the portal is an invalid bungee portal. True otherwise</p>
|
||||||
*/
|
*/
|
||||||
private static boolean isValidBungeePortal(Map<PortalOption, Boolean> portalOptions, Player player,
|
private static boolean isValidBungeePortal(Map<PortalOption, Boolean> portalOptions, Player player,
|
||||||
@ -497,7 +498,7 @@ public class PortalHandler {
|
|||||||
updateNewPortal(portal, destinationName);
|
updateNewPortal(portal, destinationName);
|
||||||
|
|
||||||
//Update portals pointing at this one if it's not a bungee portal
|
//Update portals pointing at this one if it's not a bungee portal
|
||||||
if (!portal.isBungee()) {
|
if (!portal.getOptions().isBungee()) {
|
||||||
updatePortalsPointingAtNewPortal(portal);
|
updatePortalsPointingAtNewPortal(portal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +525,7 @@ public class PortalHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Don't do network checks for bungee portals
|
//Don't do network checks for bungee portals
|
||||||
if (portal.isBungee()) {
|
if (portal.getOptions().isBungee()) {
|
||||||
if (bungeePortals.get(portal.getName().toLowerCase()) != null) {
|
if (bungeePortals.get(portal.getName().toLowerCase()) != null) {
|
||||||
Stargate.debug("createPortal::Bungee", "Gate name duplicate");
|
Stargate.debug("createPortal::Bungee", "Gate name duplicate");
|
||||||
Stargate.sendErrorMessage(player, Stargate.getString("createExists"));
|
Stargate.sendErrorMessage(player, Stargate.getString("createExists"));
|
||||||
@ -584,9 +585,9 @@ public class PortalHandler {
|
|||||||
private static void updateNewPortal(Portal portal, String destinationName) {
|
private static void updateNewPortal(Portal portal, String destinationName) {
|
||||||
portal.drawSign();
|
portal.drawSign();
|
||||||
//Open an always on portal
|
//Open an always on portal
|
||||||
if (portal.isRandom() || portal.isBungee()) {
|
if (portal.getOptions().isRandom() || portal.getOptions().isBungee()) {
|
||||||
portal.open(true);
|
portal.open(true);
|
||||||
} else if (portal.isAlwaysOn()) {
|
} else if (portal.getOptions().isAlwaysOn()) {
|
||||||
Portal destinationPortal = getByName(destinationName, portal.getNetwork());
|
Portal destinationPortal = getByName(destinationName, portal.getNetwork());
|
||||||
if (destinationPortal != null) {
|
if (destinationPortal != null) {
|
||||||
portal.open(true);
|
portal.open(true);
|
||||||
@ -618,7 +619,7 @@ public class PortalHandler {
|
|||||||
origin.drawSign();
|
origin.drawSign();
|
||||||
}
|
}
|
||||||
//Open any always on portal pointing at this portal
|
//Open any always on portal pointing at this portal
|
||||||
if (origin.isAlwaysOn()) {
|
if (origin.getOptions().isAlwaysOn()) {
|
||||||
origin.open(true);
|
origin.open(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -792,7 +793,7 @@ public class PortalHandler {
|
|||||||
BlockLocation button = portal.getButton();
|
BlockLocation button = portal.getButton();
|
||||||
|
|
||||||
builder.append(portal.getName()).append(':');
|
builder.append(portal.getName()).append(':');
|
||||||
builder.append(portal.getId().toString()).append(':');
|
builder.append(portal.getSignLocation().toString()).append(':');
|
||||||
builder.append((button != null) ? button.toString() : "").append(':');
|
builder.append((button != null) ? button.toString() : "").append(':');
|
||||||
builder.append(portal.getModX()).append(':');
|
builder.append(portal.getModX()).append(':');
|
||||||
builder.append(portal.getModZ()).append(':');
|
builder.append(portal.getModZ()).append(':');
|
||||||
@ -808,16 +809,16 @@ public class PortalHandler {
|
|||||||
builder.append(portal.getOwnerName());
|
builder.append(portal.getOwnerName());
|
||||||
}
|
}
|
||||||
builder.append(':');
|
builder.append(':');
|
||||||
builder.append(portal.isHidden()).append(':');
|
builder.append(portal.getOptions().isHidden()).append(':');
|
||||||
builder.append(portal.isAlwaysOn()).append(':');
|
builder.append(portal.getOptions().isAlwaysOn()).append(':');
|
||||||
builder.append(portal.isPrivate()).append(':');
|
builder.append(portal.getOptions().isPrivate()).append(':');
|
||||||
builder.append(portal.getWorld().getName()).append(':');
|
builder.append(portal.getWorld().getName()).append(':');
|
||||||
builder.append(portal.isFree()).append(':');
|
builder.append(portal.getOptions().isFree()).append(':');
|
||||||
builder.append(portal.isBackwards()).append(':');
|
builder.append(portal.getOptions().isBackwards()).append(':');
|
||||||
builder.append(portal.isShown()).append(':');
|
builder.append(portal.getOptions().isShown()).append(':');
|
||||||
builder.append(portal.isNoNetwork()).append(':');
|
builder.append(portal.getOptions().isNoNetwork()).append(':');
|
||||||
builder.append(portal.isRandom()).append(':');
|
builder.append(portal.getOptions().isRandom()).append(':');
|
||||||
builder.append(portal.isBungee());
|
builder.append(portal.getOptions().isBungee());
|
||||||
|
|
||||||
bw.append(builder.toString());
|
bw.append(builder.toString());
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
@ -1038,8 +1039,8 @@ public class PortalHandler {
|
|||||||
portalCount++;
|
portalCount++;
|
||||||
|
|
||||||
//Open the gate if it's set as always open or if it's a bungee gate
|
//Open the gate if it's set as always open or if it's a bungee gate
|
||||||
if (portal.isFixed() && (Stargate.enableBungee && portal.isBungee() || portal.getDestination() != null &&
|
if (portal.isFixed() && (Stargate.enableBungee && portal.getOptions().isBungee() ||
|
||||||
portal.isAlwaysOn())) {
|
portal.getDestination() != null && portal.getOptions().isAlwaysOn())) {
|
||||||
portal.open(true);
|
portal.open(true);
|
||||||
openCount++;
|
openCount++;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package net.knarcraft.stargate.portal;
|
|||||||
|
|
||||||
import net.knarcraft.stargate.container.BlockLocation;
|
import net.knarcraft.stargate.container.BlockLocation;
|
||||||
import net.knarcraft.stargate.container.RelativeBlockVector;
|
import net.knarcraft.stargate.container.RelativeBlockVector;
|
||||||
|
import org.bukkit.Axis;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +57,7 @@ public class PortalLocation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the location of the portal's sign
|
* Gets the location of the portal's sign
|
||||||
|
*
|
||||||
* @return <p>The location of the portal's sign</p>
|
* @return <p>The location of the portal's sign</p>
|
||||||
*/
|
*/
|
||||||
public BlockLocation getSignLocation() {
|
public BlockLocation getSignLocation() {
|
||||||
@ -63,6 +66,7 @@ public class PortalLocation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The relative block vector pointing to the portal's button
|
* The relative block vector pointing to the portal's button
|
||||||
|
*
|
||||||
* @return <p>The relative location of the portal's button</p>
|
* @return <p>The relative location of the portal's button</p>
|
||||||
*/
|
*/
|
||||||
public RelativeBlockVector getButtonVector() {
|
public RelativeBlockVector getButtonVector() {
|
||||||
@ -71,12 +75,32 @@ public class PortalLocation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the block face determining the button's direction
|
* Gets the block face determining the button's direction
|
||||||
|
*
|
||||||
* @return <p>The button's block face</p>
|
* @return <p>The button's block face</p>
|
||||||
*/
|
*/
|
||||||
public BlockFace getButtonFacing() {
|
public BlockFace getButtonFacing() {
|
||||||
return buttonFacing;
|
return buttonFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the rotation axis, which is the axis along which the gate is placed
|
||||||
|
* <p>The portal's rotation axis is the cross axis of the button's axis</p>
|
||||||
|
*
|
||||||
|
* @return <p>The portal's rotation axis</p>
|
||||||
|
*/
|
||||||
|
public Axis getRotationAxis() {
|
||||||
|
return getYaw() == 0.0F || getYaw() == 180.0F ? Axis.X : Axis.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the world this portal resides in
|
||||||
|
*
|
||||||
|
* @return <p>The world this portal resides in</p>
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return topLeft.getWorld();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the portal's top-left location
|
* Sets the portal's top-left location
|
||||||
*
|
*
|
||||||
@ -128,6 +152,7 @@ public class PortalLocation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the location of the portal's sign
|
* Sets the location of the portal's sign
|
||||||
|
*
|
||||||
* @param signLocation <p>The new sign location</p>
|
* @param signLocation <p>The new sign location</p>
|
||||||
* @return <p>The portal location Object</p>
|
* @return <p>The portal location Object</p>
|
||||||
*/
|
*/
|
||||||
@ -138,6 +163,7 @@ public class PortalLocation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the relative location of the portal's button
|
* Sets the relative location of the portal's button
|
||||||
|
*
|
||||||
* @param buttonVector <p>The new relative button location</p>
|
* @param buttonVector <p>The new relative button location</p>
|
||||||
* @return <p>The portal location Object</p>
|
* @return <p>The portal location Object</p>
|
||||||
*/
|
*/
|
||||||
@ -148,6 +174,7 @@ public class PortalLocation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the block face for the direction the portal button is facing
|
* Sets the block face for the direction the portal button is facing
|
||||||
|
*
|
||||||
* @param buttonFacing <p>The new block face of the portal's button</p>
|
* @param buttonFacing <p>The new block face of the portal's button</p>
|
||||||
* @return <p>The portal location Object</p>
|
* @return <p>The portal location Object</p>
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@ public class StarGateThread implements Runnable {
|
|||||||
for (Iterator<Portal> iterator = Stargate.openPortalsQueue.iterator(); iterator.hasNext(); ) {
|
for (Iterator<Portal> iterator = Stargate.openPortalsQueue.iterator(); iterator.hasNext(); ) {
|
||||||
Portal portal = iterator.next();
|
Portal portal = iterator.next();
|
||||||
// Skip always open and non-open gates
|
// Skip always open and non-open gates
|
||||||
if (portal.isAlwaysOn() || !portal.isOpen()) {
|
if (portal.getOptions().isAlwaysOn() || !portal.isOpen()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (time > portal.getOpenTime() + Stargate.getOpenTime()) {
|
if (time > portal.getOpenTime() + Stargate.getOpenTime()) {
|
||||||
|
@ -190,11 +190,11 @@ public final class EconomyHandler {
|
|||||||
*/
|
*/
|
||||||
public static int getUseCost(Player player, Portal source, Portal destination) {
|
public static int getUseCost(Player player, Portal source, Portal destination) {
|
||||||
//No payment required
|
//No payment required
|
||||||
if (!EconomyHandler.useEconomy() || source.isFree()) {
|
if (!EconomyHandler.useEconomy() || source.getOptions().isFree()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//Not charging for free destinations
|
//Not charging for free destinations
|
||||||
if (destination != null && !EconomyHandler.chargeFreeDestination && destination.isFree()) {
|
if (destination != null && !EconomyHandler.chargeFreeDestination && destination.getOptions().isFree()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//Cost is 0 if the player owns this gate and funds go to the owner
|
//Cost is 0 if the player owns this gate and funds go to the owner
|
||||||
|
@ -25,12 +25,12 @@ public final class PermissionHelper {
|
|||||||
Portal destination = portal.getDestination();
|
Portal destination = portal.getDestination();
|
||||||
|
|
||||||
//Always-open gate -- Do nothing
|
//Always-open gate -- Do nothing
|
||||||
if (portal.isAlwaysOn()) {
|
if (portal.getOptions().isAlwaysOn()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Random gate -- Do nothing
|
//Random gate -- Do nothing
|
||||||
if (portal.isRandom()) {
|
if (portal.getOptions().isRandom()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +56,13 @@ public final class PermissionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check if the player can use the private gate
|
//Check if the player can use the private gate
|
||||||
if (portal.isPrivate() && !PermissionHelper.canPrivate(player, portal)) {
|
if (portal.getOptions().isPrivate() && !PermissionHelper.canPrivate(player, portal)) {
|
||||||
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
|
Stargate.sendErrorMessage(player, Stargate.getString("denyMsg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Destination blocked
|
//Destination blocked
|
||||||
if ((destination.isOpen()) && (!destination.isAlwaysOn())) {
|
if ((destination.isOpen()) && (!destination.getOptions().isAlwaysOn())) {
|
||||||
Stargate.sendErrorMessage(player, Stargate.getString("blockMsg"));
|
Stargate.sendErrorMessage(player, Stargate.getString("blockMsg"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -98,13 +98,13 @@ public final class PermissionHelper {
|
|||||||
public static boolean cannotAccessPortal(Player player, Portal entrancePortal, Portal destination) {
|
public static boolean cannotAccessPortal(Player player, Portal entrancePortal, Portal destination) {
|
||||||
boolean deny = false;
|
boolean deny = false;
|
||||||
// Check if player has access to this server for Bungee gates
|
// Check if player has access to this server for Bungee gates
|
||||||
if (entrancePortal.isBungee() && !PermissionHelper.canAccessServer(player, entrancePortal.getNetwork())) {
|
if (entrancePortal.getOptions().isBungee() && !PermissionHelper.canAccessServer(player, entrancePortal.getNetwork())) {
|
||||||
Stargate.debug("cannotAccessPortal", "Cannot access server");
|
Stargate.debug("cannotAccessPortal", "Cannot access server");
|
||||||
deny = true;
|
deny = true;
|
||||||
} else if (PermissionHelper.cannotAccessNetwork(player, entrancePortal.getNetwork())) {
|
} else if (PermissionHelper.cannotAccessNetwork(player, entrancePortal.getNetwork())) {
|
||||||
Stargate.debug("cannotAccessPortal", "Cannot access network");
|
Stargate.debug("cannotAccessPortal", "Cannot access network");
|
||||||
deny = true;
|
deny = true;
|
||||||
} else if (!entrancePortal.isBungee() && PermissionHelper.cannotAccessWorld(player, destination.getWorld().getName())) {
|
} else if (!entrancePortal.getOptions().isBungee() && PermissionHelper.cannotAccessWorld(player, destination.getWorld().getName())) {
|
||||||
Stargate.debug("cannotAccessPortal", "Cannot access world");
|
Stargate.debug("cannotAccessPortal", "Cannot access world");
|
||||||
deny = true;
|
deny = true;
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ public final class PermissionHelper {
|
|||||||
*/
|
*/
|
||||||
public static boolean isFree(Player player, Portal src, Portal dest) {
|
public static boolean isFree(Player player, Portal src, Portal dest) {
|
||||||
// This gate is free
|
// This gate is free
|
||||||
if (src.isFree()) {
|
if (src.getOptions().isFree()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Player gets free use
|
// Player gets free use
|
||||||
@ -227,7 +227,7 @@ public final class PermissionHelper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Don't charge for free destination gates
|
// Don't charge for free destination gates
|
||||||
return dest != null && !EconomyHandler.chargeFreeDestination && dest.isFree();
|
return dest != null && !EconomyHandler.chargeFreeDestination && dest.getOptions().isFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,7 +241,7 @@ public final class PermissionHelper {
|
|||||||
*/
|
*/
|
||||||
public static boolean canSeePortal(Player player, Portal portal) {
|
public static boolean canSeePortal(Player player, Portal portal) {
|
||||||
// The gate is not hidden
|
// The gate is not hidden
|
||||||
if (!portal.isHidden()) {
|
if (!portal.getOptions().isHidden()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// The player is an admin with the ability to see hidden gates
|
// The player is an admin with the ability to see hidden gates
|
||||||
|
@ -25,7 +25,7 @@ public final class SignHelper {
|
|||||||
//Default sign text
|
//Default sign text
|
||||||
drawInactiveSign(sign, portal);
|
drawInactiveSign(sign, portal);
|
||||||
} else {
|
} else {
|
||||||
if (portal.isBungee()) {
|
if (portal.getOptions().isBungee()) {
|
||||||
//Bungee sign
|
//Bungee sign
|
||||||
drawBungeeSign(sign, portal);
|
drawBungeeSign(sign, portal);
|
||||||
} else if (portal.isFixed()) {
|
} else if (portal.isFixed()) {
|
||||||
@ -126,7 +126,7 @@ public final class SignHelper {
|
|||||||
private static void drawInactiveSign(Sign sign, Portal portal) {
|
private static void drawInactiveSign(Sign sign, Portal portal) {
|
||||||
Stargate.setLine(sign, 1, Stargate.getString("signRightClick"));
|
Stargate.setLine(sign, 1, Stargate.getString("signRightClick"));
|
||||||
Stargate.setLine(sign, 2, Stargate.getString("signToUse"));
|
Stargate.setLine(sign, 2, Stargate.getString("signToUse"));
|
||||||
if (!portal.isNoNetwork()) {
|
if (!portal.getOptions().isNoNetwork()) {
|
||||||
Stargate.setLine(sign, 3, "(" + portal.getNetwork() + ")");
|
Stargate.setLine(sign, 3, "(" + portal.getNetwork() + ")");
|
||||||
} else {
|
} else {
|
||||||
Stargate.setLine(sign, 3, "");
|
Stargate.setLine(sign, 3, "");
|
||||||
@ -139,18 +139,18 @@ public final class SignHelper {
|
|||||||
* @param sign <p>The sign to draw on</p>
|
* @param sign <p>The sign to draw on</p>
|
||||||
*/
|
*/
|
||||||
private static void drawFixedSign(Sign sign, Portal portal) {
|
private static void drawFixedSign(Sign sign, Portal portal) {
|
||||||
if (portal.isRandom()) {
|
if (portal.getOptions().isRandom()) {
|
||||||
Stargate.setLine(sign, 1, "> " + Stargate.getString("signRandom") + " <");
|
Stargate.setLine(sign, 1, "> " + Stargate.getString("signRandom") + " <");
|
||||||
} else {
|
} else {
|
||||||
Stargate.setLine(sign, 1, ">" + portal.getDestinationName() + "<");
|
Stargate.setLine(sign, 1, ">" + portal.getDestinationName() + "<");
|
||||||
}
|
}
|
||||||
if (portal.isNoNetwork()) {
|
if (portal.getOptions().isNoNetwork()) {
|
||||||
Stargate.setLine(sign, 2, "");
|
Stargate.setLine(sign, 2, "");
|
||||||
} else {
|
} else {
|
||||||
Stargate.setLine(sign, 2, "(" + portal.getNetwork() + ")");
|
Stargate.setLine(sign, 2, "(" + portal.getNetwork() + ")");
|
||||||
}
|
}
|
||||||
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
|
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
|
||||||
if (destination == null && !portal.isRandom()) {
|
if (destination == null && !portal.getOptions().isRandom()) {
|
||||||
Stargate.setLine(sign, 3, Stargate.getString("signDisconnected"));
|
Stargate.setLine(sign, 3, Stargate.getString("signDisconnected"));
|
||||||
} else {
|
} else {
|
||||||
Stargate.setLine(sign, 3, "");
|
Stargate.setLine(sign, 3, "");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user