BetterConfig
🟠 Updated over a year agoPreview

🔍 Analysis
- 👍 0.1% endorsement rate
- 🏆 #45 of 99 fabric mods in this game by downloads
📋 About This Mod
# BetterConfig A very powerful and easy to use command based configuration library for servers and clients. ## Creating a simple configuration To start, create a new class. This will be the class where all your configurations are stored. For this example, we'll call this class `Configs`. Make sure that this class is `public`! Next, create a field for your configuration entry. The field should not be final. Mark this field with the annotation `@Config`. The initial value of the field will be used as default (fallback) value. You can add a comment by setting the `comment` attribute. ```java public class Configs { @Config(comment = "This is an example!") public static String exampleString = "default"; } ``` Finally, register your `Configs` class. - For Fabric users, register the `Configs` class in your mod's `onInitialize(Client)` method. Replace `<mod id>` with your mod's id. Sometimes you may omit the generics and just do `<>` instead. - On clients: ```java new ModConfigBuilder<FabricClientCommandSource, CommandBuildContext>(<mod id>, Configs.class).build(); ``` - On servers: ```java new ModConfigBuilder<CommandSourceStack, CommandBuildContext>(<mod id>, Configs.class).build(); ``` - For Paper users, register the `Configs` class in your plugin's `onEnable` method. Replace `<plugin name>` with your plugin's name. ```java new ModConfigBuilder<>(<plugin name>, Configs.class).build(); ``` That's it! Now you can access `exampleString` through `Configs.exampleString`. You can edit `exampleString` by using the config command. - On Fabric there are different commands for the client and server. For both, replace `<mod id>` with your mod's id. - On clients, execute `/cconfig <mod id> exampleString set <string>`. - On servers, execute `/config <mod id> exampleString set <string>`. - On Paper servers, execute `/config <plugin name> exampleString set <string>`. Replace `<plugin name>` with your plugin's name. ## That's not all! This mod also natively supports the use of `Collection`s and `Map`s as variable types. These configurations will have the options `add`, `put` and `remove` available. Moreover, you can define your own (de)serialisers to create configurations with arbitrary types. To do this, all you have to do is register the (de)serialiser when you build your config. For instance, to create configurations with type `Block` you can do ```java new ModConfigBuilder<>(<mod id>, Configs.class) .registerTypeHierarchy(Block.class, new BlockAdapter(), BlockArgumentType::block) .build(); ``` where `BlockAdapter` extends `TypeAdapter<Block>` and `BlockArgumentType` implements `ArgumentType<Block>`. See (fabric/src/testmod/java/dev/xpple/betterconfig) for a complete picture. An identical setup for Paper can be found (paper/src/testplugin/java/dev/xpple/betterconfig). Furthermore, you can completely change the behaviour of updating your config values by creating your own methods. Simply add one or more of `setter`, `adder`, `putter` or `remover` as attribute to your `@Config` annotation. A great use for this would be adding key-value entries to a `Map` based on a single value. Consider the following configuration. ```java @Config(putter = @Config.Putter("none"), adder = @Config.Adder("customMapAdder")) public static Map<String, String> exampleMapAdder = new HashMap<>(Map.of("a", "A", "b", "B")); public static void customMapAdder(String string) { exampleMapAdder.put(string.toLowerCase(Locale.ROOT), string.toUpperCase(Locale.ROOT)); } ``` The value of `"none"` for the putter indicates that no putter will be available. This way, you can use this `Map` in your code like usual, and add values to it using `/(c)config <mod id> exampleMapAdder add <string>`. For more details, see (common/src/main/java/dev/xpple/betterconfig/api/Config.java). The parameters of the update method can also be customised. ```java @Config(adder = @Config.Adder(value = "customTypeAdder", type = int.class)) public static Collection<String> exampleCustomType = new ArrayList<>(List.of("%", "@")); public static void customTypeAdder(int codepoint) { exampleCustomType.add(Character.toString(codepoint)); } ``` For putters, there are separate key and value type attributes. And many more things! For some illustrative examples, see the `Configs` class for both (fabric/src/testmod/java/dev/xpple/betterconfig/Configs.java) and (paper/src/testplugin/java/dev/xpple/betterconfig/Configs.java). ## Installation Replace `${betterconfig_version}` with the artifact version. You may choose between my own maven repository and GitHub's package repository. ### My own ```gradle repositories { maven { url 'https://maven.xpple.dev/maven2' } } ``` ### GitHub packages ```gradle repositories { maven { url 'https://maven.pkg.github.com/xpple/BetterConfig' credentials { username = project.findProperty("gpr.use
# BetterConfig A very powerful and easy to use command based configuration library for servers and clients.
## Creating a simple configuration
To start, create a new class. This will be the class where all your configurations are stored. For this example, we'll
call this class `Configs`. Make sure that this class is `public`! Next, create a field for your configuration entry. The
field should not be final. Mark this field with the annotation `@Config`. The initial value of the field will be used as
default (fallback) value. You can add a comment by setting the `comment` attribute.
```java
public class Configs {
@Config(comment = "This is an example!")
public static String exampleString = "default";
}
```
Finally, register your `Configs` class.
- For Fabric users, register the `Configs` class in your mod's `onInitialize(Client)` method. Replace `
## That's not all!
This mod also natively supports the use of `Collection`s and `Map`s as variable types. These configurations will have
the options `add`, `put` and `remove` available. Moreover, you can define your own (de)serialisers to create
configurations with arbitrary types. To do this, all you have to do is register the (de)serialiser when you build your
config. For instance, to create configurations with type `Block` you can do
```java
new ModConfigBuilder<>(
Furthermore, you can completely change the behaviour of updating your config values by creating your own methods. Simply
add one or more of `setter`, `adder`, `putter` or `remover` as attribute to your `@Config` annotation. A great use for
this would be adding key-value entries to a `Map` based on a single value. Consider the following configuration.
```java
@Config(putter = @Config. Putter("none"), adder = @Config. Adder("customMapAdder"))
public static Map
The parameters of the update method can also be customised.
```java
@Config(adder = @Config. Adder(value = "customTypeAdder", type = int.class))
public static Collection
And many more things! For some illustrative examples, see the `Configs` class for both (fabric/src/testmod/java/dev/xpple/betterconfig/Configs.java) and (paper/src/testplugin/java/dev/xpple/betterconfig/Configs.java).
## Installation Replace `${betterconfig_version}` with the artifact version.
You may choose between my own maven repository and GitHub's package repository. ### My own ```gradle repositories { maven { url 'https://maven.xpple.dev/maven2' } } ``` ### GitHub packages ```gradle repositories { maven { url 'https://maven.pkg.github.com/xpple/BetterConfig' credentials { username = project.findProperty("gpr.use
📊 Mod Details
- Game
- Minecraft Plugins
- Author
- xpple
- Version
- 2.3.0
- Downloads
- 9,022
- Endorsements
- 10
- Category
- fabric
- Created
- 2/6/2023
- Updated
- 1/19/2025
- Game Versions
- 1.21
- Tags
- library, management, storage
🔧 How to Install Minecraft Plugins Mods
Download from Modrinth. Use Prism Launcher or drop into your mods folder.
📖 Full step-by-step install guide for Minecraft Plugins →
Visit the official mod page for specific installation instructions for this mod.
🎮 Need cheat codes or console commands? Check ur gaming wiki for Minecraft Plugins commands, item IDs, and more.
❓ Frequently Asked Questions
Which Minecraft Plugins versions does BetterConfig support?
The author lists 1.21. Other versions may work but are untested by the author.
What is the latest version of BetterConfig?
Version 2.3.0, published 2025-01-19 with 9,022 downloads recorded at the source.
Keep browsing — more Minecraft Plugins mods await