Solved Problem with schedulers

Discussion in 'Plugin Development' started by Flyverse, Mar 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Flyverse

    Hey there!

    I'm running a scheduler method called runTaskTimer, and I remove blocks in it by setting its type to air. But, now here's the problem: Spigot is telling me "java.lang.IllegalStateException: Asynchronous block remove!" - And I've no idea why! I mean, shouldn't the runTaskTimer method be synchronous anyway?

    Kindly regards
     
  2. Offline

    Wolfey

    I don't believe spigot is supported here, sorry.
     
  3. Offline

    GaaTavares

    Bukkit doesn't supports Spigot. But you are probably trying to remove a block on an async scheduler. Try using sync.
     
  4. Offline

    Flyverse

    Oh, sorry. I thought it would be the same. I said spigot because the server where the plugin should run on (Server of a friend, he asked me to do this plugin ^^) runs with spigot.
    GaaTavares
    Thats the thing: I use an sync scheduler! Or why else would there be a method called "runAsyncTaskTimer" if the method "runTaskTimer" isn't synchronous? (By the way, I hope I don't said anything wrong.. I'm using a bukkit runnable, not the scheduler directly, but it hsould basically be the same thing, no :eek:?)
     
  5. Offline

    GaaTavares

    Show us your code
     
  6. Offline

    Flyverse

    Code:java
    1. class RoundCountdown extends BukkitRunnable {
    2. int countdown = roundTimeInSeconds;
    3. public void run(){
    4. //Do some not important things here
    5. if(countdown == 0){
    6. this.cancel();
    7. finishRound();
    8. if(roundsPlayed >= roundsPerPlay) finishGame(); else nextRound();
    9. }
    10. countdown--;
    11. }
    12. }

    Code:java
    1.  
    2. The Event
    3. ...
    4. rcd.cancel(); // rcd = Name of the instance of the RoundCountdown
    5. finishRound();
    6. if(roundsPlayed >= roundsPerPlay) finishGame(); else nextRound();
    7.  

    Code:java
    1.  
    2. public void nextRound(){
    3. //Do some not important things like messaging
    4. rcd = new RoundCountdown();
    5. rcd.runTaskTimer(this, 20, 20);
    6. //taskid = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, rcd, 20, 20); I EVEN TRIED THIS!
    7. }
    8.  

    Code:java
    1.  
    2. public void finishRound(){
    3. clearArena(); //loop through coordinate, then new Location(world, x, y, z).getBlock().setType(Material.AIR) or something like that
    4. rcd.cancel();
    5. }
    6.  


    That is it. The error is on clearArena.

    Anyone got an Idea :(? I find this error really weird...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  7. Offline

    Flyverse

    Solved. I just put that clearArena in an runnable wich I run with Bukkit.getScheduler().runTask(...).
     
Thread Status:
Not open for further replies.

Share This Page