Skip to content

Commit 53a7cd7

Browse files
committed
Add paging to mail.
Support aliases in rule and baltop output.
1 parent 4fd026f commit 53a7cd7

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected void run(final Server server, final CommandSource sender, final String
5353
{
5454
if (cacheage > System.currentTimeMillis() - CACHETIME)
5555
{
56-
outputCache(sender, page);
56+
outputCache(sender, commandLabel, page);
5757
return;
5858
}
5959
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
@@ -65,20 +65,20 @@ protected void run(final Server server, final CommandSource sender, final String
6565
{
6666
lock.readLock().unlock();
6767
}
68-
ess.runTaskAsynchronously(new Viewer(sender, page, force));
68+
ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
6969
}
7070
else
7171
{
7272
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
7373
{
7474
sender.sendMessage(tl("orderBalances", ess.getUserMap().getUniqueUsers()));
7575
}
76-
ess.runTaskAsynchronously(new Viewer(sender, page, force));
76+
ess.runTaskAsynchronously(new Viewer(sender, commandLabel, page, force));
7777
}
7878

7979
}
8080

81-
private static void outputCache(final CommandSource sender, int page)
81+
private static void outputCache(final CommandSource sender, String command, int page)
8282
{
8383
final Calendar cal = Calendar.getInstance();
8484
cal.setTimeInMillis(cacheage);
@@ -167,12 +167,14 @@ private class Viewer implements Runnable
167167
private final transient CommandSource sender;
168168
private final transient int page;
169169
private final transient boolean force;
170+
private final transient String commandLabel;
170171

171-
public Viewer(final CommandSource sender, final int page, final boolean force)
172+
public Viewer(final CommandSource sender, final String commandLabel, final int page, final boolean force)
172173
{
173174
this.sender = sender;
174175
this.page = page;
175176
this.force = force;
177+
this.commandLabel = commandLabel;
176178
}
177179

178180
@Override
@@ -183,15 +185,15 @@ public void run()
183185
{
184186
if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
185187
{
186-
outputCache(sender, page);
188+
outputCache(sender, commandLabel, page);
187189
return;
188190
}
189191
}
190192
finally
191193
{
192194
lock.readLock().unlock();
193195
}
194-
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, false), force));
196+
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, commandLabel, page, false), force));
195197
}
196198
}
197199
}

Essentials/src/com/earth2me/essentials/commands/Commandmail.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import com.earth2me.essentials.CommandSource;
44
import static com.earth2me.essentials.I18n.tl;
55
import com.earth2me.essentials.User;
6+
import com.earth2me.essentials.textreader.IText;
7+
import com.earth2me.essentials.textreader.SimpleTextInput;
8+
import com.earth2me.essentials.textreader.SimpleTextPager;
9+
import com.earth2me.essentials.textreader.TextPager;
610
import com.earth2me.essentials.utils.FormatUtil;
711
import com.earth2me.essentials.utils.StringUtil;
812
import org.bukkit.Server;
@@ -34,10 +38,11 @@ public void run(final Server server, final User user, final String commandLabel,
3438
user.sendMessage(tl("noMail"));
3539
throw new NoChargeException();
3640
}
37-
for (String messages : mail)
38-
{
39-
user.sendMessage(messages);
40-
}
41+
42+
IText input = new SimpleTextInput(mail);
43+
final TextPager pager = new TextPager(input);
44+
pager.showPage(args.length > 1 ? args[1] : null, null, commandLabel + " " + args[0], user.getSource());
45+
4146
user.sendMessage(tl("mailClear"));
4247
return;
4348
}

Essentials/src/com/earth2me/essentials/commands/Commandrules.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public void run(final Server server, final CommandSource sender, final String co
2626
final IText input = new TextInput(sender, "rules", true, ess);
2727
final IText output = new KeywordReplacer(input, sender, ess);
2828
final TextPager pager = new TextPager(output);
29-
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "rules", sender);
29+
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
3030
}
3131
}

0 commit comments

Comments
 (0)