mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 01:03:44 +01:00 
			
		
		
		
	Update /mcpurge command to use Bukkit CommandAPI. Addresses #628
This commit is contained in:
		| @@ -19,6 +19,8 @@ import com.gmail.nossr50.commands.player.McmmoCommand; | |||||||
| import com.gmail.nossr50.commands.player.McrankCommand; | import com.gmail.nossr50.commands.player.McrankCommand; | ||||||
| import com.gmail.nossr50.commands.player.McstatsCommand; | 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.database.commands.McpurgeCommand; | ||||||
| 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; | ||||||
| @@ -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.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); | ||||||
|         command.setExecutor(new MctopCommand()); |         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()); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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.locale.LocaleLoader; | import com.gmail.nossr50.locale.LocaleLoader; | ||||||
| @@ -12,10 +11,8 @@ import com.gmail.nossr50.locale.LocaleLoader; | |||||||
| public class McpurgeCommand implements CommandExecutor{ | public class McpurgeCommand 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) { | ||||||
|         if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcpurge")) { |         switch (args.length) { | ||||||
|             return true; |         case 0: | ||||||
|         } |  | ||||||
|  |  | ||||||
|             if (Config.getInstance().getUseMySQL()) { |             if (Config.getInstance().getUseMySQL()) { | ||||||
|                 Database.purgePowerlessSQL(); |                 Database.purgePowerlessSQL(); | ||||||
|  |  | ||||||
| @@ -29,5 +26,9 @@ public class McpurgeCommand implements CommandExecutor{ | |||||||
|  |  | ||||||
|             sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); |             sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); | ||||||
|             return true; |             return true; | ||||||
|  |  | ||||||
|  |         default: | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,7 +30,6 @@ import com.gmail.nossr50.config.Config; | |||||||
| import com.gmail.nossr50.config.HiddenConfig; | import com.gmail.nossr50.config.HiddenConfig; | ||||||
| import com.gmail.nossr50.config.TreasuresConfig; | import com.gmail.nossr50.config.TreasuresConfig; | ||||||
| import com.gmail.nossr50.database.Database; | 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.McremoveCommand; | ||||||
| import com.gmail.nossr50.database.commands.MmoupdateCommand; | import com.gmail.nossr50.database.commands.MmoupdateCommand; | ||||||
| import com.gmail.nossr50.database.runnables.UserPurgeTask; | import com.gmail.nossr50.database.runnables.UserPurgeTask; | ||||||
| @@ -277,7 +276,7 @@ public class mcMMO extends JavaPlugin { | |||||||
|         CommandRegistrationHelper.registerSkillCommands(); |         CommandRegistrationHelper.registerSkillCommands(); | ||||||
|  |  | ||||||
|         // mc* commands |         // mc* commands | ||||||
|         getCommand("mcpurge").setExecutor(new McpurgeCommand()); |         CommandRegistrationHelper.registerMcpurgeCommand(); | ||||||
|         getCommand("mcremove").setExecutor(new McremoveCommand()); |         getCommand("mcremove").setExecutor(new McremoveCommand()); | ||||||
|         CommandRegistrationHelper.registerMcabilityCommand(); |         CommandRegistrationHelper.registerMcabilityCommand(); | ||||||
|         getCommand("mcc").setExecutor(new MccCommand()); |         getCommand("mcc").setExecutor(new MccCommand()); | ||||||
|   | |||||||
| @@ -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.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.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.mcstats=Show your mcMMO levels and XP | Commands.Description.mcstats=Show your mcMMO levels and XP | ||||||
|   | |||||||
| @@ -100,8 +100,7 @@ commands: | |||||||
|         aliases: [] |         aliases: [] | ||||||
|         description: Toggle Admin chat or send admin chat messages |         description: Toggle Admin chat or send admin chat messages | ||||||
|     mcpurge: |     mcpurge: | ||||||
|         aliases: [] |         description: Purge users with 0 powerlevel and/or who haven't connected in several months from the server DB. | ||||||
|         description: Purge users with 0 powerlevel and/or who haven't connected in over 30 days from the server DB. |  | ||||||
| permissions: | permissions: | ||||||
|     mcmmo.*: |     mcmmo.*: | ||||||
|         default: false |         default: false | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 GJ
					GJ