Compare commits
13
Commits
1.0.8-1.17
...
1.1.0-1.17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24c0d9a039 | ||
|
|
6db4f12eed | ||
|
|
6ed97d4e00 | ||
|
|
3ecbae5593 | ||
|
|
d15fcd0732 | ||
|
|
bd2cc57eb9 | ||
|
|
539d3ee1af | ||
|
|
ebfaac9fb9 | ||
|
|
fbc0a2b354 | ||
|
|
3da79e7860 | ||
|
|
228c1bb7e6 | ||
|
|
e09f903332 | ||
|
|
1fe4d53565 |
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
# Done to increase the memory available to gradle.
|
# Done to increase the memory available to gradle.
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx2G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://fabricmc.net/versions.html
|
||||||
minecraft_version=1.17
|
minecraft_version=1.17
|
||||||
yarn_mappings=1.17+build.7
|
yarn_mappings=1.17+build.7
|
||||||
loader_version=0.11.3
|
loader_version=0.11.3
|
||||||
@@ -9,6 +9,6 @@ loader_version=0.11.3
|
|||||||
#Fabric api
|
#Fabric api
|
||||||
fabric_version=0.34.10+1.17
|
fabric_version=0.34.10+1.17
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.8
|
mod_version=1.1.0
|
||||||
maven_group=draylar
|
maven_group=draylar
|
||||||
archives_base_name=omega-config
|
archives_base_name=omega-config
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -23,7 +23,12 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class OmegaConfig {
|
public class OmegaConfig {
|
||||||
|
|
||||||
@@ -109,10 +114,9 @@ public class OmegaConfig {
|
|||||||
addFieldComments(field, keyToComments);
|
addFieldComments(field, keyToComments);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get inner-class fields
|
// "flattens" all the inner classes of the Config class into a single list
|
||||||
// TODO: recursively get inner classes?
|
for (Class<?> clazz : flatten(configClass.getDeclaredClasses())) {
|
||||||
for (Class<?> innerClass : configClass.getDeclaredClasses()) {
|
for (Field field : clazz.getDeclaredFields()) {
|
||||||
for (Field field : innerClass.getDeclaredFields()) {
|
|
||||||
addFieldComments(field, keyToComments);
|
addFieldComments(field, keyToComments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,14 +124,18 @@ public class OmegaConfig {
|
|||||||
// Find areas we should insert comments into...
|
// Find areas we should insert comments into...
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
String at = lines.get(i);
|
String at = lines.get(i);
|
||||||
|
String startingWhitespace = getStartingWhitespace(at);
|
||||||
|
|
||||||
// Check if we should insert comment
|
|
||||||
for (Map.Entry<String, String> entry : keyToComments.entrySet()) {
|
for (Map.Entry<String, String> entry : keyToComments.entrySet()) {
|
||||||
String key = entry.getKey();
|
|
||||||
String comment = entry.getValue();
|
String comment = entry.getValue();
|
||||||
|
// Check if we should insert comment
|
||||||
if (at.trim().startsWith(String.format("\"%s\"", key))) {
|
if (at.trim().startsWith(String.format("\"%s\"", entry.getKey()))) {
|
||||||
insertions.put(i + insertions.size(), String.format("%s//%s", getStartingWhitespace(at), comment));
|
if (comment.contains("\n")) {
|
||||||
|
comment = startingWhitespace + "//" + String.join(String.format("\n%s//", startingWhitespace), comment.split("\n"));
|
||||||
|
} else {
|
||||||
|
comment = String.format("%s//%s", startingWhitespace, comment);
|
||||||
|
}
|
||||||
|
insertions.put(i + insertions.size(), comment);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,6 +162,28 @@ public class OmegaConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<Class<?>> flatten(Class<?>[] array) {
|
||||||
|
List<Class<?>> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Class<?> clazz : array) {
|
||||||
|
populateRecursively(list, clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void populateRecursively(List<Class<?>> list, Class<?> aClass) {
|
||||||
|
list.add(aClass);
|
||||||
|
|
||||||
|
Class<?>[] classes = aClass.getDeclaredClasses();
|
||||||
|
|
||||||
|
if (classes.length != 0) {
|
||||||
|
for (Class<?> clazz : classes) {
|
||||||
|
populateRecursively(list, clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void addFieldComments(Field field, Map<String, String> keyToComments) {
|
private static void addFieldComments(Field field, Map<String, String> keyToComments) {
|
||||||
String fieldName = field.getName();
|
String fieldName = field.getName();
|
||||||
Annotation[] annotations = field.getDeclaredAnnotations();
|
Annotation[] annotations = field.getDeclaredAnnotations();
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
"Draylar",
|
"Draylar",
|
||||||
"Frqnny"
|
"Frqnny"
|
||||||
],
|
],
|
||||||
"contact": {},
|
"contact": {
|
||||||
|
"homepage": "https://github.com/Draylar/omega-config",
|
||||||
|
"sources": "https://github.com/Draylar/omega-config",
|
||||||
|
"issues": "https://github.com/Draylar/omega-config/issues"
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
@@ -18,5 +22,10 @@
|
|||||||
"fabricloader": "*",
|
"fabricloader": "*",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "*"
|
"minecraft": "*"
|
||||||
}
|
},
|
||||||
|
"custom": {
|
||||||
|
"modmenu": {
|
||||||
|
"badges": [ "library" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
"Draylar"
|
"Draylar"
|
||||||
],
|
],
|
||||||
"contact": {},
|
"contact": {
|
||||||
|
"homepage": "https://github.com/Draylar/omega-config",
|
||||||
|
"sources": "https://github.com/Draylar/omega-config",
|
||||||
|
"issues": "https://github.com/Draylar/omega-config/issues"
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
@@ -17,5 +21,10 @@
|
|||||||
"fabricloader": "*",
|
"fabricloader": "*",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "*"
|
"minecraft": "*"
|
||||||
}
|
},
|
||||||
|
"custom": {
|
||||||
|
"modmenu": {
|
||||||
|
"badges": [ "library" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package draylar.omegatest;
|
|||||||
|
|
||||||
import draylar.omegaconfig.OmegaConfig;
|
import draylar.omegaconfig.OmegaConfig;
|
||||||
import draylar.omegatest.config.ClassConfigTest;
|
import draylar.omegatest.config.ClassConfigTest;
|
||||||
|
import draylar.omegatest.config.CommentedNestedClassConfig;
|
||||||
import draylar.omegatest.config.NestedConfigTest;
|
import draylar.omegatest.config.NestedConfigTest;
|
||||||
import draylar.omegatest.config.SimpleConfigTest;
|
import draylar.omegatest.config.SimpleConfigTest;
|
||||||
import draylar.omegatest.config.StructuresConfigTest;
|
import draylar.omegatest.config.StructuresConfigTest;
|
||||||
@@ -13,6 +14,7 @@ public class OmegaTestMain implements ModInitializer {
|
|||||||
public static final StructuresConfigTest MO_CONFIG = OmegaConfig.register(StructuresConfigTest.class);
|
public static final StructuresConfigTest MO_CONFIG = OmegaConfig.register(StructuresConfigTest.class);
|
||||||
public static final NestedConfigTest NESTED = OmegaConfig.register(NestedConfigTest.class);
|
public static final NestedConfigTest NESTED = OmegaConfig.register(NestedConfigTest.class);
|
||||||
public static final ClassConfigTest CLASS = OmegaConfig.register(ClassConfigTest.class);
|
public static final ClassConfigTest CLASS = OmegaConfig.register(ClassConfigTest.class);
|
||||||
|
public static final CommentedNestedClassConfig COMMENTED_NESTED_CLASS = OmegaConfig.register(CommentedNestedClassConfig.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package draylar.omegatest.config;
|
||||||
|
|
||||||
|
import draylar.omegaconfig.api.Comment;
|
||||||
|
import draylar.omegaconfig.api.Config;
|
||||||
|
|
||||||
|
public class CommentedNestedClassConfig implements Config {
|
||||||
|
|
||||||
|
@Comment("Very nested test")
|
||||||
|
public First first = new First();
|
||||||
|
|
||||||
|
@Comment("True")
|
||||||
|
public boolean test = false;
|
||||||
|
|
||||||
|
@Comment("First-Level")
|
||||||
|
public VeryNested veryNested = new VeryNested();
|
||||||
|
|
||||||
|
public static class First {
|
||||||
|
@Comment("Cucumbers")
|
||||||
|
public boolean cucumbers = true;
|
||||||
|
|
||||||
|
@Comment("InnerFirst")
|
||||||
|
public InnerFirst innerFirst = new InnerFirst();
|
||||||
|
|
||||||
|
@Comment("InnerSecond")
|
||||||
|
public InnerSecond innerSecond = new InnerSecond();
|
||||||
|
|
||||||
|
public static class InnerFirst {
|
||||||
|
@Comment("Number of Tomatoes")
|
||||||
|
public int numberOfTomatoes = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InnerSecond {
|
||||||
|
@Comment("Inner Second First")
|
||||||
|
public InnerSecondFirst innerSecondFirst = new InnerSecondFirst();
|
||||||
|
|
||||||
|
public static class InnerSecondFirst {
|
||||||
|
@Comment("Olive Oil")
|
||||||
|
public String oliveOil = "oliveOil";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VeryNested {
|
||||||
|
@Comment("Second-Level")
|
||||||
|
public Very very = new Very();
|
||||||
|
public static class Very {
|
||||||
|
@Comment("Third-Level")
|
||||||
|
public VeryVery veryVery = new VeryVery();
|
||||||
|
public static class VeryVery {
|
||||||
|
@Comment("Forth-Level")
|
||||||
|
public VeryVeryVery veryVeryVery = new VeryVeryVery();
|
||||||
|
public static class VeryVeryVery {
|
||||||
|
@Comment("Fifth-Level")
|
||||||
|
public VeryVeryVeryVery veryVeryVeryVery = new VeryVeryVeryVery();
|
||||||
|
public static class VeryVeryVeryVery {
|
||||||
|
@Comment("Sixth-Level")
|
||||||
|
public String last = "last";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "commented-inner-classes";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExtension() {
|
||||||
|
return "json5";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,16 +13,16 @@ public class StructuresConfigTest implements Config {
|
|||||||
|
|
||||||
@Comment("""
|
@Comment("""
|
||||||
Welcome to Mo'Structures Config!
|
Welcome to Mo'Structures Config!
|
||||||
//
|
|
||||||
// Here, you can turn off structures, change their chance, and also change their salt.
|
Here, you can turn off structures, change their chance, and also change their salt.
|
||||||
//
|
|
||||||
// To turn off a structure, simply go to the corresponding entry and set `activated` to false.
|
To turn off a structure, simply go to the corresponding entry and set `activated` to false.
|
||||||
//
|
|
||||||
// Mo' Structures uses the vanilla structure spawning system. That is-
|
Mo' Structures uses the vanilla structure spawning system. That is-
|
||||||
// - Seperation is the minimum chunks between structures
|
- Seperation is the minimum chunks between structures
|
||||||
// - Spacing is the average chunks between structures
|
- Spacing is the average chunks between structures
|
||||||
//
|
|
||||||
// Salt is a special field that gives structures unique spawning positions. DO NOT TOUCH IT, ONLY ADVANCED TROUBLESHOOTING!
|
Salt is a special field that gives structures unique spawning positions. DO NOT TOUCH IT, ONLY ADVANCED TROUBLESHOOTING!
|
||||||
|
|
||||||
""")
|
""")
|
||||||
public final Map<String, StructureConfigEntry> structureConfigEntries = new HashMap<>(17);
|
public final Map<String, StructureConfigEntry> structureConfigEntries = new HashMap<>(17);
|
||||||
|
|||||||
Reference in New Issue
Block a user