Chunk claim data

Hello world. So I’m working on a plugin that handles teams, claims, and battles for our servers specific needs. Player and team data is getting stored in a h2 file and that’s all fine I’m just worried about claims.

Their are two sorts of claims one being a regional claim and a base claim. Base claims are where cities are and players can build regional claims around them up to a certain distance which are chunk based like factions. Base claims are all fine and I’m currently drawing up a wavefront algorithm to validate regional claims and groups which are stored in basic text files in levels. Level 0 is where a base is, level 1 is one chunk out of a base, level 2 is one chunk out from that and so on. This is great for me because it let’s me organize regions and quickly add more claims to a region without needing to make a path to a base from scratch. It also let’s me easily create a map overlay which I plan to create and send to clients with a journeymap extension.

The problem with this system is its not easy to find information relative to a player for example. My current idea is looking for the closest city then finding which file contains the location of the chunks it resides in then using something like running through all the contents after a certain level which is the distance to the city. If it can’t find that chunk it then looks for the next closest city in a different region group and repeats this until it either finds the chunk or the cities get out of range. This seems time consuming and inefficient. Although I haven’t finished it so I don’t know how good or bad it would be. But that check needs to get ran a lot for checking who’s land you are in to display it, check if you are allowed there or a task is valid and so on so I really think something else would be better.

I think I saw somewhere that you can save data to chunks with forge and that really seems like the route to go if I can do it with sponge because I don’t really want this client side. I’ll need to store data like nation name, distance from the closest base and region group (so I can easily find it in the file data), maybe a table of flags. If i could add things to chest data that would be amazing too for a lock pick addon I plan to add in the future once this is all working.

Sorry for the long post but I’m just looking for ideas of how to improve any ideas I have here or any concerns anyone might have. Also suggestions on how to save and retrieve that chunk data would be very helpful.