mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
Added expiration timer to sessions. Sessions will now last up to 10 minutes (by default) before removed, so you can quickly disconnect (or crash) and come back and still maintain your history.
This commit is contained in:
@ -51,9 +51,11 @@ import com.sk89q.worldedit.regions.RegionSelector;
|
||||
*/
|
||||
public class LocalSession {
|
||||
public static int MAX_HISTORY_SIZE = 15;
|
||||
public static int EXPIRATION_GRACE = 600000;
|
||||
|
||||
private LocalConfiguration config;
|
||||
|
||||
private long expirationTime = 0;
|
||||
private LocalWorld selectionWorld;
|
||||
private RegionSelector selector = new CuboidRegionSelector();
|
||||
private boolean placeAtPos1 = false;
|
||||
@ -615,4 +617,20 @@ public class LocalSession {
|
||||
return date.getBeginCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the last update time for calculating expiration.
|
||||
*/
|
||||
public void update() {
|
||||
expirationTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this session has expired.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasExpired() {
|
||||
return System.currentTimeMillis() - expirationTime > EXPIRATION_GRACE;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user