Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-227

Boolean flag which determines whether or not an entity is going to be saved to disk

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None

      Hey,
      I am currently trying to prevent certain entities, which were spawned via plugin, from being stored to disk whenever their chunk is saved.

      My usecase looks as follows:

      • I am spawning those entities via plugin, remember their uuid and trigger certain stuff whenever a player comes by and interacts with them.
      • I remove those entities again on chunk unloads and server shutdowns / plugin disable, so that those 'customly spawned' entities are no longer in world if the server owner should decide to no longer use this plugin.
      • I store information about those entities, so I can respawn them when the chunk loads again.

      Now this works perfectly fine as long as the server doesn't crash or gets killed.

      Let's assume the server triggered some world save while one of those entities is alive in the world. The entity is now stored to disk. Now the server instantly gets shut down for some reason, the server is restarted and this entity is still there (which is exactly what I tried to prevent originally).

      And easy fix for my situation would be to prevent the saving of those entities to disk all together, for example via some tiny boolean flag added to each entity.

      There is another reason why I don't want to store those entities to disk in my use case, but I don't want to make the description of this ticket unnecessary large. So I hope the reason outlined above is sufficient enough for this being added. If not let me know and I can elaborate more on this other reason.

      Most npc plugins (like citizens) accomplish this by creating their own entity classes which extend the original minecraft entity classes for each available entity type and which return 'false' for the output of the method 'public boolean d(NBTTagCompound nbttagcompound)'.
      However having this flag would mean that I would not have to create and update an own class for each entity type I want to support in my plugin.

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: