Add /commands
This commit is contained in:
parent
a941631fe7
commit
1c459228b7
|
@ -16,8 +16,8 @@ public abstract class BaseCommand
|
|||
{
|
||||
private MapParser _plugin;
|
||||
private List<String> _aliases;
|
||||
private String _description = "Null";
|
||||
private String _usage = "Undefined";
|
||||
private String _description = null;
|
||||
private String _usage = null;
|
||||
|
||||
public BaseCommand(MapParser plugin, String... aliases)
|
||||
{
|
||||
|
|
|
@ -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<String, BaseCommand> 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;
|
||||
}
|
||||
}
|
|
@ -110,4 +110,9 @@ public class CommandModule extends Module
|
|||
_commandsByAlias.put(label.toLowerCase(), baseCommand);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, BaseCommand> getCommands()
|
||||
{
|
||||
return _commands;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue