Skip to content

Commit 2b06b39

Browse files
authored
feat: Add author field to RunConfig (#313)
* Update RunConfig.java * Update runConfig.json * Update RunConfig.java * fix: authorList * Revert runConfig
1 parent f828d45 commit 2b06b39

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

examples/runConfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"packName": "GroovyScript Dev",
33
"packId": "groovyscriptdev",
4+
"author": "GroovyScript, Dev, Author",
45
"version": "1.0.0",
56
"debug": true,
67
"loaders": {

src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.minecraft.util.ResourceLocation;
1616
import net.minecraftforge.fml.common.Loader;
1717
import net.minecraftforge.fml.common.ModMetadata;
18+
import org.apache.commons.lang3.StringUtils;
1819
import org.apache.commons.lang3.tuple.Pair;
1920
import org.jetbrains.annotations.ApiStatus;
2021

@@ -29,6 +30,7 @@ public static JsonObject createDefaultJson() {
2930
JsonObject json = new JsonObject();
3031
json.addProperty("packName", "PlaceHolder name");
3132
json.addProperty("packId", "placeholdername");
33+
json.addProperty("author", "Placeholder, author");
3234
json.addProperty("version", "1.0.0");
3335
json.addProperty("debug", false);
3436
JsonObject loaders = new JsonObject();
@@ -61,6 +63,7 @@ public static JsonObject createDefaultJson() {
6163

6264
private final String packName;
6365
private final String packId;
66+
private final String packAuthor;
6467
private final String version;
6568
private final Map<String, List<String>> loaderPaths = new Object2ObjectOpenHashMap<>();
6669
private final List<String> packmodeList = new ArrayList<>();
@@ -91,12 +94,19 @@ public RunConfig(JsonObject json) {
9194
name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, id).replace('_', ' ');
9295
}
9396
this.packName = name;
97+
this.packAuthor = JsonHelper.getString(json, "", "packAuthor", "author");
9498
this.packId = id;
9599
this.version = JsonHelper.getString(json, "1.0.0", "version", "ver");
96100
modMetadata.modId = this.packId;
97101
modMetadata.name = this.packName;
98102
modMetadata.version = this.version;
99103
modMetadata.parent = GroovyScript.ID;
104+
modMetadata.authorList.addAll(
105+
Arrays.stream(StringUtils.split(this.packAuthor, ","))
106+
.map(String::trim)
107+
.filter(s -> !s.isEmpty())
108+
.collect(Collectors.toList())
109+
);
100110
}
101111

102112
@ApiStatus.Internal

0 commit comments

Comments
 (0)