mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-31 07:39:42 +01:00
Implemented the purgebannedplayers command
This commit is contained in:
parent
17c103a7b2
commit
4ff8cb8c59
@ -232,6 +232,20 @@ public class CommandManager {
|
||||
purgeCommand.setCommandPermissions("authme.admin.purge", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
purgeCommand.addArgument(new CommandArgumentDescription("days", "Number of days", false));
|
||||
|
||||
// Register the purgebannedplayers command
|
||||
CommandDescription purgeBannedPlayersCommand = new CommandDescription(
|
||||
new PurgeBannedPlayersCommand(),
|
||||
new ArrayList<String>() {{
|
||||
add("purgebannedplayers");
|
||||
add("purgebannedplayer");
|
||||
add("deletebannedplayers");
|
||||
add("deletebannedplayer");
|
||||
}},
|
||||
"Purge banned palyers data",
|
||||
"Purge all AuthMeReloaded data for banned players.",
|
||||
authMeCommand);
|
||||
purgeBannedPlayersCommand.setCommandPermissions("authme.admin.purgebannedplayers", CommandPermissions.DefaultPermission.OP_ONLY);
|
||||
|
||||
// Register the reload command
|
||||
CommandDescription reloadCommand = new CommandDescription(
|
||||
new ReloadCommand(),
|
||||
|
@ -0,0 +1,50 @@
|
||||
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 fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeBannedPlayersCommand 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(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
// Get the list of banned players
|
||||
List<String> bannedPlayers = new ArrayList<>();
|
||||
for (OfflinePlayer offlinePlayer : plugin.getServer().getBannedPlayers()) {
|
||||
bannedPlayers.add(offlinePlayer.getName().toLowerCase());
|
||||
}
|
||||
|
||||
// Purge the banned players
|
||||
plugin.database.purgeBanned(bannedPlayers);
|
||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
||||
plugin.dataManager.purgeEssentials(bannedPlayers);
|
||||
if (Settings.purgePlayerDat)
|
||||
plugin.dataManager.purgeDat(bannedPlayers);
|
||||
if (Settings.purgeLimitedCreative)
|
||||
plugin.dataManager.purgeLimitedCreative(bannedPlayers);
|
||||
if (Settings.purgeAntiXray)
|
||||
plugin.dataManager.purgeAntiXray(bannedPlayers);
|
||||
|
||||
// Show a status message
|
||||
sender.sendMessage("[AuthMe] Database has been purged correctly");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user