mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Update /mcremove to use the Bukkit CommandAPI.
This commit is contained in:
parent
7e70c4001b
commit
6be0714872
@ -21,6 +21,7 @@ import com.gmail.nossr50.commands.player.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.player.MctopCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.commands.McpurgeCommand;
|
||||
import com.gmail.nossr50.database.commands.McremoveCommand;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||
@ -246,4 +247,13 @@ public final class CommandRegistrationHelper {
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
||||
command.setExecutor(new McpurgeCommand());
|
||||
}
|
||||
|
||||
public static void registerMcremoveCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcremove");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove", Config.getInstance().getOldUsersCutoff()));
|
||||
command.setPermission("mcmmo.commands.mcremove");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setExecutor(new McremoveCommand());
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Database;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
@ -13,49 +12,34 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String playerName;
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
//String databaseName = Config.getInstance().getMySQLDatabaseName();
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">");
|
||||
String success;
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcremove")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
playerName = args[0];
|
||||
success = LocaleLoader.getString("Commands.mcremove.Success", playerName);
|
||||
break;
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
int affected = 0;
|
||||
affected = Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
||||
|
||||
if (affected > 0) {
|
||||
sender.sendMessage(success);
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (Leaderboard.removeFlatFileUser(playerName)) {
|
||||
sender.sendMessage(success);
|
||||
if (Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
||||
Database.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
if (Leaderboard.removeFlatFileUser(args[0])) {
|
||||
Database.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Database.profileCleanup(playerName);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
// mc* commands
|
||||
CommandRegistrationHelper.registerMcpurgeCommand();
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand());
|
||||
CommandRegistrationHelper.registerMcremoveCommand();
|
||||
CommandRegistrationHelper.registerMcabilityCommand();
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
CommandRegistrationHelper.registerMcgodCommand();
|
||||
|
@ -695,9 +695,10 @@ Commands.Description.inspect=View detailed mcMMO info on another player
|
||||
Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off
|
||||
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||
Commands.Description.mcmmo=Show a brief description of mcMMO
|
||||
Commands.Description.mcpurge=Purge users with no mcMMO levels and/or who haven't connected in over {0} months from the server DB.
|
||||
Commands.Description.mcpurge=Purge users with no mcMMO levels and users who haven't connected in over {0} months from the mcMMO database.
|
||||
Commands.Description.mcrank=Show mcMMO ranking for a player
|
||||
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
||||
Commands.Description.mcremove=Remove a user from the mcMMO database
|
||||
Commands.Description.mcstats=Show your mcMMO levels and XP
|
||||
Commands.Description.mctop=Show mcMMO leader boards
|
||||
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||
|
@ -51,7 +51,6 @@ commands:
|
||||
aliases: [stats]
|
||||
description: Shows your mcMMO stats and xp
|
||||
mcremove:
|
||||
aliases: []
|
||||
description: Remove a user from the database
|
||||
mmoedit:
|
||||
description: Edit the mcMMO skill values for a user
|
||||
|
Loading…
Reference in New Issue
Block a user