Solved PersistentDataContainer not updating when set on TileStates

Discussion in 'Plugin Development' started by Reflxction, Jul 18, 2019.

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


    Hello. In my plugin (1.14.2), I have to store persistent data on a custom spawner, this allows me to track entities that this spawner spawns and hence make those entities drop custom items. I have used the metadata API for the same purpose and it worked flawlessly, except that it got lost on restart, which is what I need to avoid, so I converted to the persistence API.

    When I modify the CreatureSpawner's persistence data by adding a specific key, it updates in the same scope (i.e method/etc.) as I accessed the customDataMap (from CraftBukkit) and printed its content. However, when I listen to SpawnerSpawnEvent, and print the persistent data the event#getSpawner() has, it prints an empty map. I tried printing the spawner location and hashcode, and it was exactly matching the one I have modified earlier, except that the persistent data is not there.

    Am I doing anything wrong? Is this a bug? Is there a better way to achieve my goal? Thanks in advance.

    (p.s: by the time this post was written, I will be asking in PaperSpigot's discord channel for help, and will post any solution I get in here.)

    UPDATE: The issue was fixed by simply calling TileState#update().
    Last edited: Jul 18, 2019
Thread Status:
Not open for further replies.

Share This Page