It might be useful to create some kind of data structure that holds this information for you. Something along the lines of:
@ConfigSerializable
public class Property {
public static final TypeToken<Property> TYPE = TypeToken.of(Property.class);
@Setting
private List<String> owners;
// To be honest UUID's would probably be better, if the owner is not a player just make a new one, but it's up to you
@Setting
private List<Location<World>> bounds;
// Anything within these bounds (you could do corners or something, list is generic enough to support any shape) is in the property
/* ... code for this here, whatever you do ... */
}
And then all you have to do is load this from your config file, something like this:
Property property = node.getValue(Property.TYPE);
// or
List<Property> properties = node.getList(Property.TYPE);
And to save would just be this:
node.setValue(property, Property.TYPE);
// or
node.setValue(properties, new TypeToken<List<Property>>() {});
Where node
is a ConfigurationNode
holding your properties.
With this, you could store a list of properties, each holding their owners and bounds, and then save and load to any configurate supported file type, like Hocon or YAML.
If you want to be able to save any region modifications on the fly, you would want each property to have its own node, with the node name being the name of the property. That way you could save to disk without worrying about affecting other parts of the file.
If you know your regions will only be bound by a set number of coordinates it might be easier to just have that number of coordinates as fields in the object rather than a list, for quick resizing of regions.
It’s important to mention that, if this plugin is going to be used on servers with large player bases, it will be really strenuous to be constantly reading and writing to disk, especially writing. It might be more efficient to just store it into the configuration nodes, like in my example, and then perform a save on the whole file on a timed interval, and before the server stops. That way you save writes (which, if it is onto an SSD, is important) while still retaining the changes in memory as a saveable value, and can write to file on demand.