mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +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.commands.player.MctopCommand;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.commands.McpurgeCommand;
|
import com.gmail.nossr50.database.commands.McpurgeCommand;
|
||||||
|
import com.gmail.nossr50.database.commands.McremoveCommand;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||||
@ -246,4 +247,13 @@ public final class CommandRegistrationHelper {
|
|||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
||||||
command.setExecutor(new McpurgeCommand());
|
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.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.database.Leaderboard;
|
import com.gmail.nossr50.database.Leaderboard;
|
||||||
@ -13,49 +12,34 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
public class McremoveCommand implements CommandExecutor {
|
public class McremoveCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
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) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
playerName = args[0];
|
|
||||||
success = LocaleLoader.getString("Commands.mcremove.Success", playerName);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sender.sendMessage(usage);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* MySQL */
|
/* MySQL */
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
int affected = 0;
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
affected = Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
|
||||||
|
|
||||||
if (affected > 0) {
|
if (Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
||||||
sender.sendMessage(success);
|
Database.profileCleanup(args[0]);
|
||||||
} else {
|
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
}
|
||||||
}
|
else {
|
||||||
}
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
else {
|
}
|
||||||
if (Leaderboard.removeFlatFileUser(playerName)) {
|
}
|
||||||
sender.sendMessage(success);
|
else {
|
||||||
|
if (Leaderboard.removeFlatFileUser(args[0])) {
|
||||||
|
Database.profileCleanup(args[0]);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.profileCleanup(playerName);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
// mc* commands
|
// mc* commands
|
||||||
CommandRegistrationHelper.registerMcpurgeCommand();
|
CommandRegistrationHelper.registerMcpurgeCommand();
|
||||||
getCommand("mcremove").setExecutor(new McremoveCommand());
|
CommandRegistrationHelper.registerMcremoveCommand();
|
||||||
CommandRegistrationHelper.registerMcabilityCommand();
|
CommandRegistrationHelper.registerMcabilityCommand();
|
||||||
getCommand("mcc").setExecutor(new MccCommand());
|
getCommand("mcc").setExecutor(new MccCommand());
|
||||||
CommandRegistrationHelper.registerMcgodCommand();
|
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.mcability=Toggle mcMMO abilities being readied on right-click on/off
|
||||||
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||||
Commands.Description.mcmmo=Show a brief description of mcMMO
|
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.mcrank=Show mcMMO ranking for a player
|
||||||
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
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.mcstats=Show your mcMMO levels and XP
|
||||||
Commands.Description.mctop=Show mcMMO leader boards
|
Commands.Description.mctop=Show mcMMO leader boards
|
||||||
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||||
|
@ -51,7 +51,6 @@ commands:
|
|||||||
aliases: [stats]
|
aliases: [stats]
|
||||||
description: Shows your mcMMO stats and xp
|
description: Shows your mcMMO stats and xp
|
||||||
mcremove:
|
mcremove:
|
||||||
aliases: []
|
|
||||||
description: Remove a user from the database
|
description: Remove a user from the database
|
||||||
mmoedit:
|
mmoedit:
|
||||||
description: Edit the mcMMO skill values for a user
|
description: Edit the mcMMO skill values for a user
|
||||||
|
Loading…
Reference in New Issue
Block a user