From 2fe79f4140011f93df1567afcc9b75fababa187e Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 11 Jan 2020 19:30:15 +0000 Subject: Add AbstractTickCounter --- .../me/lucko/spark/fabric/FabricTickCounter.java | 29 +++------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'spark-fabric/src/main') diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java index b189e3f..ce58dcf 100644 --- a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java +++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricTickCounter.java @@ -20,35 +20,14 @@ package me.lucko.spark.fabric; +import me.lucko.spark.common.sampler.AbstractTickCounter; import me.lucko.spark.common.sampler.TickCounter; -import java.util.HashSet; -import java.util.Set; - -public abstract class FabricTickCounter implements TickCounter { - private final Set tasks = new HashSet<>(); - private int tick = 0; - - public void onTick() { - for (TickTask r : this.tasks) { - r.onTick(this); - } - this.tick++; - } - - @Override - public int getCurrentTick() { - return this.tick; - } - - @Override - public void addTickTask(TickTask runnable) { - this.tasks.add(runnable); - } +public abstract class FabricTickCounter extends AbstractTickCounter implements TickCounter { @Override - public void removeTickTask(TickTask runnable) { - this.tasks.remove(runnable); + public void onTick() { + super.onTick(); } public static final class Server extends FabricTickCounter { -- cgit