refactor(pomodoro): simplify plugin instance retrieval
Some checks are pending
/ build (push) Waiting to run
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:
parent
ad1a699d38
commit
1fafc90e04
2 changed files with 4 additions and 6 deletions
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue