Compare commits

...
Author SHA1 Message Date
DraylarandGitHub 239ec7c3bc 1.2.3 version bump 2022-01-18 11:14:38 -06:00
DraylarandGitHub 0f0abe558e Merge pull request #12 from Luligabi1/1.18
Better config screen title
2022-01-18 11:14:04 -06:00
Luligabi1 5bdce25e29 OmegaConfigGui's generated config screen now has a TranslatableText for its title rather than a LiteralText.q 2021-12-28 15:07:41 -03:00
frqnny 9d7aa7581d Automated fabric mod json version
Closes #11
2021-12-28 10:58:42 -05:00
Draylar 8611edb92c update README 2021-12-20 18:38:58 -06:00
6 changed files with 78 additions and 9 deletions
+67 -2
View File
@@ -7,9 +7,10 @@
ΩConfig is a hyper-minimal config library based on [Auto Config](https://github.com/shedaniel/AutoConfig). It aims to ΩConfig is a hyper-minimal config library based on [Auto Config](https://github.com/shedaniel/AutoConfig). It aims to
achieve the following goals: achieve the following goals:
- Be lightweight (<10 KB) for JIJ usage - Be lightweight (<25 KB) for JIJ usage
- Exceedingly simple design & API for developers - Exceedingly simple design & API for developers
- Intuition and usability for players - Intuition and usability for players
- Bonus annotations for advanced config options (syncing values)
The following is an example of a simple ΩConfig setup: The following is an example of a simple ΩConfig setup:
@@ -39,6 +40,67 @@ public class MyModInitializer {
} }
``` ```
Looking for a simple config screen? Talk about easy!
```java
public class ClientInitializer implements ClientModInitializer {
@Override
public void onInitializeClient() {
// Make sure you implement getModid in your config class!
OmegaConfigGui.registerConfigScreen(MainInitializer.CONFIG);
}
}
```
---
### Pulling Omega Config into Development
To use Omega Config, you will have to add it to your build.gradle file.
What you pull in depends on whether you want GUI functionality. For basic config files using the base module (~20KB),
you can use the following gradle declarations:
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
include("com.github.Draylar.omega-config:omega-config-base:${project.omega_config_version}")
modImplementation("com.github.Draylar.omega-config:omega-config-base:${project.omega_config_version}")
}
```
Easy - you now have a bundled configuration library. Use the examples in the first section to implement your config.
If you want to add GUI functionality (most likely Mod Menu support), you can pull in the GUI module (~25 KB):
```groovy
repositories {
...
// Needed to retrieve Cloth Config Lite for Omega Config in development environments.
maven {
name = "Shedaniel's Maven"
url = "https://maven.shedaniel.me/"
}
// Optional dependency for Mod Menu - recommended for viewing your screen in development
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/releases/"
}
}
dependencies {
... (including the base declarations)
include("com.github.Draylar.omega-config:omega-config-gui:${project.omega_config_version}")
modImplementation("com.github.Draylar.omega-config:omega-config-gui:${project.omega_config_version}")
modRuntimeOnly ("com.terraformersmc:modmenu:${project.modmenu_version}") // 3.0.1 for 1.18.1
}
```
--- ---
### Extra API Utilities ### Extra API Utilities
@@ -52,8 +114,11 @@ MyModInitializer.CONFIG.value=false;
MyModInitializer.CONFIG.save(); // writes the new value to disk MyModInitializer.CONFIG.save(); // writes the new value to disk
``` ```
**@Syncing** - *configuration options marked with this annotation will automatically sync to the client when they join a server.*
--- ---
### License ### License
ΩConfig is available under Public Domain. You are encouraged to utilize the code in this repository in any way you wish. ΩConfig is available under MIT. Omega Config will bundle the MIT license inside the jar you pull as a dependency, which means you can distribute it as a bundled dependency without any additional steps.
+4 -4
View File
@@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx2G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/versions.html # check these on https://fabricmc.net/versions.html
minecraft_version=1.18.1 minecraft_version=1.18.1
yarn_mappings=1.18.1+build.2 yarn_mappings=1.18.1+build.12
loader_version=0.12.11 loader_version=0.12.12
#Fabric api #Fabric api
fabric_version=0.44.0+1.18 fabric_version=0.45.0+1.18
# Mod Properties # Mod Properties
mod_version=1.2.1 mod_version=1.2.3
maven_group=draylar maven_group=draylar
archives_base_name=omega-config archives_base_name=omega-config
@@ -1,7 +1,7 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"id": "omega-config", "id": "omega-config",
"version": "1.1.0", "version": "${version}",
"name": "OmegaConfig", "name": "OmegaConfig",
"description": "The last config solution you will ever use.", "description": "The last config solution you will ever use.",
"authors": [ "authors": [
+1 -1
View File
@@ -17,7 +17,7 @@ dependencies {
modCompileOnly ("com.terraformersmc:modmenu:${project.modmenu_version}") { modCompileOnly ("com.terraformersmc:modmenu:${project.modmenu_version}") {
transitive(false) transitive(false)
} }
modRuntime ("com.terraformersmc:modmenu:${project.modmenu_version}") { modRuntimeOnly ("com.terraformersmc:modmenu:${project.modmenu_version}") {
transitive(false) transitive(false)
} }
@@ -10,6 +10,7 @@ import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@@ -55,7 +56,7 @@ public class OmegaConfigGui {
return parent -> { return parent -> {
try { try {
Config defaultConfig = config.getClass().getDeclaredConstructor().newInstance(); Config defaultConfig = config.getClass().getDeclaredConstructor().newInstance();
ConfigScreen screen = ConfigScreen.create(new LiteralText(config.getName()), parent); ConfigScreen screen = ConfigScreen.create(new TranslatableText(String.format("config.%s.%s", config.getModid(), config.getName())), parent);
// Fields // Fields
for (Field field : config.getClass().getDeclaredFields()) { for (Field field : config.getClass().getDeclaredFields()) {
@@ -0,0 +1,3 @@
{
"config.omega-config-test.test-config": "Omega Config - Test Config"
}