
net.minecraft.server.CommandHelp Maven / Gradle / Ivy
package net.minecraft.server;
import java.util.*;
public class CommandHelp extends CommandAbstract {
public CommandHelp() {
}
public String getCommand() {
return "help";
}
public int a() {
return 0;
}
public String getUsage(ICommandListener icommandlistener) {
return "commands.help.usage";
}
public List b() {
return Arrays.asList("?");
}
public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException {
List list = this.d(icommandlistener);
boolean flag = true;
int i = (list.size() - 1) / 7;
boolean flag1 = false;
int j;
try {
j = astring.length == 0 ? 0 : a(astring[0], 1, i + 1) - 1;
} catch (ExceptionInvalidNumber exceptioninvalidnumber) {
Map map = this.d();
ICommand icommand = (ICommand) map.get(astring[0]);
if (icommand != null) {
throw new ExceptionUsage(icommand.getUsage(icommandlistener));
}
if (MathHelper.a(astring[0], -1) != -1) {
throw exceptioninvalidnumber;
}
throw new ExceptionUnknownCommand();
}
int k = Math.min((j + 1) * 7, list.size());
ChatMessage chatmessage = new ChatMessage("commands.help.header", Integer.valueOf(j + 1), Integer.valueOf(i + 1));
chatmessage.getChatModifier().setColor(EnumChatFormat.DARK_GREEN);
icommandlistener.sendMessage(chatmessage);
for (int l = j * 7; l < k; ++l) {
ICommand icommand1 = (ICommand) list.get(l);
ChatMessage chatmessage1 = new ChatMessage(icommand1.getUsage(icommandlistener));
chatmessage1.getChatModifier().setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, "/" + icommand1.getCommand() + " "));
icommandlistener.sendMessage(chatmessage1);
}
if (j == 0 && icommandlistener instanceof EntityHuman) {
ChatMessage chatmessage2 = new ChatMessage("commands.help.footer");
chatmessage2.getChatModifier().setColor(EnumChatFormat.GREEN);
icommandlistener.sendMessage(chatmessage2);
}
}
protected List d(ICommandListener icommandlistener) {
List list = MinecraftServer.getServer().getCommandHandler().a(icommandlistener);
Collections.sort(list);
return list;
}
protected Map d() {
return MinecraftServer.getServer().getCommandHandler().getCommands();
}
public List tabComplete(ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
if (astring.length == 1) {
Set set = this.d().keySet();
return a(astring, (String[]) set.toArray(new String[set.size()]));
} else {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy