diff options
Diffstat (limited to 'spark-bukkit/src/main')
-rw-r--r-- | spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitTickCounter.java | 28 | ||||
-rw-r--r-- | spark-bukkit/src/main/java/me/lucko/spark/bukkit/PaperTickCounter.java | 28 |
2 files changed, 6 insertions, 50 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 44a69cb..2a71257 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 @@ -20,30 +20,22 @@ package me.lucko.spark.bukkit; +import me.lucko.spark.common.sampler.AbstractTickCounter; import me.lucko.spark.common.sampler.TickCounter; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitTask; -import java.util.HashSet; -import java.util.Set; - -public class BukkitTickCounter implements TickCounter, Runnable { +public class BukkitTickCounter extends AbstractTickCounter implements TickCounter, Runnable { private final Plugin plugin; private BukkitTask task; - private final Set<TickTask> tasks = new HashSet<>(); - private int tick = 0; - public BukkitTickCounter(Plugin plugin) { this.plugin = plugin; } @Override public void run() { - for (TickTask r : this.tasks) { - r.onTick(this); - } - this.tick++; + onTick(); } @Override @@ -56,18 +48,4 @@ public class BukkitTickCounter 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); - } } diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/PaperTickCounter.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/PaperTickCounter.java index e545687..7189429 100644 --- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/PaperTickCounter.java +++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/PaperTickCounter.java @@ -21,31 +21,23 @@ package me.lucko.spark.bukkit; import com.destroystokyo.paper.event.server.ServerTickStartEvent; +import me.lucko.spark.common.sampler.AbstractTickCounter; import me.lucko.spark.common.sampler.TickCounter; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import java.util.HashSet; -import java.util.Set; - -public class PaperTickCounter implements TickCounter, Listener { +public class PaperTickCounter extends AbstractTickCounter implements TickCounter, Listener { private final Plugin plugin; - private final Set<TickTask> tasks = new HashSet<>(); - private int tick = 0; - public PaperTickCounter(Plugin plugin) { this.plugin = plugin; } @EventHandler public void onServerTickEvent(ServerTickStartEvent e) { - for (TickTask r : this.tasks) { - r.onTick(this); - } - this.tick++; + onTick(); } @Override @@ -58,18 +50,4 @@ public class PaperTickCounter implements TickCounter, Listener { HandlerList.unregisterAll(this); } - @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); - } } |