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 ----",
|
2016-06-25 11:09:21 +00:00
|
|
|
"Prints out help messages for the TBMC plugins" };
|
2016-06-22 23:38:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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",
|
2016-06-25 08:48:24 +00:00
|
|
|
"Do /u help <commandname> [subcommands] for more info about a command",
|
2016-06-25 00:02:38 +00:00
|
|
|
"Topics:",
|
2016-06-25 11:09:21 +00:00
|
|
|
"newp: Info for new players",
|
2016-06-22 23:38:35 +00:00
|
|
|
"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;
|
|
|
|
}
|
2016-06-25 11:09:21 +00:00
|
|
|
if (args[0].equalsIgnoreCase("newp"))
|
|
|
|
sender.sendMessage(new String[] { "§6---- Info for new players ----", "(Under construction)" }); // TODO
|
2016-06-22 23:38:35 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("commands")) {
|
2016-06-25 00:02:38 +00:00
|
|
|
ArrayList<String> text = new ArrayList<String>();
|
2016-06-25 08:48:24 +00:00
|
|
|
text.add("§6---- Command list ----");
|
2016-06-25 00:02:38 +00:00
|
|
|
for (TBMCCommandBase cmd : CommandCaller.GetCommands().values())
|
|
|
|
if (!cmd.GetCommandPath().contains("/"))
|
2016-06-25 08:48:24 +00:00
|
|
|
text.add("/" + cmd.GetCommandPath());
|
|
|
|
sender.sendMessage(text.toArray(new String[text.size()]));
|
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";
|
|
|
|
}
|
2016-06-25 08:48:24 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean GetPlayerOnly() {
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-22 23:38:35 +00:00
|
|
|
}
|