Custom DataManipulator not functioning

So I’m trying to revamp one of my first plugins, which I made with the more narrow Spigot mindset. I’ve found out that the way I was storing data in it was inefficient, and could be greatly improved by using a custom DataManipulator. The only problem is that the system doesn’t even work, because the fill() method is generating a NoSuchElementException. The log and code can be found here. If anyone knows how to fix this, it would be greatly appreciated

The problem is that your fill method is assuming that your custom data is always present on the DataHolder parameter. This won’t always be the case (e.g. when calling getOrCreate for the first time).

Instead of calling Optional#get() on the Optional returned by DataHolder#get, you’ll want to call .orElse(null), and pass the result to the MergeFunction. MergeFunction allows at most of its parameters to be null, so this is perfectly fine.