All Mods Resource Packs Data Packs Shaders Modpacks Plugins
BetterConfig

BetterConfig

by xpple • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

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.

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:
      new ModConfigBuilder<FabricClientCommandSource, CommandBuildContext>(<mod id>, Configs.class).build();
    • On servers:
      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.
    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 Collections and Maps 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

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 these tests for a complete picture. An identical setup for Paper can be found here.

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.

@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 the JavaDocs for @Config.

The parameters of the update method can also be customised.

@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 and Paper.

Installation

Replace ${betterconfig_version} with the artifact version.

You may choose between my own maven repository and GitHub's package repository.

My own

repositories {
    maven {
        url 'https://maven.xpple.dev/maven2'
    }
}

GitHub packages

repositories {
    maven {
        url 'https://maven.pkg.github.com/xpple/BetterConfig'
        credentials {
            username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
            password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
        }
    }
}

Import it:

dependencies {
    // Fabric
    include modImplementation('dev.xpple:betterconfig-fabric:${betterconfig_version}')
    // Paper (also include the JAR in the plugins folder)
    compileOnly 'dev.xpple:betterconfig-paper:${betterconfig_version}'
}

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Paper
18h ago 1
1.21
Fabric
18h ago 1
1.21
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20.1
Fabric
18h ago 1
1.20
Fabric
18h ago 1
1.20
Fabric
18h ago 1
1.19.4
Fabric
18h ago 1
1.19.4
Fabric
18h ago 1
1.19.4
Fabric
18h ago 1
1.19.3
Fabric
18h ago 1
1.19.3
Fabric
18h ago 1
1.19.3
Fabric
18h ago 1
1.19.3
Fabric
18h ago 1
1.19.3
Fabric
18h ago 1
  • Greatly improved documentation of Config class
  • Greatly improved documentation of Config class
_No relevant changes._
  • Replaced modRuntimeOnly with modLocalRuntime in Fabric Gradle build script
_No relevant changes._
  • Fixed a mixin bug causing a crash with some mods
  • Added the sources JAR to the publication
  • Added the sources JAR to the publication
  • Fixed a bug with ModConfig#resetTemporaryConfigs that could cause a bug when a config is both temporary and readOnly
  • Fixed a bug with ModConfig#resetTemporaryConfigs that could cause a bug when a config is both temporary and readOnly
This release introduces two new features and some bug fixes!
``java
@Config(onChange = "onChange")
public static List<String> exampleOnChange = new ArrayList<>(List.of("xpple, earthcomputer"));
private static void onChange(List<String> oldValue, List<String> newValue) {
LOGGER.info("exampleOnChange was updated | old: {}, new: {}", oldValue, newValue);
}
`
`java
new ModConfigBuilder<>("<mod id>", Configs.class)
.registerGlobalChangeHook(event -> BetterConfigCommon.LOGGER.info("{} was updated | old: {}, new: {}", event.config(), event.oldValue(), event.newValue()))
.build();
``
This release introduces two new features and some bug fixes!
``java
@Config(onChange = "onChange")
public static List<String> exampleOnChange = new ArrayList<>(List.of("xpple, earthcomputer"));
private static void onChange(List<String> oldValue, List<String> newValue) {
LOGGER.info("exampleOnChange was updated | old: {}, new: {}", oldValue, newValue);
}
`
`java
new ModConfigBuilder<>("<mod id>", Configs.class)
.registerGlobalChangeHook(event -> BetterConfigCommon.LOGGER.info("{} was updated | old: {}, new: {}", event.config(), event.oldValue(), event.newValue()))
.build();
``
[2.0] Release Paper 2.0 by xpple on Oct 15, 2026
Download
  • Added support for Paper servers
Depending on your setup, you might have to adjust how the config is initialised:
  • Fabric clients:
