Skip to content

Commit

Permalink
Merge pull request #53 from SplotyCode/fix/command-async
Browse files Browse the repository at this point in the history
MenuCommand: Don't run heavy io tasks on minecraft server thread
  • Loading branch information
funkemunky authored Jun 21, 2022
2 parents 2fe8d7b + 2649183 commit 8896d29
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import dev.brighten.anticheat.logs.objects.Log;
import dev.brighten.anticheat.menu.LogsGUI;
import dev.brighten.anticheat.utils.Pastebin;
import dev.brighten.anticheat.utils.menu.Menu;
import dev.brighten.anticheat.utils.menu.button.Button;
import dev.brighten.anticheat.utils.menu.button.ClickAction;
import dev.brighten.anticheat.utils.menu.preset.button.FillerButton;
Expand Down Expand Up @@ -107,7 +108,10 @@ private static ChestMenu getMainMenu() {
menu.setItem(15, createButton(XMaterial.PAPER.parseMaterial(), 1, "&cView Recent Violators",
(player, info) -> {
player.sendMessage(Color.Gray + "Loading menu...");
getRecentViolatorsMenu(true).showMenu(player);
Kauri.INSTANCE.executor.execute(() -> {
Menu violatorsMenu = MenuCommand.getRecentViolatorsMenu(true);
RunUtils.task(() -> violatorsMenu.showMenu(player));
});
}, "", "&7View players who flagged checks recently."));

menu.fill(new FillerButton());
Expand Down Expand Up @@ -511,12 +515,16 @@ public static ChestMenu getRecentViolatorsMenu(boolean fromMain) {
(target, info) -> {
if (info.getClickType().equals(ClickType.SHIFT_LEFT)
&& target.hasPermission("kauri.command.logs")) {
LogsGUI gui = new LogsGUI(finalName, uuid);
menu.setParent(null);
menu.close(target);
gui.setParent(info.getMenu());
menu.setParent(main);
gui.showMenu(target);
Kauri.INSTANCE.executor.execute(() -> {
LogsGUI gui = new LogsGUI(finalName, uuid);
RunUtils.task(() -> {
menu.setParent(null);
menu.close(target);
gui.setParent(info.getMenu());
menu.setParent(main);
gui.showMenu(target);
});
});
}
}));
}
Expand Down

0 comments on commit 8896d29

Please sign in to comment.