Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
Hello,
it is historically possible to create a new world (cRoot:CreateAndInitializeWorld()), but it is an unsafe operation and it is quite prone to errors - the server is known to deadlock quite often in such cases. And there's no way to remove a world, mostly due to similar reasons (the operation wouldn't be safe) and also because of the built-in assumption of the Lua API (and MCS internals) that once you have a valid cWorld object, it will remain valid for the rest of the server execution. Breaking this assumption would require too much work, so it hasn't been even considered.
Can you elaborate on what exactly you're trying to do? Perhaps there's a better way of doing it, or at least a workaround.
Posts: 3
Threads: 1
Joined: Jul 2014
Thanks: 0
Given 0 thank(s) in 0 post(s)
02-06-2015, 10:49 PM
(This post was last modified: 02-06-2015, 10:50 PM by Zentdayn.)
Sure.
Me and some friends we just finished a semester and wanted something to do.
I had this idea ( originally ), a scalable minecraft mini-game which would work in this fashion, a client connects to a modified MCServer ( either modified C++ or via plugin ) and that server has a bunch of slaves it would order one of them to create a mini-game instance ( like skywars for example ) this would be nothing but a short lived copy of a pre-made world, which would not need saving and could be destroyed when the game finishes.
A simpler version would mean making it work for one server only and then connect a bunch of them via bungee cord which would work fine as well, but it would be nice to be able to prevent the worlds form saving ( since they would have to be rolled back to initial state anyway so there is no need for saving ) and the world creation / destruction would be nice so that the solution wouldn't be having like hundreds of worlds / each possible minigame.
tl;dr i want to have minigames (like skywars) so i either create/destroy worlds or rollback changes made, and changes made one game don't need to be saved.
I might have screwed up trying to explain if anything isn't clear let me know.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
I think restoring an existing world back to its pristine state is a much easier option at this moment. That is, if you can keep the worlds reasonably limited. Restoring a 10k * 10k block world will not work, but for, say, 20 chunks * 20 chunks it should be perfect.
One more choice that comes to mind, make it a custom generator. Then whenever the chunk is (re)generated, the generator will restore the world.
And another: Set the world storage to forgetful - the changes won't get written to the disk, but still all players currently online in that world would see them. As soon as all of them log out, boom, the server unloads the chunks and the world is gone. If you put your regular MCA files to the world folder, they will get loaded the next time the world is used.
This might need some help from a plugin, too, though - you may need to override the OnChunkUnloading hook not to let any chunks unload as long as there's a player present in the world, otherwise they lose that chunk while playing.