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
commit0cab5b960145bcc718707257eeb7a3cb82a5a2ea (patch)
tree6f3547e3b86c7cc45afc523d9e086ea46a2d1024
parentf4e6f01cd9274476e3cb7334bf3819c6f2ec8856 (diff)
downloadEssentials-0cab5b960145bcc718707257eeb7a3cb82a5a2ea.tar
Essentials-0cab5b960145bcc718707257eeb7a3cb82a5a2ea.tar.gz
Essentials-0cab5b960145bcc718707257eeb7a3cb82a5a2ea.tar.lz
Essentials-0cab5b960145bcc718707257eeb7a3cb82a5a2ea.tar.xz
Essentials-0cab5b960145bcc718707257eeb7a3cb82a5a2ea.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);
}
}