diff --git a/src/main/java/ru/windcorp/progressia/server/Server.java b/src/main/java/ru/windcorp/progressia/server/Server.java index 8aca03c..487616d 100644 --- a/src/main/java/ru/windcorp/progressia/server/Server.java +++ b/src/main/java/ru/windcorp/progressia/server/Server.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + package ru.windcorp.progressia.server; import java.util.function.Consumer; @@ -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 diff --git a/src/main/java/ru/windcorp/progressia/server/world/ticking/TickerCoordinator.java b/src/main/java/ru/windcorp/progressia/server/world/ticking/TickerCoordinator.java index fa2a2d2..7d58d6d 100644 --- a/src/main/java/ru/windcorp/progressia/server/world/ticking/TickerCoordinator.java +++ b/src/main/java/ru/windcorp/progressia/server/world/ticking/TickerCoordinator.java @@ -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"); @@ -151,6 +152,10 @@ public class TickerCoordinator { public double getTPS() { return 1 / tickLength; } + + public long getUptimeTicks() { + return ticks; + } private void onTickStart() { long now = System.currentTimeMillis(); @@ -163,6 +168,10 @@ public class TickerCoordinator { tickStart = System.currentTimeMillis(); } + + private void onTickEnd() { + ticks++; + } /* * runOneTick & Friends @@ -182,6 +191,8 @@ public class TickerCoordinator { logger.debug("Pass complete"); passes++; } + + onTickEnd(); logger.debug("Tick complete; run {} passes", passes); @@ -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"); } }