Only this pageAll pages
Powered by GitBook
1 of 42

OneConfig V1

Loading...

Loading...

Introduction

Loading...

Configuration

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Commands

Loading...

Loading...

Events

Loading...

Loading...

Loading...

Utilities Module

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Migration

Loading...

Loading...

Listening for option changes

Monitoring changes to options for any reason is simple, thanks to the convenient methods provided by OneConfig. You can use them like so:

public MyConfig() {
    addCallback("myOptionName", () -> {
        System.out.println("myOptionName changed!");
    });
}
init {
    addCallback("myOptionName") {
        println("myOptionName changed!");
    }
}

Easy enough, eh? But what if we want to know the new value at the time of the change?

public MyConfig() {
    addCallback<Boolean>("myOptionName", (value) -> {
        System.out.println("myOptionName value: " + value);
    });
}
init {
    addCallback<Boolean>("myOptionName") { value ->
        println("myOptionName value: $value")
    }
}

Option dependencies & hiding options

Dependency management

public MyConfig() {
    addDependency("myOptionName", "myOtherOptionName"); // Disables myOptionName when myOtherOptionName = false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
    
    addDependency("myOtherOtherOptionName", () -> Property.Display.HIDDEN); // Hides myOtherOtherOptionName
    
    addDependency("myOtherOtherOtherOptionName", "myOptionName", true); // Hides myOtherOtherOtherOptionName when myOptionName is false
}
init {
    addDependency("myOptionName", "myOtherOptionName") // Disables myOptionName when myOtherOptionName = false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
    
    addDependency("myOtherOtherOptionName") { Property.Display.HIDDEN } // Hides myOtherOtherOptionName
    
    addDependency("myOtherOtherOtherOptionName", "myOptionName", true) // Hides myOtherOtherOtherOptionName when myOptionName is false
}

Hiding your options

public MyConfig() {
    hideIf("myOptionName", () -> true); // Hides myOptionName
    
    hideIf("myOptionName", "myOtherOptionName"); // Hides myOptionName if myOtherOptionName is false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
}
init {
    hideIf("myOptionName") { true } // Hides myOptionName
    
    hideIf("myOptionName", "myOtherOptionName") // Hides myOptionName if myOtherOptionName is false
    // The above obviously only works when myOtherOptionName is a boolean-typed option.
}

What's the difference?

You can use addDependency to fine-tune the display status of your options based on your own conditions or other options. By default, simply using addDependency and passing the options of your choosing will cause the dependant to be disabled rather than hidden.

hideIf will ALWAYS completely hide the option passed to it based on the condition(s) provided as opposed to having to pick a display status.

Creating your config

Getting Started

Building your base

To create your config, you'll first need to create a new class that extends OneConfig's Config class, like so:

public class ExampleConfig extends Config {
}
object ExampleConfig : KtConfig() // This is an object so we can easily access a singleton instance of the config. Refer to later section for more info

Why do we use KtConfig for the Kotlin example?

KtConfig provides additional functionality which makes it easier to create type-safe options in Kotlin with a much more readable and serviceable syntax.

Easy, right? Now, you'll need to provide it with some info via it's constructor, which takes your config's name, category, file name and some other relating data.

The filename you pass to OneConfig is what the file will be named inside of the user's OneConfig settings profile, f.ex .minecraft/config/OneConfig/profiles/example_config.json.

public class ExampleConfig extends Config {
    public ExampleConfig() {
         super(
              "example_config.json",                // Your mod's config file's name and extension
              "/assets/examplemod/example_mod.png", // A path to a PNG or SVG file, used as your mod's icon in OneConfig's UI
              "Example Mod",                        // Your mod's name was it is shown in OneConfig's UI
              Category.QOL                          // The category your mod will be sorted in within OneConfig's UI
         );
    }
}
object ExampleConfig : KtConfig(
     id = "example_config.json",                  // Your mod's config file's name and extension
     icon = "/assets/examplemod/example_mod.png", // A path to a PNG or SVG file, used as your mod's icon in OneConfig's UI
     title = "Example Mod",                       // Your mod's name was it is shown in OneConfig's UI
     category = Config.Category.QOL               // The category your mod will be sorted in within OneConfig's UI
)

Simple as that!

Initializing your config when the game launches

There are various different ways to initialize your config, but here are the way we recommend:

If you are on Java, add an INSTANCE field to your config. This is where you will access your dedicated object of your config for non-static methods, such as save.

public class ExampleConfig extends Config {

    // Your actual config options here...
    
    public static final ExampleConfig INSTANCE = new ExampleConfig();
    
    // Your constructor here...
}

If you are on Kotlin and you have not already, make your config class an object. This makes your class a singleton, which essentially will create the INSTANCE field in Java for you, and make accessing it via Kotlin syntax easier.

object ExampleConfig : KtConfig(
     // Your constructor stuff here...
)

Now, all you need to do is initialize your config when the game first launches with your mod, via the preload method. This can be done using your mod loader's standard means of initializing your mod at game launch, or alternatively, by using OneConfig's events system, using the InitializationEvent.

@Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION, name = ExampleMod.NAME)
public class ExampleMod {
    public static final String MODID = "examplemod";
    public static final String VERSION = "1.0.0";
    public static final String NAME = "Example Mod";
    
    @Mod.EventHandler
    public void onInitialize(FMLInitializationEvent event) {
        ExampleConfig.INSTANCE.preload();  // Ensures that everything is set up as it should be!
    }
}
@Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION, name = ExampleMod.NAME)
class ExampleMod { // This can also be an object via a language adapter, which you can use via OneConfig!
    companion object {
        const val MODID = "examplemod"
        const val VERSION = "1.0.0"
        const val NAME = "Example Mod"
    }
    
    @Mod.EventHandler
    fun onInitialize(event: FMLInitializationEvent) {
        // Unlike Java, you don't need the `INSTANCE` reference here.
        ExampleMod.preload() // Ensures that everything is set up as it should be!
    }
}
public class ExampleMod {
    
    @Subscribe
    public void onInitialize(InitializationEvent event) {
        ExampleConfig.INSTANCE.preload();  // Ensures that everything is set up as it should be!
    }
}
class ExampleMod {
    
    @Subscribe
    fun onInitialize(event: InitializationEvent) {
        // Unlike Java, you don't need the `INSTANCE` reference here.
        ExampleConfig.preload()  // Ensures that everything is set up as it should be!
    }
}

Welcome

Welcome to the OneConfig documentation for developers. If you're confused about how to integrate your mod with OneConfig, or just what something does, there's a good chance the answer is here.

Contributions

Licensing

The OneConfig Docs are licensed under the GNU Free Documentation License, version 1.3 or later.

Getting started

How to add OneConfig to your mod

This is NOT a guide on how to start with modding or set up a modding template. There is documentation for every version of Minecraft that we support on how to set up a mod on their loader.

Latest versions

OneConfig Example Mod

Branch
Versions
Preprocessor?
DGT?
Notes

multi-version

All OneConfig-supported versions (1.8.9-Latest, Fabric/Forge)

You can always clone this branch and remove all but a single version, in case you want to tackle multiversion later.

legacy-forge

1.8.9 Forge

legacy-fabric

1.8.9 Fabric

modern-fabric

Latest Fabric

modern-forge

Latest Forge

kotlin-[branch]

N/A

Each branch has a Kotlin version.

Including OneConfig yourself

If you don't want to use our mod template, or wish to include OneConfig in one of your new or existing mods, add this to your build.gradle(.kts).

The toolkit works for all Minecraft versions from 1.8.9 - latest, and supports Forge, Fabric and NeoForge. Setting it up is as simple as applying the appropriate plugins for your needs and configuring the required configuration options. DGT also supports complicated setups such as multi-version projects.

Available modules

OneConfig's functionality is split into several modules for ease of use and to improve the developer experience. When making a mod using OneConfig, you will need to individually select modules you will be utilizing within your mod in order to gain access to their functionality, and the platform / Minecraft version-specific implementation of OneConfig.

Module
Purpose

commands

The tree based command system used in OneConfig.

config

The tree based configuration system used in OneConfig.

config-impl

The default implementation of the configuration system used in OneConfig.

events

The event system used in OneConfig.

hud

The HUD system used in OneConfig.

internal

OneConfig's UI implementation.

ui

The UI system used in OneConfig.

utils

Various utilities used in OneConfig.

Setting up your build files

toolkitLoomHelper {
    useOneConfig {
        version = "1.0.0-alpha.55" // Put whatever the latest is here
        loaderVersion = "1.1.0-alpha.35" // Put whatever the latest is here

        usePolyMixin = true // If you want to use Mixin on Legacy Forge, you need PolyMixin
        polyMixinVersion = "0.8.4+build.2" // If you want to use Mixin on Legacy Forge, you need PolyMixin

        applyLoaderTweaker = true // Set this to false if you want to use a custom tweaker.

        for (module in arrayOf("commands", "config-impl", "events", "hud", "internal", "ui", "utils")) {
            +module
        }
    }
}
loom {
    launchConfigs.named("client") {
        if (platform.isLegacyForge) { // If Forge and MC is 1.12.2 or below
            // Loads OneConfig in dev env. Replace other tweak classes with this, but keep any other attributes!
            arg("--tweakClass", "org.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
        }
    }
}

repositories {
    maven("https://repo.polyfrost.org/releases")
    maven("https://repo.polyfrost.org/snapshots") // Remove when OneConfig is out of beta
}

dependencies {
    // `include` should be replaced with a configuration that includes your dependencies in the JAR
    
    // Basic OneConfig dependencies for legacy versions. See OneConfig example mod for more info
    val oneConfigMcVersion = "1.8.9"
    val oneConfigModLoader = "forge"
    val oneConfigModules = arrayOf("commands", "config-impl", "events", "hud", "internal", "ui", "utils") // Refer to possible modules above
    val oneconfigVersion = "1.0.0-alpha.55" // Put whatever the latest is here
    for (module in oneConfigModules) {
        if (platform.isLegacyForge) {
            compileOnly("org.polyfrost.oneconfig:$module:$oneConfigVersion") // Should NOT be included in JAR
        } else {
            implementation("org.polyfrost.oneconfig:$module:$oneConfigVersion") // Should NOT be included in JAR
        }
    }
    
    if (platform.isLegacyForge) {
        val loaderModule = "launchwrapper"
        val loaderVersion = "1.1.0-alpha.35" // Put whatever the latest is here
        include("org.polyfrost.oneconfig:stage0:$loaderModule:$loaderVersion") // Should be included in JAR
        
        modCompileOnly("org.polyfrost.oneconfig:$oneConfigMcVersion-$oneConfigModLoader:$oneConfigVersion")
    } else {
        modImplementation("org.polyfrost.oneconfig:$oneConfigMcVersion-$oneConfigModLoader:$oneConfigVersion")
    }
}

tasks {
    jar { // loads OneConfig at launch. Add these launch attributes but keep your old attributes!
        if (platform.isLegacyForge) {
            manifest.attributes += mapOf(
                "ModSide" to "CLIENT",
                "TweakOrder" to 0,
                "ForceLoadAsMod" to true,
                "TweakClass" to "org.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker"
            )
        }
    }
}

toolkitLoomHelper {
    useOneConfig {
        version = "1.0.0-alpha.55" // Put whatever the latest is here
        loaderVersion = "1.1.0-alpha.35" // Put whatever the latest is here

        usePolyMixin = true // If you want to use Mixin on Legacy Forge, you need PolyMixin
        polyMixinVersion = "0.8.4+build.2" // If you want to use Mixin on Legacy Forge, you need PolyMixin

        applyLoaderTweaker = true // Set this to false if you want to use a custom tweaker.

        for (String module : ["commands", "config-impl", "events", "hud", "internal", "ui", "utils"]) {
            addModule(module)
        }
    }
}
loom {
    launchConfigs {
        client {
            if (platform.isLegacyForge) { // If Forge and MC is 1.12.2 or below
                // Loads OneConfig in dev env. Replace other tweak classes with this, but keep any other attributes!
                arg("--tweakClass", "org.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
            }
        }
    }
}

repositories {
    maven { url 'https://repo.polyfrost.org/releases' }
    maven { url 'https://repo.polyfrost.org/snapshots' } // Remove when OneConfig is out of beta
}

dependencies {
    // `include` should be replaced with a configuration that includes your dependencies in the JAR

    // Basic OneConfig dependencies for legacy versions. See OneConfig example mod for more info
    def oneConfigMcVersion = "1.8.9"
    def oneConfigModLoader = "forge"
    def oneConfigModules = ["commands", "config-impl", "events", "hud", "internal", "ui", "utils"] // Refer to possible modules above
    def oneconfigVersion = "1.0.0-alpha.55" // Put whatever the latest is here
    for (String module : oneConfigModules) {
        if (platform.isLegacyForge) {
            compileOnly('org.polyfrost.oneconfig:${module}:${oneConfigVersion}') // Should NOT be included in JAR
        } else {
            implementation('org.polyfrost.oneconfig:${module}:${oneConfigVersion}') // Should NOT be included in JAR
        }
    }
    
    if (platform.isLegacyForge) {
        def loaderModule = "launchwrapper"
        def loaderVersion = "1.1.0-alpha.35" // Put whatever the latest is here
        include('org.polyfrost.oneconfig:stage0:$loaderModule:$loaderVersion') // Should be included in JAR
        
        modCompileOnly('org.polyfrost.oneconfig:${oneConfigMcVersion}-${oneConfigModLoader}:${oneConfigVersion}')
    } else {
        modImplementation('org.polyfrost.oneconfig:${oneConfigMcVersion}-${oneConfigModLoader}:${oneConfigVersion}')
    }
}

jar { // loads OneConfig at launch. Add these launch attributes but keep your old attributes!
    if (platform.isLegacyForge) {
        manifest.attributes(
                "ModSide": "CLIENT",
                "TweakOrder": "0",
                "ForceLoadAsMod": true,
                "TweakClass": "org.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
        )
    }
}

Are you someone who knows nothing about programming and just wants to use OneConfig? Check out our website !

Keep in mind though, that these docs aren't perfect, so if something is wrong, feel free to , before we even notice.

If you encounter any errors or bugs in OneConfig, feel free to or If you're still stuck, join our server and create a ticket!

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3, or any later version published by the Free Software Foundation; with the Invariant Sections just being "Welcome" with no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "".

For Forge 1.8.9 and 1.12.2:

For Forge (modern):

For Fabric:

For NeoForge:

From there, instead of using the default templates of those loaders, you would use the .

If you're just starting out or need more advanced features like multiple versions, we highly recommend looking at our . When cloning the example mod, please choose from one of the following branches:

While you’re here, we recommend using , which automatically configures everything in your project for you, including OneConfig. DGT is included in our example mod template.

It also provides several smaller utilities for things such as authenticating your Minecraft/Microsoft account in the developer environment via or setting up your own Forge coremod.

here
fix it yourself
make an issue
pull request.
Discord
Documentation license
https://moddev.nea.moe/ide-setup/
https://docs.minecraftforge.net/en/latest/gettingstarted/
https://fabricmc.net/wiki/tutorial:start#creating_your_first_mod
https://docs.neoforged.net/docs/gettingstarted/
OneConfigExampleMod
example mod
Deftu's Gradle Toolkit
DevAuth

Available options

OneConfig offers several different kinds of options for several different data types. Expand this page in the sidebar to view them all.

Boolean options

Checkboxes

Switches

Checkbox option
Switch option

Switch option

Example

@Switch(
    title = "My Switch",
    description = "This is my switch", // Recommended, default = ""
    icon = "/my_switch.svg", // Optional, default = ""
    category = "Switches", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)
public static boolean mySwitch = false;
var mySwitch: Boolean by switch(
    name = "My Switch",
    def = false, // Sets option's default value. Recommended, default = true
    description = "This is my switch", // Recommended, default = ""
    icon = "/my_switch.svg", // Optional, default = ""
    category = "Switches", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)

Number options

Slider

Number

Documentation license

GNU Free Documentation License version 1.3

Below you can find a copy of the license and its terms for this documentation:

Checkbox option

Example

Slider option
Number option
Copyright (C) 2024 Polyfrost. All Rights Reserved. 
   <https://polyfrost.org/> <https://github.com/Polyfrost>
The OneConfig Developer Documentation is licensed under the terms of 
GNU Free Documentation License, Version 1.3, or (at your option) 
any later version published by the Free Software Foundation; with 
the Invariant Sections just being "Welcome" with no Front-Cover 
Texts, and no Back-Cover Texts.

                GNU Free Documentation License
                 Version 1.3, 3 November 2008


 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
     <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.

This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense.  It
complements the GNU General Public License, which is a copyleft
license designed for free software.

We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does.  But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book.  We recommend this License
principally for works whose purpose is instruction or reference.


1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License.  Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein.  The "Document", below,
refers to any such manual or work.  Any member of the public is a
licensee, and is addressed as "you".  You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.

A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.

A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject.  (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.)  The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.

The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.  If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant.  The Document may contain zero
Invariant Sections.  If the Document does not identify any Invariant
Sections then there are none.

The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.  A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.

A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters.  A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text.  A copy that is not "Transparent" is called "Opaque".

Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification.  Examples of
transparent image formats include PNG, XCF and JPG.  Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.

The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page.  For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.

The "publisher" means any person or entity that distributes copies of
the Document to the public.

A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language.  (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".)  To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.

The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document.  These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.

2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no
other conditions whatsoever to those of this License.  You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute.  However, you may accept
compensation in exchange for copies.  If you distribute a large enough
number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and
you may publicly display copies.


3. COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover.  Both covers must also clearly and legibly identify
you as the publisher of these copies.  The front cover must present
the full title with all words of the title equally prominent and
visible.  You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.

If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.

It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to
give them a chance to provide you with an updated version of the
Document.


4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it.  In addition, you must do these things in the Modified Version:

A. Use in the Title Page (and on the covers, if any) a title distinct
   from that of the Document, and from those of previous versions
   (which should, if there were any, be listed in the History section
   of the Document).  You may use the same title as a previous version
   if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
   responsible for authorship of the modifications in the Modified
   Version, together with at least five of the principal authors of the
   Document (all of its principal authors, if it has fewer than five),
   unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
   Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
   adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
   giving the public permission to use the Modified Version under the
   terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
   and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
   to it an item stating at least the title, year, new authors, and
   publisher of the Modified Version as given on the Title Page.  If
   there is no section Entitled "History" in the Document, create one
   stating the title, year, authors, and publisher of the Document as
   given on its Title Page, then add an item describing the Modified
   Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
   public access to a Transparent copy of the Document, and likewise
   the network locations given in the Document for previous versions
   it was based on.  These may be placed in the "History" section.
   You may omit a network location for a work that was published at
   least four years before the Document itself, or if the original
   publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
   Preserve the Title of the section, and preserve in the section all
   the substance and tone of each of the contributor acknowledgements
   and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
   unaltered in their text and in their titles.  Section numbers
   or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements".  Such a section
   may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
   or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.

If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant.  To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.

You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.

You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version.  Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity.  If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.


5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy.  If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications".  You must delete all sections
Entitled "Endorsements".


6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other
documents released under this License, and replace the individual
copies of this License in the various documents with a single copy
that is included in the collection, provided that you follow the rules
of this License for verbatim copying of each of the documents in all
other respects.

You may extract a single document from such a collection, and
distribute it individually under this License, provided you insert a
copy of this License into the extracted document, and follow this
License in all other respects regarding verbatim copying of that
document.


7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.


8. TRANSLATION

Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections.  You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers.  In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.

If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.


9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense, or distribute it is void, and
will automatically terminate your rights under this License.

However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.

Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.


10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the
GNU Free Documentation License from time to time.  Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns.  See
https://www.gnu.org/licenses/.

Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation.  If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.  If the Document
specifies that a proxy can decide which future versions of this
License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the
Document.

11. RELICENSING

"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works.  A
public wiki that anybody can edit is an example of such a server.  A
"Massive Multiauthor Collaboration" (or "MMC") contained in the site
means any set of copyrightable works thus published on the MMC site.

"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.

"Incorporate" means to publish or republish a Document, in whole or in
part, as part of another Document.

An MMC is "eligible for relicensing" if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole or
in part into the MMC, (1) had no cover texts or invariant sections, and
(2) were thus incorporated prior to November 1, 2008.

The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.


ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:

    Copyright (c)  YEAR  YOUR NAME.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU
    Free Documentation License".

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:

    with the Invariant Sections being LIST THEIR TITLES, with the
    Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.

If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@Checkbox(
    title = "My Checkbox",
    description = "This is my checkbox", // Recommended, default = ""
    icon = "/my_checkbox.svg", // Optional, default = ""
    category = "Checkboxes", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)
public static boolean myCheckbox = false;
var myCheckbox: Boolean by checkbox(
    name = "My Checkbox",
    def = false, // Sets option's default value. Recommended, default = true
    description = "This is my switch", // Recommended, default = ""
    icon = "/my_switch.svg", // Optional, default = ""
    category = "Switches", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)

Slider option

Example

@Slider(
    title = "My Slider",
    description = "This is my slider", // Recommended, default = ""
    icon = "/my_slider.svg", // Optional, default = ""
    category = "Sliders", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    min = 0f, // Recommended, default = 0f
    max = 100f, // Recommended, default = 100f
    step = 1f // Optional, default = 10f
)
public static float mySlider = 0f;
var mySlider: Float by slider(
    name = "My Slider",
    def = 0f, // Sets option's default value. Recommended, default = 0f
    description = "This is my switch", // Recommended, default = ""
    icon = "/my_switch.svg", // Optional, default = ""
    category = "Switches", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    min = 0f, // Recommended, default = 0f
    max = 100f, // Recommended, default = 100f
    step = 1f, // Optional, default = 10f
)

Your field can be typed with any subtype of Number.

Dropdown option

Example

TODO: Redo Kotlin example with Kotlin DSL for enumerables and dropdowns

Using an integer index

@Dropdown(
    title = "My Dropdown",
    description = "This is my dropdown", // Recommended, default = ""
    icon = "/my_dropdown.svg", // Optional, default = ""
    category = "Dropdowns", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
    options = { "HELLO", "WORLD", "ONECONFIG" } // Recommended, default = {}
)
public static int myDropdown = 0; // 0 = "HELLO"
@Dropdown(
    title = "My Dropdown",
    description = "This is my dropdown", // Recommended, default = ""
    icon = "/my_dropdown.svg", // Optional, default = ""
    category = "Dropdowns", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
    options = ["HELLO", "WORLD", "ONECONFIG"] // Recommended, default = []
)
var myDropdown = 0 // 0 = "HELLO"

Using a custom enum class

public enum MyDropdownOptions {
    HELLO,
    WORLD,
    ONECONFIG;
}

@Dropdown(
    title = "My Dropdown",
    description = "This is my dropdown", // Recommended, default = ""
    icon = "/my_dropdown.svg", // Optional, default = ""
    category = "Dropdowns", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
    // We can't use the options field when using an enum.
)
public static MyDropdownOptions myDropdown = MyDropdownOptions.HELLO;
enum class MyDropdownOptions {
    HELLO,
    WORLD,
    ONECONFIG
}

@Dropdown(
    title = "My Dropdown",
    description = "This is my dropdown", // Recommended, default = ""
    icon = "/my_dropdown.svg", // Optional, default = ""
    category = "Dropdowns", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
    // We can't use the options field when using an enum.
)
var myDropdown = MyDropdownOptions.HELLO

Selector options

Dropdown

Radio Button

Number option

Example

Your field can be typed with any subtype of Number.

An example of what the switch looks like in-game, toggled both on and off.
Dropdown option
Radio button option
@Number(
    title = "My Number",
    description = "This is my number", // Recommended, default = ""
    icon = "/my_number.svg", // Optional, default = ""
    category = "Numbers", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    unit = "ms", // Optional, default = ""
    min = 0f, // Recommended, default = -10f
    max = 100f, // Recommended, default = 100f
    placeholder = "Percent..." // Optional, default = "oneconfig.numberinput.placeholder"
)
public static float myNumber = 0f;
var myNumber: Float by number(
    title = "My Number",
    def = 0f, // Sets option's default value. Recommended, default = 0f
    description = "This is my switch", // Recommended, default = ""
    icon = "/my_switch.svg", // Optional, default = ""
    category = "Switches", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    unit = "ms", // Optional, default = ""
    min = 0f, // Recommended, default = = -10f
    max = 100f, // Recommended, default = 100f
    placeholder = "Percent..." // Optional, default = "oneconfig.numberinput.placeholder"
)

Text option

Example

@Text(
    title = "My Text",
    description = "This is my text", // Recommended, default = ""
    icon = "/my_text.svg", // Optional, default = ""
    category = "Text", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    placeholder = "Name..." // Optional, default = "polyui.textinput.placeholder"
)
public static String myText = "";
var myText: String by text(
    title = "My Text",
    def = "", // Sets option's default value. Recommended, default = ""
    description = "This is my text", // Recommended, default = ""
    icon = "/my_text.svg", // Optional, default = ""
    category = "Text", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    placeholder = "Name..." // Optional, default = "polyui.textinput.placeholder"
)

Color option

Example

@Color(
    title = "My Color",
    description = "This is my color", // Recommended, default = ""
    icon = "/my_color.svg", // Optional, default = ""
    category = "Colors", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    alpha = true // Optional, default = true
)
public static PolyColor myColor = PolyColor.WHITE;
var myColor: PolyColor by color(
    name = "My Color",
    def = PolyColor.WHITE, // Sets option's default value. Recommended, default = PolyColor.WHITE
    description = "This is my color", // Recommended, default = ""
    icon = "/my_color.svg", // Optional, default = ""
    category = "Colors", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    alpha = true // Optional, default = true
)

Buttons

Example

It's preferable to make your button callback methods to private so that they can't be called elsewhere (unless you want to call them elsewhere yourself manually).

@Button(
    title = "My Button",
    description = "This is my button", // Recommended, default = ""
    icon = "/my_button.svg", // Optional, default = ""
    category = "Buttons", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    text = "Say hi!" // Recommended, default = "Click"
)
private void sayHi() {
    System.out.println("Hello, OneConfig!");
}
@Button(
    title = "My Button",
    description = "This is my button", // Recommended, default = ""
    icon = "/my_button.svg", // Optional, default = ""
    category = "Buttons", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    text = "Say hi!" // Recommended, default = "Click"
)
private fun sayHi() {
    println("Hello, OneConfig!");
}

Accordions

TODO

Keybind option

Example

@Keybind(
    title = "My Keybind",
    description = "This is my keybind", // Recommended, default = ""
    icon = "/my_keybind.svg", // Optional, default = ""
    category = "Keybinds", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)
public static KeyBinder.Bind myKeybind = KeybindHelper.builder().keys(UKeyboard.KEY_NONE).does(() -> {
    System.out.println("Hello, OneConfig!");
}).build();

public MyConfig() {
    registerKeybind(myKeybind);
}
val myKeybind: KeyBinder.Bind by keybind(
    name = "My Keybind",
    def = KeybindHelper.builder().keys(UKeyboard.KEY_NONE).does {
        println("Hello, OneConfig!")
    }.build(), // Sets option's default value. Recommended, default = null
    description = "This is my keybind", // Recommended, default = ""
    icon = "/my_keybind.svg", // Optional, default = ""
    category = "Keybinds", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)

init {
    registerKeybind(myKeybind)
}

Radio button option

Example

TODO: Redo Kotlin example with Kotlin DSL for enumerables and radiobuttons

Using an integer index

@RadioButton(
    title = "My Radio",
    description = "This is my radio", // Recommended, default = ""
    icon = "/my_radio.svg", // Optional, default = ""
    category = "Radio Buttons", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    options = { "HELLO", "WORLD", "ONECONFIG" } // Recommended, default = {}
)
public static int myRadio = 0; // 0 = "HELLO"
@RadioButton(
    title = "My Radio",
    description = "This is my radio", // Recommended, default = ""
    icon = "/my_radio.svg", // Optional, default = ""
    category = "Radio Buttons", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    options = ["HELLO", "WORLD", "ONECONFIG"] // Recommended, default = []
)
var myRadio = 0 // 0 = "HELLO"

Using a custom enum class

public enum MyRadioOptions {
    HELLO,
    WORLD,
    ONECONFIG;
}

@RadioButton(
    title = "My Radio",
    description = "This is my radio", // Recommended, default = ""
    icon = "/my_radio.svg", // Optional, default = ""
    category = "Radio Buttons", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    // this field cannot be present when using an enum: options = { "HELLO", "WORLD", "ONECONFIG" }
)
public static MyRadioOptions myRadio = MyRadioOptions.HELLO;
public enum class MyRadioOptions {
    HELLO,
    WORLD,
    ONECONFIG
}

@RadioButton(
    title = "My Radio",
    description = "This is my radio", // Recommended, default = ""
    icon = "/my_radio.svg", // Optional, default = ""
    category = "Radio Buttons", // Recommended, default = "General"
    subcategory = "General", // Recommended, default = "General"
    // this field cannot be present when using an enum: options = ["HELLO", "WORLD", "ONECONFIG"]
)
var myRadio = MyRadioOptions.HELLO

Your field can be typed with an integer, or with an enum.

When using an integer, you NEED to provide the options property, otherwise it is not supported when using an enum.

Decorations

Info

@Info(
    title = "My Info Block",
    description = "This is my info block", // Recommended, default = ""
    icon = "/my_info.svg", // Optional, default = "". Please refer to Notifications.Type to see default types
    category = "Decorations", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)
private void info1() {} // Can be anything, methods are just easiest to write.
@Info(
    title = "My Info Block",
    description = "This is my info block", // Recommended, default = ""
    icon = "/my_info.svg", // Optional, default = "". Please refer to Notifications.Type to see default types
    category = "Decorations", // Recommended, default = "General"
    subcategory = "General" // Recommended, default = "General"
)
fun info1() {}

Creating your own options

TODO

An example of what the dropdown looks like in-game.
An example of what the dropdown looks like in-game when it is expanded.
An example of what the number option looks like in-game.
An example of what the text option looks like in-game.
An example of what the color picker option looks like in-game.

Using the events system

OneConfig has it's own custom event system, which can either be callback- or subscriber-based depending on your preferences. It provides several default events relating to basic OneConfig functionality and Minecraft-relating functionality.

It is preferred to use callback-based events for code quality, maintainability and speed.

If you have used the , you are likely more familiar with callback-based events. If you have worked with or , you are likely more familiar with subscriber-based events.

Fabric API
MinecraftForge
NeoForge
Callback events
Subscriber events

Tree-based commands

CommandBuilder builder = CommandBuilder.command("examplemod", "example", "example_mod");
val builder = CommandBuilder.command("examplemod", "example", "example_mod")

From here, if you want to do something when the command is run on it's own (f.ex /examplemod), you can use the runs method to define what is executed, like so:

builder.then(CommandBuilder.runs().does(() -> {
    System.out.println("Hello, OneConfig!");
}));
builder.then(CommandBuilder.runs().does {
    println("Hello, OneConfig!")
})

Both the object which command and runs returns have a description method which allow you to describe what happens when you execute that command or subcommand, it is recommended to use this where possible.

Finally, to register your command, you can simply use CommandManager#registerCommand like so:

CommandManager.registerCommand(builder.build());
CommandManager.registerCommand(builder.build())

Annotation-based commands

Understanding how your commands are set up

In order to create a command, you need to annotate a class with the @Command annotation and provide it with the data required for users to interact with it (such as a name).

The values you provide to the annotation here are what the user types into the chat input to execute your command, such as /examplemod

Executing code when someone runs your command

To start, you'll obviously need to apply your starting annotation on a class, like so:

From here, you can add your main execution point! This method is executed when the user simply runs your command with no arguments or subcommand, like /examplemod

When the user executes any of the provided command names, "Hello, OneConfig!" will be printed out to the console / log file.

Command parameters

Now that you know how to create your command, and allow users to run it on it's own, let's take a look at allowing the user to input data.

Let's say we want to take in a name to greet someone in the console. We'd need the user to provide a string.

In the above example, we take a non-optional parameter called "Name", which we can then use to print out a greeting in the console.

Parameter parsers

OneConfig provides default parsers for all of the basic primitive types and very few custom types, such as Minecraft's GameProfile, meaning that you'll need to provide your own parser for your own data objects.

So, let's say we have en enum type:

And we want the user to be able to select one of it's values. For this, we will need to create a custom ArgumentParser.

So... What's going on here?!

First, in our parse method, we're taking our arg value and converting it to full uppercase to conform to enum naming conventions, then trying to find a value matching that name inside of ExampleEnum.

Then, we implement autocompletion in getAutoCompletions by checking the current input against all possible values in the enum. This is entirely optional, we can simply return null to opt out of autocomplete for whatever reason.

Lastly, we provide our ArgumentParser with the definitive type of our custom object so that OneConfig's internals can determine when and where our parser needs to be utilized.

Now, when we create a command with ExampleEnum as one of the parameter types, a user will be able to input any of the names in our enum and our command's execution point will receive that enum! Nifty, huh?

Subcommands

When you've got multiple functions under a single base command name, you're going to want to separate them into multiple subcommands. Luckily, it's as easy as creating more methods and annotating them with the very same annotation you used to create your base command:

Now, instead of your users needing to type /examplemod <NAME> in the chat to greet someone in their console, they will be required to type /examplemod greet <NAME> or /examplemod grt <NAME>, as define by our subcommand.

To get started with OneConfig's tree-based (-style) command system, you'll need to get started by creating a CommandBuilder:

Brigadier
@Command({"examplemod", "example", "example_mod"})
@Command(arrayOf("examplemod", "example", "example_mod"))
@Command({"examplemod", "example", "example_mod"})
public class ExampleCommand {
}
@Command(arrayOf("examplemod", "example", "example_mod"))
class ExampleCommand {
}
@Command({"examplemod", "example", "example_mod"})
public class ExampleCommand {

    @Command
    public void main() {
        System.out.println("Hello, OneConfig!");    
    }

}
@Command(arrayOf("examplemod", "example", "example_mod"))
class ExampleCommand {

    @Command
    fun main() {
        println("Hello, OneConfig!");    
    }

}
@Command({"examplemod", "example", "example_mod"})
public class ExampleCommand {

    @Command
    public void main(@Parameter("Name") @NotNull String name) {
        System.out.println("Hello, " + name + "!");    
    }

}
@Command(arrayOf("examplemod", "example", "example_mod"))
class ExampleCommand {

    @Command
    fun main(@Parameter("Name") name: String) {
        println("Hello, $name!");    
    }

}
public enum ExampleEnum {
    LOREM,
    IPSUM
}
public class ExampleEnumArgumentParser extends ArgumentParser<ExampleEnum> {
    
    @Override
    public ExampleEnum parse(@NotNull String arg) {
        return ExampleEnum.valueOf(arg.toUpperCase(Locale.US));
    }
    
    @Override
    public @Nullable List<String> getAutoCompletions(String arg) {
        if (arg.isEmpty()) {
            return null;
        }
        
        List<String> result = new ArrayList<>();
        for (ExampleEnum value : ExampleEnum.values()) {
            String name = value.name().toLowerCase(Locale.US);
            if (!name.startsWith(arg.toLowerCase(Locale.US))) {
                continue;
            }
            
            result.add(name);
        }
        
        return result;
    }
    
    @Override
    public Class<ExampleEnum> getType() {
        return ExampleEnum.class;
    }
    
}
class ExampleEnumArgumentParser : ArgumentParser<ExampleEnum>() {
    
    override fun parse(arg: String): ExampleEnum {
        return ExampleEnum.valueOf(arg.toUpperCase(Locale.US))
    }
    
    override fun getAutoCompletions(arg: String): List<String>? {
        if (arg.isEmpty()) {
            return null
        }
        
        val result = mutableListOf<String>()
        for (value in ExampleEnum.values()) {
            String name = value.name().toLowerCase(Locale.US)
            if (!name.startsWith(arg.toLowerCase(Locale.US))) {
                continue
            }
            
            result.add(name)
        }
        
        return result
    }
    
    override fun getType(): Class<ExampleEnum> {
        return ExampleEnum::class.java;
    }
    
}
@Command({"examplemod", "example", "example_mod"})
public class ExampleCommand {

    @Command({"greet", "grt"})
    public void greet(@Parameter("Name") @NotNull String name) {
        System.out.println("Hello, " + name + "!");    
    }

}
@Command(arrayOf("examplemod", "example", "example_mod"))
class ExampleCommand {

    @Command(arrayOf("greet", "grt"))
    fun greet(@Parameter("Name") name: String) {
        println("Hello, $name!");
    }

}
An example of what the radio button looks like in-game.

Callback events

Getting started with OneConfig's callback-based events system is familiar, easy to learn and fast. If you've worked with FabricMC or QuiltMC before, you'll already be familiar with how these function.

Registering a listener & listening for events

Registering a listener is as simple as defining the class of the event you'd like to listen to, and providing a callback to be executed whenever that event is dispatched. This can be done via OneConfig's EventManager, like so:

public void setupEvents() {
    EventManager.register(TickEvent.Start.class, event -> System.out.println("Tick tick tick!"));
}
fun setupEvents() {
    EventManager.register(TickEvent.Start::class.java) { event ->
        println("Tick tick tick!")
    }
}

And that's it! Now, from this example, you'll be listening to the TickEvent.Start event, and every time a new game tick starts, it will print "Tick tick tick!" so long as our setupEvents method/function is executed at least once in it's lifetime.

Kotlin DSL

There is also a Kotlin DSL for an improved developer experience with event listeners:

eventHandler { event: TickEvent.Start ->
    println("Tick tick tick!")
}.register()

Networking utilities

There is a small set of basic, yet useful, networking utilities for things such as obtaining a string from a URL, downloading a file, etc.

Getting a string response from a URL

String url = "https://example.com";
String userAgent = "Example/1.0.0";
int timeout = 30_000; // 30 seconds
boolean useCaches = true; // If we request from this same URL multiple times, the response will be cached

String response = NetworkUtils.getString(url, userAgent, timeout, useCaches);
System.out.println("Response from example.com:\n" + response);
val url = "https://example.com"
val userAgent = "Example/1.0.0"
val timeout = 30_000 // 30 seconds
val useCaches = true // If we request from this same URL multiple times, the response will be cached

val response = NetworkUtils.getString(url, userAgent, timeout, useCaches)
println("Response from example.com:\n$response")

It is recommended to use the name of your mod as the first half of your user agent, and the version as the second half.

Otherwise, you can simply call getString using a URL to use the default OneConfig user agent, a timeout of 5000 milliseconds (5 seconds) and no caching.

String url = "https://example.com";

String response = NetworkUtils.getString(url);
System.out.println("Response from example.com:\n" + response);
val url = "https://example.com"

val response = NetworkUtils.getString(url)
println("Response from example.com:\n$response")

Getting a JSON response from a URL

String url = "https://example.com";
JsonElement json = JsonUtils.parseFromUrl(url);

// You can use your JsonElement as you please
val url = "https://example.com"
val json: JsonElement = JsonUtils.parseFromUrl(url)

// You can use your JsonElement as you please

Downloading files

String url = "https://example.com";
Path path = Paths.get("/path/to/your/file");
String userAgent = "Example/1.0.0";
int timeout = 30_000; // 30 seconds
boolean useCaches = true; // If we request from this same URL multiple times, the response will be cached

boolean result = NetworkUtils.downloadFile(url, path, userAgent, timeout, useCaches);
System.out.println("File download status: " + result);
val url = "https://example.com"
val path = Paths.get("/path/to/your/file")
val userAgent = "Example/1.0.0"
val timeout = 30_000 // 30 seconds
val useCaches = true // If we request from this same URL multiple times, the response will be cached

val result = NetworkUtils.downloadFile(url, path, userAgent, timeout, useCaches)
println("File download status: $result")

Again, similarly to getString, you can simply call this method with only the URL and path of the downloaded file.

String url = "https://example.com";
Path path = Paths.get("/path/to/your/file");

boolean result = NetworkUtils.downloadFile(url, path);
System.out.println("File download status: " + result);
val url = "https://example.com"
val path = Paths.get("/path/to/your/file")

val result = NetworkUtils.downloadFile(url, path)
println("File download status: $result")

Opening a link in the user's default browser

String ourUrl = "https://example.com";
NetworkUtils.browseLink(ourUrl);

Hypixel utilities

OneConfig's utils module provides a set of Hypixel-specific utility methods for a better development experience.

Getting server-side info about the client player (rank, prefix, etc)

HypixelUtils.PlayerInfo playerInfo = HypixelUtils.getPlayerInfo();
Optional<PlayerRank> playerRank = playerInfo.getRank(); // NORMAL, YOUTUBER, GAME MASTER or ADMIN
Optional<PackageRank> packageRank = playerInfo.getPackageRank(); // NONE, VIP, VIP PLUS, MVP, MVP PLUS
Optional<MonthlyPackageRank> monthlyPackageRank = player.getMonthlyPackageRank(); // NONE, SUPERSTAR
Optional<String> prefix = playerInfo.getPrefix();
val playerInfo = HypixelUtils.getPlayerInfo()
val playerRank = playerInfo.getRank().getOrNull() // NORMAL, YOUTUBER, GAME MASTER or ADMIN
val packageRank = playerInfo.getPackageRank().getOrNull() // NONE, VIP, VIP PLUS, MVP, MVP PLUS
val monthlyPackageRank = player.getMonthlyPackageRank().getOrNull() // NONE, SUPERSTAR
val prefix = playerInfo.getPrefix().getOrNull()

Getting info about the player's current party

HypixelUtils.PartyInfo partyInfo = HypixelUtils.getPartyInfo();
boolean isInParty = partyInfo.isInParty();
int partySize = partyInfo.getPartySize(); // Returns 0 if the client player is not in a party
Map<UUID, ClientboundPartyInfoPacket.PartyMember> members = partyInfo.getMembers();
val partyInfo = HypixelUtils.getPartyInfo()
val isInParty = partyInfo.isInParty()
val partySize = partyInfo.getPartySize() // Returns 0 if the client player is not in a party
val members: Map<UUID, ClientboundPartyInfoPacket.PartyMember> = partyInfo.getMembers()

Getting info about the client player's location on the Hypixel Network

HypixelUtils.Location location = HypixelUtils.getLocation();
Optional<String> lastServerName = location.getLastServerName();
Optional<String> serverName = location.getServerName();
Optional<String> lastLobbyName = location.getLastLobbyName();
Optional<String> lobbyName = location.getLobbyName();
Optional<String> lastMapName = location.getLastMapName();
Optional<String> mapName = location.getMapName();
Optional<String> lastMode = location.getLastMode();
Optional<String> mode = location.getMode();
Optional<ServerType> lastServerType = location.getLastServerType();
Optional<ServerType> serverType = location.getServerType();
boolean wasInLobby = location.wasInLobby();
boolean inLobby = location.inLobby();
boolean wasInGame = location.wasInGame();
boolean inGame = location.inGame();
Optional<GameType> lastGameType = location.getLastGameType();
Optional<GameType> gameType = location.getGameType();
val location = HypixelUtils.getLocation()
val lastServerName: Optional<String> = location.lastServerName
val serverName: Optional<String> = location.serverName
val lastLobbyName: Optional<String> = location.lastLobbyName
val lobbyName: Optional<String> = location.lobbyName
val lastMapName: Optional<String> = location.lastMapName
val mapName: Optional<String> = location.mapName
val lastMode: Optional<String> = location.lastMode
val mode: Optional<String> = location.mode
val lastServerType: Optional<ServerType> = location.lastServerType
val serverType: Optional<ServerType> = location.serverType
val wasInLobby: Boolean = location.wasInLobby()
val inLobby: Boolean = location.inLobby()
val wasInGame: Boolean = location.wasInGame()
val inGame: Boolean = location.inGame()
val lastGameType: Optional<GameType> = location.lastGameType
val gameType: Optional<GameType> = location.gameType

IO utilities

Clipboard manipulation

Obtaining a clipboard instance

Clipboard clipboard = Clipboard.getInstance();

The default implementation of Clipboard uses the natives provided by Copycat. Calling the getInstance method will automatically load the natives should it need to.

Copying and getting strings

String clipboardString = clipboard.getString();
if (clipboardString == null) {
    // If the user does not have anything copied, or the copied content
    // is not a string (if, f.ex, it's an image), then the `getString`
    // method returns null.
    return;
}

String newClipboardString = "Hello, OneConfig!";
clipboard.setString(newClipboardString); // Copies our string to the user's clipboard
val clipboardString = clipboard.getString()
if (clipboardString == null) {
    // If the user does not have anything copied, or the copied content
    // is not a string (if, f.ex, it's an image), then the `getString`
    // method returns null.
    return
}

val newClipboardString = "Hello, OneConfig!"
clipboard.setString(newClipboardString) // Copies our string to the user's clipboard

Copying and getting images

ClipboardImage clipboardImage = clipboard.getImage();
if (clipboardString == null) {
    // If the user does not have anything copied, or the copied content
    // is not a string (if, f.ex, it's an image), then the `getString`
    // method returns null.
    return;
}

ClipboardImage newClipboardImage = null; // Obtain your image somehow...
clipboard.setImage(newClipboardImage); // Copies our string to the user's clipboard
String clipboardString = clipboard.getString();
if (clipboardString == null) {
    // If the user does not have anything copied, or the copied content
    // is not a string (if, f.ex, it's an image), then the `getString`
    // method returns null.
    return;
}

String newClipboardString = "Hello, OneConfig!";
clipboard.setString(newClipboardString); // Copies our string to the user's clipboard

By default, ClipboardImage on it's own is simply two ints for the width x height, and an array of bytes for the raw image data. Thus meaning, that should you want to make use of it in any meaningful way, you'll need to convert it to another type for another library OR handle the raw bytes on your own. Thankfully, Copycat provides a means of converting to and from the Java AWT types for you, which you can find below.

Copying AWT images (BufferedImage)

BufferedImage ourImage = ImageIO.read("/path/to/your/image");
// Now, we can't simply copy the above image as it is because we need
// a ClipboardImage, not a BufferedImage.

// So, we'll convert it using this subtype.
ClipboardImage ourClipboardImage = BufferedClipboardImage.toClipboardImage(ourImage);

// Now, we can finally copy it.
Clipboard clipboard = Clipboard.getInstance();
clipboard.setImage(ourClipboardImage);
val ourImage = ImageIO.read("/path/to/your/image")
// Now, we can't simply copy the above image as it is because we need
// a ClipboardImage, not a BufferedImage.

// So, we'll convert it using this subtype.
val ourClipboardImage: ClipboardImage = BufferedClipboardImage.toClipboardImage(ourImage)

// Now, we can finally copy it.
val clipboard = Clipboard.getInstance()
clipboard.setImage(ourClipboardImage)

This works vice-versa too!

Clipboard clipboard = Clipboard.getInstance();
ClipboardImage clipboardImage = clipboard.getImage();

// Now, we just need to convert it to a BufferedImage
BufferedImage image = BufferedClipboardImage.toBufferedImage(clipboardImage);
val clipboard = Clipboard.getInstance()
val clipboardImage = clipboard.getImage()

// Now, we just need to convert it to a BufferedImage
val image = BufferedClipboardImage.toBufferedImage(clipboardImage)

File checksums (SHA-256 only)

OneConfig provides a single, ease-to-use method for obtaining the checksum of a file at a given path.

Path myFilePath = Paths.get("/path/to/your/file");
String sha256Checksum = IOUtils.getFileChecksum(myFilePath);

// Couldn't obtain the file's checksum
if (sha256Checksum.isEmpty()) {
    return;
}
val myFilePath = Paths.get("/path/to/your/file")
val sha256Checksum = IOUtils.getFileChecksum(myFilePath)

// Couldn't obtain the file's checksum
if (sha256Checksum.isEmpty()) {
    return
}

All of the custom data types contained within PlayerInfo come from the library.

All of the custom data types contained within PartyInfo come from the library.

All of the custom data types contained within Location come from the library.

OneConfig no longer provides in-house utilities for managing the user's clipboard; however, we do include , which uses native code to bypass any issues brought on by certain operating systems (such as macOS disallowing headless apps from using the AWT clipboard API).

Hypixel HypixelData
Hypixel ModAPI
Hypixel HypixelData
Deftu's Copycat library

Platform-specific utilities

The Platform class in OneConfig's utils module is a means to provide several methods which will serve the same function regardless of what Minecraft version or mod loader is currently being used by the player. It serves several general purpose, smaller platform utilities such a localization, mod loader, OpenGL, etc utilities.

Mod loader platform

Getting the current Minecraft version

LoaderPlatform#getMinecraftVersion (or Platform.loader().getMinecraftVersion()) returns a 0-padded representation of the current Minecraft version, f.ex: 11605 or 10809 which represent 1.16.5 and 1.8.9 respectively.

Getting the current mod loader name

LoaderPlatform#getLoader (or Platform.loader().getLoader()) returns the current mod loader, represented by the Loaders enum, which contains FORGE and FABRIC.

Checking if we're in a developer environment

LoaderPlatform#isDevelopmentEnvironment(or Platform.loader().isDevelopmentEnvironment()) can be used to check if the player is currently inside of a developer environment.

Checking if a specific mod ID is loaded

LoaderPlatform#isModLoaded(or Platform.loader().isModLoaded(String)) returns a boolean for if a mod with the given ID is currently loaded.

Getting all currently loaded mods

LoaderPlatform#getLoadedMods(or Platform.loader().getLoadedMods()) returns a list of ActiveMod instances, all containing information such as a mod's name, ID, version and where it was loaded from (it's source).

Player platform

Checking if the player is in multiplayer

PlayerPlatform#inMultiplayer(or Platform.player().inMultiplayer()) returns a boolean for if the player is currently connected to a multiplayer server or LAN world.

Checking if the player currently exists (in a world)

PlayerPlatform#inMultiplayer(or Platform.player().inMultiplayer()) returns a boolean for if the player is currently connected to a multiplayer server or LAN world.

Getting the player's username

Getting information about the server the player is connected to

GL platform

Screen platform

I18n platform

Multithreading

Submitting actions to run in multiple threads

Runnable action = () -> {
    System.out.println("Hello! I'm in another thread!");
};

Multithreading.submit(action);
val action = Runnable {
    println("Hello! I'm in another thread!")
}

Multithreading.submit(action)

Scheduling an action to run after some time

Runnable action = () -> {
    System.out.println("Hello! I'm in another thread and was run after 5 seconds!");
};

Mulithreading.schedule(action, 5, TimeUnit.SECONDS);
val action = Runnable {
    println("Hello! I'm in another thread and was run after 5 seconds!")
}

Mulithreading.schedule(action, 5, TimeUnit.SECONDS)

Migrating your configs from Vigilance

Updating from V0

OneConfig V0 had a system in which you would add a new VigilanceMigrator(...) to your config's super constructor call in order to tell it where to find your old Vigilance config. Now, in OneConfig V1, we are prioritizing allowing developers to migrate from more other config systems independently.

You can now replace your VigilanceMigrator instantiation with a call to loadFrom in your constructor, passing the path to your old config to it.

You can also replace all @VigilanceName annotations with the new @PreviousNames annotation, in which you can simply pass the full path (category + subcategory + name) to your old option, f.ex: "oldCategory.oldSubcategory.oldName1", "oldCategory.oldName2", ...

Full example

public class MyConfig extends Config {

    @Switch(
        title = "My Switch",
        description = "This is my switch",
        icon = "/my_switch.svg",
        category = "Switches",
        subcategory = "General"
    )
    @PreviousNames({"switches.general.mySwitch"})
    public static boolean mySwitch = false;
    
    public MyConfig() {
        super(
              "example_config.json",
              "/assets/examplemod/example_mod.png",
              "Example Mod",
              Category.QOL
         );
    
        loadFrom("config/my_mod.toml"); // Old Vigilance config
    }

}
object MyConfig : KtConfig(
     id = "example_config.json",
     icon = "/assets/examplemod/example_mod.png",
     title = "Example Mod",
     category = Config.Category.QOL
) {

    // TODO: Add @PreviousNames annotation for the Kotlin DSL
    var mySwitch: Boolean by switch(
        name = "My Switch",
        def = false, // Sets option's default value. Recommended, default = true
        description = "This is my switch", // Recommended, default = ""
        icon = "/my_switch.svg", // Optional, default = ""
        category = "Switches", // Recommended, default = "General"
        subcategory = "General" // Recommended, default = "General"
    )
    
    init {
        loadFrom("config/my_mod.toml") // Old Vigilance config
    }

}

Temporary V0 -> V1 migration guide

OneConfig V1 is now available to all developers, with some conditions:

  • Not everything has been documented just yet...

  • Currently, V1 will not work on modern versions due to an issue with LWJGL natives. But it compiles!

  • Expect bugs with OneConfig V1 itself.

Below are screenshots of the new GUI. Yes, these are concept designs, but it's basically been implemented 1:1 and I'm way too lazy to take actual screenshots lol

Get it working in Gradle

Notable changes

New

Package changes

You should be able to do a find and replace with import <old package name> . Go in opposite order from this list if you want to do a full search and replace.

Class name changes

Misc

Examples

All the ported versions should be in the "twoconfig" branch (EXCEPT EvergreenHUD, that work is in the "rewrite" branch).

This is in NO WAY a complete guide as of yet. if you find any discrepancies.

Please follow the guide for this.

This is in NO WAY a complete guide as of yet. if you find any discrepancies.

We recommend checking out our mods, which have somewhat already been ported to V1 (59%). Good examples are , , and . Here is a periodically updated list of our ported mods:

Now split into multiple, non-Minecraft dependant modules, and one Minecraft module
Uses PolyUI
  - Extremely optimized UI lib, using NanoVG
  - "Render what you need ONLY WHEN you need it"
    - Performance boost as a result of this
  - As a result, theming support is automatic and will be implemented soon
Official support for Legacy Fabric and modern MC (Forge, Fabric, and soon NeoForge)
Commands can now be created via `CommandBuilder`, a Brigadier-style builder.
Complete rewrite of config system
  -https://github.com/Polyfrost/OneConfig/tree/v1/modules/config#oneconfig-config
  - Now supports more than just registering config values via annotations
Complete rewrite of HUD system
  - Using PolyUI
  - Separate from configs now
  - Supports multiple of a HUD
  - https://github.com/Polyfrost/OneConfig/tree/v1/modules/hud#oneconfig-hud
  - As explained, you can use `LegacyHud` to just render like in V0. But we STRONGLY recommend using the new PolyUI-based APIs
Keybind rewrite
cc.polyfrost -> org.polyfrost
cc.polyfrost.libs.universal -> org.polyfrost.universal
cc.polyfrost.oneconfig.events -> org.polyfrost.oneconfig.api.event.v1.events
cc.polyfrost.oneconfig.platform -> org.polyfrost.oneconfig.api.platform.v1
cc.polyfrost.oneconfig.utils -> org.polyfrost.oneconfig.utils.v1
cc.polyfrost.oneconfig.utils (for Notifications class) -> org.polyfrost.oneconfig.api.ui.v1
cc.polyfrost.oneconfig.utils.hypixel -> org.polyfrost.oneconfig.api.hypixel.v0
cc.polyfrost.oneconfig.utils.commands -> org.polyfrost.oneconfig.api.commands.v1
cc.polyfrost.oneconfig.utils.commands.annotations -> org.polyfrost.oneconfig.api.commands.v1.factories.annotated
cc.polyfrost.oneconfig.config -> org.polyfrost.oneconfig.api.config.v1
@Main and @SubCommand -> @Command
@Description -> @Parameter
@Greedy -> `greedy` field in @Command annotation
OneColor -> PolyColor
@VigilanceName (or any other migrator name -> @PreviousName (check javadocs for new syntax)
new OneColor(value) -> ColorUtils.rgba(value)
NetworkUtils.getJsonElement -> JsonUtils.parseFromUrl
JsonUtils.parseString -> `parse` or `parseOrNull`
EventManager.register notes:
- We strongly recommend devs to switch from annotation-based event registering to the new system.
  - EventManager.register(EventName.class, (event) -> { doStuff(); });
  - In Kotlin you can do eventHandler { event: EventName -> { doStuff() } }.register()
- If for whatever reason you cannot, keep the following in mind:
  - Registered objects to the EventManager are now not removable by default. To allow it to be removed, call `register(new ClassName(), true)`
TickDelay -> EventDelay.ticks
RenderTickDelay -> EventDelay.render
new VigilanceMigrator (or any other migrator) -> `loadFrom` method in config.
CommandManager.INSTANCE.registerCommand -> CommandManager.registerCommand
CommandManager.INSTANCE.addParser -> CommandManager.INSTANCE.registerParser
@Command `aliases` field -> `value`
- it is now an array, you pass the main one as the first and the rest as aliases
Notifications.INSTANCE.send -> NotificationsManager.INSTANCE.enqueue
- You now need to provide a notification "type"
- We'll probably rename the class back to Notifications depending on how things go
Multithreading.runAsync -> Multithreading.submit
ConfigUtils.getProfileFile -> ConfigManager.active().getFolder().resolve
- Returns a Path instead of a File
HypixelUtils.INSTANCE -> HypixelUtils
- Locraw Util is completely removed, instead we now provide a Hypixel Mod API-based API in HypixelUtils
ArgumentParser.complete -> getAutoCompletions
- It is now nullable, so pass `null` instead of an empty list
- For config annotations, the `name` field is now `title`
- For config annotations, `size` is removed. All config options are "size 2"
- **VERY IMPORTANT** - variables in configs are NOT serialized by default anymore. Instead of @Exclude-ing variables you don't want, you need to @Include variable you DO want and not annotate the others.
- new VigilanceMigrator (or any other migrator) -> `loadFrom` method in config.
- @VigilanceName (or any other migrator name -> @PreviousName (check javadocs for new syntax)
- `initialize` method is no longer necessary.
- addListener -> addCallback
- CrashPatch [V1 DONE]
- PolyBlur [V1 DONE]
- ColorSaturation [V1 DONE]
- OverflowAnimations [V1 DONE]
- GlintColorizer [V1 DONE]
- PolyPatcher [V1 DONE]
- REDACTION [V1 DONE]
- PolySprint [V1 DONE]
- BehindYouV3 [V1 ½ done]
- PolyCrosshair [V1 __not__ done]
- OverflowParticles [V1 __not__ done]

- EvergreenHUD [V1 ½ done]
- PolyHitbox [V1 __not__ done]
- VanillaHUD [V1 ½ DONE]
- Chatting [V1 __not__ done]
- Keystrokes Reborn [V1 __not__ done]

- PolyNametag [V1 DONE]

- DamageTint [V1 DONE]
- Hytils Reborn [V1 DONE]

- PolyTime [V1 DONE]
- PolyWeather [V1 DONE]

Subscriber events

Getting started with OneConfig's subscriber-based events system is easy and straightforward! If you've worked with MinecraftForge or NeoForge before, you'll be more than familiar with how these function.

Registering a listener

In order for your subscriber methods to execute when an event is dispatched, you'll need to register their containing instance as an event listener. This can be done via an instance of EventManager, typically the statically provided INSTANCE:

public class ExampleListener {
    // This should be called somewhere - Like when your mod is first initialized
    public void run() {
        EventManager.INSTANCE.register(this);
    }
}
object ExampleListener {
    // This should be called somewhere - Like when your mod is first initialized
    fun run() {
        EventManager.INSTANCE.register(this)
    }
}

Listening for events

Now that your instance is registered as an event listener, you can define your subscriber methods for the events which you want to listen for dispatches of. This can be done by defining those events as parameters for a method/function then annotating that same method/function with @Subscribe.

public class ExampleListener {
    // This should be called somewhere - Like when your mod is first initialized
    public void run() {
        EventManager.INSTANCE.register(this);
    }
    
    // This method is called every tick, as the TickEvent is dispatched every game tick
    @Subscribe
    public void onTick(TickEvent.Start event) { // TickEvent.End also exists.
        System.out.println("Tick tick tick!");   
    }
}
object ExampleListener {
    // This should be called somewhere - Like when your mod is first initialized
    fun run() {
        EventManager.INSTANCE.register(this)
    }
    
    // This method is called every tick, as the TickEvent is dispatched every game tick
    @Subscribe
    fun onTick(event: TickEvent) {
        println("Tick tick tick!")
    }
}

And there you have it! This instance of our ExampleListener now receives all dispatched instances of TickEvent.Start as long as our run method/function is executed at least once in it's lifetime.

PLEASE contribute to this guide
Getting Started
PLEASE contribute to this guide
CrashPatch
EvergreenHUD
Hytils Reborn

JSON utilities

Getting JSON elements from a string

Unsafe (exceptional) parsing

You can unsafely (exceptionally) parse JSON from a string using JsonUtils#parse(String), like so:

JsonElement jsonElement = JsonUtils.parse("{}");

If incorrect JSON syntax is passed to this method, GSON will throw a JsonSyntaxException

Safe parsing

JsonUtils#parseOrNull will automatically catch any exceptions thrown by GSON's parser and return the resulting JsonElement or null if a parsing error was thrown. It can be used like so:

JsonElement jsonElement1 = JsonUtils.parseOrNull("{}"); // non-null, JsonObject
JsonElement jsonElement2 = JsonUtils.parseOrNull("Hello, OneConfig!"); // null

Safe parsing via callbacks

An additional, third method is present for the purpose of running a callback if parsing succeeds on the string given.

JsonUtils.parse("{}", (jsonElement) -> {
    System.out.println("I'll print out if the JSON is parsed properly! " + jsonElement);
});