diff options
author | Luck <git@lucko.me> | 2020-01-11 19:30:15 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2020-01-11 19:30:15 +0000 |
commit | 2fe79f4140011f93df1567afcc9b75fababa187e (patch) | |
tree | 2a747c3da719d061302577b9cda422fe609ab636 /spark-sponge/src/main | |
parent | 9e066d1052643b2be270b4039a102260abb41ebb (diff) | |
download | spark-2fe79f4140011f93df1567afcc9b75fababa187e.tar.gz spark-2fe79f4140011f93df1567afcc9b75fababa187e.tar.bz2 spark-2fe79f4140011f93df1567afcc9b75fababa187e.zip |
Add AbstractTickCounter
Diffstat (limited to 'spark-sponge/src/main')
-rw-r--r-- | spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickCounter.java | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickCounter.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickCounter.java index 3c5db06..d7823b1 100644 --- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickCounter.java +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeTickCounter.java @@ -20,17 +20,13 @@ package me.lucko.spark.sponge; +import me.lucko.spark.common.sampler.AbstractTickCounter; import me.lucko.spark.common.sampler.TickCounter; +import org.spongepowered.api.scheduler.Task; -import java.util.HashSet; -import java.util.Set; - -public class SpongeTickCounter implements TickCounter, Runnable { +public class SpongeTickCounter extends AbstractTickCounter implements TickCounter, Runnable { private final SpongeSparkPlugin plugin; - private org.spongepowered.api.scheduler.Task task; - - private final Set<TickTask> tasks = new HashSet<>(); - private int tick = 0; + private Task task; public SpongeTickCounter(SpongeSparkPlugin plugin) { this.plugin = plugin; @@ -38,15 +34,12 @@ public class SpongeTickCounter implements TickCounter, Runnable { @Override public void run() { - for (TickTask r : this.tasks){ - r.onTick(this); - } - this.tick++; + onTick(); } @Override public void start() { - this.task = org.spongepowered.api.scheduler.Task.builder().intervalTicks(1).name("spark-ticker").execute(this).submit(this.plugin); + this.task = Task.builder().intervalTicks(1).name("spark-ticker").execute(this).submit(this.plugin); } @Override @@ -54,18 +47,4 @@ public class SpongeTickCounter implements TickCounter, Runnable { this.task.cancel(); } - @Override - public int getCurrentTick() { - return this.tick; - } - - @Override - public void addTickTask(TickTask runnable) { - this.tasks.add(runnable); - } - - @Override - public void removeTickTask(TickTask runnable) { - this.tasks.remove(runnable); - } } |