mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-31 07:39:42 +01:00
Implemented the switchantibot command
This commit is contained in:
parent
559072b3c6
commit
e3a6c73b58
@ -721,6 +721,10 @@ public class AuthMe extends JavaPlugin {
|
||||
Settings.switchAntiBotMod(mode);
|
||||
}
|
||||
|
||||
public boolean getAntiBotModMode() {
|
||||
return this.antibotMod;
|
||||
}
|
||||
|
||||
private void recallEmail() {
|
||||
if (!Settings.recallEmail)
|
||||
return;
|
||||
|
@ -317,6 +317,20 @@ public class CommandManager {
|
||||
authMeCommand);
|
||||
purgeBannedPlayersCommand.setCommandPermissions("authme.admin.purgebannedplayers", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
|
||||
// Register the switchantibot command
|
||||
CommandDescription switchAntiBotCommand = new CommandDescription(
|
||||
new PurgeLastPositionCommand(),
|
||||
new ArrayList<String>() {{
|
||||
add("switchantibot");
|
||||
add("toggleantibot");
|
||||
add("antibot");
|
||||
}},
|
||||
"Switch AntiBot mode",
|
||||
"Switch or toggle the AntiBot mode to the specified state.",
|
||||
authMeCommand);
|
||||
switchAntiBotCommand.setCommandPermissions("authme.admin.switchantibot", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
switchAntiBotCommand.addArgument(new CommandArgumentDescription("mode", "ON / OFF", true));
|
||||
|
||||
// Register the reload command
|
||||
CommandDescription reloadCommand = new CommandDescription(
|
||||
new ReloadCommand(),
|
||||
|
@ -0,0 +1,46 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class SwitchAntiBotCommand extends ExecutableCommand {
|
||||
|
||||
/**
|
||||
* Execute the command.
|
||||
*
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
// Get the new state
|
||||
String newState = plugin.getAntiBotModMode() ? "OFF" : "ON";
|
||||
if(commandArguments.getCount() >= 1)
|
||||
newState = commandArguments.get(0);
|
||||
|
||||
// Enable the mod
|
||||
if(newState.equalsIgnoreCase("ON")) {
|
||||
plugin.switchAntiBotMod(true);
|
||||
sender.sendMessage("[AuthMe] AntiBotMod enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disable the mod
|
||||
if(newState.equalsIgnoreCase("OFF")) {
|
||||
plugin.switchAntiBotMod(false);
|
||||
sender.sendMessage("[AuthMe] AntiBotMod disabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Invalid command arguments, return false
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user