Search in sources :

Example 1 with TextPager

use of com.earth2me.essentials.textreader.TextPager in project Essentials by drtshock.

the class Commandcustomtext method run.

@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (sender.isPlayer()) {
        ess.getUser(sender.getPlayer()).setDisplayNick();
    }
    final IText input = new TextInput(sender, "custom", true, ess);
    final IText output = new KeywordReplacer(input, sender, ess);
    final TextPager pager = new TextPager(output);
    String chapter = commandLabel;
    String page;
    if (commandLabel.equalsIgnoreCase("customtext") && args.length > 0 && !NumberUtil.isInt(commandLabel)) {
        chapter = args[0];
        page = args.length > 1 ? args[1] : null;
    } else {
        page = args.length > 0 ? args[0] : null;
    }
    pager.showPage(chapter, page, null, sender);
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText) TextInput(com.earth2me.essentials.textreader.TextInput)

Example 2 with TextPager

use of com.earth2me.essentials.textreader.TextPager in project Essentials by drtshock.

the class Commandrules method run.

@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (sender.isPlayer()) {
        ess.getUser(sender.getPlayer()).setDisplayNick();
    }
    final IText input = new TextInput(sender, "rules", true, ess);
    final IText output = new KeywordReplacer(input, sender, ess);
    final TextPager pager = new TextPager(output);
    pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText) TextInput(com.earth2me.essentials.textreader.TextInput)

Example 3 with TextPager

use of com.earth2me.essentials.textreader.TextPager in project Essentials by drtshock.

the class Commandmotd method run.

@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (sender.isPlayer()) {
        ess.getUser(sender.getPlayer()).setDisplayNick();
    }
    final IText input = new TextInput(sender, "motd", true, ess);
    final IText output = new KeywordReplacer(input, sender, ess);
    final TextPager pager = new TextPager(output);
    pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText) TextInput(com.earth2me.essentials.textreader.TextInput)

Example 4 with TextPager

use of com.earth2me.essentials.textreader.TextPager in project Essentials by drtshock.

the class Commandinfo method run.

@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    if (sender.isPlayer()) {
        ess.getUser(sender.getPlayer()).setDisplayNick();
    }
    final IText input = new TextInput(sender, "info", true, ess);
    final IText output = new KeywordReplacer(input, sender, ess);
    final TextPager pager = new TextPager(output);
    pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText) TextInput(com.earth2me.essentials.textreader.TextInput)

Example 5 with TextPager

use of com.earth2me.essentials.textreader.TextPager in project Essentials by drtshock.

the class Commandmail method run.

//TODO: Tidy this up / TL these errors.
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
    if (args.length >= 1 && "read".equalsIgnoreCase(args[0])) {
        final List<String> mail = user.getMails();
        if (mail.isEmpty()) {
            user.sendMessage(tl("noMail"));
            throw new NoChargeException();
        }
        IText input = new SimpleTextInput(mail);
        final TextPager pager = new TextPager(input);
        pager.showPage(args.length > 1 ? args[1] : null, null, commandLabel + " " + args[0], user.getSource());
        user.sendMessage(tl("mailClear"));
        return;
    }
    if (args.length >= 3 && "send".equalsIgnoreCase(args[0])) {
        if (!user.isAuthorized("essentials.mail.send")) {
            throw new Exception(tl("noPerm", "essentials.mail.send"));
        }
        if (user.isMuted()) {
            throw new Exception(tl("voiceSilenced"));
        }
        User u = getPlayer(server, args[1], true, true);
        if (u == null) {
            throw new Exception(tl("playerNeverOnServer", args[1]));
        }
        final String mail = tl("mailFormat", user.getName(), StringUtil.sanitizeString(FormatUtil.stripFormat(getFinalArg(args, 2))));
        if (mail.length() > 1000) {
            throw new Exception(tl("mailTooLong"));
        }
        if (!u.isIgnoredPlayer(user)) {
            if (Math.abs(System.currentTimeMillis() - timestamp) > 60000) {
                timestamp = System.currentTimeMillis();
                mailsPerMinute = 0;
            }
            mailsPerMinute++;
            if (mailsPerMinute > ess.getSettings().getMailsPerMinute()) {
                throw new Exception(tl("mailDelay", ess.getSettings().getMailsPerMinute()));
            }
            u.addMail(tl("mailMessage", mail));
        }
        user.sendMessage(tl("mailSentTo", u.getDisplayName(), u.getName()));
        user.sendMessage(mail);
        return;
    }
    if (args.length > 1 && "sendall".equalsIgnoreCase(args[0])) {
        if (!user.isAuthorized("essentials.mail.sendall")) {
            throw new Exception(tl("noPerm", "essentials.mail.sendall"));
        }
        ess.runTaskAsynchronously(new SendAll(tl("mailFormat", user.getName(), FormatUtil.stripFormat(getFinalArg(args, 1)))));
        user.sendMessage(tl("mailSent"));
        return;
    }
    if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) {
        user.setMails(null);
        user.sendMessage(tl("mailCleared"));
        return;
    }
    throw new NotEnoughArgumentsException();
}
Also used : User(com.earth2me.essentials.User) SimpleTextInput(com.earth2me.essentials.textreader.SimpleTextInput) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText)

Aggregations

TextPager (com.earth2me.essentials.textreader.TextPager)8 IText (com.earth2me.essentials.textreader.IText)7 KeywordReplacer (com.earth2me.essentials.textreader.KeywordReplacer)6 TextInput (com.earth2me.essentials.textreader.TextInput)6 IOException (java.io.IOException)2 Trade (com.earth2me.essentials.Trade)1 User (com.earth2me.essentials.User)1 SimpleTextInput (com.earth2me.essentials.textreader.SimpleTextInput)1 DateFormat (java.text.DateFormat)1 Player (org.bukkit.entity.Player)1