Skip to content

Commit

Permalink
ci(fabric): release
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed Feb 12, 2024
1 parent 544a3ef commit 38e070d
Show file tree
Hide file tree
Showing 65 changed files with 614 additions and 1,001 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/fabric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
show-progress: false

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
distribution: 'dragonwell'

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Make Gradle Wrapper Executable
run: chmod +x ./fabric/gradlew

- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: build
build-root-directory: fabric

- name: Find Correct JAR
id: findjar
run: |
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Fabric Release

on:
push:
tags:
- 'v*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
show-progress: false

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'dragonwell'

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Make Gradle Wrapper Executable
run: chmod +x ./fabric/gradlew

- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: buildNeeded
build-root-directory: forge

- name: Find Correct JAR
id: findjar
run: |
output="$(find fabric/wrapper/build/libs/ ! -name "*-sources.jar" -type f -printf "%f\n")"
echo "::set-output name=jarname::$output"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: fabric/wrapper/build/libs/${{ steps.findjar.outputs.jarname }}
body: Please refer to [CHANGELOG.md](https://github.com/Nova-Committee/re-avaritia/blob/master/CHANGELOG.md) for details.
8 changes: 1 addition & 7 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@ plugins {
}

preprocess {
def mc1144 = createNode("1.14.4", 1_14_04, "yarn")
def mc1152 = createNode("1.15.2", 1_15_02, "yarn")
def mc1165 = createNode("1.16.5", 1_16_05, "yarn")
def mc1171 = createNode("1.17.1", 1_17_01, "yarn")
def mc1182 = createNode("1.18.2", 1_18_02, "yarn")
def mc1192 = createNode("1.19.2", 1_19_02, "yarn")
def mc1193 = createNode("1.19.3", 1_19_03, "yarn")
def mc1194 = createNode("1.19.4", 1_19_04, "yarn")
def mc1201 = createNode("1.20.1", 1_20_01, "yarn")
def mc1202 = createNode("1.20.2", 1_20_02, "yarn")

mc1144.link(mc1152, null)
mc1152.link(mc1165, null)
mc1165.link(mc1171, null)
mc1171.link(mc1182, null)
mc1165.link(mc1182, null)
mc1182.link(mc1192, null)
mc1192.link(mc1193, null)
mc1193.link(mc1194, null)
Expand Down
4 changes: 2 additions & 2 deletions fabric/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ remapJar {
remapperIsolation = true
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

version = project.mod_version
group = project.maven_group
Expand Down
4 changes: 2 additions & 2 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx8G

# Mod Properties
mod_version=2.1.9
mod_version=2.1.9.1
maven_group=cn.evole.mods
archives_base_name=McBot-fabric

Expand All @@ -12,4 +12,4 @@ minecraft_version=1.20.1
loader_version=0.14.21
fabric_version=0.83.1+1.20.1
onebot_client_version=0.3.8
toml_version=0.1.1
toml_version=0.1.4
3 changes: 0 additions & 3 deletions fabric/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ pluginManagement {
}

def versions = Arrays.asList(
"1.14.4",
"1.15.2",
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.2",
"1.19.3",
Expand Down
66 changes: 8 additions & 58 deletions fabric/src/main/java/cn/evole/mods/mcbot/Const.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package cn.evole.mods.mcbot;

import cn.evole.mods.mcbot.init.config.ModConfig;
import cn.evole.onebot.sdk.util.BotUtils;
import com.google.gson.JsonArray;
import net.fabricmc.loader.api.FabricLoader;
import cn.evole.mods.mcbot.util.MessageThread;
import cn.evole.onebot.sdk.util.BotUtils;
import java.nio.file.Path;

//#if MC >= 11700
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//$$ import org.slf4j.Logger;
//$$ import org.slf4j.LoggerFactory;
//#else
//$$ import org.apache.logging.log4j.Logger;
//$$ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
//#endif

/**
Expand All @@ -23,9 +22,9 @@
public class Const {
public static final String MODID = "mcbot";
//#if MC >= 11700
public static final Logger LOGGER = LoggerFactory.getLogger("McBot");
//$$ public static final Logger LOGGER = LoggerFactory.getLogger("McBot");
//#else
//$$ public static final Logger LOGGER = LogManager.getLogger("McBot");
public static final Logger LOGGER = LogManager.getLogger("McBot");
//#endif
public static boolean isShutdown = false;
public static Path configDir = FabricLoader.getInstance().getConfigDir();
Expand Down Expand Up @@ -70,54 +69,5 @@ public static void guildMsg(String guildId, String channelId, String message){
}
}

class MessageThread extends Thread {
private long groupIDInt;
private String guildIDString;
private String messageString;
private JsonArray messageArray;
private boolean autoEscape;
private String channelIDString;
private final short mode;

MessageThread(long groupId, String msg, boolean autoEscape) {
this.mode = 0;
this.groupIDInt = groupId;
this.messageString = msg;
this.autoEscape = autoEscape;
}

MessageThread(long groupId, JsonArray msg, boolean autoEscape) {
this.mode = 1;
this.groupIDInt = groupId;
this.messageArray = msg;
this.autoEscape = autoEscape;
}
MessageThread(String guildID, String channelID, String message) {
this.mode = 2;
this.guildIDString = guildID;
this.channelIDString = channelID;
this.messageString = message;
}

MessageThread(String guildID, String channelID, JsonArray message) {
this.mode = 3;
this.guildIDString = guildID;
this.channelIDString = channelID;
this.messageArray = message;
}

public void run() {
switch (mode) {
case 0 -> McBot.bot.sendGroupMsg(groupIDInt, messageString, autoEscape);
case 1 -> McBot.bot.sendGroupMsg(groupIDInt, messageArray, autoEscape);
case 2 -> McBot.bot.sendGuildMsg(guildIDString, channelIDString, messageString);
case 3 -> McBot.bot.sendGuildMsg(guildIDString, channelIDString, messageArray);
}
}

public void start() {
Const.LOGGER.info(String.format("转发游戏消息: %s", messageString!= null ? messageString : messageArray));
Thread thread = new Thread(this, "MessageThread");
thread.start();
}
}
8 changes: 4 additions & 4 deletions fabric/src/main/java/cn/evole/mods/mcbot/McBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import cn.evole.onebot.sdk.util.FileUtils;
import net.fabricmc.api.ModInitializer;
//#if MC >= 11900
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
//$$ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
//#else
//$$ import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
//#endif
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
Expand Down Expand Up @@ -45,9 +45,9 @@ public MinecraftServer getServer() {
public void onInitialize() {
init();
//#if MC >= 11900
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> ICmdEvent.register(dispatcher));
//$$ CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> ICmdEvent.register(dispatcher));
//#else
//$$ CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> ICmdEvent.register(dispatcher));
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> ICmdEvent.register(dispatcher));
//#endif

ServerLifecycleEvents.SERVER_STARTING.register(this::onServerStarting);
Expand Down
38 changes: 16 additions & 22 deletions fabric/src/main/java/cn/evole/mods/mcbot/cmds/BotCmdRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
//#if MC >= 11900
//#if MC < 11900
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
//#else
//$$ import net.minecraft.network.chat.TextComponent;
//$$ import net.minecraft.network.chat.Component;
//#endif

//#if MC < 11600
//$$ import net.minecraft.world.level.dimension.DimensionType;
//#endif


/**
Expand All @@ -34,15 +31,12 @@
*/
public class BotCmdRun extends CommandSourceStack {

//#if MC >= 11900
public static BotCmdRun CUSTOM = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "Bot", Component.literal("Bot"), McBot.SERVER, null);
public static BotCmdRun OP = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "OP", Component.literal("OP"), McBot.SERVER, null);
//#elseif MC < 11600
//$$ public static BotCmdRun CUSTOM = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.getLevel(DimensionType.OVERWORLD), 4, "Bot", new TextComponent("Bot"), McBot.SERVER, null);
//$$ public static BotCmdRun OP = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.getLevel(DimensionType.OVERWORLD), 4, "OP", new TextComponent("OP"), McBot.SERVER, null);
//#if MC < 11900
public static BotCmdRun CUSTOM = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "Bot", new TextComponent("Bot"), McBot.SERVER, null);
public static BotCmdRun OP = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "OP", new TextComponent("OP"), McBot.SERVER, null);
//#else
//$$ public static BotCmdRun CUSTOM = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "Bot", new TextComponent("Bot"), McBot.SERVER, null);
//$$ public static BotCmdRun OP = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "OP", new TextComponent("OP"), McBot.SERVER, null);
//$$ public static BotCmdRun CUSTOM = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "Bot", Component.literal("Bot"), McBot.SERVER, null);
//$$ public static BotCmdRun OP = new BotCmdRun(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, McBot.SERVER.overworld(), 4, "OP", Component.literal("OP"), McBot.SERVER, null);
//#endif


Expand All @@ -53,17 +47,17 @@ public BotCmdRun(CommandSource commandSource, Vec3 vec3, Vec2 vec2, ServerLevel
}

//#if MC >= 12000
@Override
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
super.sendSuccess(supplier, bl);
this.outPut.add(supplier.get().getString());
}
//#else
//$$ @Override
//$$ public void sendSuccess(@NotNull Component component, boolean p_81356_) {
//$$ super.sendSuccess(component, p_81356_);
//$$ this.outPut.add(component.getString());
//$$ public void sendSuccess(Supplier<Component> supplier, boolean bl) {
//$$ super.sendSuccess(supplier, bl);
//$$ this.outPut.add(supplier.get().getString());
//$$ }
//#else
@Override
public void sendSuccess(@NotNull Component component, boolean p_81356_) {
super.sendSuccess(component, p_81356_);
this.outPut.add(component.getString());
}
//#endif

}
4 changes: 2 additions & 2 deletions fabric/src/main/java/cn/evole/mods/mcbot/cmds/CmdApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class CmdApi {
private static StringBuilder CmdMain(String cmd, boolean isOp) {
StringBuilder result = new StringBuilder();
//#if MC >= 11900
McBot.SERVER.getCommands().performPrefixedCommand(isOp ? BotCmdRun.OP : BotCmdRun.CUSTOM, cmd);//优雅
//$$ McBot.SERVER.getCommands().performPrefixedCommand(isOp ? BotCmdRun.OP : BotCmdRun.CUSTOM, cmd);//优雅
//#else
//$$ McBot.SERVER.getCommands().performCommand(isOp ? BotCmdRun.OP : BotCmdRun.CUSTOM, cmd);
McBot.SERVER.getCommands().performCommand(isOp ? BotCmdRun.OP : BotCmdRun.CUSTOM, cmd);
//#endif
for (String s : (isOp ? BotCmdRun.OP.outPut : BotCmdRun.CUSTOM.outPut)) {
result.append(s.replaceAll(\\S", "")).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import lombok.val;
import net.minecraft.commands.CommandSourceStack;
//#if MC >= 11900
import net.minecraft.network.chat.Component;
//#else
//$$ import net.minecraft.network.chat.TextComponent;
//#if MC <11900
import net.minecraft.network.chat.TextComponent;
//#endif

public class AddChannelIDCommand {
Expand All @@ -20,9 +19,9 @@ public static int execute(CommandContext<CommandSourceStack> context) throws Com
if (ModConfig.INSTANCE.getCommon().getChannelIdList().contains(id)) {

//#if MC >= 12000
context.getSource().sendSuccess(()->Component.literal("子频道号:" + id + "已经出现了!"), true);
//$$ context.getSource().sendSuccess(()->Component.literal("子频道号:" + id + "已经出现了!"), true);
//#elseif MC < 11900
//$$ context.getSource().sendSuccess(new TextComponent("子频道号:" + id + "已经出现了!"), true);
context.getSource().sendSuccess(new TextComponent("子频道号:" + id + "已经出现了!"), true);
//#else
//$$ context.getSource().sendSuccess(Component.literal("子频道号:" + id + "已经出现了!"), true);
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import lombok.val;
import net.minecraft.commands.CommandSourceStack;
//#if MC >= 11900
import net.minecraft.network.chat.Component;
//#else
//$$ import net.minecraft.network.chat.TextComponent;
//#if MC <11900
import net.minecraft.network.chat.TextComponent;
//#endif

public class AddGroupIDCommand {
Expand All @@ -18,18 +17,18 @@ public static int execute(CommandContext<CommandSourceStack> context) throws Com
val id = context.getArgument("GroupId", Long.class);
if (ModConfig.INSTANCE.getCommon().getGroupIdList().contains(id)) {
//#if MC >= 12000
context.getSource().sendSuccess(()->Component.literal("QQ群号:" + id + "已经出现了!"), true);
//$$ context.getSource().sendSuccess(()->Component.literal("QQ群号:" + id + "已经出现了!"), true);
//#elseif MC < 11900
//$$ context.getSource().sendSuccess(new TextComponent("QQ群号:" + id + "已经出现了!"), true);
context.getSource().sendSuccess(new TextComponent("QQ群号:" + id + "已经出现了!"), true);
//#else
//$$ context.getSource().sendSuccess(Component.literal("QQ群号:" + id + "已经出现了!"), true);
//#endif
} else {
ModConfig.INSTANCE.getCommon().addGroupId(id);
//#if MC >= 12000
context.getSource().sendSuccess(()->Component.literal("已成功添加QQ群号:" + id + "!"), true);
//$$ context.getSource().sendSuccess(()->Component.literal("已成功添加QQ群号:" + id + "!"), true);
//#elseif MC < 11900
//$$ context.getSource().sendSuccess(new TextComponent("已成功添加QQ群号:" + id + "!"), true);
context.getSource().sendSuccess(new TextComponent("已成功添加QQ群号:" + id + "!"), true);
//#else
//$$ context.getSource().sendSuccess(Component.literal("已成功添加QQ群号:" + id + "!"), true);
//#endif
Expand Down
Loading

0 comments on commit 38e070d

Please sign in to comment.