Search in sources :

Example 6 with TextPager

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

the class SignInfo method onSignInteract.

@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
    final Trade charge = getTrade(sign, 3, ess);
    charge.isAffordableFor(player);
    String chapter = sign.getLine(1);
    String page = sign.getLine(2);
    final IText input;
    try {
        player.setDisplayNick();
        input = new TextInput(player.getSource(), "info", true, ess);
        final IText output = new KeywordReplacer(input, player.getSource(), ess);
        final TextPager pager = new TextPager(output);
        pager.showPage(chapter, page, null, player.getSource());
    } catch (IOException ex) {
        throw new SignException(ex.getMessage(), ex);
    }
    charge.charge(player);
    Trade.log("Sign", "Info", "Interact", username, null, username, charge, sign.getBlock().getLocation(), ess);
    return true;
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) Trade(com.earth2me.essentials.Trade) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText) IOException(java.io.IOException) TextInput(com.earth2me.essentials.textreader.TextInput)

Example 7 with TextPager

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

the class Commandbalancetop method outputCache.

private static void outputCache(final CommandSource sender, String command, int page) {
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(cacheage);
    final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    sender.sendMessage(tl("balanceTop", format.format(cal.getTime())));
    new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
}
Also used : DateFormat(java.text.DateFormat) TextPager(com.earth2me.essentials.textreader.TextPager)

Example 8 with TextPager

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

the class EssentialsPlayerListener method delayedJoin.

public void delayedJoin(final Player player, final String message) {
    if (!player.isOnline()) {
        return;
    }
    ess.getBackup().onPlayerJoin();
    final User dUser = ess.getUser(player);
    dUser.startTransaction();
    if (dUser.isNPC()) {
        dUser.setNPC(false);
    }
    final long currentTime = System.currentTimeMillis();
    dUser.checkMuteTimeout(currentTime);
    dUser.updateActivity(false);
    dUser.stopTransaction();
    IText tempInput = null;
    if (!ess.getSettings().isCommandDisabled("motd")) {
        try {
            tempInput = new TextInput(dUser.getSource(), "motd", true, ess);
        } catch (IOException ex) {
            if (ess.getSettings().isDebug()) {
                LOGGER.log(Level.WARNING, ex.getMessage(), ex);
            } else {
                LOGGER.log(Level.WARNING, ex.getMessage());
            }
        }
    }
    final IText input = tempInput;
    class DelayJoinTask implements Runnable {

        @Override
        public void run() {
            final User user = ess.getUser(player);
            if (!user.getBase().isOnline()) {
                return;
            }
            user.startTransaction();
            user.setLastAccountName(user.getBase().getName());
            user.setLastLogin(currentTime);
            user.setDisplayNick();
            updateCompass(user);
            if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see")) {
                for (String p : ess.getVanishedPlayers()) {
                    Player toVanish = ess.getServer().getPlayerExact(p);
                    if (toVanish != null && toVanish.isOnline()) {
                        user.getBase().hidePlayer(toVanish);
                    }
                }
            }
            if (user.isAuthorized("essentials.sleepingignored")) {
                user.getBase().setSleepingIgnored(true);
            }
            if (ess.getSettings().allowSilentJoinQuit() && (user.isAuthorized("essentials.silentjoin") || user.isAuthorized("essentials.silentjoin.vanish"))) {
                if (user.isAuthorized("essentials.silentjoin.vanish")) {
                    user.setVanished(true);
                }
            } else if (message == null) {
            //NOOP
            } else if (ess.getSettings().isCustomJoinMessage()) {
                String msg = ess.getSettings().getCustomJoinMessage().replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName()).replace("{UNIQUE}", NumberFormat.getInstance().format(ess.getUserMap().getUniqueUsers()));
                ess.getServer().broadcastMessage(msg);
            } else if (ess.getSettings().allowSilentJoinQuit()) {
                ess.getServer().broadcastMessage(message);
            }
            if (input != null && user.isAuthorized("essentials.motd")) {
                final IText output = new KeywordReplacer(input, user.getSource(), ess);
                final TextPager pager = new TextPager(output, true);
                pager.showPage("1", null, "motd", user.getSource());
            }
            if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail")) {
                final List<String> mail = user.getMails();
                if (mail.isEmpty()) {
                    if (ess.getSettings().isNotifyNoNewMail()) {
                        // Only notify if they want us to.
                        user.sendMessage(tl("noNewMail"));
                    }
                } else {
                    user.sendMessage(tl("youHaveNewMail", mail.size()));
                }
            }
            if (user.isAuthorized("essentials.fly.safelogin")) {
                user.getBase().setFallDistance(0);
                if (LocationUtil.shouldFly(user.getLocation())) {
                    user.getBase().setAllowFlight(true);
                    user.getBase().setFlying(true);
                    if (ess.getSettings().isSendFlyEnableOnJoin()) {
                        user.getBase().sendMessage(tl("flyMode", tl("enabled"), user.getDisplayName()));
                    }
                }
            }
            if (!user.isAuthorized("essentials.speed")) {
                user.getBase().setFlySpeed(0.1f);
                user.getBase().setWalkSpeed(0.2f);
            }
            if (user.isSocialSpyEnabled() && !user.isAuthorized("essentials.socialspy")) {
                user.setSocialSpyEnabled(false);
                ess.getLogger().log(Level.INFO, "Set socialspy to false for {0} because they had it enabled without permission.", user.getName());
            }
            user.stopTransaction();
        }
    }
    ess.scheduleSyncDelayedTask(new DelayJoinTask());
}
Also used : KeywordReplacer(com.earth2me.essentials.textreader.KeywordReplacer) Player(org.bukkit.entity.Player) TextPager(com.earth2me.essentials.textreader.TextPager) IText(com.earth2me.essentials.textreader.IText) IOException(java.io.IOException) TextInput(com.earth2me.essentials.textreader.TextInput)

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