``java
new ModConfigBuilder<FabricClientCommandSource, CommandBuildContext>(<mod id>, Configs.class)
// ...
.build();
`
  • Fabric servers:
`java
new ModConfigBuilder<CommandSourceStack, CommandBuildContext>(<mod id>, Configs.class)
// ...
.build();
`
  • Paper servers:
`java
new ModConfigBuilder<>(<plugin name>, Configs.class)
// ...
.build();
`
  • Added support for server-sided custom argument types
  • Fabric:
`java
dev.xpple.betterconfig.util.WrappedArgumentType
`
  • Paper:
`java
io.papermc.paper.command.brigadier.argument.CustomArgumentType
`
  • Fixed bug where the reset` subcommand would be available for readonly configs
[2.0] Release Fabric 2.0 by xpple on Oct 15, 2026
Download
  • Added support for Paper servers
Depending on your setup, you might have to adjust how the config is initialised:
  • Fabric clients:
``java
new ModConfigBuilder<FabricClientCommandSource, CommandBuildContext>(<mod id>, Configs.class)
// ...
.build();
`
  • Fabric servers:
`java
new ModConfigBuilder<CommandSourceStack, CommandBuildContext>(<mod id>, Configs.class)
// ...
.build();
`
  • Paper servers:
`java
new ModConfigBuilder<>(<plugin name>, Configs.class)
// ...
.build();
`
  • Added support for server-sided custom argument types
  • Fabric:
`java
dev.xpple.betterconfig.util.WrappedArgumentType
`
  • Paper:
`java
io.papermc.paper.command.brigadier.argument.CustomArgumentType
`
  • Fixed bug where the reset` subcommand would be available for readonly configs
  • Added support for Paper servers (details will follow in the stable release)
  • Added support for Paper servers (details will follow in the stable release)
[1.3] Release 1.3 by xpple on Oct 15, 2026
Download
  • Updated to Minecraft 1.21
  • Fixed resetting some configs by using deep copied value
[1.2.1] Release 1.2.1 by xpple on Oct 15, 2026
Download
  • Added boolean argument type back to default arguments
[1.2.0] Release 1.2.0 by xpple on Oct 15, 2026
Download
  • Made non-api packages no longer visible
  • Rewrote argument registration

Consider the below example to see how things have changed.
``diff
  • .registerTypeWithArgument(Block.class, new BlockAdapter(), new Pair<>(BlockArgumentType::block, BlockArgumentType::getBlock))
+ .registerType(Block.class, new BlockAdapter(), BlockArgumentType::block)
``

[1.1.7] Release 1.1.7 by xpple on Oct 15, 2026
Download
  • Fixed enum parsing when enum overrides toString
  • Prioritised custom arguments/suggestors over enum check
  • Fixed crashing on startup when the config is corrupted

[1.1.6] Release 1.1.6 by xpple on Oct 15, 2026
Download
  • Added comments
  • Prevented getting a config being broadcasted on servers
  • Fixed keys being improperly printed when putting to a map

[1.1.5] Release 1.1.5 by xpple on Oct 15, 2026
Download
  • Changed string type to greedy phrase for suggestor based argument types
  • Fixed config directory not being created on initialisation

[1.1.4] Release 1.1.4 by xpple on Oct 15, 2026
Download
  • Disallowed final fields reasons
  • Allowed custom updaters to be private
  • Provided (English) fallback translations for servers

[1.1.3] Release 1.1.3 by xpple on Oct 15, 2026
Download
  • Fixed config not saving after resetting
[1.1.2] Release 1.1.2 by xpple on Oct 15, 2026
Download
  • Made sure config is always saved after first read

[1.1.1] Release 1.1.1 by xpple on Oct 15, 2026
Download
  • Added conditions
[1.1] Release 1.1 by xpple on Oct 15, 2026
Download
  • Updated to Minecraft 1.20
[1.0.7] Release 1.0.7 by xpple on Oct 15, 2026
Download
  • Added reset and resetTemporaryConfigs methods to the API
BetterConfig Icon
Download BetterConfig
Select game version
Select platform