-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Common | ||
on: | ||
workflow_call: | ||
inputs: | ||
type: | ||
required: true | ||
type: string | ||
publish-task: | ||
required: false | ||
type: string | ||
is-snapshot: | ||
required: false | ||
type: boolean | ||
default: true | ||
|
||
jobs: | ||
build-common: | ||
name: Build Common | ||
runs-on: ubuntu-latest | ||
environment: Build | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'gradle' | ||
- | ||
name: Build | ||
env: | ||
IS_SNAPSHOT: ${{ inputs.is-snapshot }} | ||
run: | | ||
./gradlew clean build --stacktrace | ||
- | ||
name: Publish | ||
if: ${{ inputs.publish-task }} | ||
env: | ||
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} | ||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | ||
run: | | ||
export GIT_COMMIT_DESC=$(git log --format=%B -n 1 $GITHUB_SHA) | ||
./gradlew ${{ inputs.publish-task }} --info --stacktrace | ||
- | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: CustomSkinLoader-${{ inputs.type }}-${{ github.run_number }} | ||
path: build/libs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package i18nupdatemod.core; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
import i18nupdatemod.I18nUpdateMod; | ||
import org.apache.commons.io.FileUtils; | ||
|
||
import java.lang.reflect.Type; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class GameConfig { | ||
private static final Gson GSON = new Gson(); | ||
private static final Type STRING_LIST_TYPE = new TypeToken<List<String>>() { | ||
}.getType(); | ||
protected Map<String, String> configs = new LinkedHashMap<>(); | ||
private final Path configFile; | ||
|
||
public GameConfig(Path configFile) throws Exception { | ||
this.configFile = configFile; | ||
if (!Files.exists(configFile)) { | ||
return; | ||
} | ||
this.configs = FileUtils.readLines(configFile.toFile(), StandardCharsets.UTF_8).stream() | ||
.map(it -> it.split(":", 2)) | ||
.collect(Collectors.toMap(it -> it[0], it -> it[1], (a, b) -> a, LinkedHashMap::new)); | ||
} | ||
|
||
public void writeToFile() throws Exception { | ||
FileUtils.writeLines(configFile.toFile(), configs.entrySet().stream() | ||
.map(it -> it.getKey() + ":" + it.getValue()).collect(Collectors.toList())); | ||
} | ||
|
||
public void addResourcePack(String baseName, String resourcePack) { | ||
List<String> resourcePacks = GSON.fromJson( | ||
configs.computeIfAbsent("resourcePacks", it -> "[]"), STRING_LIST_TYPE); | ||
//Remove other Minecraft Mod Language Pack | ||
resourcePacks = resourcePacks.stream().filter(it -> !it.contains(baseName)).collect(Collectors.toList()); | ||
resourcePacks.add(resourcePack); | ||
configs.put("resourcePacks", GSON.toJson(resourcePacks)); | ||
I18nUpdateMod.LOGGER.info("Resource Packs: {}", configs.get("resourcePacks")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters