Skip to content

Commit bdc5f4c

Browse files
authored
Fix baltop not working in command blocks (#5078)
1 parent 0be056b commit bdc5f4c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.common.collect.Lists;
88
import net.essentialsx.api.v2.services.BalanceTop;
99
import org.bukkit.Server;
10+
import org.bukkit.command.BlockCommandSender;
1011

1112
import java.math.BigDecimal;
1213
import java.text.DateFormat;
@@ -32,8 +33,15 @@ private void outputCache(final CommandSource sender, final int page) {
3233
final Calendar cal = Calendar.getInstance();
3334
cal.setTimeInMillis(ess.getBalanceTop().getCacheAge());
3435
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
35-
sender.sendMessage(tl("balanceTop", format.format(cal.getTime())));
36-
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
36+
final Runnable runnable = () -> {
37+
sender.sendMessage(tl("balanceTop", format.format(cal.getTime())));
38+
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
39+
};
40+
if (sender.getSender() instanceof BlockCommandSender) {
41+
ess.scheduleSyncDelayedTask(runnable);
42+
} else {
43+
runnable.run();
44+
}
3745
}
3846

3947
@Override

0 commit comments

Comments
 (0)