diff --git a/.github/workflows/styleCheck.yml b/.github/workflows/styleCheck.yml new file mode 100644 index 0000000..c47b7b6 --- /dev/null +++ b/.github/workflows/styleCheck.yml @@ -0,0 +1,30 @@ +name: Check Style in Pull Request +on: + pull_request_target: + +jobs: + checkstyle: + runs-on: ubuntu-latest + permissions: + pull-requests: write + checks: write + contents: read + steps: + - name: checkout + uses: actions/checkout@v4 + with: + ref: refs/pull/${{ github.event.number }}/merge + - name: Setup Java 17 + uses: actions/setup-java@v3.6.0 + with: + distribution: zulu + java-version: 17 + - uses: reviewdog/action-setup@v1 + with: + reviewdog_version: latest + - name: download checkstyle + run: curl -o checkstyle.jar -L https://github.com/checkstyle/checkstyle/releases/download/checkstyle-12.1.2/checkstyle-12.1.2-all.jar + - name: checkstyle + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: java -jar checkstyle.jar -c style.xml -f xml src | reviewdog -f=checkstyle -name="Checkstyle" -reporter=github-pr-review -fail-level=any \ No newline at end of file diff --git a/README.md b/README.md index 021a22e..8aafd44 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It provides utility methods and core functionality that other mods can build upon. ### How to implementation? -​ **In repositories:** +#### **In repositories:** ```groovy maven { @@ -17,10 +17,41 @@ It provides utility methods and core functionality that other mods can build upo } ``` -​ **In dependencies:** - +#### **In dependencies:** +##### General +​ **gradle.properties** +```properties +lib39_version=0.5.1 +```` +##### For Loom +​ **build.gradle** ```groovy dependencies { - implementation("top.r3944realms.lib39:lib39:1.20.1-0.4.1") + modImplementation("top.r3944realms.lib39:lib39-fabric-1.20.1:${lib39_version}") +} +``` + +##### For ForgeGradle +​ **build.gradle** +```groovy +dependencies { + implementation fg.deof("top.r3944realms.lib39:lib39-forge-1.20.1:${lib39_version}") +} +``` + +##### For NeoForgeGradle / ModDevGradle +​ **build.gradle** +```groovy +dependencies { + modImplementation("top.r3944realms.lib39:lib39-forge-1.20.1:${lib39_version}") +} +``` + +##### For MultiLoader Project +Add this in your common subproject. +​ **build.gradle** +```groovy +dependencies { + implementation("top.r3944realms.lib39:lib39-common-1.20.1:${lib39_version}") } ``` \ No newline at end of file diff --git a/common/src/main/java/top/r3944realms/lib39/base/command/Lib39CommandHelpManager.java b/common/src/main/java/top/r3944realms/lib39/base/command/Lib39CommandHelpManager.java index bc43ef6..9474c90 100644 --- a/common/src/main/java/top/r3944realms/lib39/base/command/Lib39CommandHelpManager.java +++ b/common/src/main/java/top/r3944realms/lib39/base/command/Lib39CommandHelpManager.java @@ -5,20 +5,26 @@ import top.r3944realms.lib39.Lib39; import top.r3944realms.lib39.core.command.SimpleCommandHelpManager; /** - * The type Lib 39 command help manager. + *
+ * 命令帮助注册管理类
+ * 这是一个模组内置的示例
+ * 
*/ public class Lib39CommandHelpManager extends SimpleCommandHelpManager { /** - * The constant INSTANCE. + * 单例模式 */ public static volatile Lib39CommandHelpManager INSTANCE = new Lib39CommandHelpManager(); /** - * The Id. + * 作为唯一标识符 */ ResourceLocation ID = Lib39.rl("command_helper"); /** + *
+     * 一定要在构造器方法里调用 {@link #initialize 初始化方法}
      * Instantiates a new Lib 39 command help manager.
+     * 
*/ public Lib39CommandHelpManager() { initialize(); diff --git a/common/src/main/java/top/r3944realms/lib39/base/command/Lib39HelpCommand.java b/common/src/main/java/top/r3944realms/lib39/base/command/Lib39HelpCommand.java index cbf4050..9cea4f9 100644 --- a/common/src/main/java/top/r3944realms/lib39/base/command/Lib39HelpCommand.java +++ b/common/src/main/java/top/r3944realms/lib39/base/command/Lib39HelpCommand.java @@ -21,11 +21,17 @@ import top.r3944realms.lib39.core.command.SimpleHelpCommand; import java.util.Map; /** - * The type Lib 39 help command. + *
+ * 指令注册以及帮助编写类
+ * 这是一个模组内置的示例
+ * 
*/ public class Lib39HelpCommand extends SimpleHelpCommand { /** + *
+     * 需要{@link CommandDispatcher 指令注册调度器} 和 {@link CommandBuildContext 指令上下文}
+     * 
* Instantiates a new Lib 39 help command. * * @param dispatcher the dispatcher diff --git a/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java b/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java index d983969..8d70a38 100644 --- a/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java +++ b/common/src/main/java/top/r3944realms/lib39/base/datagen/value/Lib39LangKey.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Consumer; /** * The enum Lib 39 lang key. @@ -322,7 +323,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_ROOT. */ -// 根命令 public static final LangKeyValue LIB39_ROOT = addAndRet( LangKeyValue.ofKey( "commands.lib39.root", ModPartEnum.MESSAGE, @@ -337,7 +337,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_TEST. */ -// 測試命令 public static final LangKeyValue LIB39_TEST = addAndRet( LangKeyValue.ofKey( "commands.lib39.test", ModPartEnum.MESSAGE, @@ -408,7 +407,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_GREET_BASIC. */ -// 問候命令 public static final LangKeyValue LIB39_GREET_BASIC = addAndRet( LangKeyValue.ofKey( "commands.lib39.greet.basic", ModPartEnum.MESSAGE, @@ -465,7 +463,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_CALCULATE. */ -// 計算命令 public static final LangKeyValue LIB39_CALCULATE = addAndRet( LangKeyValue.ofKey( "commands.lib39.calculate", ModPartEnum.MESSAGE, @@ -494,7 +491,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_TELEPORT. */ -// 傳送命令 public static final LangKeyValue LIB39_TELEPORT = addAndRet( LangKeyValue.ofKey( "commands.lib39.teleport", ModPartEnum.MESSAGE, @@ -523,7 +519,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_INFO. */ -// 信息命令 public static final LangKeyValue LIB39_INFO = addAndRet( LangKeyValue.ofKey( "commands.lib39.info", ModPartEnum.MESSAGE, @@ -580,7 +575,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_TEAM. */ -// 隊伍系統 public static final LangKeyValue LIB39_TEAM = addAndRet( LangKeyValue.ofKey( "commands.lib39.team", ModPartEnum.MESSAGE, @@ -679,7 +673,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_GAME. */ -// 遊戲系統 public static final LangKeyValue LIB39_GAME = addAndRet( LangKeyValue.ofKey( "commands.lib39.game", ModPartEnum.MESSAGE, @@ -806,7 +799,6 @@ public enum Lib39LangKey implements ILangKeyValueCollection { /** * The constant LIB39_SETTINGS. */ -// 設置命令 public static final LangKeyValue LIB39_SETTINGS = addAndRet( LangKeyValue.ofKey( "commands.lib39.settings", ModPartEnum.MESSAGE, @@ -861,7 +853,7 @@ public enum Lib39LangKey implements ILangKeyValueCollection { ); // ===== 添加缺失的導入 ===== - private static final java.util.function.Consumer addConsumer = items::add; + private static final Consumer addConsumer = items::add; private static LangKeyValue addAndRet(LangKeyValue item) { items.add(item); diff --git a/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java b/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java index 12f1708..5285f4e 100644 --- a/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java +++ b/common/src/main/java/top/r3944realms/lib39/client/gui/component/WheelWidget.java @@ -353,8 +353,8 @@ public class WheelWidget extends AbstractWidget { * * @return the section circle diameter */ -// 滚轮选择器中每个扇形的圆形直径 public float getSectionCircleDiameter() { + // 滚轮选择器中每个扇形的圆形直径 return this.ringOuterRadius + this.ringInnerRadius; } diff --git a/common/src/main/java/top/r3944realms/lib39/core/command/SimpleHelpCommand.java b/common/src/main/java/top/r3944realms/lib39/core/command/SimpleHelpCommand.java index dd0badc..ac8f286 100644 --- a/common/src/main/java/top/r3944realms/lib39/core/command/SimpleHelpCommand.java +++ b/common/src/main/java/top/r3944realms/lib39/core/command/SimpleHelpCommand.java @@ -15,6 +15,9 @@ public abstract class SimpleHelpCommand implements IHelpCommand { protected final LiteralArgumentBuilder root; /** + *
+     * 需要{@link CommandDispatcher 指令注册调度器} 和 {@link CommandBuildContext 指令上下文}
+     * 
* Instantiates a new Simple help command. * * @param dispatcher the dispatcher diff --git a/fabric/build.gradle b/fabric/build.gradle index 170e754..e667b02 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,7 +40,6 @@ loom { } runs { client { - client() client() ideConfigGenerated true programArgs '--launch_target', 'net.fabricmc.loader.impl.launch.knot.KnotClient' diff --git a/gradle.properties b/gradle.properties index 8d11ea4..782aa24 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ # Every field you add must be added to buildSrc/src/main/groovy/multiloader-common.gradle expandProps map. # Project -version=0.5.0 +version=0.5.1 group=top.r3944realms.lib39 java_version=17