Compare commits

...
16 Commits
Author SHA1 Message Date
DraylarandGitHub a3cde2c8e7 JDK17 for JitPack.yml on 1.18 2021-12-13 20:39:14 -06:00
DraylarandGitHub 6fa8e58665 Merge pull request #7 from Luligabi1/1.17
Updates to 1.18.1
2021-12-13 20:37:46 -06:00
Luligabi1 ed4e9f6c19 Updates to 1.18.1 2021-12-11 15:09:18 -03:00
DraylarandGitHub 24c0d9a039 Version bump to 1.1.0 2021-12-09 00:13:32 -06:00
DraylarandGitHub 6db4f12eed Merge pull request #6 from RDKRACZ/patch-1
Add "library" badge for ModMenu; Add contact tags to the fabric.mod.json file.
2021-12-09 00:13:04 -06:00
DraylarandGitHub 6ed97d4e00 Merge pull request #4 from alkyaly/fix/comments-in-nested-classes
Fixes comments not applying when inside nested classes.
2021-12-09 00:11:55 -06:00
DraylarandGitHub 3ecbae5593 Merge pull request #5 from alkyaly/fix/multiline
Fixes multi-line comments breaking
2021-12-09 00:11:44 -06:00
K0RRandGitHub d15fcd0732 Update gradle.properties 2021-09-09 12:42:47 +02:00
K0RRandGitHub bd2cc57eb9 Update fabric.mod.json 2021-08-18 13:20:55 +02:00
K0RRandGitHub 539d3ee1af Update gradle-wrapper.properties 2021-08-18 13:18:37 +02:00
adrianoy ebfaac9fb9 Add multiline comments more sensibly... 2021-08-10 01:21:53 -03:00
K0RRandGitHub fbc0a2b354 Add "library" badge for ModMenu; Add contact tags to the fabric.mod.json file.
>It aims to achieve the following goals:
Be lightweight (<10 KB) for JIJ usage

It's 15 KB already :)
2021-08-04 20:18:04 +02:00
adrianoy 3da79e7860 Fixes multi-line comments breaking 2021-07-28 03:38:36 -03:00
adrianoy 228c1bb7e6 This check does nothing. 2021-07-25 23:54:52 -03:00
adrianoy e09f903332 oops. 2021-07-25 22:21:02 -03:00
adrianoy 1fe4d53565 Makes comments apply when inside nested classes of nested classes. 2021-07-25 22:20:35 -03:00
11 changed files with 171 additions and 47 deletions
+9 -10
View File
@@ -14,7 +14,7 @@ buildscript {
} }
plugins { plugins {
id "fabric-loom" version "0.8-SNAPSHOT" id "fabric-loom" version "0.10-SNAPSHOT"
id "maven-publish" id "maven-publish"
id "java-library" id "java-library"
} }
@@ -154,8 +154,9 @@ allprojects {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modRuntime "com.terraformersmc:modmenu:2.0.0-beta.4"
modCompileOnly "com.terraformersmc:modmenu:2.0.0-beta.4" modRuntimeOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
} }
} }
@@ -209,10 +210,10 @@ repositories {
} }
dependencies { dependencies {
implementation project(":omega-config-base") implementation project(path: ":omega-config-base", configuration: "namedElements")
implementation project(":omega-config-gui") implementation project(path: ":omega-config-gui", configuration: "namedElements")
modRuntime "com.terraformersmc:modmenu:1.16.8" modRuntimeOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
modCompileOnly "com.terraformersmc:modmenu:1.16.8" modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
afterEvaluate { afterEvaluate {
testmodImplementation sourceSets.main.output testmodImplementation sourceSets.main.output
@@ -222,9 +223,7 @@ dependencies {
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
artifact(file("${project.buildDir}/libs/${archivesBaseName}-${project.mod_version}.jar")) { from components.java
builtBy(remapJar)
}
pom.withXml { pom.withXml {
def depsNode = asNode().appendNode("dependencies") def depsNode = asNode().appendNode("dependencies")
+9 -7
View File
@@ -1,14 +1,16 @@
# 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.18.1
yarn_mappings=1.17+build.7 yarn_mappings=1.18.1+build.2
loader_version=0.11.3 loader_version=0.12.11
#Fabric api #Fabric api
fabric_version=0.34.10+1.17 fabric_version=0.44.0+1.18
# 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
modmenu_version=3.0.0
+1 -1
View File
@@ -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.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
+1 -1
View File
@@ -1,4 +1,4 @@
before_install: before_install:
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
- source install-jdk.sh --feature 16 - source install-jdk.sh --feature 17
- jshell --version - jshell --version
@@ -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();
@@ -1,14 +1,18 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"id": "omega-config", "id": "omega-config",
"version": "1.0.8", "version": "1.1.0",
"name": "OmegaConfig", "name": "OmegaConfig",
"description": "The last config solution you will ever use.", "description": "The last config solution you will ever use.",
"authors": [ "authors": [
"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" ]
}
}
} }
@@ -114,7 +114,7 @@ public class OmegaConfigScreen<T extends Config> extends Screen {
@Override @Override
public void onClose() { public void onClose() {
client.openScreen(parent); client.setScreen(parent);
} }
@Override @Override
@@ -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);