Skip to content

feat: Add author field to RunConfig #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/runConfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"packName": "GroovyScript Dev",
"packId": "groovyscriptdev",
"author": "GroovyScript, Dev, Author",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be an array - ["GroovyScript", "Dev", "Author"]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I would like to see it as a regular string, and then inside it is parsed as needed for modMetadata, like the curseforge manifest, pakku
Screenshot_633

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats CurseForge's format - for mods, in the mcmod.info the relevant element is authorList, an array. this is creating a mod, and so it should be an array.

"version": "1.0.0",
"debug": true,
"loaders": {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModMetadata;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.ApiStatus;

Expand All @@ -29,6 +30,7 @@ public static JsonObject createDefaultJson() {
JsonObject json = new JsonObject();
json.addProperty("packName", "PlaceHolder name");
json.addProperty("packId", "placeholdername");
json.addProperty("author", "Placeholder, author");
json.addProperty("version", "1.0.0");
json.addProperty("debug", false);
JsonObject loaders = new JsonObject();
Expand Down Expand Up @@ -61,6 +63,7 @@ public static JsonObject createDefaultJson() {

private final String packName;
private final String packId;
private final String packAuthor;
private final String version;
private final Map<String, List<String>> loaderPaths = new Object2ObjectOpenHashMap<>();
private final List<String> packmodeList = new ArrayList<>();
Expand Down Expand Up @@ -91,12 +94,19 @@ public RunConfig(JsonObject json) {
name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, id).replace('_', ' ');
}
this.packName = name;
this.packAuthor = JsonHelper.getString(json, "", "packAuthor", "author");
this.packId = id;
this.version = JsonHelper.getString(json, "1.0.0", "version", "ver");
modMetadata.modId = this.packId;
modMetadata.name = this.packName;
modMetadata.version = this.version;
modMetadata.parent = GroovyScript.ID;
modMetadata.authorList.addAll(
Arrays.stream(StringUtils.split(this.packAuthor, ","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList())
);
}

@ApiStatus.Internal
Expand Down