有没有办法在没有 AsyncPlayerChatEvent 的情况下捕获玩家聊天输入?

Is there a way to catch a players chat input without an AsyncPlayerChatEvent?

我又在写另一个 Banksystem 插件,但这次是用 ATM。我想弄清楚如何在单击该选项后让玩家聊天输入,以防止单击 100 次以在银行帐户中存入 50,000 美元。

我正在用 Paper-Spigot 1.14.4 编写这个插件,我尝试了以下步骤:

Bukkit.getPluginManager().registerEvents(new ChatListener(), Main.getPlugin());
String input = getChat().getMessage();

我目前的chatListener()方法:

public void chatListener(Inventory inv, Player pl) {
        pl.closeInventory();
        pl.sendMessage("§6Please enter your amount:");
        String input = getChat().getMessage();
        if(input.matches("[0-9]+")) {
            pl.openInventory(inv);
            inv.setItem(0, new ItemStack(Material.AIR));
            inv.setItem(0, CustomHeads.customHead(CustomHeads.BITCOIN,
                    input));
        } else {
            pl.sendMessage("§cPlease enter only numeric characters!");
        }
    }

AsyncPlayerChatEvent 获取方法:

public AsyncPlayerChatEvent getChat() {
        return chat;
    }

我希望在 "Please enter your amount:" 消息出现后,玩家的消息被保存在 input 变量中。

当我创建 System.out.println(input) 时,控制台不显示任何内容,既不包括错误也不显示任何警告。

创建一个 AsyncPlayerChatEvent 和一个 public static ArrayList

ExampleChatEvent.class

public static ArrayList<Player> waitingForAmountPlayers = new ArrayList<>();

public void onChat(AsyncPlayerChatEvent e) {

 Player p = e.getPlayer();

 if (waitingForAmountPlayers.indexOf(p) != -1) {

  //
  // YOUR CODE
  //

  waitingForAmountPlayers.remove(p);

 }

}

当您想在聊天中输入玩家数量时,请不要忘记将玩家添加到 waitingForAmountPlayers (ExampleChatEvent.waitingForAmountPlayers.add(p);)。