Renames activatedTime to triggeredTime and makes some public fields private

Makes the active portals queue and open portals queue and languageLoader fields private
Cleans the StargateThread a bit
Renames activatedTime to triggeredTime as the dual use (open and activate) made the name confusing
This commit is contained in:
2021-10-29 17:22:58 +02:00
parent 5d84e1d78a
commit 0237f45046
7 changed files with 116 additions and 48 deletions

View File

@ -125,15 +125,15 @@ public class Portal {
}
/**
* Gets the time this portal was activated/opened
* Gets the time this portal was triggered (activated/opened)
*
* <p>The time is given in the equivalent of a Unix timestamp. It's used to decide when a portal times out and
* automatically closes.</p>
* automatically closes/deactivates.</p>
*
* @return <p>The time this portal was activated/opened</p>
* @return <p>The time this portal was triggered (activated/opened)</p>
*/
public long getActivatedTime() {
return portalOpener.getActivatedTime();
public long getTriggeredTime() {
return portalOpener.getTriggeredTime();
}
/**

View File

@ -131,7 +131,7 @@ public class PortalActivator {
this.destinations.clear();
//Adds the active gate to the active queue to allow it to be remotely deactivated
Stargate.activePortalsQueue.add(portal);
Stargate.getStargateConfig().getActivePortalsQueue().add(portal);
//Set the given player as the active player
activePlayer = player;
@ -166,7 +166,7 @@ public class PortalActivator {
StargateActivateEvent event = new StargateActivateEvent(portal, player, destinations, destination);
Stargate.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
Stargate.activePortalsQueue.remove(portal);
Stargate.getStargateConfig().getActivePortalsQueue().remove(portal);
return false;
}
@ -189,7 +189,7 @@ public class PortalActivator {
}
//Un-mark the portal as activated
Stargate.activePortalsQueue.remove(portal);
Stargate.getStargateConfig().getActivePortalsQueue().remove(portal);
//For a fixed gate, the destinations and the sign never really change, but at the same time, fixed gates are
// never really activated, so in theory, this check should be redundant.
@ -261,7 +261,7 @@ public class PortalActivator {
//Update the activated time to allow it to be deactivated after a timeout, and re-draw the sign to show the
// selected destination
opener.setActivatedTime(System.currentTimeMillis() / 1000);
opener.setTriggeredTime(System.currentTimeMillis() / 1000);
portal.drawSign();
}

View File

@ -17,7 +17,7 @@ public class PortalOpener {
private boolean isOpen = false;
private final Portal portal;
private long activatedTime;
private long triggeredTime;
private Player player;
private final PortalActivator portalActivator;
@ -42,12 +42,12 @@ public class PortalOpener {
}
/**
* Sets the time when this portal was activated/opened
* Sets the time when this portal was triggered (activated/opened)
*
* @param activatedTime <p>Unix timestamp when portal was activated/opened</p>
* @param triggeredTime <p>Unix timestamp when portal was triggered</p>
*/
public void setActivatedTime(long activatedTime) {
this.activatedTime = activatedTime;
public void setTriggeredTime(long triggeredTime) {
this.triggeredTime = triggeredTime;
}
/**
@ -88,7 +88,7 @@ public class PortalOpener {
//Change the entrance blocks to the correct type
for (BlockLocation inside : portal.getStructure().getEntrances()) {
Stargate.blockChangeRequestQueue.add(new BlockChangeRequest(inside, openType, axis));
Stargate.addBlockChangeRequest(new BlockChangeRequest(inside, openType, axis));
}
//Update the portal state to make is actually open
@ -103,11 +103,11 @@ public class PortalOpener {
private void updatePortalOpenState(Player openFor) {
//Update the open state of this portal
isOpen = true;
activatedTime = System.currentTimeMillis() / 1000;
triggeredTime = System.currentTimeMillis() / 1000;
//Change state from active to open
Stargate.openPortalsQueue.add(portal);
Stargate.activePortalsQueue.remove(portal);
Stargate.getStargateConfig().getOpenPortalsQueue().add(portal);
Stargate.getStargateConfig().getActivePortalsQueue().remove(portal);
PortalOptions options = portal.getOptions();
@ -165,7 +165,7 @@ public class PortalOpener {
//Close the portal by requesting the opening blocks to change
Material closedType = portal.getGate().getPortalClosedBlock();
for (BlockLocation entrance : portal.getStructure().getEntrances()) {
Stargate.blockChangeRequestQueue.add(new BlockChangeRequest(entrance, closedType, null));
Stargate.addBlockChangeRequest(new BlockChangeRequest(entrance, closedType, null));
}
//Update the portal state to make it actually closed
@ -184,8 +184,8 @@ public class PortalOpener {
isOpen = false;
//Un-mark the portal as active and open
Stargate.openPortalsQueue.remove(portal);
Stargate.activePortalsQueue.remove(portal);
Stargate.getStargateConfig().getOpenPortalsQueue().remove(portal);
Stargate.getStargateConfig().getActivePortalsQueue().remove(portal);
//Close the destination portal if not always open
if (!portal.getOptions().isAlwaysOn()) {
@ -219,12 +219,12 @@ public class PortalOpener {
}
/**
* Gets the time this portal opener's portal was activated/opened
* Gets the time this portal opener's portal was triggered (activated/opened)
*
* @return <p>The time this portal opener's portal was activated/opened</p>
* @return <p>The time this portal opener's portal was triggered</p>
*/
public long getActivatedTime() {
return activatedTime;
public long getTriggeredTime() {
return triggeredTime;
}
}