Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdAutoHelp.java

49 lines
1.2 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
2019-06-29 03:49:46 +02:00
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.zcore.CommandVisibility;
import com.massivecraft.factions.zcore.MCommand;
import com.massivecraft.factions.zcore.util.TL;
import java.util.ArrayList;
2019-06-29 03:49:46 +02:00
public class CmdAutoHelp extends MCommand<SaberFactions> {
public CmdAutoHelp() {
2019-06-29 03:49:46 +02:00
super(SaberFactions.plugin);
this.aliases.add("?");
this.aliases.add("h");
this.aliases.add("help");
this.setHelpShort("");
this.optionalArgs.put("page", "1");
}
@Override
public void perform() {
if (this.commandChain.size() == 0) {
return;
}
MCommand<?> pcmd = this.commandChain.get(this.commandChain.size() - 1);
ArrayList<String> lines = new ArrayList<>();
lines.addAll(pcmd.helpLong);
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));
}
}
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), TL.COMMAND_AUTOHELP_HELPFOR.toString() + pcmd.aliases.get(0) + "\""));
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_HELP_DESCRIPTION;
}
}