YACL Synced
This is an extension for the YetAnotherConfigLib library that implements client-server configuration synchronization.
Important: this is a library modification that does not work on its own without mods that depend on it!
What is Synchronization?
YACL provides developers with a convenient tool for creating configuration interfaces in Minecraft, but does not support automatic synchronization between server and client settings. YACL Synced adds exactly this functionality, ensuring configuration consistency in multiplayer environments.
For Developers
Installation
To connect the library to your project, add the following repositories and dependencies to build.gradle:
// build.gradle
repositories {
// Required only for Forge (needed for YACL)
maven {
name = 'Kotlin for Forge'
url = 'https://thedarkcolour.github.io/KotlinForForge/'
}
maven {
name 'Xander Maven'
url 'https://maven.isxander.dev/releases'
}
maven {
name = "Tiger Maven"
url = "https://maven.tigercrl.top/releases/"
}
}
dependencies {
modImplementation "top.tigercrl:YACLSynced-<common/fabric/neoforge>:<version>"
}
Usage
Configurations are created in a manner similar to YACL, but using SyncedConfigClassHandler:
public class CommonConfig {
public static final ConfigClassHandler<CommonConfig> HANDLER = SyncedConfigClassHandler.createBuilder(CommonConfig.class)
.id(YACLPlatform.rl("yacl3-test", "config"))
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(YACLPlatform.getConfigDir().resolve("yacl-test-v2.json5"))
.setJson5(true)
.build())
.build();
// ...
}
On both sides, you can use HANDLER.instance() to get the configuration instance.
On the client side, HANDLER.localInstance() and HANDLER.remoteInstance() are also available for accessing local and server configurations respectively.
Configuration Mismatch Detection
For automatic configuration generation, you can use @OptionFlags to define option flags.
This is equivalent to using Option.Builder.flag(...OptionFlag flag) in YACL:
public class CommonConfig {
@AutoGen(category = "test", group = "test")
@SerialEntry(comment = "This option requires game restart")
@OptionFlags({OptionFlags.FlagType.GAME_RESTART})
@BooleanFlag
public boolean myOption = true;
}
Using @OptionFlags allows YACL Synced to detect configuration discrepancies when connecting to a server and display a warning screen.