2019-03-03 04:51:21 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2019-08-02 23:01:33 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2019-03-03 04:51:21 +01:00
|
|
|
import com.massivecraft.factions.zcore.CommandVisibility;
|
|
|
|
import com.massivecraft.factions.zcore.MCommand;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2019-08-02 23:01:33 +02:00
|
|
|
public class CmdAutoHelp extends MCommand<P> {
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
public CmdAutoHelp() {
|
|
|
|
super(P.p);
|
|
|
|
this.aliases.add("?");
|
|
|
|
this.aliases.add("h");
|
|
|
|
this.aliases.add("help");
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
this.setHelpShort("");
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
this.optionalArgs.put("page", "1");
|
|
|
|
}
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
@Override
|
|
|
|
public void perform() {
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
if (this.commandChain.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
ArrayList<String> lines = new ArrayList<>(pcmd.helpLong);
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
for (MCommand<?> scmd : pcmd.subCommands) {
|
|
|
|
if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) {
|
|
|
|
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
|
|
|
}
|
|
|
|
}
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
|
|
|
|
}
|
2019-03-03 04:51:21 +01:00
|
|
|
|
2019-08-24 19:18:50 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_HELP_DESCRIPTION;
|
|
|
|
}
|
2019-03-03 04:51:21 +01:00
|
|
|
}
|