2011-10-13 14:41:07 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.P;
|
|
|
|
import com.massivecraft.factions.zcore.CommandVisibility;
|
|
|
|
import com.massivecraft.factions.zcore.MCommand;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2011-10-13 14:41:07 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class CmdAutoHelp extends MCommand<P> {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdAutoHelp() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super(P.p);
|
|
|
|
this.aliases.add("?");
|
|
|
|
this.aliases.add("h");
|
|
|
|
this.aliases.add("help");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
this.setHelpShort("");
|
|
|
|
|
|
|
|
this.optionalArgs.put("page", "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (this.commandChain.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
|
|
|
|
|
2017-12-19 11:18:13 +01:00
|
|
|
ArrayList<String> lines = new ArrayList<>();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
lines.addAll(pcmd.helpLong);
|
|
|
|
|
|
|
|
for (MCommand<?> scmd : pcmd.subCommands) {
|
2014-07-01 21:52:40 +02:00
|
|
|
if (scmd.visibility == CommandVisibility.VISIBLE || (scmd.visibility == CommandVisibility.SECRET && scmd.validSenderPermissions(sender, false))) {
|
2014-04-04 20:55:21 +02:00
|
|
|
lines.add(scmd.getUseageTemplate(this.commandChain, true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-08 00:12:52 +01:00
|
|
|
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_HELP_DESCRIPTION;
|
|
|
|
}
|
2011-10-13 14:41:07 +02:00
|
|
|
}
|