Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/build.yml
  • Loading branch information
17TheWord committed Feb 15, 2025
2 parents 255aa8b + d6bb3fa commit 30ccc48
Show file tree
Hide file tree
Showing 37 changed files with 1,288 additions and 146 deletions.
60 changes: 22 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,67 @@ permissions:

env:
GH_TOKEN: ${{ github.token }}
USERNAME: ${{ github.actor }}
PACKAGE_READ_ONLY_TOKEN: ${{ secrets.PACKAGE_READ_ONLY_TOKEN }}

jobs:
generate-matrix:
runs-on: windows-latest
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- name: Generate Matrix
id: set-matrix
shell: pwsh
run: .\matrix.ps1 -path "fabric","forge","spigot","velocity","minecraft"
run: chmod 777 matrix.sh && ./matrix.sh -path "minecraft","spigot","velocity","forge","neoforge","fabric"

build:
runs-on: windows-latest
needs:
- generate-matrix
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4

- name: Chose JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper/dists
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Read version.txt and save to variable
shell: pwsh
run: |
$mod_version = Get-Content version.txt
Write-Host "Version: $mod_version"
echo "MOD_VERSION=$mod_version" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV
mod_version=$(cat version.txt)
echo "Version: $mod_version"
echo "MOD_VERSION=$mod_version" >> $GITHUB_ENV
- name: Init Files
shell: pwsh
run: ./init.ps1
run: chmod 777 init.sh && ./init.sh

- name: Build
env:
USERNAME: ${{ github.actor }}
PACKAGE_READ_ONLY_TOKEN: ${{ secrets.PACKAGE_READ_ONLY_TOKEN }}
run: |
cd ${{ matrix.config.mc-loader }}/${{ matrix.config.mc-loader }}-${{ matrix.config.mc-version }}
chmod 777 gradlew
./gradlew clean build
cd ../..
- name: Set Version Type
id: set-version-type
shell: pwsh
run: |
if ($env:GITHUB_REF -eq 'refs/heads/main') {
echo "VERSION_TYPE=release" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV
} else {
echo "VERSION_TYPE=beta" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV
}
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
echo "VERSION_TYPE=release" >> $GITHUB_ENV
else
echo "VERSION_TYPE=beta" >> $GITHUB_ENV
fi
- name: Set Game Version
id: set-game-version
shell: pwsh
run: |
if ("${{ matrix.config.mc-loader }}" -eq 'velocity') {
echo "game_version=1.20" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV
} else {
echo "game_version=${{ matrix.config.mc-version }}" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV
}
if [ "${{ matrix.config.mc-loader }}" == "velocity" ]; then
echo "game_version=1.20.1" >> $GITHUB_ENV
else
echo "game_version=${{ matrix.config.mc-version }}" >> $GITHUB_ENV
fi
- uses: actions/upload-artifact@v4
with:
Expand All @@ -100,7 +85,6 @@ jobs:
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 1084495
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

name: QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}
version: ${{ env.MOD_VERSION }}
version-type: ${{ env.VERSION_TYPE }}
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@
## 介绍

