1.15.2 Error running command

Discussion in 'Spigot Plugin Development' started by Inspectiver, Apr 3, 2020.

  1. I have a method in my main class that gets some coordinates (I know it does it an extremely inefficient way), and is supposed to run the fill command, however as a result I get this error:

    Code (Text):
    java.lang.IllegalStateException: Asynchronous command dispatch!
    code:
    Code (Java):
        public void updateWater() {
            Bukkit.getServer().broadcastMessage("§c§oThe water is rising...");
            System.out.println(isChangeEnabled());
            try {
                if (isChangeEnabled()) {
                    int sx = (int) this.getConfig().get("start.x");
                    int sy = (int) this.getConfig().get("start.y");
                    int sz = (int) this.getConfig().get("start.z");
                    int ex = (int) this.getConfig().get("end.x");
                    int ez = (int) this.getConfig().get("end.z");
                    if (getLevel() == 0) {
                        setLevel(sy);
                    }
                    setLevel(0);
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "fill " + sx + " " + sy + " " + sz + " " + ex + " " + getLevel() + " " + ez + " minecraft:water");

                }
            }
    Any help appreciated!
     
  2. SteelPhoenix

    Moderator

    Don't do it asynchronous, like it says. You can use the bukkit scheduler for this.
    Also, there is no reason to execute /fill through console when there are API methods for world editing.