refactor(pomodoro): simplify plugin instance retrieval
Some checks are pending
/ build (push) Waiting to run

Replaced passing the plugin instance to PomodoroRunnable with direct access via TweaksPlugin singleton. This removes redundant code, improving clarity and maintainability.
This commit is contained in:
Minecon724 2025-02-02 14:57:18 +01:00
parent ad1a699d38
commit 1fafc90e04
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
2 changed files with 4 additions and 6 deletions

View file

@ -12,7 +12,7 @@ public class PomodoroModule extends TweaksModule {
@Override @Override
protected void onInit() { protected void onInit() {
registerEvents(new PomodoroListener()); registerEvents(new PomodoroListener());
new PomodoroRunnable(getPlugin()).runTaskTimerAsynchronously(getPlugin(), 0, 20L); new PomodoroRunnable().runTaskTimerAsynchronously(getPlugin(), 0, 20L);
registerCommand("pomodoro", new PomodoroCommands()); registerCommand("pomodoro", new PomodoroCommands());
} }

View file

@ -6,6 +6,7 @@
package eu.m724.tweaks.module.pomodoro; package eu.m724.tweaks.module.pomodoro;
import eu.m724.tweaks.TweaksPlugin;
import eu.m724.tweaks.config.TweaksConfig; import eu.m724.tweaks.config.TweaksConfig;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -15,15 +16,12 @@ import org.bukkit.scheduler.BukkitRunnable;
public class PomodoroRunnable extends BukkitRunnable { public class PomodoroRunnable extends BukkitRunnable {
private final boolean force = TweaksConfig.getConfig().pomodoroForce(); private final boolean force = TweaksConfig.getConfig().pomodoroForce();
private final Plugin plugin; private final Plugin plugin = TweaksPlugin.getInstance(); // used only to kick
public PomodoroRunnable(Plugin plugin) {
this.plugin = plugin; // only used for kicking
}
@Override @Override
public void run() { public void run() {
long now = System.nanoTime(); long now = System.nanoTime();
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
PlayerPomodoro pomodoro = Pomodoros.get(player); PlayerPomodoro pomodoro = Pomodoros.get(player);
if (pomodoro == null) return; if (pomodoro == null) return;