-`Minecraft` 服务端**玩家事件**`Json` 格式通过 `Websocket` 分发的服务端 `plugin/mod`
- 已实现的 [`事件`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家聊天`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家命令`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家死亡`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B) (`Velocity`
暂无)
- [`玩家加入`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家登出`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
-
已实现的 [`事件`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家聊天`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家命令`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家死亡`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B) (`Velocity`
暂无)
- [`玩家加入`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- [`玩家登出`](https://github.com/17TheWord/QueQiao/wiki/4.-%E5%9F%BA%E6%9C%AC%E4%BA%8B%E4%BB%B6%E7%B1%BB%E5%9E%8B)
- 通过 `Websocket` 接收 `Json` 消息,并转发至游戏玩家。
- 已实现的接口
- [`Broadcast`](https://github.com/17TheWord/QueQiao/wiki/5.-API#broadcast--send-message)
Expand Down Expand Up @@ -95,10 +96,16 @@

## 对接

- [`@17TheWord/nonebot-adapter-minecraft`](https://github.com/17TheWord/nonebot-adapter-minecraft):`NoneBot2` 适配器,与本模组连接
- [`@17TheWord/nonebot-plugin-mcqq`](https://github.com/17TheWord/nonebot-plugin-mcqq):`NoneBot2` 插件,与 `Minecraft`
- [`@17TheWord/nonebot-adapter-minecraft`](https://github.com/17TheWord/nonebot-adapter-minecraft):`NoneBot2`
适配器,支持收发消息与`Rcon`
- [`@17TheWord/nonebot-plugin-mcqq`](https://github.com/17TheWord/nonebot-plugin-mcqq):`NoneBot2` 插件,`QQ`
`Minecraft`
互通聊天
- [`@CikeyQi/mc-plugin`](https://github.com/CikeyQi/mc-plugin):云崽插件,与 `Minecraft` 互通聊天
- [`@CikeyQi/mc-plugin`](https://github.com/CikeyQi/mc-plugin):云崽插件,`QQ` 与 `Minecraft` 互通聊天,`Rcon` 提供支持命令
- [`@Twiyan0/koishi-plugin-minecraft-sync-msg`](https://github.com/Twiyin0/koishi-plugin-minecraft-sync-msg):`Koishi`
插件,`QQ``Minecraft` 互通聊天,`Rcon` 提供支持命令
- [`@17TheWord/zerobot-plugin-mcqq`](https://github.com/17TheWord/zerobot-plugin-mcqq):`ZeroBot` 插件,`QQ`
`Minecraft` 互通聊天

## 兼容

Expand All @@ -117,6 +124,10 @@
- 有意见或者建议也欢迎提交 [`Issues`](https://github.com/17TheWord/QueQiao/issues)
和 [`Pull requests`](https://github.com/17TheWord/QueQiao/pulls) 。

## 星星

[![Stargazers over time](https://starchart.cc/17TheWord/QueQiao.svg?variant=adaptive)](https://starchart.cc/17TheWord/QueQiao)

## 开源许可

本项目使用 [`MIT`](https://github.com/17TheWord/QueQiao/blob/main/LICENSE) 作为开源许可证。
19 changes: 5 additions & 14 deletions fabric/origin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,18 @@ plugins {
id 'maven-publish'
}

def getVersionFromFile() {
def versionFile = file('../../version.txt')
def getVersionFromFile(String fileName) {
def versionFile = file(fileName)
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Version file not found: ${versionFile.absolutePath}") as Throwable
throw new Exception("File not found: ${versionFile.absolutePath}") as Throwable
}
}

def mod_version = getVersionFromFile()
def tool_version = getVersionFromFile('../../tool_version.txt')

def getToolVersionFromFile() {
def versionFile = file('../../tool_version.txt')
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Tool Version file not found: ${versionFile.absolutePath}") as Throwable
}
}

def tool_version = getToolVersionFromFile()
def mod_version = getVersionFromFile('../../version.txt')

version = mod_version
group = project.maven_group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.theword.queqiao.command.CommandExecutor;
import com.github.theword.queqiao.handle.HandleApiImpl;
import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl;
import com.github.theword.queqiao.tool.constant.ServerTypeConstant;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.server.MinecraftServer;
Expand All @@ -16,10 +17,16 @@ public class QueQiao implements ModInitializer {

@Override
public void onInitialize() {
initTool(true, new HandleApiImpl(), new HandleCommandReturnMessageImpl());
ServerLifecycleEvents.SERVER_STARTING.register(server -> {
minecraftServer = server;
websocketManager.startWebsocket(null);
initTool(
true,
minecraftServer.getVersion(),
ServerTypeConstant.FABRIC,
new HandleApiImpl(),
new HandleCommandReturnMessageImpl()
);
websocketManager.startWebsocketOnServerStart();
});

new CommandExecutor();
Expand Down
19 changes: 5 additions & 14 deletions forge/origin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,18 @@ plugins {
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
}

def getVersionFromFile() {
def versionFile = file('../../version.txt')
def getVersionFromFile(String fileName) {
def versionFile = file(fileName)
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Version file not found: ${versionFile.absolutePath}") as Throwable
throw new Exception("File not found: ${versionFile.absolutePath}") as Throwable
}
}

def mod_version = getVersionFromFile()
def tool_version = getVersionFromFile('../../tool_version.txt')

def getToolVersionFromFile() {
def versionFile = file('../../tool_version.txt')
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Tool Version file not found: ${versionFile.absolutePath}") as Throwable
}
}

def tool_version = getToolVersionFromFile()
def mod_version = getVersionFromFile('../../version.txt')

group = mod_group_id
version = mod_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.theword.queqiao.handle.HandleApiImpl;
import com.github.theword.queqiao.handle.HandleCommandReturnMessageImpl;
import com.github.theword.queqiao.tool.constant.BaseConstant;
import com.github.theword.queqiao.tool.constant.ServerTypeConstant;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
Expand All @@ -19,27 +20,27 @@ public class QueQiao {
public static MinecraftServer minecraftServer;

public QueQiao() {
initTool(true, new HandleApiImpl(), new HandleCommandReturnMessageImpl());
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new EventProcessor());
}

@OnlyIn(Dist.DEDICATED_SERVER)
@SubscribeEvent
// IF > forge-1.16.5
// public void onServerStarted(net.minecraftforge.event.server.ServerStartedEvent event) {
// ELSE
// public void onServerStarted(net.minecraftforge.fml.event.server.FMLServerStartedEvent event) {
// public void onServerStarted(net.minecraftforge.event.server.ServerStartingEvent event) {
// ELSE
// public void onServerStarted(net.minecraftforge.fml.event.server.FMLServerStartingEvent event) {
// END IF
minecraftServer = event.getServer();
websocketManager.startWebsocket(null);
initTool(true, minecraftServer.getServerVersion(), ServerTypeConstant.FORGE, new HandleApiImpl(), new HandleCommandReturnMessageImpl());
websocketManager.startWebsocketOnServerStart();
}

@OnlyIn(Dist.DEDICATED_SERVER)
@SubscribeEvent
// IF > forge-1.16.5
// public void onServerStopping(net.minecraftforge.event.server.ServerStoppingEvent event) {
// ELSE
// ELSE
// public void onServerStopping(net.minecraftforge.fml.event.server.FMLServerStoppingEvent event) {
// END IF
websocketManager.stopWebsocketByServerClose();
Expand Down
9 changes: 9 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

file=$(find tool -name "ModMultiVersionTool*.jar" | head -n 1)

if [ -n "$file" ]; then
java -jar "$file"
else
echo "can't find ModMultiVersionTool.jar"
fi
52 changes: 52 additions & 0 deletions matrix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

while [[ $# -gt 0 ]]; do
case $1 in
-path)
IFS=',' read -r -a paths <<< "$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done

# 用于存储所有文件夹的数组
allFolderObjects=()

# 遍历每个路径
for path in "${paths[@]}"; do
# 获取指定路径下的文件夹
folders=$(find "$path" -mindepth 1 -maxdepth 1 -type d)

# 过滤掉名为 "origin" 的文件夹
for folder in $folders; do
folderName=$(basename "$folder")
if [[ "$folderName" != "origin" ]]; then
# 提取 mc-version 和 mc-loader 信息
mcVersion="${folderName//$path-/}"
mcLoader="$path"
supportVersionFile="$mcLoader/$mcLoader-$mcVersion/support_version.txt"
if [[ -f "$supportVersionFile" ]]; then
supportVersion=$(cat "$supportVersionFile")
else
supportVersion="$mcVersion"
fi

if [ "$mcLoader" == "fabric" ]; then
publishLoaders="fabric quilt"
else
publishLoaders="$mcLoader"
fi
allFolderObjects+=("{\"mc-version\": \"$mcVersion\", \"mc-loader\": \"$mcLoader\", \"publish-loaders\": \"$publishLoaders\", \"publish-version\": \"$supportVersion\"}")
fi
done
done

# 创建 JSON 格式的输出
json=$(printf "{\"config\":[%s]}" "$(IFS=,; echo "${allFolderObjects[*]}")")

# 输出最终的 JSON 结果
echo "matrix=$json" >> $GITHUB_OUTPUT
Binary file not shown.

This file was deleted.

Loading

0 comments on commit 30ccc48

Please sign in to comment.