[00:02:34] [Async Chat Thread - #167/ERROR]: Could not pass event AsyncPlayerChatEvent to XXXXXXX v1.6.0 java.lang.IllegalStateException: Asynchronous command dispatch! at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:15) ~[patched_1.13.2.jar:git-Paper-655] at org.bukkit.craftbukkit.v1_13_R2.CraftServer.dispatchCommand(CraftServer.java:709) ~[patched_1.13.2.jar:git-Paper-655]
if (commandSender.getName().equalsIgnoreCase("console")) { commandSender.sendMessage(ChatColor.translateAlternateColorCodes( '&',"&cConsole can not use this command" )); returntrue; } Player p = Bukkit.getServer.getPlayer(commandSender.getName());
然而有更高雅的方法
1 2 3 4
if (!(sender instanceof Player)) { returntrue; } Player p = (Player) commandSender;