TickNextTick list out of synch ?!?

Discussion in 'Plugin Development' started by Clemens, Feb 26, 2011.

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

    Clemens

    Hi there. Can someone help me? I'm no expert, but I got the following error:

    Code:
    [SEVERE] Unexpected exception
    java.lang.IllegalStateException: TickNextTick list out of synch
        at net.minecraft.server.World.a(World.java:1513)
        at net.minecraft.server.World.g(World.java:1433)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:329)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:253)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    I quess it has something to do with the timers i'm using.
    One timer "scans" an area of blocks every 900 milliseconds throughout the whole game (to find specific blocks), the other one is inserted in the TimerTask of this first timer and changes the TypeId of specific blocks that are found in the "scan". I had to use the second timer, because depending on what kind of block it is, I want it to be changed to a certain time.

    Can someone help me fix this error or give me a hint on how I could solve my problem with a different method?

    I can also post some code if it helps...
     
  2. Offline

    Edward Hand

    Are you using the bukkit scheduler?
    Are you using the synchronised timer methods?
    It would be a good idea to do both if not.
     
  3. Offline

    Clemens

  4. Offline

    Edward Hand

    Yes. That javadoc is the right page. You'll see several methods on there. Some start scheduleSync... and others scheduleAsync. Make sure to use the synced ones.

    The reason to use the bukkit scheduler rather than any separate timer/thread is that using separate threads can mean that two threads try to change something at the same time, which can lead to corruption. Using the nice synchronised bukkit scheduler guarantees that your function calls will be allocated a little time slot in the normal order of things in which the server will not be doing anything.
     
  5. Offline

    Clemens

    Ok, I now used the synchronised bukkit scheduler everywhere and my TickNextTick Problem is gone =)

    But... I got a new error:

    Code:
    [SEVERE] java.lang.NullPointerException
    2011-02-27 11:11:04 [SEVERE]     at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:122)
    2011-02-27 11:11:04 [SEVERE]     at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:326)
    2011-02-27 11:11:04 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:253)
    2011-02-27 11:11:04 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    2011-02-27 11:11:04 [SEVERE] Unexpected exception
    java.lang.NullPointerException
        at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:122)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:326)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:253)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Do you have any idea from what this error might come from?

    Oh, by the way: Thank you for your time and help. I appreciate it.
     
  6. Offline

    Edward Hand

    Could you show the code relating to the scheduler?

    Ah. I think you have misunderstood somewhere
    That runnable thing you pass as the second argument for the scheduling function isnt supposed to be a function. It's supposed to be an instance of a class.

    You need something like this:
    Code:
    public class myRunnable implements Runnable{
        public function run(){
            //stuff to do when running
        }
    }
    
    And then:
    Code:
    plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new myRunnable(), 1L, 15L);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 10, 2016
  7. Offline

    Clemens

    YESSS :):):) it works !!!!

    Thank you very much Edward Hand, you saved me ;)
     
Thread Status:
Not open for further replies.

Share This Page