Add paging to mail.

Support aliases in rule and baltop output.
This commit is contained in:
KHobbits 2014-08-11 19:03:24 +01:00
parent 4fd026ff99
commit 53a7cd732f
3 changed files with 19 additions and 12 deletions

View file

@ -53,7 +53,7 @@ public class Commandbalancetop extends EssentialsCommand
{ {
if (cacheage > System.currentTimeMillis() - CACHETIME) if (cacheage > System.currentTimeMillis() - CACHETIME)
{ {
outputCache(sender, page); outputCache(sender, commandLabel, page);
return; return;
} }
if (ess.getUserMap().getUniqueUsers() > MINUSERS) if (ess.getUserMap().getUniqueUsers() > MINUSERS)
@ -65,7 +65,7 @@ public class Commandbalancetop extends EssentialsCommand
{ {
lock.readLock().unlock(); lock.readLock().unlock();
} }
ess.runTaskAsynchronously(new Viewer(sender, page, force)); ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
} }
else else
{ {
@ -73,12 +73,12 @@ public class Commandbalancetop extends EssentialsCommand
{ {
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers())); sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers()));
} }
ess.runTaskAsynchronously(new Viewer(sender, page, force)); ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
} }
} }
private static void outputCache(final CommandSource sender, int page) private static void outputCache(final CommandSource sender, String command, int page)
{ {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(cacheage); cal.setTimeInMillis(cacheage);
@ -167,12 +167,14 @@ public class Commandbalancetop extends EssentialsCommand
private final transient CommandSource sender; private final transient CommandSource sender;
private final transient int page; private final transient int page;
private final transient boolean force; private final transient boolean force;
private final transient String commandLabel;
public Viewer(final CommandSource sender, final int page, final boolean force) public Viewer(final CommandSource sender, final String commandLabel, final int page, final boolean force)
{ {
this.sender = sender; this.sender = sender;
this.page = page; this.page = page;
this.force = force; this.force = force;
this.commandLabel = commandLabel;
} }
@Override @Override
@ -183,7 +185,7 @@ public class Commandbalancetop extends EssentialsCommand
{ {
if (!force && cacheage > System.currentTimeMillis() - CACHETIME) if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
{ {
outputCache(sender, page); outputCache(sender, commandLabel, page);
return; return;
} }
} }
@ -191,7 +193,7 @@ public class Commandbalancetop extends EssentialsCommand
{ {
lock.readLock().unlock(); lock.readLock().unlock();
} }
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, false), force)); ess.runTaskAsynchronously(new Calculator(new Viewer(sender, commandLabel, page, false), force));
} }
} }
} }

View file

@ -3,6 +3,10 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource; import com.earth2me.essentials.CommandSource;
import static com.earth2me.essentials.I18n.tl; import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.textreader.SimpleTextPager;
import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.FormatUtil; import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.StringUtil; import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.Server; import org.bukkit.Server;
@ -34,10 +38,11 @@ public class Commandmail extends EssentialsCommand
user.sendMessage(tl("noMail")); user.sendMessage(tl("noMail"));
throw new NoChargeException(); throw new NoChargeException();
} }
for (String messages : mail)
{ IText input = new SimpleTextInput(mail);
user.sendMessage(messages); final TextPager pager = new TextPager(input);
} pager.showPage(args.length > 1 ? args[1] : null, null, commandLabel + " " + args[0], user.getSource());
user.sendMessage(tl("mailClear")); user.sendMessage(tl("mailClear"));
return; return;
} }

View file

@ -26,6 +26,6 @@ public class Commandrules extends EssentialsCommand
final IText input = new TextInput(sender, "rules", true, ess); final IText input = new TextInput(sender, "rules", true, ess);
final IText output = new KeywordReplacer(input, sender, ess); final IText output = new KeywordReplacer(input, sender, ess);
final TextPager pager = new TextPager(output); final TextPager pager = new TextPager(output);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "rules", sender); pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
} }
} }