From 66a8afab99efb7ac7669961eb2e67e2244d494e5 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 19 Dec 2018 14:07:01 +0000 Subject: Count current tick using an int instead of LongAdder Assuming 20tps, there's enough space in an int to store a tick count spanning a number of years :) --- .../main/java/me/lucko/spark/bukkit/BukkitTickCounter.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'spark-bukkit/src/main/java/me/lucko/spark') diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java index fbab3e7..3b95399 100644 --- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java +++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java @@ -27,14 +27,13 @@ import org.bukkit.scheduler.BukkitTask; import java.util.HashSet; import java.util.Set; -import java.util.concurrent.atomic.LongAdder; public class BukkitTickCounter implements TickCounter, Runnable { private final Plugin plugin; private BukkitTask task; private final Set tasks = new HashSet<>(); - private final LongAdder tick = new LongAdder(); + private int tick = 0; public BukkitTickCounter(Plugin plugin) { this.plugin = plugin; @@ -42,10 +41,10 @@ public class BukkitTickCounter implements TickCounter, Runnable { @Override public void run() { - for (Runnable r : this.tasks){ + for (Runnable r : this.tasks) { r.run(); } - this.tick.increment(); + this.tick++; } @Override @@ -59,8 +58,8 @@ public class BukkitTickCounter implements TickCounter, Runnable { } @Override - public long getCurrentTick() { - return this.tick.longValue(); + public int getCurrentTick() { + return this.tick; } @Override -- cgit