From 1c459228b7631deeca4693751d5cc691464fb22b Mon Sep 17 00:00:00 2001 From: Spencer Date: Wed, 7 Mar 2018 12:58:21 -0500 Subject: [PATCH] Add /commands --- .../mapparser/command/BaseCommand.java | 4 +- .../mapparser/command/CommandListCommand.java | 52 +++++++++++++++++++ .../module/modules/CommandModule.java | 5 ++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CommandListCommand.java diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java index 951c0f6a4..254b5c7c0 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java @@ -16,8 +16,8 @@ public abstract class BaseCommand { private MapParser _plugin; private List _aliases; - private String _description = "Null"; - private String _usage = "Undefined"; + private String _description = null; + private String _usage = null; public BaseCommand(MapParser plugin, String... aliases) { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CommandListCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CommandListCommand.java new file mode 100644 index 000000000..a48e5003e --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CommandListCommand.java @@ -0,0 +1,52 @@ +package mineplex.mapparser.command; + +import java.util.Map; + +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.mapparser.MapParser; +import mineplex.mapparser.module.modules.CommandModule; + +public class CommandListCommand extends BaseCommand +{ + private CommandModule _commandModule; + + public CommandListCommand(MapParser plugin, CommandModule commandModule) + { + super(plugin, "commands"); + + _commandModule = commandModule; + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + player.sendMessage(F.main(getPlugin().getName(), "Commands list:")); + player.sendMessage(""); + player.sendMessage(F.main(getPlugin().getName(), C.cPurple + C.Italics + "Some of these commands may require OP/Map Admin")); + player.sendMessage(""); + + for (Map.Entry entry : _commandModule.getCommands().entrySet()) + { + String message = C.cGray + "•" + C.cAqua + " /" + entry.getKey(); + + BaseCommand command = entry.getValue(); + + if (command.getUsage() != null) + { + message += C.cGray + " - " + C.cYellow + command.getUsage(); + } + + player.sendMessage(message); + + if (command.getDescription() != null) + { + player.sendMessage(" " + C.cGray + C.Italics + command.getDescription()); + } + } + + return true; + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java index 480192e3a..99b56645a 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java @@ -110,4 +110,9 @@ public class CommandModule extends Module _commandsByAlias.put(label.toLowerCase(), baseCommand); } } + + public Map getCommands() + { + return _commands; + } }