Change AntiBot from static to instance
- Convert static methods in AntiBot - Create BukkitService for operations requiring calls to static methods on the Bukkit class
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package fr.xephi.authme.util;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* Service for operations requiring server entities, such as for scheduling.
|
||||
*/
|
||||
public class BukkitService {
|
||||
|
||||
private final AuthMe authMe;
|
||||
|
||||
public BukkitService(AuthMe authMe) {
|
||||
this.authMe = authMe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a once off task to occur as soon as possible.
|
||||
* <p>
|
||||
* This task will be executed by the main server thread.
|
||||
*
|
||||
* @param task Task to be executed
|
||||
* @return Task id number (-1 if scheduling failed)
|
||||
*/
|
||||
public int scheduleSyncDelayedTask(Runnable task) {
|
||||
return Bukkit.getScheduler().scheduleSyncDelayedTask(authMe, task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a once off task to occur after a delay.
|
||||
* <p>
|
||||
* This task will be executed by the main server thread.
|
||||
*
|
||||
* @param task Task to be executed
|
||||
* @param delay Delay in server ticks before executing task
|
||||
* @return Task id number (-1 if scheduling failed)
|
||||
*/
|
||||
public int scheduleSyncDelayedTask(Runnable task, long delay) {
|
||||
return Bukkit.getScheduler().scheduleSyncDelayedTask(authMe, task, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a message to all players.
|
||||
*
|
||||
* @param message the message
|
||||
* @return the number of players
|
||||
*/
|
||||
public int broadcastMessage(String message) {
|
||||
return Bukkit.broadcastMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user