Skip to content

Commit

Permalink
API 更新(第一部分)
Browse files Browse the repository at this point in the history
此更新包括对 fabric mod 构建配置的多项改进和优化,提升了构建效率和代码的可维护性。主要变更如下:

- 将 architectury.loom 插件版本升级至 1.7-SNAPSHOT,以获得最新的特性和支持。
- 调整了版本号的命名格式,以更清晰地表示版本之间的关系。
- 更新了依赖项的版本,包括 lombok 和 vanish,确保与最新 Minecraft 版本的兼容性。
- 在 CQUtils.java 中添加了对字符串转义的处理,优化了消息处理逻辑。
- 升级了 Minecraft Loader 版本至 0.15.11,以适配最新的 Minecraft 和 Fabric API。

此次更新为 API 的第一部分更新,后续还将有更多改进和新功能的加入。
  • Loading branch information
cnlimiter committed Jul 14, 2024
1 parent 1e48e88 commit 0ea3cc4
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 41 deletions.
30 changes: 16 additions & 14 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
plugins {
id 'dev.architectury.loom' version '1.5-SNAPSHOT' apply false
id 'dev.architectury.loom' version '1.7-SNAPSHOT' apply false
id "com.replaymod.preprocess" version "SNAPSHOT"
id 'dev.vankka.dependencydownload.plugin' version '1.3.1' apply false

}

