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
 | 
			
		||||
    protected void onInit() {
 | 
			
		||||
        registerEvents(new PomodoroListener());
 | 
			
		||||
        new PomodoroRunnable(getPlugin()).runTaskTimerAsynchronously(getPlugin(), 0, 20L);
 | 
			
		||||
        new PomodoroRunnable().runTaskTimerAsynchronously(getPlugin(), 0, 20L);
 | 
			
		||||
 | 
			
		||||
        registerCommand("pomodoro", new PomodoroCommands());
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@
 | 
			
		|||
 | 
			
		||||
package eu.m724.tweaks.module.pomodoro;
 | 
			
		||||
 | 
			
		||||
import eu.m724.tweaks.TweaksPlugin;
 | 
			
		||||
import eu.m724.tweaks.config.TweaksConfig;
 | 
			
		||||
import net.md_5.bungee.api.ChatMessageType;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
| 
						 | 
				
			
			@ -15,15 +16,12 @@ import org.bukkit.scheduler.BukkitRunnable;
 | 
			
		|||
 | 
			
		||||
public class PomodoroRunnable extends BukkitRunnable {
 | 
			
		||||
    private final boolean force = TweaksConfig.getConfig().pomodoroForce();
 | 
			
		||||
    private final Plugin plugin;
 | 
			
		||||
 | 
			
		||||
    public PomodoroRunnable(Plugin plugin) {
 | 
			
		||||
        this.plugin = plugin; // only used for kicking
 | 
			
		||||
    }
 | 
			
		||||
    private final Plugin plugin = TweaksPlugin.getInstance(); // used only to kick
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void run() {
 | 
			
		||||
        long now = System.nanoTime();
 | 
			
		||||
 | 
			
		||||
        Bukkit.getOnlinePlayers().forEach(player -> {
 | 
			
		||||
            PlayerPomodoro pomodoro = Pomodoros.get(player);
 | 
			
		||||
            if (pomodoro == null) return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue