Skip to content

Commit

Permalink
clean + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wulian233 authored Feb 4, 2024
1 parent 9242aff commit 6c732f2
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 13 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Release

on:
workflow_dispatch:
release:
types:
- published

permissions:
contents: write

jobs:
Build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 20
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 20
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle') }}
- uses: gradle/wrapper-validation-action@v1
- run: |
chmod +x gradlew
./gradlew mergeJars publishMods --stacktrace -Porg.gradle.parallel.threads=4
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 更新日志
- Add mod release workflow
- clean code

## Changelog
- 添加 mod release workflow
- 代码清理
45 changes: 40 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "io.github.pacifistmc.forgix" version "1.2.6"
id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

architectury {
Expand All @@ -23,7 +24,7 @@ allprojects {
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
version = "${rootProject.mod_version}-${rootProject.minecraft_version}"
version = "${rootProject.mod_version}+mc${rootProject.minecraft_version}"
group = rootProject.maven_group

repositories {
Expand All @@ -46,16 +47,50 @@ allprojects {

forgix {
group = rootProject.maven_group
mergedJarName = "${rootProject.archives_base_name}-${project.version}.jar"
mergedJarName = "${rootProject.archives_base_name}-${rootProject.version}.jar"
outputDir = "build/libs/forgix"

forge {
projectName = "forge"
jarLocation = "build/libs/${rootProject.archives_base_name}-forge-${ rootProject.version }.jar"
jarLocation = "build/libs/${rootProject.archives_base_name}-forge-${rootProject.version}.jar"
}

fabric {
projectName = "fabric"
jarLocation = "build/libs/${rootProject.archives_base_name}-fabric-${ rootProject.version }.jar"
jarLocation = "build/libs/${rootProject.archives_base_name}-fabric-${rootProject.version}.jar"
}
}

publishMods {
file = file(forgix.getOutputDir() + "/" + forgix.getMergedJarName())
changelog = file("CHANGELOG.md").getText('UTF-8')
type = STABLE
modLoaders = ["fabric", "forge"]

var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
projectId = rootProject.curseforge_id
accessToken = providers.environmentVariable(CURSEFORGE_TOKEN as Provider<String>)
minecraftVersions = ["1.19.3", "1.19.4"]

requires {
slug = ["architectury-api", "cloth-config"]
}
}
}


var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
projectId = rootProject.modrinth_id
accessToken = providers.environmentVariable(MODRINTH_TOKEN as Provider<String>)
minecraftVersions = ["1.19.3", "1.19.4"]
}

requires {
slug = ["architectury-api", "cloth-config"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import java.util.concurrent.CompletableFuture;

public class VMTranslationUpdate {
public static final Random random = new Random();
public static Random random = new Random();
public static int tickCounter;
public static final String MODNAME = "VMTranslationUpdate";
public static final String MOD_ID = "vmtranslationupdate";
static MinecraftClient client = MinecraftClient.getInstance();
private static final boolean isStenographerLoaded = Platform.isModLoaded("stenographer"); // Stenographer 兼容
public static final Logger LOGGER = LoggerFactory.getLogger(MODNAME);
private static final boolean isStenographerLoaded = Platform.isModLoaded("stenographer"); // Stenographer 兼容

public static void init() {
if (ModConfigUtil.getConfig().autoSwitchLanguage && !isStenographerLoaded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public class ModConfigs implements ConfigData {
public String modPackTranslationVersion = "1.0.0";
public int tipsMinutes = 25;
public String traslationPackName = "VM汉化组模组汉化包1.19";
public String traslationPackUrl= "https://cdn.modrinth.com/data/IDWIdXwS/versions/acZy8zAY/VM汉化组模组汉化包1.19";
public String traslationPackUrl= "https://cdn.modrinth.com/data/IDWIdXwS/versions/acZy8zAY/";
public String nameUrl = "https://vmct-cn.top/name.json";
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package top.vmctcn.vmtranslationupdate.forge;

import dev.architectury.platform.forge.EventBuses;
import dev.architectury.utils.EnvExecutor;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.network.NetworkConstants;
import top.vmctcn.vmtranslationupdate.VMTranslationUpdate;
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil;
Expand All @@ -17,7 +17,9 @@ public VMTranslationUpdateClientForge() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));
EventBuses.registerModEventBus(VMTranslationUpdate.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());

EnvExecutor.runInEnv(Dist.CLIENT, () -> this::onInitializeClient);
if (FMLLoader.getDist() == Dist.CLIENT) {
onInitializeClient();
}
}

public void onInitializeClient() {
Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ enabled_platforms=fabric,forge
yarn_mappings=1.19.4+build.2

archives_base_name=VMTranslationUpdate
mod_version=2.3
maven_group=top.vmctcn
mod_version=2.3.1
maven_group=top.vmctcn.vmtranslationupdate

architectury_version=8.2.89
clothconfig_version=10.1.117
Expand All @@ -16,3 +16,6 @@ fabric_loader_version=0.14.22
fabric_api_version=0.87.2+1.19.4

forge_version=1.19.4-45.2.8

curseforge_id=890229
modrinth_id=wvCSIW08
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 6c732f2

Please sign in to comment.