> Agents can also search and read this documentation through its [MCP server](https://docs.polyfrost.org/oneconfig/~gitbook/mcp).

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
This site has an agentic ask interface you may use to query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.polyfrost.org/oneconfig/index.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

---

# Introduction

## Are you someone who knows nothing about programming and just want to use OneConfig? Check out our website [here](https://polyfrost.org/projects/oneconfig/)!

Welcome to the OneConfig documentation for developers and designers. 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.

Keep in mind though, that these docs aren't perfect, so if something is wrong, feel free to [fix it yourself](https://github.com/Polyfrost/OneConfig-Documentation/), before we even notice.

## Contributions

If you encounter any errors or bugs in OneConfig, feel free to [make an issue](https://github.com/Polyfrost/OneConfig/issues) or [pull request.](https://github.com/Polyfrost/OneConfig/pulls) If you're still stuck, join our [Discord](https://polyfrost.cc/discord) server and create a ticket!

## Licensing

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

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 "Introduction" with no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "[**Documentation License**](https://docs.polyfrost.org/oneconfig/documentation-license)".


# Documentation License

GNU Free Documentation License version 1.3

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

```
Copyright (C) 2022 Polyfrost. All Rights Reserved. 
   <https://polyfrost.cc/> <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 "Introduction" 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.
```


# Modding Basics

A beginner's guide to starting modding with OneConfig

This page will serve as a basic guide to getting started with modding using OneConfig's example mod.

Minecraft mods are most commonly added into the game using a **loader**, the most popular of which are [Fabric](https://fabricmc.net) and [Forge](https://files.minecraftforge.net/). Forge is popular for older Minecraft versions, while Fabric is considered the main platform for vanilla compatible modding in 1.16+. The term 'mod' refers to a modification of the Minecraft game.&#x20;

Since Minecraft is in Java, most of its mods are as well. You may also find mods written in [Kotlin](https://kotlinlang.org/), a programming language designed to be compatible with the JVM (Java Virtual Machine). Some developers find Kotlin easier to use than Java. **OneConfig includes Kotlin so you shouldn't include it yourself in your mod if you wish to use it.** However, OneConfig itself mostly uses Java over Kotlin.

**You will need some basic knowledge of programming to effectively develop Minecraft mods.** But don't worry! Java is reasonably easy to pick up, as it is an **object-orientated programming (OOP)** language with a reasonably easy-to-understand syntax. However, you should still watch a few tutorials and get your feet relatively wet before diving into Minecraft modding.

### Step 1: Installing IntelliJ IDEA

For this tutorial, we are going to use the OneConfig Example which can be found [here](https://github.com/Polyfrost/OneConfigExampleMod). In this guide, we are going to use [JetBrains IntelliJ IDEA](https://www.jetbrains.com/idea/) as our **integrated development environment (IDE)**, as this is the preferred choice for most Minecraft mod developers.

Firstly, head to their [**downloads page**](https://www.jetbrains.com/idea/download/) and download IntelliJ IDEA for your operating system or platform. We recommend the 'Community Edition' for casual developers. It's free and probably has all the features you'll need. After downloading it, follow the prompts to get it installed.

Once that has been downloaded, you may want to open up your files browser and create yourself a directory for all your mods (e.g `C:/Users/Bob/Developer/`). This is just a quality of life step, so if you wish, you can ignore it and do as you wish.

### Step 2: Creating the Project

Now that you have installed IntelliJ, you should be ready to clone the project. Open up IntelliJ and you should be greeted with a screen a bit like this (after accepting the terms):

![IntelliJ welcome screen](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FCVbK2AvvoJRjEV4cFjv7%2Fimage.png?alt=media\&token=7c35869d-345d-423b-8494-1b00b44fb066)

Once you're at this screen:

* Click the **Get from VCS** button.
* Go to **Repository URL**.
* Check that **Version Control** is set to **Git**.
* Set the directory to the root folder you made earlier for mod development.
* In the **URL** box, input `https://github.com/Polyfrost/OneConfigExampleMod`.
* At the end of the Directory box, add the name of your mod. In this tutorial, it will be called `ExampleMod`.

It should now look something like this:

![IntelliJ clone screen](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FTLKkDx8FxNXciFOly01j%2Fimage.png?alt=media\&token=f47224d1-5447-435d-8452-c979ef7e2523)

If that all looks good, go ahead and click the **Clone** button in the bottom right.

### Step 3: Project Setup

Now, you will need to set up your **Java Development Kits (JDKs)** to get started with coding. These are used to run your code and Minecraft, and allow you to build your projects into distributable java executable binaries (commonly known as JARs).

#### GRADLE JVM

* **Windows & Linux:** Press **Ctrl+Alt+S** to open **Settings**\
  **macOS:** Press **⌘ , (command + comma)**, or go to **IntelliJ IDEA > Preferences** from the menu bar, to open **Preferences**
* Go to **Build, Execution and Deployment** **> Build Tools > Gradle** from the left sidebar menu.
* At the bottom of this screen, look for a dropdown list button labelled **Gradle JVM**. Open the dropdown list.
* Now, click **Download JDK** and set the **Version** to **17 or above** on the popup that appears. Don't change anything else — just hit **Download**. Once finished, set this new JVM as the **Gradle JVM** and click **Apply** to complete the changes.

![Gradle JVM settings screen](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FqnXIdoDkjqr943AJYKOs%2Fimage.png?alt=media\&token=01c12426-29fe-43ff-af55-4b115c4e25b1)

#### PROJECT JVM

* Windows & Linux: Press **Ctrl+Alt+Shift+S** to open **Project Structure**. \
  macOS: Press **⌘ ; (command + semicolon)**, or go to **File > Project Structure** from the menu bar to open **Project Structure**.
* Go to **Project Settings > Project**.
* Open the **SDK** dropdown menu.
* Again, go to **Add SDK** then **Download JDK**. This time, **choose 1.8 as the version** and press **Download**. Once finished, set this new JVM as the **Project SDK**. Click **Apply** to set the changes.
* Again, go to **Add SDK and then Download SDK**. This time, choose **1.8 as the version** and press **Download**. Once that has finished, set that new JVM as the **Project SDK** and click **Apply** to set the changes.
* Set the **Language level** to **SDK Default**.

![Project SDK settings](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FXqxyJdyuzbbeTcnVJh5F%2Fimage.png?alt=media\&token=c6df98a5-50f5-4737-84fd-479e288c4cd4)

In case you weren't sure, here is an example of the download dialogue box:

![Java 8 download window (example)](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2Fgit-blob-61b2099a521eaac1a5a233b36cd77e35b2bd4fbe%2Fimage.png?alt=media)

### Step 4: Reloading and Building

Now you have your JDKs set up, you can go ahead and close all those windows to go back to the main IDE.

### Step 5: Run Your Mod

**You are now ready to run your mod for the first time!** Make sure that **Minecraft Client** is selected, and click the play button. Loom should have automatically installed the build configs for you, if not, try restarting IntelliJ or reimporting the Gradle project. With some luck, your game should launch.

{% hint style="info" %}
If you encounter any issues, feel free to join our [Discord server](https://polyfrost.cc/discord) and ask.
{% endhint %}


# Getting Started

(aka "How the hell do I add OneConfig to my mod?")

If you're unfamiliar with Java, or Minecraft Modding, please read [Modding Basics](https://docs.polyfrost.org/oneconfig/including-oneconfig) first. It's a fantastic beginner's guide.

### OneConfig's Example Mod

If you're just starting out or need more advanced features like multiple versions, we highly recommend looking at our updated [example mod](https://github.com/Polyfrost/OneConfigExampleMod/).

## Including OneConfig Yourself

If you want to avoid using our own [mod template](https://github.com/Polyfrost/OneConfigExampleMod/), or wish to include OneConfig in one of your new or existing mods, add this to your `build.gradle(.kts)`

{% tabs %}
{% tab title="Groovy" %}

<pre class="language-groovy"><code class="lang-groovy">loom {
    launchConfigs {
        client {
            // Loads OneConfig in dev env. Replace other tweak classes with this, but keep any other attributes!
            arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
        }
    }
}

repositories {
    maven { url 'https://repo.polyfrost.cc/releases' }
}

dependencies {
<strong>    // Basic OneConfig dependencies for legacy versions. See OneConfig example mod for more info
</strong>    compileOnly('cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+') // Should not be included in jar
    // include should be replaced with a configuration that includes this in the jar
    include('cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+') // Should be included in jar
}

jar { // loads OneConfig at launch. Add these launch attributes but keep your old attributes!
    manifest.attributes(
            "ModSide": "CLIENT",
            "TweakOrder": "0",
            "ForceLoadAsMod": true,
            "TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
    )
}
</code></pre>

{% endtab %}

{% tab title="Kotlin" %}

<pre class="language-kotlin"><code class="lang-kotlin">loom {
    launchConfigs.named("client") {
         // Loads OneConfig in dev env. Replace other tweak classes with this, but keep any other attributes!
         arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
    }
}

repositories {
    maven("https://repo.polyfrost.cc/releases")
}

dependencies {
<strong>    // Basic OneConfig dependencies for legacy versions. See OneConfig example mod for more info
</strong>    compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+") // Should not be included in jar
    // include should be replaced with a configuration that includes this in the jar
    include("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") // Should be included in jar
}

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

{% endtab %}
{% endtabs %}


# Creating a Config

Find out how to create Configs with OneConfig

## Getting Started

### Building the bare bones

To create a new config, you need to create a new class that extends `Config`, just like this:

```java
public class MyConfig extends Config {
}
```

Simple! Now, it needs a constructor. The `Mod` object stores both its name and category, along with the mod's file name. Usually, named `"yourmodname.json"`.

```java
public MyConfig() {
    // Available mod types: PVP, HUD, UTIL_QOL, HYPIXEL, SKYBLOCK
    super(new Mod("My Mod", ModType.UTIL_QOL), "config.json");
    initialize();
}
```

### Additional cosmetics

If you wish, you can specify an icon for your mod that will be shown in the GUI. All you need to do is add a third argument that specifies your icon's file path.

```java
public MyConfig() {
    // Available mod types: PVP, HUD, UTIL_QOL, HYPIXEL, SKYBLOCK
    super(new Mod("My Mod", ModType.UTIL_QOL, "/filepath/to/icon.png"), "config.json");
    initialize();
}
```

{% hint style="info" %}
OneConfig supports both the PNG and SVG (vector) image formats.
{% endhint %}

## Initializing on launch

Finally, you have to initialize your config when the game launches. This can easily be done using the [Events](https://docs.polyfrost.org/oneconfig/events/event-basics) system, with the `InitializationEvent`, most commonly in your main class:

```java
public class MyMod {
    public static MyConfig config;

    @Subscribe
    public void onInit(InitializationEvent event) {
        config = new MyConfig();
    }
}
```

And you're done, pretty simple huh? Your config is now registered and can be seen in the GUI. So naturally, it's time to add some options.

{% content-ref url="/pages/dVJbDr1lxCgVKMciTp5a" %}
[Config Options](https://docs.polyfrost.org/oneconfig/config/adding-options)
{% endcontent-ref %}

## Example Config GUI

Here is an example config GUI, if you are looking for a sneak peek or some inspiration :)

![Example Config GUI for inspiration](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FDeCNcaFEGaTwEiHqTeyf%2Fimage.png?alt=media\&token=2a1d6a24-fd04-450b-8072-7b70a2197ecd)


# Config Options

Here you will learn how to create options inside OneConfig.

## Adding options

### Creation

Options are added with Java annotations. Any field you annotate with an option will be saved to your config file, which you earlier specified in it's constructor. It'll then be displayed to the user within the OneConfig GUI.

```java
@Switch(
    name = "A random switch",
    size = OptionSize.DUAL, // optional, declares whether the element is single column or dual column
    category = "General", // optional
    subcategory = "Switches" // optional
)
public static boolean bob = false; // this is the default value.
```

### Accessing

Retrieving the value of your options is incredibly easy, as seen in the example below!

```java
System.out.println("My thing in a variable called bob: " + MyConfig.bob);
System.out.println("Is this enabled? " + MyConfig.enabled);
```

{% hint style="info" %}
Subcategories and Options are displayed in the order they are put in the config. You can have multiple subcategories with the same name, but this is not recommended unless it genuinely makes sense (e.g. "HUD Options" for two separate types of HUDs).
{% endhint %}

## Disabling Options

Disabled options are still visible to the user, but cannot be interacted with. You can disable them by adding dependencies.

If you wish to do this, go back to your config's constructer, and put in an `addDependency` line, as seen below. The first argument will specify which variable should be edited, given the value of the second argument.&#x20;

```java
@Switch(
    name = "Master Switch",
    size = OptionSize.DUAL
)
public static boolean masterSwitch = false;

@Switch(
    name = "Sub Switch",
    type = OptionType.SWITCH,
)
public static boolean subSwitch = false;

public TestConfig() {
    super(new Mod("My Mod", ModType.UTIL_QOL), "mymod.json");
    addDependency("subSwitch", () -> masterSwitch); // disable subSwitch if masterSwitch is off, making it dependant
}
```

## Other option features

### Sizes

Options come in two sizes in the GUI, `SINGLE` and `DUAL`. These are stored in a simple enum called `OptionSize`. Here is what a single and dual Text Field look like:

![Difference between Single and Dual Variants of a Text Field](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FjXWhq4o3Z8aks81tFurS%2Fimage.png?alt=media\&token=ee1ad12e-8ac0-42a4-a89a-c8e9a2957964)

## Option types

There are lots to choose from, so what are you waiting for?

{% content-ref url="/pages/ZUoTKIXDTL2N9gutr76I" %}
[Boolean Configs](https://docs.polyfrost.org/oneconfig/config/adding-options/boolean-config-components)
{% endcontent-ref %}

{% content-ref url="/pages/dU9D4OFOWwFPEcXNxAhP" %}
[Number Configs](https://docs.polyfrost.org/oneconfig/config/adding-options/number-config-components)
{% endcontent-ref %}

{% content-ref url="/pages/BnHA9PDq4S43hD6ZvbU3" %}
[Selector Configs](https://docs.polyfrost.org/oneconfig/config/adding-options/multi-config-components)
{% endcontent-ref %}

{% content-ref url="/pages/I7JKXEi0UaVn8XdGHZfm" %}
[Text Configs](https://docs.polyfrost.org/oneconfig/config/adding-options/text-configs)
{% endcontent-ref %}

{% content-ref url="/pages/6eVFq7GxrSoTPmiAtcEm" %}
[Buttons, Colors and Keybinds](https://docs.polyfrost.org/oneconfig/config/adding-options/buttons-colors-and-keybinds)
{% endcontent-ref %}

{% content-ref url="/pages/KsQA6RHonkLPePP1WS8v" %}
[Decorative Components](https://docs.polyfrost.org/oneconfig/config/adding-options/decorative-config-components)
{% endcontent-ref %}


# Boolean Configs

Learn all about boolean components.

## Common booleans

### Switch

The switch is the best way to represent a simple boolean. It's got both a single and dual column variant, and the option you'll use the most.

```java
@Switch(
    name = "Toggle Switch (1x)",
    size = OptionSize.SINGLE // optional
)
public static boolean bob = false;        // default value
```

This code will create a switch like this:

![Toggle Switch example (off and on states)](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FKGH7K79b3aKA1Bi0EELg%2Fimage.png?alt=media\&token=8fd6731d-70a5-4f4f-8c18-869c70839792)

### Checkbox

A checkbox is the best way to represent less important booleans. It's got both single and dual-column variants.

```java
@Checkbox(
    name = "Im a checkbox!",
    size = OptionSize.DUAL // optional
)
public static boolean something = false;        // default value
```

![Checkbox examples (off and on states)](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FCoEl06bzff0MiL3TPTJx%2Fimage.png?alt=media\&token=ac8198d1-70da-416e-a54c-00c1cad1cd94)

### When should you use a switch or checkbox

The switch option is intended for strict ON/OFF options, such as particles. You either see particles, or you don't. In contrast, checkboxes are intended for finer, more detailed control. Maybe you enable potion particles and disable crits.&#x20;

## Dual Option

Out of the three simple config components, dual options are the most unusual. It's got both single and dual-column variants.

{% hint style="info" %}
**Designers note:** These exist for when a simple ON/OFF component wouldn't make sense. Such as a direction, or time of day. Essentially, a boolean that wouldn't make sense with yes/no.
{% endhint %}

```java
@DualOption(
    name = "I can slide!", // name of the element
    left = "I'm Left",     // string to display on the left
    right = "No, right!"   // string to display on the right
)
public static boolean leftyrighty = false;        // default value
```

![](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FHEFqgJJU59ch51LuTtnH%2Fimage.png?alt=media\&token=e0066baa-f1a4-448d-a674-14e41c45a358)


# Number Configs

Learn all about the number config components in OneConfig

## Common numbers

### Slider

The slider is a basic draggable element, often used for numbers that control something like the width of an element. They have a little input box on the right side, to allow for manual inputs. So it's not cramped, the slider only has a single-column variant.

{% hint style="info" %}
Sliders can either return an integer or a float, and are able to be stepped.&#x20;
{% endhint %}

```java
@Slider(
    name = "You slide me right round baby right round",
    min = 0f, max = 100f        // min and max values for the slider
    // if you like, you can use step to set a step value for the slider,
    // giving it little steps that the slider snaps to.
    step = 10f
)
public static float slideyboi = 50f; // default value
```

![Slider examples (stepped and normal)](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FBXzuLSOJKgaLLatJqvmt%2Fimage.png?alt=media\&token=5ed9b321-57cb-4121-8819-f4c7296f0e54)

### Number Input

The number input is an adapted text field that only accepts valid numeric values. It similarly can be a float or integer. It can be displayed in either a dual or single-column mode.

It also has cute little arrows next to it which can be clicked to increase or decrease the number by the `step` value (default 1)

```java
@Number(
    name = "I am a number",    // name of the component
    min = 0, max = 37,        // min and max values (anything above/below is set to the max/min
    step = 5        // each time the arrow is clicked it will increase/decrease by this amount
)
public static int num = 20; // default value
```

### When should you use a slider or number input

Essentially, if the feature should be "played with", use a slider. Things like volume, size, or time. Number inputs, on the other hand, are intended for more manual control. Basically, if the user doesn't know the actual number they need, use a slider. Otherwise, number input.


# Selector Configs

Learn about components that allow the user to select between multiple options.

## Dropdown List

A dropdown list lets the user select options from a list. If switches are booleans, and sliders are integers, a dropdown is an enum. It's got both single and dual-column variants.

It uses a String Array to list the options and returns its position index within that array. In the example below, the default value is set to 1, which corresponds to the second option.

```java
@Dropdown(
    name = "I drop!",        // name of the component
    options = {"An option", "Another option", "Maybe this one?", "Or this!"},
)
public static int value = 1;        // default option (here "Another Option")
```

![Dropdown example, open and closed with list](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FxRr8JmtQ0LzEVvZyNFIU%2Fimage.png?alt=media\&token=d6df894f-0f28-4d7a-82b2-50338017bb0b)


# Text Configs

Learn about the config components that allow the user to enter text.

## Common text inputs

### Normal Text

The normal text input is a field in which a user can type in a value as a String. Simple as that. It's got both single and dual-column variants.

```java
@Text(
    name = "Write something here!",
    placeholder = "please?",        // optional, text to display when there is nothing written there
    secure = false, multiline = false
)
public static String hi = "";
```

![Example text fields](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FLmxerX5RVBufDrDuZsyJ%2Fimage.png?alt=media\&token=c3efbb83-97a7-40c9-b954-b36972099665)

### Text box

Basically the same as a normal text field, but it can have multiple lines. It dynamically changes size based on the amount of text written in it. Since it's meant to hold large bodies of text, it can only be displayed in a single-column variant.

```java
@Text(
    name = "Text box",
    secure = false, multiline = true
)
public static String moretext = "";
```

![Multiline text box examples](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FHLXGkML6AEnzPOwW103J%2Fimage.png?alt=media\&token=5547d296-054a-45ef-8152-dd2da4e30a5b)

### When to use text inputs versus boxes

It's pretty obvious. The large text box is used for long Strings or Strings with multiple lines. If you're letting the user change their HUD text, you should use regular text inputs.&#x20;

## Secure Text Input

This has the same functionality as normal text inputs, with the added feature of hiding its content until the user presses the 'show' button. It's got both single and dual-column variants.

{% hint style="warning" %}
**IMPORTANT:** This should ALWAYS be used for passwords, API keys, locations, or any other personal information.
{% endhint %}

```java
@Text(
    name = "Secrets :o :eyes:",
    secure = true, multiline = false
)
public static String shhh = "";
```

![Secure text input example](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FNjLu2h6saM5NjmmEUcKd%2Fimage.png?alt=media\&token=75ee0cb3-7a0f-4b3e-8dd9-914f6a208422)


# Buttons, Colors and Keybinds

Learn about the button, color and keybind elements that can be used in a config.

## Buttons

### Common button

The button is a simple interaction that can trigger code when pressed. It's got both single and dual-column variants.

You can create your method to run when the button is pressed using the Runnable interface:

```java
@Button(
    name = "I'm a button",    // name beside the button
    text = "Click me!"        // text on the button itself
)
Runnable runnable = () -> {    // using a lambda to create the runnable interface.
    System.out.println("I was clicked!");
    FMLCommonHandler.instance().exitJava(69, false);
}
```

![Buttons with single and dual variant examples](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2Fp6ThmpXlzxfSHGCQy2Pw%2Fimage.png?alt=media\&token=62b0f1b0-52db-4fd0-928d-942f88b6d76a)

### Keybinds

OneConfig also offers keybinds that replace Minecraft's own keybind system. Basically, it's handled and stored by OneConfig, not the game. It's got both single and dual-column variants.

{% hint style="success" %}
This config component uses OneKeyBind to store the keybinds.
{% endhint %}

```java
@KeyBind(
    name = "I'm a keybind!"
)
// using OneKeyBind to set the default key combo to Shift+S
public static OneKeyBind keyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S);
```

To register an action when a keybind is activated, add the following to your constructor:

```java
public Config() {
    registerKeyBind(keyBind, () -> System.out.println("Look mom, a keybind!"));
}
```

![Keybind field examples, including recording state](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FhhMy8kGxtwqBpJZUrBmw%2Fimage.png?alt=media\&token=da534bfd-e214-4ca9-be80-6a84e250b3b6)

## Colors

The color option lets the user change any default color to their own, using a built-in color picker.

{% hint style="success" %}
This config component uses [OneColor](https://docs.polyfrost.org/oneconfig/utils/onecolor) to store the colors.
{% endhint %}

```java
@Color(
    name = "Background Color"
)
OneColor testColor = new OneColor(26, 35, 143);        // default color
```

![Color examples, single and dual column](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2F2LtHOZWHvEWJ3ZbAsL4Z%2Fimage.png?alt=media\&token=2c7aadc4-037c-4fd1-8c60-a1e6c4a9c7fb)

![Color selector GUI examples](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FTOLE7pfeiKzGIUfclAUH%2Fimage.png?alt=media\&token=b1fd7697-01f2-48fb-895a-9965014f3e7e)


# Decorative Components

Learn about the decorations that you can add to your configs to make them prettier!

## Separation

### Header

The header lets you write a title for the following options, helping you separate large mods. You might define all of your colors in a single section, titled "Colors". Or locate all of your HUD options together.

```java
@Header(
    text = "Some information that you need to look at!"
)
public static boolean ignored; // Useless. Java limitations with @annotation.
```

![An info example with some config components beneath it](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FfOED1557bGGmWDVsKof6%2Fimage.png?alt=media\&token=00e8a115-7262-4491-91ef-101d7ce09373)

### Custom Pages

Config pages can be used with the @Page annotation. You can specify an additional class that extends Page, which will be opened when clicked. Read more about [Pages](https://docs.polyfrost.org/oneconfig/gui/pages#custom-pages) for more information.

The enum `PageLocation` describes the location of that page, which can either be `TOP` or `BOTTOM`.

```java
@Page(
    name = "I'm a page button!",
    location = PageLocation.TOP,
    // optional description that is also displayed on the page button
    description = "Press me to open a new page!"
)
public static MyPage pageToOpen = new MyPage();
```

![Page button example beneath some other config components](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FSeWrW4Z5SY0WVZoRQQnC%2Fimage.png?alt=media\&token=c54f729a-0050-4d6e-b92f-7cf92c9771e1)

## Inline documentation

### Info Line

Information lines can provide the user with extra context about something. Maybe warning the user of a potential issue or common problem you could encounter. It's got both single and dual-column variants. Read the designer's note to understand when this should be used.&#x20;

```java
@Info(
    text = "An error occurred :(",
    type = InfoType.ERROR // Types are: INFO, WARNING, ERROR, SUCCESS
)
public static boolean ignored; // Useless. Java limitations with @annotation.

@Info(
    text = "Just trying to say something here",
    type = InfoType.INFO
)
public static boolean ignored2; // Useless. Java limitations with @annotation.
```

![example info fields](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2FkKoRRZ4iuRMdjYiWDEjg%2Fimage.png?alt=media\&token=54e1f7c2-6043-4648-b087-9f14817afdea)

### Descriptions

TBD. [nextdaydelivery](mailto:undefined)

### When to use an info line over a description

Descriptions aren't always shown to the user, only when they hover over the text of an option. This means that if you're simply adding extra info about what something does, use that. Info lines should be for more crucial information, something you actually want them to read.&#x20;


# Custom options

Learn how to create custom options with OneConfig.

### Creating an option

First you have to create an option, to do this create a class that extends the BasicOption class and implement all methods.

```java
public class MyOption extends BasicOption {

    public MyOption(Field field, Object parent, String name, String category, String subcategory, int size) {
        super(field, parent, name, category, subcategory, size);
    }

    @Override
    public void draw(long vg, int x, int y) {
        // draw everything here
    }

    @Override
    public int getHeight() {
        return 32; // return the height of the option so other options can be placed accordingly
    }
}
```

### Basic usage

The easiest way to use a custom option is to annotate the field `CustomOption` annotation and specify an id.

```java
@CustomOption(id = "myOption")
public static boolean yes = true;
```

Then too add your option to the config system you have to overwrite the `getCustomOption` method in the config, add the option to the page using `ConfigUtils` and then return the option. Here is an example implementation:

```java
@Overwrite
protected BasicOption getCustomOption(Field field, CustomOption annotation, OptionPage page, Mod mod, boolean migrate) {
    BasicOption option = null;
    switch (annotation.id()) {
        case "myOption":
            option = new MyOption();
            ConfigUtils.getSubCategory(page, "category", "subcategory").options.add(option);
            break;
    }
    return option;
}
```

### Advanced usage

Using it in the way described previously is not a good option in the following situations:

* You have to use the option multiple times in different categories and subcategories
* The option has options that aren't always the same

A better alternative in these situations is to create an annotation that is annotated with the  `CustomOption` annotation.

```java
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@CustomOption(id = "myOption")
public @interface MyOptionAnnotation {
    String category();
    String subcategory();
    int exampleVariable();
}
```

Then to implement this you have to modify your `getCustomOption` a bit.

```java
@Overwrite
protected BasicOption getCustomOption(Field field, CustomOption annotation, OptionPage page, Mod mod, boolean migrate) {
    BasicOption option = null;
    switch (annotation.id()) {
        case "myOption":
            MyOptionAnnotation myOption =  ConfigUtils.findAnnotation(field, MyOptionAnnotation.class);
            option = new MyOption(myOption.exampleVariable());
            ConfigUtils.getSubCategory(page, myOption.category(), myOption.subcategory()).options.add(option);
            break;
    }
    return option;
}
```


# Migration

Learn how to migrate configs to OneConfig.

### What is this?

OneConfig includes a system to help you migrate configs into ones OneConfig can use. For example, OneConfig has built-in support for; JSON, Vigilance, and .cfg Forge files. This is very useful if you want to seamlessly migrate your old mods to OneConfig.

All migrators implement the Migrator interface, and you can create your own as well if you want. They all work in the same way, where you pass the expected location on the player's client to the old config file, and OneConfig will do the rest, like this:

```java
public MyConfig() {
    super(new Mod("My Mod", ModType.UTIL_QOL, new VigilanceMigrator("./old-config.toml")), "config.json");
    initialize();
}
```

### MigrationNames

Maybe you want to change the name of an old field or element in the new system. We've thought of this, and you can use our various `@Annotations` to maintain the support of your old files. See an example below, using Vigilance.&#x20;

```java
@VigilanceName(                    // retrieve the value from the old JSON file  
    name = "Old Name",
    category = "Old Category",
    subcategory = "Old Subcategory"
)
@Switch(                           // initialize a field like a normal config  
    name = "A random switch",
    category = "General",
    subcategory = "Switches"
)
public static boolean bob = false;
```

And a JsonName:

```java
 @JsonName("hearts.blur.disabled")                     // retrieve the value from the old JSON file  
 @Switch(name = "Disable Blur", category = "Hearts")   // initialize a field like a normal config  
 public static boolean isHeartsBlurDisabled = false;
```

### Custom Migrators

To create a custom migrator, you have to implement the `Migrator` interface and implement the `getValue` function, and this function returns the value the field should be set to, according to the old config. For a full example see [`VigilanceMigrator`](https://github.com/Polyfrost/OneConfig/blob/master/src/main/java/cc/polyfrost/oneconfig/config/migration/VigilanceMigrator.java).

```java
public class MyMigrator implements Migrator {
    @Override
    public Object getValue(Field field, String name, String category, String subcategory) {
        // logic to get old value and return object here
    }
}
```


# Event Basics

Learn more about Events, how they work and their purpose

If you are familiar with Java libraries like `javax.swing`, or have done Forge/Fabric coding before, then don't worry - events shouldn't be a mystery to you!

Forge and Fabric already use events. However, they are not very multiplatform - they change massively version to version. That's why OneConfig has its own event system, helping OneConfig to achieve its aim of uniting all Minecraft mods.

## Getting on the Bus

To get events to work, its important to register any Object/Class that uses them to the EventBus. This is very simple, and its a great idea to do this in your constructor, for example:

```java
public MyClassConstructor() {
    EventManager.INSTANCE.register(this);
}
```

This will allow that class to use the Event system. Continue reading to subscribe to your first event!

## Using the Bus

Once you have registered your class, you can now `@Subscribe` to (use) the events you would like. For example, to subscribe to a TickEvent:

```java
@Subscribe
private void onTick(TickEvent event) { // the parameter type specifies what event you are subscribing to
    // do something every tick (once every 50ms in Minecraft)
}
```

{% hint style="danger" %}
All methods annotated with `@Subscribe` must not be static!
{% endhint %}

So, as a general rule for events:

* [ ] Subscribe your class to the EventBus using EventManager
* [ ] Annotate your method you would like to use an event using `@Subscribe`
* [ ] Choose your event type by setting the parameter type in the method (you can name the variable whatever you want, a common name is just `event`)

Easy as that!


# Available Events

A list of Available events in OneConfig.

Events are split into **types**, which can be specified by the parameter type set on your method you are `@Subscribe`-ing.

Each Event has a purpose, for example `ChatReceiveEvent`, which is fired every time the client receives a message. These are useful because if you want to do something when a message is received, like check its contents for a series of letters, you can do it easily!

{% hint style="danger" %}
Remember all `@Subscribe` event methods must not be static!
{% endhint %}

## List of Available Events

{% content-ref url="/pages/Pc2iysCDtYkO6fakbKe1" %}
[ChatReceiveEvent](https://docs.polyfrost.org/oneconfig/events/available-events/chatreceiveevent)
{% endcontent-ref %}

{% content-ref url="/pages/Rk29lzHqut9rbBdWTMbO" %}
[TickEvent](https://docs.polyfrost.org/oneconfig/events/available-events/tickevent)
{% endcontent-ref %}

{% content-ref url="/pages/CqLQqatem34JQ05zC8cm" %}
[InitializationEvent](https://docs.polyfrost.org/oneconfig/events/available-events/initializationevent)
{% endcontent-ref %}

{% content-ref url="/pages/jsfuxlq1e8X6PbYQ45yr" %}
[HudRenderEvent](https://docs.polyfrost.org/oneconfig/events/available-events/hudrenderevent)
{% endcontent-ref %}

{% content-ref url="/pages/ASufF9DbUhkekxOnTCek" %}
[Packet Events](https://docs.polyfrost.org/oneconfig/events/available-events/packet-events)
{% endcontent-ref %}

{% content-ref url="/pages/5WeBTIvHRzIsvlbkNH00" %}
[LocrawEvent](https://docs.polyfrost.org/oneconfig/events/available-events/locrawevent)
{% endcontent-ref %}


# ChatReceiveEvent

Learn more about ChatReceiveEvent

ChatReceiveEvent is an event that is fired when the client receives a chat message.

{% hint style="warning" %}
This event is Cancellable, meaning you can stop other mods and the game itself from receiving messages. Be careful!
{% endhint %}

You can use `event.message` to get the message that was received as a `IChatComponent`. If you want it as plain text, don't worry! You can use `.getUnformattedText()` to get the message as a plain String.

```java
@Subscribe
public void onChatReceive(ChatReceiveEvent event) {
    System.out.println("I just received a message! " + event.message.getUnformattedText());
}
```


# TickEvent

Learn more about the TickEvent

TickEvent is an event that is fired twice Minecraft tick - once at the start, and once at the end. Minecraft ticks happen once every 50ms, or 20 times per second.

You can specify when you want this to be fired using `Stage`, like this:

```java
@Subscribe
public void onTick(TickEvent event) {
    if(event.stage == Stage.START) {
        // do something at the start of the tick
    }
    if(event.stage == Stage.END) {
        // do something at the end of the tick.
    }
}
```

If the Stage of the event is not checked, your code may run twice. Be careful!


# InitializationEvent

Learn more about InitializationEvent

InitializationEvent is an event that is fired when the client launches and mods are loading.

If you are using OneConfig's configuration system, its a great place to initialize your config as well:

```java
@Subscribe
public void init(InitializationEvent event) {
    System.out.println("The game is starting!");
    config = new MyConfig();    // initialize your config 
}
```


# HudRenderEvent

Learn more about HudRenderEvent

HudRenderEvent is an event that is fired when the GameOverlay for Minecraft is rendered (things like the hotbar, sidebar, etc.)

You can use `deltaTicks` to access the time elapsed since the last tick occurred, which is useful for animations.

```java
@Subscribe
public void onHudRender(HudRenderEvent event) {
    RenderManager.setupAndDraw((vg) -> {
        // draw a rounded rectangle on the screen
        RenderManager.drawRoundedRect(vg, 10, 50, 100, 100, -1, 12f);
    }
}
```


# Packet Events

Learn more about the Packet events OneConfig has to offer

## SendPacketEvent

SendPacketEvent is (as the name suggests) an event that is fired every time the client sends a packet.

This event also gets the packet that is going to be sent, as a `Packet<?>`. You can use code like the code below to do things with it.

{% hint style="warning" %}
This event is cancellable, meaning you can stop the packet from getting into the games code. Be careful with what you cancel!
{% endhint %}

```java
@Subscribe
public void onPacketSend(SendPacketEvent event) {
    // check if the packet is the right type
    if(event.packet instanceof S0FPacketSpawnMob) {
        // cast the packet to the right type
        S0FPacketSpawnMob packet = (S0FPacketSpawnMob) event.packet;
        // do something with it
        System.out.println("Entity attempted to be spawned with ID: " + packet.getEntityID());
        // cancel the event afterwards, rendering this packet useless.
        event.isCancelled = true;
    }
}
```

## ReceivePacketEvent

ReceivePacketEvent is (as the name suggests) an event that is fired every time the client receives a packet.

This event also gets the packet that has been received, as a `Packet<?>`. You can use code like the code below to do things with it.

{% hint style="warning" %}
This event is Cancel-able, meaning you can stop the packet from getting into the games code. Be careful with what you cancel!
{% endhint %}

```java
@Subscribe
public void onPacketReceive(ReceivePacketEvent event) {
    // check if the packet is the right type
    if(event.packet instanceof S0FPacketSpawnMob) {
        // cast the packet to the right type
        S0FPacketSpawnMob packet = (S0FPacketSpawnMob) event.packet;
        // do something with it
        System.out.println("Received data from server about an entity spawned with ID: " + packet.getEntityID());
    }
}
```


# LocrawEvent

Learn more about LocrawEvent

## What is Locraw?

Locraw is a Hypixel specific feature which means Location Raw, and it is a .json String sent by the server to the chat upon typing of the command /locraw. It is extremely useful for mods that are gamemode-specific, for example Skyblock mods that should only work in Skyblock. See [Broken mention](broken://pages/nbpRblyECm0c7pSmPuEy) for more information on Locraw.

## Event information

LocrawEvent is fired every time a Locraw message is received from the server successfully. It is intended as another method to get the location of the player, besides checking the fields of the HypixelUtils class.

Here is some code demonstrating its features:

```java
@Subscribe
public void onLocraw(LocrawEvent event) {
    // print out the location of the player
    System.out.println("got location: " + event.info.toString());
    if(event.info.gameType == LocrawInfo.GameType.BEDWARS) {
        System.out.println("in bedwars game!");
    }
}
```


# Render Manager

OneConfig's rendering system, NanoVG and how to use it

OneConfig introduces NanoVG and LWJGL3 as its rendering method, even on older versions of the game. OneConfig has a feature-rich API wrapper for this called `NanoVGHelper`, which allows developers to draw things on the display, from rectangles to circles and images.

NanoVG allows for beautiful, sharp UIs at fast speeds due to its lightweight design and antialiasing methods.

## Getting Started

To draw things using NanoVG, use the `setupAndDraw` method.

```java
NanoVGHelper.INSTANCE.setupAndDraw((vg) -> {
    NanoVGHelper.INSTANCE.drawRoundedRect(vg, 10, 50, 100, 100, -1, 12f);    // draw a white rounded rectangle with corner radius 12 at x=10, y=50 with a width and height of 100
    // do some more drawing
}
```

If Kotlin is being used, the alternative `nanoVG` method can be used. This automatically passes the NanoVG context that is required in Java.

```kotlin
nanoVG {
    drawRoundedRect(10, 50, 100, 100, -1, 12f)
}
```

Make sure to check out the Dokka Javadocs for more information on available methods in NanoVGHelper and RenderManagerDSL.

// todo add hyperlink for javadocs - MoonTidez

## When do I draw?

A great time to draw things on the screen is using the draw() method of [OneUIScreen](https://docs.polyfrost.org/oneconfig/utils/oneuiscreen) in your own GUI screen, or you can use [HudRenderEvent](https://docs.polyfrost.org/oneconfig/events/available-events/hudrenderevent) to draw things on the screen even when the player isn't in a GUI.

## Colors

OneConfig, like many other Java classes such as `java.awt.Color`, use "merged" integers as colors, in ARGB format. See [OneColor](https://docs.polyfrost.org/oneconfig/utils/onecolor) to find out more about how to use these colors and what they are.

## Images

OneConfig's NanoVGHelper also has methods to allow you to draw images - even straight from the internet!

These images use accurate scaling methods and antialiasing so you can draw them at virtually any size. Also, if you want, you can use OneConfig's internal enums SVGs and Images to draw icons and things you already see inside the OneConfig GUI:

```java
NanoVGHelper.INSTANCE.drawText(vg, "There is are images below this, and THE DAILY MAIL????", 10, 40, -1, 10, Fonts.REGULAR); // by the way, we go over font rendering in another page
NanoVGHelper.INSTANCE.drawSvg(vg, SVGs.ONECONFIG, 10, 50, 100, 200);
NanoVGHelper.INSTANCE.drawImage(vg, "https://i.dailymail.co.uk/1s/2021/07/29/20/46061771-0-image-a-349_1627585586527.jpg", 10, 50, 100, 200);
```

Please note that this can only render .jpg, .png and .svg files.

## Info Icons

OneConfig also has a handy way to draw info icons to alert the user to various things.

There are 4 types, INFO, WARNING, ERROR, and SUCCESS. You can draw them just like any other thing using NanoVGHelper.

`NanoVGHelper.INSTANCE.drawInfo(vg, InfoType.WARNING, 10, 50, 50f);`

This will draw a warning info icon at x=10 and y=50 with a size of 50px. Simple!


# Font Rendering

Rendering text using OneConfig

## Drawing Text

If you would like to display some text on the screen, you can use the various drawText methods of the `NanoVGHelper`. A list of these can be found on the Dokka docs. These methods work exactly the same as other draw methods to keep it simple:

```java
NanoVGHelper.INSTANCE.setupAndDraw((vg) -> {
    // draw Hi! at x=10 y=50 in white (-1), at 12px size in Inter Regular
    NanoVGHelper.INSTANCE.drawText(vg, "Hi!", 10, 50, -1, 12f, Fonts.REGULAR);
    
    // draw a string formatted like a URL (blue with underline) at x=10 y=50
    // which can be clicked and hovered
    NanoVGHelper.INSTANCE.drawUrl(vg, "https://www.youtube.com/watch?v=dQw4w9WgXcQ", 10, 50, 12f, Fonts.REGULAR);
    
    // draw some wrapped text at x=10 y=50 in white (-1), at 12px in Inter Regular
    // which wraps onto the next line if the line is more than 100px long
    NanoVGHelper.INSTANCE.drawWrappedText(vg, "Never gonna give you up; never gonna let you down", 10, 50, 100, -1, 12f, Fonts.REGULAR);
}
```

You can even use your own font by creating a custom `Font` object:

```java
// create the font object
public static final Font inter = new Font("inter", "/path/to/font/file.ttf");

public void draw(long vg, int x, int y) {
    // draw Hi! in your font you chose
    NanoVGHelper.INSTANCE.drawText(vg, "Hi!", 10, 50, -1, 12f, inter);
}
```


# Elements

Learn more about the UI elements OneConfig has to offer

OneConfig currently uses a proprietary element system, which is pending a rewrite due to its lack of portability and readability. When we update this to a new system, you will be able to use the components OneConfig has to happen in your own code.

{% hint style="warning" %}
**Warning: We are discouraging you from using the current OneConfig elements found in the** `cc.polyfrost.oneconfig.elements` **package. Once they have been rewritten, these will become publicly available with documentation.**
{% endhint %}


# Pages

Learn more about OneConfig's pages

## What are Pages?

Pages are the name given to the displays inside the OneConfig UI, and they are 1056x728 (1024x696 usable) rectangles of the GUI. All the content of OneConfig is displayed inside this area. They are fully scrollable, and you can even make your own pages if you want!

![OneConfig Page (highlighted in red)](https://3056662043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVPLa0wt84LweTZoNVj4Z%2Fuploads%2Fgit-blob-876e14a821ebfa2e91656d06ac8fe995b6238dac%2Fimage.png?alt=media)

## Custom Pages

Custom pages can be created easily by just extending the Page class, like this:

```java
public class MyPage extends Page {
    public MyPage() {
        super("My Page"); // set the name of the page
    }
    
    public void draw(long vg, int x, int y) {
        // draw script for the page
    }
    
    // SCROLLING
    // if you want it to be scrollable, you can use the following methods:
    public int drawStatic(long vg, int x, int y) {
        // draw elements that are not going to be scrollable
        return 12; // return the height of the elements that are drawn in this method
    }
    
    public int getMaxScrollHeight() {
        return 1240; // return the total length of the page (how far can be scrolled)
    }
```

You can use this in combination with a [Decorative Components](https://docs.polyfrost.org/oneconfig/config/adding-options/decorative-config-components#custom-pages) decorative config component to open the page, so the user can access it with the click of a button!


# Commands

Find out how to create a Command using OneConfig

## Getting Started

To create a new Command, you need to use the `@Command(value = "commandName", decription = "description")` annotation for a class, like this:

```java
@Command(value = ExampleMod.MODID, description = "Just a simple command")
public class ExampleCommand {
```

Simple! Now, you will have a command like `/examplemod`, but the command doesn't do anything yet, lets change that. To create a function for a command, we use the `@Main` annotation, like this:

```java
    @Main
    // ps. this can't have any arguments, sorry :(
    private void main() {
      System.out.println("Hello, World!");
    }
```

Awesome! now `/examplemod` will print in the console `"Hello, World!"`.&#x20;

**But first**, we need to register our command, so OneConfig knows it exists. **Just add this to your main class's init method:**

```java
    // snip!
    CommandManager.register(new ExampleCommand());
    // some more code...
}
```

## Sub Commands

But what about sub commands? They are easy too! We just have to make a new `method` using the `@SubCommand(description = "description")` annotation, and then do the same thing as above, like this:

```java
    // can be static or nonstatic
    @SubCommand(description = "Pongs you", aliases = {"p", "pp"}) // p.s. the args are optional!
    private void ping(String anArg) {
        UChat.chat("Pong!");
        // this command can be accessed by either the method name, or its aliases; e.g:
        // /examplemod ping <arg>, /examplemod p <arg>, /examplemod pp <arg>
        System.out.println("I called with arguement " + anArg);
    }
```

## Sub Command Groups

Imagine a place where you could have sub commands in groups, like `/hello ping pong` and `/hello ping pingpong`. Well, you can! Just create a new nested or inner class, like this:

```java
@Command(value = ExampleMod.MODID, description = "Just a simple command")
public class ExampleCommand {
    // snip!
    
    
    // this specifies the name of the subcommand group, like the @Command annotation
    // specifies the name of the command.
    // with this one, a use could do /examplemod ping, /examplemod pingg, or /examplemod pingu to access this.
    @SubCommandGroup(value = "ping", aliases = {"pingg", "pingu"})
    // can be static, nonstatic
    private class ASubCommandGroup {
        // subcommand groups can have a @main as well!
        // this is called when a user types /examplemod ping 
        @Main
        private void method() {
            UChat.chat("pong!");
        }
        
        @SubCommand()
        private void hi() {
            // accessed with /examplemod ping hi
            System.out.println("hello");
        }
    }
    
}
```

## Using Arguments

Using arguments is simple too! You just add them as normal arguments to a method, like normal Java. Here are some examples demonstrating features of the arguments:

```java
        // snip~
        
        // greedy example
        @SubCommand()
        private void whatDidISay(@Greedy String s) {
            // @Greedy means it will consume itself and all arguements after it.
            // It has to be the last argument on a method (for odvious reasons)
            // so someone could write whatever they want after it. 
            // /examplemod whatDidISay hello I said this cool thing
            UChat.chat("You said: " + s);
        }
        
        // basic example
        @Subcommand(aliases = {"minus"})
        private void subtract(int something, int somethingelse) {
            UChat.chat(something - somethingelse);
        }
        
        // descriptions! (optional, but recommended)
        @SubCommand(description = "Add two numbers.")
        private void add(@Descripton("First number") int a, @Description("Second number") int b) {
            // woah, whats this @Description?
            // @Description allows you to add information about the param to the user in the help message.
            // so, with these descriptors, if a person called /examplemod help:
            
            // Help for /examplemod:
            // (other command help and stuff)
            // /examplemod ping add <First number> <Second number>: Add two numbers.
            
            // would be displayed. Anyways, back to the code.
            UChat.chat("Sum is: " + (a + b));
        }
        
        // autocomplete!
        @SubCommand()
        private void autocompleteDemo(@Descripton(autocompletesTo = {"PLAYER"} String s) {
            System.out.println(s);
            // this command autocompletes to player names in the server right now (cool)
        }
        
        @SubCommand()
        private void anotherDemo(@Descripton(autocompletesTo = {"maybe", "call", "me"} String s) {
            System.out.println(s);
            // this command autocompletes to the list of args given above. ^
            // booleans also have automatic autocompletion for their args :)
        }
```

So, this quick demo hopefully has enlightened you on all the OneConfig command system has to offer. It has a much nicer syntax than brigadier or legacy command handling, and is (almost) just as feature rich! Here is a quick recap:

* Any method will be added as its name if annotated with `@SubCommand`
* Classes or methods can be of any visibility, and static or non-static
* Must be registered using `CommandManager.register(new MyCommand());`
* Descriptions and aliases are displayed in help messages, and it is recommended you describe what each command does, and its arguments, even if it is just naming them.


# An Example Command

For if you are struggling to figure out how it works :)

```java
@Command(value = "oneconfig", aliases = {"ocfg"})
public class OneConfigCommand {

    @Main(description = "Opens the OneConfig GUI")
    private void main() {
        GuiUtils.displayScreen(OneConfigGui.create());
    }

    @SubCommand(description = "Opens the OneConfig HUD configurator.", aliases = {"edithud"})
    private void hud() {
        GuiUtils.displayScreen(new HudGui());
    }

    @SubCommand(description = "Destroy the currently open OneConfig GUI.")
    private void destroy() {
        OneConfigGui.INSTANCE = null;
    }

    @SubCommandGroup(value = "Profile", aliases = {"profiles"})
    private static class Profile {
        @SubCommand(description = "View all profiles", aliases = {"view"})
        private void list() {
            StringBuilder builder = new StringBuilder()
                    .append(ChatColor.GOLD).append("Available profiles:");
            for (String profile : Profiles.getProfiles()) {
                builder.append("\n");
                if (OneConfigConfig.currentProfile.equals(profile)) builder.append(ChatColor.GREEN);
                else builder.append(ChatColor.RED);
                builder.append(profile);
            }
            UChat.chat(builder.toString());
        }

        @SubCommand(description = "Switch to a Profile", aliases = {"enable", "set", "load", "switch"})
        private void switchProfile(@Description("Profile Name") @Greedy String profile) {
            if (!Profiles.doesProfileExist(profile)) {
                UChat.chat(ChatColor.RED + "The Profile \"" + profile + "\" does not exist!");
            } else {
                Profiles.loadProfile(profile);
                UChat.chat(ChatColor.GREEN + "Switched to the \"" + profile + "\" Profile.");
            }
        }

        @SubCommand(description = "Create a new Profile", aliases = {"make"})
        private void create(@Description("Profile Name") @Greedy String profile) {
            if (Profiles.doesProfileExist(profile)) {
                UChat.chat(ChatColor.RED + "The Profile \"" + profile + "\" already exists!");
            } else {
                Profiles.createProfile(profile);
                if (Profiles.doesProfileExist(profile)) Profiles.loadProfile(profile);
                UChat.chat(ChatColor.GREEN + "Created the \"" + profile + "\" Profile.");
            }
        }

        @SubCommand(description = "Rename a Profile")
        private void rename(@Description("Old name") String profile, @Description("New name") @Greedy String newName) {
            if (!Profiles.doesProfileExist(profile)) {
                UChat.chat(ChatColor.RED + "The Profile \"" + profile + "\" does not exist!");
            } else {
                Profiles.renameProfile(profile, newName);
                UChat.chat(ChatColor.GREEN + "Renamed the \"" + profile + "\" Profile to \" " + newName + "\".");
            }
        }

        @SubCommand(description = "Delete a Profile", aliases = {"remove", "destroy"})
        private void delete(@Description("Profile name") @Greedy String profile) {
            if (!Profiles.doesProfileExist(profile)) {
                UChat.chat(ChatColor.RED + "The Profile \"" + profile + "\" does not exist!");
            } else {
                Profiles.deleteProfile(profile);
                UChat.chat(ChatColor.GREEN + "Deleted the \"" + profile + "\" Profile.");
            }
        }
    }
}
```


# HUD Basics

Learn about the HUD system OneConfig has to offer

### What are HUDs?

HUDs are small pieces of information rendered on the player's screen which can display all kinds of things, from images to coordinates. These use an extensive positioning and scaling system built into OneConfig, and this helps us achieve our goal of being able to edit everything for every mod in one place.

OneConfig HUDs are extremely easy to use, with little code needed to create a HUD, and positioning, scaling and everything else handled behind the scenes by OneConfig!

Huds are essentially an extension to the Config system, with a few extra methods, and follow the same syntax for adding additional configuration options to your hud, using annotated fields. (see [Creating a Config](https://docs.polyfrost.org/oneconfig/config/creating-a-config))

### Creating a HUD

To create a HUD, all you have to do is extend the class you would like. OneConfig by default has SingleTextHud and TextHud for premade, text only HUDs. These are purely convenience classes which offer an easier way for the most common type of HUD.

This guide will focus on creating a simple HUD that extends SingleTextHud, but if you want to create a more advanced HUD, you should use the BasicHud class instead.

```java
public class MyHud extends SingleTextHud {
    // you can use this to add additional saved config values to your HUD class,
    // just like a normal config.
    int times = 0;
    @Switch(
            name = "Custom Option"
    )
    public boolean yes;
    

    public MyHud() {
        // this is the name of the HUD as shown in the config,
        // and if it is enabled by default
        super("Time", true);
    }

    // this method is called every ingame tick. It is used to update the text shown
    // on the hud. If you need to update this every render tick, you can override
    // getTextFrequent() instead (not recommended)
    @Override
    public String getText(boolean example) {
        // example determines whether or not the HUD is in 'example' mode, which
        // means the user has the Edit HUD screen open. This should ideally be static
        // so that it does not change while the user is moving around their huds,
        // and should give an accurate representation of how the hud will look ingame. 
        if(example) return "I'm in Example mode";
        times++;
        return String.valueOf(times);
    }
}
```

For more information on how to create more advanced HUDs, and to see the wealth of methods that the BasicHud has to offer, make sure to checkout its javadocs, and the [test.huds package of OneConfig.](https://github.com/Polyfrost/OneConfig/tree/master/versions/src/main/java/cc/polyfrost/oneconfig/test/huds)

### Using a HUD

Now you have created a HUD class, you can use it by adding it as a field to your main config class, with the @HUD annotation, just like this:

```java
@HUD(
        name = "Test HUD",
        category = "HUD"
)
public MyHud hud = new MyHud();
```

Simple right? I hope this has given you a basic understanding of how HUDs work in OneConfig, and why they are useful and how powerful they are to use!


# OneConfig's Utilities

Learn more about the various utilities OneConfig has to offer

OneConfig has many utilities to make your life as a developer easier! From Multi-threading to Profiling, OneConfig really does have it all! All these utilities can be found in `cc.polyfrost.oneconfig.utils`.<br>

### Here is a short summary of all the utilities available in OneConfig: <a href="#all" id="all"></a>

* InputHandler - various utilities to do with mouse input, including click and hover detection, scaling, and blocking areas of the screen from being clicked.
* IOUtils - utilities for copying and pasting strings and BufferedImages, checksums, and getting data from the internet or files
* JsonUtils - utilities for gson parsing of Strings
* LogScanner - features for detecting what class called a method, and blaming other files/mods for stack traces
* Multithreading - utilities for asynchronous running of code in thread pools.
* NetworkUtils - utilitites for getting JSON files, raw strings, and opening the browser of the client.
* SimpleProfiler - a simple class for profiling how long code takes to execute
* StringUtils - a collection of utilities related to sub-sequencing strings in a safe way
* TickDelay - a simple utility for delaying execution of some code by a certain amount of ticks
* ColorUtils - a collection of utilities for getting and setting components of a 32bit int color
* **Commands -** [**see here**](https://docs.polyfrost.org/oneconfig/commands/commands)
* **Notifications -** [**see here**](https://docs.polyfrost.org/oneconfig/utils/oneconfigs-utilities/notifications)
* **HypixelUtils -** [**see here**](https://docs.polyfrost.org/oneconfig/utils/oneconfigs-utilities/hypixelutils)

### Kotlin DSLs <a href="#dsls" id="dsls"></a>

OneConfig also uses Kotlin's meta-programming features to enable these utilities to be used in a more handy way with a much tighter syntax, such as StringUtils and ColorUtils. I'm sure you will be familiar with them if you are a Kotlin enjoyer :)


# Notifications

More information on the Notifications system of OneConfig

OneConfig has an extensive notifications system which you can use to inform the player of various events that have happened, for example how much EXP they have just got from a game.&#x20;

They support click actions, text, progress bars, and animations to make them look pretty and functional for your code, plus they can be queued!

For even more information, you can check out the javadocs for the Notifications class.


# HypixelUtils

A more detailed look into the HypixelUtils that OneConfig has

OneConfig has a collection of Hypixel-orientated utilities, most notably for the locraw system that Hypixel offers. Credit to [Seraph](https://github.com/Scherso/Seraph) for allowing us to include it in OneConfig!

These utilities work by sending the `/locraw` command when the client is detected to be on the Hypixel server. This then allows you to get various information on what server, what map, and what gamemode the player is in.

### LocrawInfo <a href="#locraw" id="locraw"></a>

LocrawInfo is the name of the class given to the information gathered from the locraw message. It contains the following information:

* Server ID, e.g. mini121
* Gamemode, for example eight\_two for Doubles BedWars
* Game type, for example SKYWARS for SkyWars
* Map name, such as Shire


# OneColor

Learn more about OneColor, OneConfig's way of processing colors

## Why?

OneColor exists for many reasons.

Firstly, there are limitations when converting RGB to HSB and vice versa. We wanted to have HSB color selectors because they are much more usable than a few RGB sliders. Rendering uses ARGB though, so we have to convert! This means multiple conversions for RGB to HSB every tick, and there can be miscalculations with this.

Secondly, we wanted to have a more lightweight alternative to `java.awt.Color`. While it's not bad for performance, it contains a lot of code that isn't strictly necessary, so we built a more lightweight alternative. There are many similarities to `Color` in terms of methods and language for parity, but they are different under the hood.

Lastly, we wanted to support chroma **natively.** So, we have a data bit, which controls the speed of the chroma, along with favorites, and the `getRGB()` methods will return these chroma colors instantly.

So, in a nutshell, we made OneColor for performance and accuracy.

## OneColor's structure

OneColor stores color as a `short[]` array, creating an `int rgba` every time the color is changed (upon instantiation). They are used with the @Color Config element, are used widely throughout OneConfig's codebase and are fully integrated with `java.awt.Color` and [Broken mention](broken://pages/hxX0ZbMjcsbU2S2xUhAg).

```java
short hue = 240;          // hue of the color (0-360)
short saturation = 50;    // saturation of the color (0-100)
short brightness = 25;    // brightness of the color (0-100)
short alpha = 255;        // alpha of the color (0-255)

int argb = -38279103;    // the color stored as ARGB merged integer (used for rendering)

// how ARGB is made (hexadecimal):
// 0xFF000000 alpha (0-FF)
// 0x00FF0000 red (0-FF)
// 0x0000FF00 blue (0-FF)
// 0x000000FF green (0-FF)
// when merged with bitshifts, it will return the color as an integer like above.
```

## Creating a OneColor

Creating a OneColor is very easy! Here are some of the methods you can use:

```java
public OneColor color = new OneColor(int red, int green, int blue, int alpha);
public OneColor color = new OneColor(int red, int green, int blue);
public OneColor color = new OneColor(float hue, float saturation, float brightness, float alpha);
public OneColor color = new OneColor(float hue, float saturation, float brightness);
public OneColor color = new OneColor(java.awt.Color);
public OneColor color = new OneColor(int argb);
```

## Hex

OneColor also has full support for hex strings. You can create a OneColor from a parsed hex, or get the hex of a OneColor easily.

The hex parser has **auto-completion features**, and supports a variety of hexes even if they are malformed:

* If the hex is less than 6 characters, 0s are appended.
* If the hex is 3 characters long, it is understood as a 3-digit RGB hex and is repeated appropriately.
  * E.g. CF2 -> CCFF22.
* If the hex is 1 character long, it is repeated across the R, G and B fields.
  * E.g. C -> CCCCCC.
* The alpha will be fetched from the hex color if it is 8 characters long (RRGGBBAA).


# OneUIScreen

OneConfig's easy to use, multiplatform GuiScreen alternative

## Why?

OneUIScreen is a convenient class that can be used for easy handling of mouse, keyboard, and rendering with NanoVG (see [Broken mention](broken://pages/N2Gvbih0Phu7KFxrJKpc)).

## Creating a OneUIScreen

Creating a OneUIScreen is simple - just extend the class, like so:

```java
public class MyScreen extends OneUIScreen {
    public MyScreen() {
        super();        // constructor for your screen - you can initialize things here as well
    }

    @Override
    public void initScreen(int width, int height) {
        super.initScreen(width, height);
        // setup variables, initialize components, etc.
    }       

    @Override
    public void draw(long vg, float partialTicks) {
        // draw script for the screen with a NanoVG context already prepared
        RenderManager.drawRoundedRect(10,50,100,100,-1,12f);
        // You can also use partialTicks for animations as a deltaTime.

    @Override
    public void onScreenClose() {
        // clean up, etc. when the screen closes.
    }
```

## Displaying Your Screen

You can Display your screen in many ways, for example using a [Buttons, Colors and Keybinds](https://docs.polyfrost.org/oneconfig/config/adding-options/buttons-colors-and-keybinds#button) implementation, or opening it when a key is pressed using a OneKeyBind. They can be opened easily using `GuiUtils.displayScreen(new MyScreen())`.


