Chroma-Chat/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/HelpCommand.java

61 lines
2.1 KiB
Java
Raw Normal View History

2016-06-22 23:38:35 +00:00
package io.github.norbipeti.thebuttonmcchat.commands.ucmds;
2016-06-25 00:02:38 +00:00
import java.util.ArrayList;
import io.github.norbipeti.thebuttonmcchat.commands.CommandCaller;
2016-06-22 23:38:35 +00:00
import io.github.norbipeti.thebuttonmcchat.commands.TBMCCommandBase;
import org.bukkit.command.CommandSender;
public final class HelpCommand extends UCommandBase {
@Override
public String[] GetHelpText(String alias) {
return new String[] { "§6---- Help ----",
"Prints out help messages for the TBMC plugin" };
}
@Override
2016-06-24 17:32:34 +00:00
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
2016-06-22 23:38:35 +00:00
if (args.length == 0) {
sender.sendMessage(new String[] {
"§6---- TBMC Help ----",
2016-06-25 00:02:38 +00:00
"Do /u help <topic> for more info",
"Alternatively, you can do /u help <commandname> [subcommands] for more info about a command",
"Topics:",
2016-06-22 23:38:35 +00:00
"flairs: The flairs are the numbers near your name",
"commands: See all the commands from this plugin",
"login: If you or someone else has any problems with logins, lost inventory/location, etc." });
return true;
}
if (args[0].equalsIgnoreCase("flairs"))
sender.sendMessage(new String[] { "§6---- About flairs ----", "" }); // TODO
else if (args[0].equalsIgnoreCase("commands")) {
2016-06-25 00:02:38 +00:00
ArrayList<String> text = new ArrayList<String>();
2016-06-22 23:38:35 +00:00
int i = 0;
2016-06-25 00:02:38 +00:00
text.set(i++, "§6---- Command list ----");
for (TBMCCommandBase cmd : CommandCaller.GetCommands().values())
if (!cmd.GetCommandPath().contains("/"))
text.set(i++, "/" + cmd.GetCommandPath());
sender.sendMessage((String[]) text.toArray());
2016-06-22 23:38:35 +00:00
} else {
2016-06-25 00:02:38 +00:00
String path = args[0];
for (int i = 1; i < args.length; i++)
path += "/" + args[i];
TBMCCommandBase cmd = CommandCaller.GetCommands().get(path);
2016-06-22 23:38:35 +00:00
if (cmd == null)
sender.sendMessage(new String[] {
2016-06-25 00:02:38 +00:00
"§cError: Command not found: " + path.replace('/', ' '),
"Usage example: /u accept --> /u help u accept" });
2016-06-22 23:38:35 +00:00
else
sender.sendMessage(cmd.GetHelpText(args[0]));
}
return true;
}
@Override
2016-06-24 17:32:34 +00:00
public String GetUCommandPath() {
2016-06-22 23:38:35 +00:00
return "help";
}
}