Setting many blocks at once

Discussion in 'Plugin Development' started by maxben34, Oct 27, 2013.

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

    maxben34

    I'm making a plugin that requires me to reset an arena after or even during the game. There will be exploded areas and such, ao how could i go about setting the map blocks back all at once?

    Also, I need an idea on how i can go about shrinking the arena size as the match progresses. I'm not worried about timing it, im just worried about how im going to get it to shrink. I'd try the worldedit API but i see little information on it.

    Any help/ideas? Thanks :)
     
  2. Offline

    alex123099

    maxben34
    For restoring the arena, you could simply store all the blocks in the area of the arena in a hashmap and then reload them at the specific location. If you want to be more safe so if the server restarts or shuts down before the arena was restored, you could always save the hashmap data into a file and load it later.
    Regarding the shrinking, when you say shrinking, you mean the borders become smaller? or (if it's a cube) the walls literally move closer to each other?
     
  3. alex123099
    Restoring the blocks like that would cause huge amounts of lag, I believe WorldEdit uses some special method to do this, maybe maxben34 could look into its API and see if there's anything related to this.
     
  4. Offline

    alex123099

    To reduce lag you could always load and spawn it in parts with a small sleep time in between spawns.
     
  5. alex123099
    True, just remember not to use Thread.sleep() in the main thread ;)
     
  6. Offline

    maxben34

    alex123099 Assist
    By shrinking I mean the borders get smaller. Exactly.

    I'll look into storing block states through hashmaps.

    Any of you know anything about using the worldedit api?

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

    jackson30007

    Hmm, this is something I need as well, hope your problem gets solved :p
     
  8. Offline

    maxben34

    Only one way it can jackson30007! Somebody needs to tell us how :/ I've tried researching stuffs.
     
  9. Offline

    unforgiven5232

    maxben34 I'm not going to give you the code seeing how its a simple for-loop, all you need is to run the loop through every block, save the block. then replace.
     
Thread Status:
Not open for further replies.

Share This Page