Skip to content

Commit

Permalink
Cleaned code
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Sep 23, 2022
1 parent e65cc29 commit e2ff574
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -5,14 +5,15 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;

public class CalcTask extends BukkitRunnable {

private static final SuperiorSkyblockPlugin plugin = SuperiorSkyblockPlugin.getPlugin();
private static int id = -1;
private static BukkitTask calcTask;

private CalcTask() {
id = runTaskTimerAsynchronously(plugin, plugin.getSettings().getCalcInterval(), plugin.getSettings().getCalcInterval()).getTaskId();
calcTask = runTaskTimerAsynchronously(plugin, plugin.getSettings().getCalcInterval(), plugin.getSettings().getCalcInterval());
}

public static void startTask() {
Expand All @@ -22,8 +23,10 @@ public static void startTask() {
}

public static void cancelTask() {
if (id != -1)
Bukkit.getScheduler().cancelTask(id);
if (calcTask != null) {
calcTask.cancel();
calcTask = null;
}
}

@Override
Expand Down

0 comments on commit e2ff574

Please sign in to comment.