aboutsummaryrefslogtreecommitdiff
path: root/spark-bukkit/src/main
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2018-12-19 14:07:01 +0000
committerLuck <git@lucko.me>2018-12-19 14:07:01 +0000
commit66a8afab99efb7ac7669961eb2e67e2244d494e5 (patch)
tree7930ab1768da5df81799995472292d73d6ce2647 /spark-bukkit/src/main
parentdb6ac9b36ae0242c53dc1452ac8fbc6cd7b748c2 (diff)
downloadspark-66a8afab99efb7ac7669961eb2e67e2244d494e5.tar.gz
spark-66a8afab99efb7ac7669961eb2e67e2244d494e5.tar.bz2
spark-66a8afab99efb7ac7669961eb2e67e2244d494e5.zip
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 :)
Diffstat (limited to 'spark-bukkit/src/main')
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java11
1 files changed, 5 insertions, 6 deletions
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<Runnable> 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