1.20.2
Compatibility
Changes
Critical Update: Data Safety!
Issues:
- Thread Safety: The original code was not thread-safe, which could lead to data inconsistency when multiple threads access and modify the clearedChunks set simultaneously.
- Saving Chunks: The plugin needed to save cleared chunks periodically, but there was no mechanism to do so at regular intervals.
- Chunk Clearing: The code clears chunks in response to the ChunkLoadEvent, but it was necessary to ensure that the chunks were not cleared repeatedly.
Remedies:
-
Thread Safety: Used a ConcurrentHashMap.newKeySet() for the clearedChunks set to make it thread-safe. Additionally, I added the synchronized keyword to the saveClearedChunks method to ensure that the saving process is thread-safe.
-
Saving Chunks: Implemented a scheduled task using Bukkit's scheduler to call the saveClearedChunks method at regular intervals (e.g., every 5 seconds) to save cleared chunks.
-
Chunk Clearing: Introduced a check in the clearChunk method to ensure that chunks are not cleared again if they have already been cleared. This helps prevent repeated clearing of chunks in the same session.
By making these changes, the plugin should now handle data more safely and efficiently, especially in multi-threaded environments, and ensure that cleared chunks are saved periodically.
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle. To learn more about the Modrinth Maven API, click here.
Note: When available, you should use the creator's maven repo instead as it will have transitive dependency information that the Modrinth Maven API does not. You may also end up with duplicate dependencies if you use a mix of Modrinth and non-Modrinth Maven repositories for your dependencies, because the group identifier will be different when served through the Modrinth Maven API.
Maven coordinates:
Version ID:
build.gradle:
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
// forRepositories(fg.repository) // Uncomment when using ForgeGradle
filter {
includeGroup "maven.modrinth"
}
}
}
// Standard Gradle dependency
dependencies {
implementation "maven.modrinth:ihjAiP7L:EJ2PasmY"
}
// Legacy Loom dependency
dependencies {
modImplementation "maven.modrinth:ihjAiP7L:EJ2PasmY"
}

