Skip to content

Commit

Permalink
Merge pull request #1 from skongkonga/fix-async
Browse files Browse the repository at this point in the history
默认关闭异步,可配置
  • Loading branch information
skongkonga authored Dec 31, 2023
2 parents 9738700 + 8165ecd commit 301a95e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 2 additions & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ proxy:
port: 10809

gui:
#是否异步打开gui,部分服务端核心不允许异步
async: false
#玩家排名总榜的显示数量
topplayers: 5
#玩家排名月榜的显示数量
Expand Down
1 change: 1 addition & 0 deletions src/moe/feo/bbstoper/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum Option {
PROXY_ENABLE("proxy.enable"),
PROXY_IP("proxy.ip"),
PROXY_PORT("proxy.port"),
GUI_ASYNC("gui.async"),
GUI_TOPPLAYERS("gui.topplayers"),
GUI_TOPPLAYERSMONTHLY("gui.topplayersmonthly"),
GUI_TOPPLAYERSDAILY("gui.topplayersdaily"),
Expand Down
14 changes: 10 additions & 4 deletions src/moe/feo/bbstoper/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ public static String getTitle() {// 获取插件的gui标题必须用此方法
}

public GUI(Player player) {
Bukkit.getScheduler().runTaskAsynchronously(BBSToper.getInstance(), () -> {
createGui(player);
player.openInventory(inv);
});
if (Option.GUI_ASYNC.getBoolean())
Bukkit.getScheduler().runTaskAsynchronously(BBSToper.getInstance(), () -> {
createGui(player);
player.openInventory(inv);
});
else
Bukkit.getScheduler().runTask(BBSToper.getInstance(), () -> {
createGui(player);
player.openInventory(inv);
});
}

class BBSToperGUIHolder implements InventoryHolder {// 定义一个Holder用于识别此插件的GUI
Expand Down
14 changes: 10 additions & 4 deletions src/moe/feo/bbstoper/gui/TopGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ public static String getTitle() {// 获取插件的gui标题必须用此方法
}

public TopGUI(Player player) {
Bukkit.getScheduler().runTaskAsynchronously(BBSToper.getInstance(), () -> {
createGui();
player.openInventory(inv);
});
if (Option.GUI_ASYNC.getBoolean())
Bukkit.getScheduler().runTaskAsynchronously(BBSToper.getInstance(), () -> {
createGui();
player.openInventory(inv);
});
else
Bukkit.getScheduler().runTask(BBSToper.getInstance(), () -> {
createGui();
player.openInventory(inv);
});
}

class BBSToperGUIHolder implements InventoryHolder {// 定义一个Holder用于识别此插件的GUI
Expand Down

0 comments on commit 301a95e

Please sign in to comment.