preprocess {
def mc1165 = createNode("1.16.5", 1_16_05, "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 mc1204 = createNode("1.20.4", 1_20_04, "yarn")
def mc11605 = createNode("1.16.5", 1_16_05, "yarn")
def mc11802 = createNode("1.18.2", 1_18_02, "yarn")
def mc11902 = createNode("1.19.2", 1_19_02, "yarn")
def mc11903 = createNode("1.19.3", 1_19_03, "yarn")
def mc11904 = createNode("1.19.4", 1_19_04, "yarn")
def mc12001 = createNode("1.20.1", 1_20_01, "yarn")
def mc12004 = createNode("1.20.4", 1_20_04, "yarn")
def mc12100 = createNode("1.21", 1_21_00, "yarn")

mc1165.link(mc1182, null)
mc1182.link(mc1192, null)
mc1192.link(mc1193, null)
mc1193.link(mc1194, null)
mc1194.link(mc1201, null)
mc1201.link(mc1204, null)
mc11605.link(mc11802, null)
mc11802.link(mc11902, null)
mc11902.link(mc11903, null)
mc11903.link(mc11904, null)
mc11904.link(mc12001, null)
mc12001.link(mc12004, null)
mc12004.link(mc12100, null)
}
7 changes: 3 additions & 4 deletions fabric/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ dependencies {
implementation ("cn.evole.config:AtomConfig-Toml:${toml_version}"){transitive = false}

if (mcVersion == 11605) include ("org.slf4j:slf4j-api:2.0.7")
modCompileOnly ("maven.modrinth:vanish:1.5.2-1.20.1")
compileOnly ("org.projectlombok:lombok:1.18.24")
annotationProcessor ("org.projectlombok:lombok:1.18.24")
modCompileOnly ("maven.modrinth:vanish:1.5.4+1.20.1")
compileOnly ("org.projectlombok:lombok:1.18.30")
annotationProcessor ("org.projectlombok:lombok:1.18.30")

}

Expand All @@ -43,7 +43,6 @@ loom {


loom {
silentMojangMappingsLicense()
mixin {
useLegacyMixinAp = false
}
Expand Down
4 changes: 2 additions & 2 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
org.gradle.jvmargs=-Xmx8G

# Mod Properties
mod_version=2.2.1.1
mod_version=2.2.1.2
maven_group=cn.evole.mods
archives_base_name=McBot-fabric

# Wrapper Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
loader_version=0.15.7
loader_version=0.15.11
fabric_version=0.83.1+1.20.1
onebot_client_version=0.4.0
toml_version=0.1.5
Expand Down
2 changes: 1 addition & 1 deletion fabric/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
org.gradle.jvmargs=-Dfile.encoding=UTF-8
1 change: 1 addition & 0 deletions fabric/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def versions = Arrays.asList(
"1.19.4",
"1.20.1",
"1.20.4",
"1.21",
)
for (String version : versions) {
include(":$version")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.network.chat.Component;
//#if MC >= 12006
//$$ import net.minecraft.core.component.DataComponents;
//#endif

//#if MC <11900
import net.minecraft.network.chat.TextComponent;
//#endif
Expand Down Expand Up @@ -76,7 +80,11 @@ public static void death(DamageSource source, ServerPlayer player) {
} else {
itemStack = ItemStack.EMPTY;
}
//#if MC < 12100
message = !itemStack.isEmpty() && itemStack.hasCustomHoverName() ? I18n.get(string + ".item", player.getDisplayName().getString(), component.getString(), itemStack.getDisplayName().getString()) : I18n.get(string,player.getDisplayName().getString(), component.getString());
//#else
//$$ message = !itemStack.isEmpty() && itemStack.get(DataComponents.CUSTOM_NAME) != null ? I18n.get(string + ".item", player.getDisplayName().getString(), component.getString(), itemStack.getDisplayName().getString()) : I18n.get(string,player.getDisplayName().getString(), component.getString());
//#endif
}
val msg = String.format(message, player.getDisplayName().getString());
send(msg);
Expand Down
28 changes: 15 additions & 13 deletions fabric/src/main/java/cn/evole/mods/mcbot/util/onebot/CQUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

import cn.evole.mods.mcbot.Const;
import cn.evole.mods.mcbot.config.ModConfig;
import cn.evole.onebot.sdk.event.message.GroupMessageEvent;
import cn.evole.onebot.sdk.event.message.MessageEvent;
import io.netty.util.concurrent.SingleThreadEventExecutor;
import lombok.val;
import org.apache.commons.lang3.StringEscapeUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;
import java.util.concurrent.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -77,7 +74,11 @@ public static String replace(String msg) {
switch (type) {
case "image":
if (ModConfig.INSTANCE.getCommon().isImageOn() && Const.isLoad("chatimage")) {
val url = Arrays.stream(data.split(","))//具体数据分割
val url = Arrays.stream(
StringEscapeUtils
.escapeJava(data)//转义字符转义
.split(",")//具体数据分割
)
.filter(it -> it.startsWith("url"))//非空判断
.map(it -> it.substring(it.indexOf('=') + 1))
.findFirst();
Expand All @@ -91,14 +92,15 @@ public static String replace(String msg) {
}
break;
case "at":
val id = data.split("=");
if (id.length == 2) {
if (id[0].equals("qq"))
try {
matcher.appendReplacement(message, String.format("[@%s]", BotUtils.getNickname(Long.parseLong(id[1]))));
break;
} catch (NumberFormatException ignored) {}
}
val id = data.split("=");
if (id.length == 2) {
if (id[0].equals("qq"))
try {
matcher.appendReplacement(message, String.format("[@%s]", BotUtils.getNickname(Long.parseLong(id[1]))));
break;
} catch (NumberFormatException ignored) {
}
}
matcher.appendReplacement(message, "[@]");
break;
case "record":
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.16.5/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.16.5
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.18.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.19.2/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.19.3/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.3
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.19.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.20.1/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
2 changes: 1 addition & 1 deletion fabric/versions/1.20.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
loader_version=0.15.7
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
Expand Down
11 changes: 11 additions & 0 deletions fabric/versions/1.21/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
loader_version=0.15.11
loom.platform=fabric

# Fabric Mod Metadata
minecraft_dependency=1.21

# Dependencies
fabric_version=0.100.7+1.21

0 comments on commit 0ea3cc4

Please sign in to comment.