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:
@@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import fr.xephi.authme.AntiBot;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
@@ -34,6 +35,7 @@ public class CommandService {
|
||||
private final IpAddressManager ipAddressManager;
|
||||
private final PluginHooks pluginHooks;
|
||||
private final SpawnLoader spawnLoader;
|
||||
private final AntiBot antiBot;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -51,7 +53,8 @@ public class CommandService {
|
||||
*/
|
||||
public CommandService(AuthMe authMe, CommandMapper commandMapper, HelpProvider helpProvider, Messages messages,
|
||||
PasswordSecurity passwordSecurity, PermissionsManager permissionsManager, NewSetting settings,
|
||||
IpAddressManager ipAddressManager, PluginHooks pluginHooks, SpawnLoader spawnLoader) {
|
||||
IpAddressManager ipAddressManager, PluginHooks pluginHooks, SpawnLoader spawnLoader,
|
||||
AntiBot antiBot) {
|
||||
this.authMe = authMe;
|
||||
this.messages = messages;
|
||||
this.helpProvider = helpProvider;
|
||||
@@ -62,6 +65,7 @@ public class CommandService {
|
||||
this.ipAddressManager = ipAddressManager;
|
||||
this.pluginHooks = pluginHooks;
|
||||
this.spawnLoader = spawnLoader;
|
||||
this.antiBot = antiBot;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,4 +215,8 @@ public class CommandService {
|
||||
return spawnLoader;
|
||||
}
|
||||
|
||||
public AntiBot getAntiBot() {
|
||||
return antiBot;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
AntiBot antiBot = commandService.getAntiBot();
|
||||
if (arguments.isEmpty()) {
|
||||
sender.sendMessage("[AuthMe] AntiBot status: " + AntiBot.getAntiBotStatus().name());
|
||||
sender.sendMessage("[AuthMe] AntiBot status: " + antiBot.getAntiBotStatus().name());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,10 +28,10 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
|
||||
|
||||
// Enable or disable the mod
|
||||
if ("ON".equalsIgnoreCase(newState)) {
|
||||
AntiBot.overrideAntiBotStatus(true);
|
||||
antiBot.overrideAntiBotStatus(true);
|
||||
sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!");
|
||||
} else if ("OFF".equalsIgnoreCase(newState)) {
|
||||
AntiBot.overrideAntiBotStatus(false);
|
||||
antiBot.overrideAntiBotStatus(false);
|
||||
sender.sendMessage("[AuthMe] AntiBot Manual Override: disabled!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Invalid AntiBot mode!");
|
||||
|
||||
Reference in New Issue
Block a user