Added a serverside uptime tick counter
This commit is contained in:
parent
c49fdfa5ff
commit
32851b8fb0
@ -183,6 +183,18 @@ public class Server {
|
||||
return this.serverThread.getTicker().getTPS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of ticks performed since the server has started. This
|
||||
* value resets on shutdowns. The counter is incremented at the end of a
|
||||
* tick.
|
||||
*
|
||||
* @return the number of times the world has finished a tick since the
|
||||
* server has started.
|
||||
*/
|
||||
public long getUptimeTicks() {
|
||||
return this.serverThread.getTicker().getUptimeTicks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link WorldAccessor} object for this server. Use the
|
||||
* provided accessor to
|
||||
|
@ -82,6 +82,7 @@ public class TickerCoordinator {
|
||||
private boolean isTickStartSet = false;
|
||||
private long tickStart = -1;
|
||||
private double tickLength = 1.0 / 20; // Do something about it
|
||||
private long ticks = 0;
|
||||
|
||||
private final Logger logger = LogManager.getLogger("Ticker Coordinator");
|
||||
|
||||
@ -152,6 +153,10 @@ public class TickerCoordinator {
|
||||
return 1 / tickLength;
|
||||
}
|
||||
|
||||
public long getUptimeTicks() {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
private void onTickStart() {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
@ -164,6 +169,10 @@ public class TickerCoordinator {
|
||||
tickStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void onTickEnd() {
|
||||
ticks++;
|
||||
}
|
||||
|
||||
/*
|
||||
* runOneTick & Friends
|
||||
*/
|
||||
@ -183,6 +192,8 @@ public class TickerCoordinator {
|
||||
passes++;
|
||||
}
|
||||
|
||||
onTickEnd();
|
||||
|
||||
logger.debug("Tick complete; run {} passes", passes);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
@ -191,7 +202,7 @@ public class TickerCoordinator {
|
||||
// ...or almost silently
|
||||
logger.debug("Tick interrupted. WTF?");
|
||||
} catch (Exception e) {
|
||||
crash(e, "Coordinator");
|
||||
throw CrashReports.report(e, "Coordinator");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user