diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 5e1edb50a..9848d9342 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -19,6 +19,8 @@ import com.gmail.nossr50.commands.player.McmmoCommand; import com.gmail.nossr50.commands.player.McrankCommand; 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.locale.LocaleLoader; import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand; import com.gmail.nossr50.skills.archery.ArcheryCommand; @@ -252,4 +254,13 @@ public final class CommandRegistrationHelper { command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); command.setExecutor(new MctopCommand()); } + + public static void registerMcpurgeCommand() { + PluginCommand command = mcMMO.p.getCommand("mcpurge"); + command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff())); + command.setPermission("mcmmo.commands.mcpurge"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge")); + command.setExecutor(new McpurgeCommand()); + } } diff --git a/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java index 57631fb37..acadf185c 100644 --- a/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java +++ b/src/main/java/com/gmail/nossr50/database/commands/McpurgeCommand.java @@ -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.locale.LocaleLoader; @@ -12,22 +11,24 @@ import com.gmail.nossr50.locale.LocaleLoader; public class McpurgeCommand implements CommandExecutor{ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcpurge")) { - return true; - } + switch (args.length) { + case 0: + if (Config.getInstance().getUseMySQL()) { + Database.purgePowerlessSQL(); - if (Config.getInstance().getUseMySQL()) { - Database.purgePowerlessSQL(); - - if (Config.getInstance().getOldUsersCutoff() != -1) { - Database.purgeOldSQL(); + if (Config.getInstance().getOldUsersCutoff() != -1) { + Database.purgeOldSQL(); + } + } + else { + //TODO: Make this work for Flatfile data. } - } - else { - //TODO: Make this work for Flatfile data. - } - sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); - return true; + sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); + return true; + + default: + return false; + } } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index a2599825e..502a2b616 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -30,7 +30,6 @@ import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; import com.gmail.nossr50.config.TreasuresConfig; import com.gmail.nossr50.database.Database; -import com.gmail.nossr50.database.commands.McpurgeCommand; import com.gmail.nossr50.database.commands.McremoveCommand; import com.gmail.nossr50.database.commands.MmoupdateCommand; import com.gmail.nossr50.database.runnables.UserPurgeTask; @@ -277,7 +276,7 @@ public class mcMMO extends JavaPlugin { CommandRegistrationHelper.registerSkillCommands(); // mc* commands - getCommand("mcpurge").setExecutor(new McpurgeCommand()); + CommandRegistrationHelper.registerMcpurgeCommand(); getCommand("mcremove").setExecutor(new McremoveCommand()); CommandRegistrationHelper.registerMcabilityCommand(); getCommand("mcc").setExecutor(new MccCommand()); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 446653f12..838ad8ad2 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -695,6 +695,7 @@ 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.mcrank=Show mcMMO ranking for a player Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO Commands.Description.mcstats=Show your mcMMO levels and XP diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f2105c52f..f4b16325e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -100,8 +100,7 @@ commands: aliases: [] description: Toggle Admin chat or send admin chat messages mcpurge: - aliases: [] - description: Purge users with 0 powerlevel and/or who haven't connected in over 30 days from the server DB. + description: Purge users with 0 powerlevel and/or who haven't connected in several months from the server DB. permissions: mcmmo.*: default: false