-
-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add region files API #2466
Add region files API #2466
Conversation
Aren't regions an implementation detail? A custom implementation could theoretically stores worlds in a different format (not region based). It could even be in memory or in a database, without files. |
@Yeregorix I fully agree, but the API already leaks this detail currently (ServerWorld.directory). |
* | ||
* @return The stream of existing chunk positions. | ||
*/ | ||
Stream<Vector3i> chunkPositions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so how about this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine
/** | ||
* Returns the path of the directory where region files are stored. | ||
* | ||
* @return The path of the region directory | ||
*/ | ||
Path regionDirPath(); | ||
|
||
/** | ||
* Returns the path of the region file containing the given {@link WorldChunk}. | ||
* | ||
* @param chunk The {@link WorldChunk} for which to acquire the region file path | ||
* @return The path of the region file for the given chunk | ||
*/ | ||
Path regionFilePath(WorldChunk chunk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd almost want to have a StorageHandler interface to deal with this so that it's not directly exposed in the API, but can be something exposed for "vanilla" kinds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not always guaranteed that the world has region files (like mods) that could be storing chunks in a different region handler that we simply won't be able to directly interface with.
* | ||
* @return The stream of existing chunks. | ||
*/ | ||
Stream<OfflineChunk> offlineChunks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this if you want the chunk data too
SpongeAPI | Sponge
Adds API to handle region files,
as discussed, adding access to offline chunks instead.