Solved Detecting World Save and Excluding Entities from Save

Discussion in 'Plugin Development' started by SoThatsIt, Oct 27, 2014.

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

    SoThatsIt

    i have a plugin which creates entities which are used as npcs which plugins can hook into and make it do stuff when players click it. The problem is when the server shuts down it saves these entities but not any of their metadata which i use to identify them. I was wondering if there was a way to detect when a world saves and then remove the entity from the world. I have tried doing this in world/chunk unload using entity.remove() which didnt work. I then tried to use nms and invoke remove entity from the world instead of the entity, which didnt work either. All help will be greatly appreciated.

    Edit:
    I am trying onDisable now but the problem with that is if the server crashes the entities will be saved.

    Edit 2:
    onDisable did not work, using entity.remove or the nms alternative.

    Edit 3:
    Cant believe i missed org.bukkit.event.world.WorldSaveEvent (facepalm)

    Edit 4:
    WorldSaveEvent works using entity.remove(). Cant believe i didnt see that earlier

    ~sothatsit
     
Thread Status:
Not open for further replies.

Share This Page