summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2014-08-11 19:03:24 +0100
committerKHobbits <rob@khobbits.co.uk>2014-08-11 19:03:24 +0100
commit3133dc266aea58be00aebee34beaa27c85a8b5b4 (patch)
tree54abb5fb517ed3f7fe562e911242e48200f13fd4
parentff487418ea1fe967d6bb5dedcf20459299488dbd (diff)
downloadEssentials-3133dc266aea58be00aebee34beaa27c85a8b5b4.tar
Essentials-3133dc266aea58be00aebee34beaa27c85a8b5b4.tar.gz
Essentials-3133dc266aea58be00aebee34beaa27c85a8b5b4.tar.lz
Essentials-3133dc266aea58be00aebee34beaa27c85a8b5b4.tar.xz
Essentials-3133dc266aea58be00aebee34beaa27c85a8b5b4.zip
Add paging to mail.
Support aliases in rule and baltop output.
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java16
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmail.java13
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrules.java2
3 files changed, 19 insertions, 12 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
index 42946fbe2..41f78ad11 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
@@ -53,7 +53,7 @@ public class Commandbalancetop extends EssentialsCommand
{
if (cacheage > System.currentTimeMillis() - CACHETIME)
{
- outputCache(sender, page);
+ outputCache(sender, commandLabel, page);
return;
}
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
@@ -65,7 +65,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
- ess.runTaskAsynchronously(new Viewer(sender, page, force));
+ ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
}
else
{
@@ -73,12 +73,12 @@ public class Commandbalancetop extends EssentialsCommand
{
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();
cal.setTimeInMillis(cacheage);
@@ -167,12 +167,14 @@ public class Commandbalancetop extends EssentialsCommand
private final transient CommandSource sender;
private final transient int page;
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.page = page;
this.force = force;
+ this.commandLabel = commandLabel;
}
@Override
@@ -183,7 +185,7 @@ public class Commandbalancetop extends EssentialsCommand
{
if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
{
- outputCache(sender, page);
+ outputCache(sender, commandLabel, page);
return;
}
}
@@ -191,7 +193,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
- ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, false), force));
+ ess.runTaskAsynchronously(new Calculator(new Viewer(sender, commandLabel, page, false), force));
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
index 808842884..0e4869df5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
@@ -3,6 +3,10 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import static com.earth2me.essentials.I18n.tl;
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.StringUtil;
import org.bukkit.Server;
@@ -34,10 +38,11 @@ public class Commandmail extends EssentialsCommand
user.sendMessage(tl("noMail"));
throw new NoChargeException();
}
- for (String messages : mail)
- {
- user.sendMessage(messages);
- }
+
+ 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;
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
index 51ca08053..f9a109a51 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
@@ -26,6 +26,6 @@ public class Commandrules extends EssentialsCommand
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, "rules", sender);
+ pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
}
}