2011-07-23 00:50:52 +02:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2011-11-21 02:55:26 +01:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-11-18 17:42:26 +00:00
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import com.earth2me.essentials.Util;
|
2011-11-22 04:00:04 +00:00
|
|
|
import com.earth2me.essentials.textreader.*;
|
2011-07-23 00:50:52 +02:00
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandhelp extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandhelp()
|
|
|
|
{
|
|
|
|
super("help");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-08-30 03:15:10 +02:00
|
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
2011-07-23 00:50:52 +02:00
|
|
|
{
|
2011-11-22 04:00:04 +00:00
|
|
|
IText output;
|
|
|
|
String pageStr = args.length > 0 ? args[0] : null;
|
|
|
|
String chapterPageStr = args.length > 1 ? args[1] : null;
|
|
|
|
final IText input = new TextInput(user, "help", false, ess);
|
|
|
|
|
|
|
|
if (input.getLines().isEmpty())
|
2011-07-23 00:50:52 +02:00
|
|
|
{
|
2011-11-22 04:00:04 +00:00
|
|
|
if (Util.isInt(pageStr) || pageStr == null)
|
2011-07-23 00:50:52 +02:00
|
|
|
{
|
2011-11-22 04:00:04 +00:00
|
|
|
output = new HelpInput(user, "", ess);
|
2011-07-23 00:50:52 +02:00
|
|
|
}
|
2011-11-22 04:00:04 +00:00
|
|
|
else
|
2011-07-23 00:50:52 +02:00
|
|
|
{
|
2011-11-22 04:00:04 +00:00
|
|
|
output = new HelpInput(user, pageStr, ess);
|
|
|
|
pageStr = chapterPageStr;
|
2011-07-23 00:50:52 +02:00
|
|
|
}
|
2011-11-22 04:00:04 +00:00
|
|
|
chapterPageStr = null;
|
2011-07-23 00:50:52 +02:00
|
|
|
}
|
2011-11-22 04:00:04 +00:00
|
|
|
else
|
2011-07-23 00:50:52 +02:00
|
|
|
{
|
2011-11-22 04:00:04 +00:00
|
|
|
output = new KeywordReplacer(input, user, ess);
|
2011-07-23 00:50:52 +02:00
|
|
|
}
|
2011-11-22 04:00:04 +00:00
|
|
|
final TextPager pager = new TextPager(output);
|
2012-01-14 16:53:18 +00:00
|
|
|
pager.showPage(pageStr, chapterPageStr, commandLabel, user);
|
2011-07-23 00:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-08-30 03:15:10 +02:00
|
|
|
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
2011-07-23 00:50:52 +02:00
|
|
|
{
|
2011-11-21 02:55:26 +01:00
|
|
|
sender.sendMessage(_("helpConsole"));
|
2011-07-23 00:50:52 +02:00
|
|
|
}
|
|
|
|
}
|