Lag-induced block changes

Discussion in 'Plugin Development' started by escortkeel, Aug 20, 2012.

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

    escortkeel

    One of my plugins requires some "super-intense block placement/deletion" stuff to go on. :p

    Thing is, executing this directly in an event handler causes some obvious problems (the server doesn't tick for several seconds and all players loose connection because of communication timeouts. Unfortunately, I can't move this to a separate thread for obvious reasons (i.e. concurrency and synchronization exceptions). How can I solve this?

    EDIT: Also, and on a sort-of unrelated note, the changes I perform are not sent to the client, potentially because of their magnitude. How can I force the player/client to re-download the chunks?

    Thanks in advance! :D

    ~Keeley

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  2. There are methods in the bukkit API to allow you to send individual block changes or entire chunk change packets to the client.
    EDIT: )]player.sendChunkChanged()

    The chunk change packet would be better than the individual blocks if you set the blocks in an internal method so they don't send individual packets on their own because that will increase lag.

    Also, you could use a queue to set the blocks like WorldEdit does, like 100 blocks per tick and stuff like that.
     
  3. Offline

    escortkeel

    Thanks for the tip!

    Here's another question. ;)

    How would I use that method? I mean, there is a bytebuffer and all sorts of other confusing stuff. ;)

    Thanks Again for you help! :D

    ~Keeley

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  4. I never used it myself... but you could've searched, which I just did and I found out something about it:
    http://forums.bukkit.org/threads/solved-sending-chunk-updates-to-clients.68735/#post-1055845

    In the search I also came accros this: http://forums.bukkit.org/threads/how-plugin-effects-on-server-performance.48869/
    bergerkiller's reply says about how block.setType() is CPU intensive.
     
Thread Status:
Not open for further replies.

Share This Page