World Reset

Discussion in 'Plugin Development' started by Pawnguy7, Aug 29, 2014.

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

    Pawnguy7

    A long time ago, I was making a minigame. It would allow players to destroy the terrain, and thus needed to be reset. I had a simple idea for how to do this. Have a permanent copy of the map. Every game, copy the map, load it, play on it, unload it, delete it, and repeat.

    This was back in 1.5. I soon learned this was seemingly not possible. I don't fully remember the error, but I want to say ConcurrentModification. Anyway, fast forward to the present.

    I was seeing if it now works. And it does... sort of. I seems to work roughly 80% of the time, until... it doesn't.

    Occasionally when the files are deleted, an IOException is the result. Specifically, deleting one of the chunk files. It is a recursive delete, however, so this in itself is not noteworthy for me at the moment. I did check if calling world.unloadchunk on all the chunks before unloading the world made a difference, but it did not.

    This is on Windows. 7, specifically. On a (non-Windows) server host, the same thing occurs, kind of. It seems to fail in roughly the same way. It, however, does not throw an exception. Rather, it is painfully obvious that the world does not reset. I tried to log some information to get to the bottom of it, but am yet to find anything.

    Every time, Server.unloadWorld(world, false) returns true. 20 ticks later, checking Server.getWorlds() does not contain the unloaded world, as determined by the world name. I had initially wondered if, somehow, I was setting locations to the old world reference, and somehow keeping the world in memory. Checking with the hashcodes, however (more specifically, System.identifyHashcode as World overrides it) seems to indicate they are not.

    Is there a general (and working) way to use this approach now? Do you suspect the error on both systems has the same cause?
     
  2. Offline

    Pawnguy7

    Bump.
     
Thread Status:
Not open for further replies.

Share This Page