How do I prevent NoLagg exceptions?

Discussion in 'Plugin Development' started by genesis19, Jun 27, 2012.

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

    genesis19

    I'm creating a plugin that logs all blocks changes. When I try to fireball pretty big area, for example when 40 000 are broken and I need to rollback it, it is just dangerous to run it in main thread. So I start a new scheduled task and try to rollback all changes. The problem is that NoLagg gives me this exception (which is being spammed in console)

    (and more of this type). I understand that this is just a warning, but how to really solve it?

    I'm not using Bukkit's Block.setTypeId() because it's too slow, so I just use net.minecraft.server.Chunk.a directly to change a block and I send changes to players later.

    How do I prevent these warnings?
     
  2. you using an ascry task to chance the blocks, that causres thread problems and give this warning
     
  3. Offline

    genesis19

    I know it does, but how do I prevent it?
     
  4. run it on the main thread
     
  5. Offline

    genesis19

    I can't. The whole server will get stuck for a few seconds, which is the thing I want to avoid
     
  6. You don't have an alternative, you can't modify world in threads, you can use a sync task (which runs in the main thread) and progresively restore blocks, few hundreds at a time, small enough so it doesn't lag and large enough so it gets the job done in as few ticks as possible.

    Still, did you contact the author of that plugin ? Because after all it's his plugin and maybe there's an issue with it, or maybe he can suggest some better alternatives for your code if your code is the fauly one.
     
  7. Offline

    rominos2

    If you want to use thread.
    Just "read" your world with it.
    And let the main thread "writing" your world.
    You've no other choice
     
Thread Status:
Not open for further replies.

Share This Page