SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 343 forks source link

Add a DeleteWorldEvent #1127

Open CrystalMageX opened 8 years ago

CrystalMageX commented 8 years ago

Sponge should have a DeleteWorldEvent, just like we have a ConstructWorldEvent. This would allow plugins to delete their own meta-world data. Uses for this are cleaning up world-specific settings, refunding players of their world-creation costs, and resetting invalid player homes.

ewized commented 8 years ago

This would never be called in normal Minecraft though, once a server or client creates a world it's there to stay. Unless a plugin unloads it first then deletes the folder.

ryantheleach commented 8 years ago

Have to heavily disagree with you ewized.

Worlds get deleted by multiverse plugins all the time. And in vanilla?

image

But I thought that ConstructWorldEvent was called every time the world class was constructed? not just when the world was created the first time?

Edit: But that's probably just poor naming and me not looking at the javadocs.

ewized commented 8 years ago

I thought the client just deletes the folder and would not have a reference to the work settings.

On 10:15, Thu, Mar 3, 2016 Ryan Leach notifications@github.com wrote:

Have to heavily disagree with you ewized.

Worlds get deleted by multiverse plugins all the time. And in vanilla?

[image: image] https://cloud.githubusercontent.com/assets/141554/13504267/c08efd4e-e1c3-11e5-8050-794c6bbe3f76.png

But I thought that ConstructWorldEvent was called every time the world class was constructed? not just when the world was created the first time?

— Reply to this email directly or view it on GitHub https://github.com/SpongePowered/SpongeAPI/issues/1127#issuecomment-191892523 .

Deamon5550 commented 8 years ago

Using an event like this to cleanup metadata would be bad practice as there are many times when the world is deleted directly rather than through an api call or the client. If you want to store per-world metadata you're better off just storing it with the world so there theres no issue of cleaning it up if the world is deleted since deleting the world also deletes your metadata.

CrystalMageX commented 8 years ago

you're better off just storing it with the world

Some plugins may want to store that data in a database. Yes, it is possible to configure the database to put the specific table for the world in the world data folder, maybe even back across a network using network folders when connecting to one on another server, but that would be even worse practice.

many times when the world is deleted directly rather than through an api call or the client

A responsible plugin would do everything it can do to clean up its leftover mess (several hundred world folders on a large server with something like Mystcraft). If the server owner/admin decides to delete the world folder directly anyway, then they can only blame themselves once this is implemented, not the plugin or Sponge.