2019-03-03 04:51:21 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2019-09-14 21:13:01 +02:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
2019-03-03 04:51:21 +01:00
|
|
|
import com.massivecraft.factions.zcore.CommandVisibility;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2019-09-14 21:13:01 +02:00
|
|
|
public class CmdAutoHelp extends FCommand {
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-12-02 19:55:38 +01:00
|
|
|
/**
|
|
|
|
* @author FactionsUUID Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdAutoHelp() {
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.help);
|
2019-09-15 11:19:06 +02:00
|
|
|
|
|
|
|
this.setHelpShort("");
|
|
|
|
|
|
|
|
this.optionalArgs.put("page", "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
if (context.commandChain.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FCommand pcmd = context.commandChain.get(context.commandChain.size() - 1);
|
|
|
|
|
|
|
|
ArrayList<String> lines = new ArrayList<>(pcmd.helpLong);
|
|
|
|
|
|
|
|
for (FCommand scmd : pcmd.subCommands) {
|
|
|
|
if (scmd.visibility == CommandVisibility.VISIBLE) {
|
2019-09-15 22:33:22 +02:00
|
|
|
lines.add(scmd.getUsageTemplate(context, true));
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
// TODO deal with other visibilities
|
|
|
|
}
|
|
|
|
|
|
|
|
context.sendMessage(FactionsPlugin.getInstance().txt.getPage(lines, context.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_HELP_DESCRIPTION;
|
|
|
|
}
|
2019-03-03 04:51:21 +01:00
|
|
|
}
|