Skip to content

Commit

Permalink
问题修复 (#148)
Browse files Browse the repository at this point in the history
* 临时的崩溃修复

* 问题修复和代码格式化

现在发送消息不会导致服务器暂停
调整一些对象的作用域

* 现在游戏内聊天中的"[""]"不会被错误转义。

孩子们我回来了

* 异步游戏->QQ的CQ转义

反卡服

* 移除多余的代码

忘删了

* 添加一个替选的旧方法

把上一个提交删的加回来了

* APIUpdate

优化MessageThread效率
添加一个回调api。

* APIUpdate

清理MessageThread代码
添加一个自定义请求API。

* bug fix

修复游戏崩溃

* 自动重连更新

你说得对,但是我最开始是检测心跳包的。

* fix

* Update fabric.yml

* test for auto-publish

* Update fabric.yml

* Update fabric.yml

* test for auto-publish

* 滚回功率

* 滚回功率

* 滚回功率

* api修正

* fix heartbeat bug

* fix mod-config bug
  • Loading branch information
xia-mc authored Mar 19, 2024
1 parent 59abaff commit f425f65
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 1 addition & 3 deletions fabric/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ apply(plugin: "dev.architectury.loom")
apply(plugin: "com.replaymod.preprocess")
apply(plugin: "dev.vankka.dependencydownload.plugin")

int mcVersion = 1

preprocess {
mcVersion = vars.get()["MC"]
int mcVersion = vars.get()["MC"]
tabIndentation = true
}

Expand Down
1 change: 1 addition & 0 deletions fabric/src/main/java/cn/evole/mods/mcbot/McBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void onServerStarting(MinecraftServer server) {
}

public void onServerStarted(MinecraftServer server) {
ModConfig.INSTANCE.save();
if (ModConfig.INSTANCE.getCommon().isAutoOpen()) {
onebot = OneBotClient.create(ModConfig.INSTANCE.getBotConfig().build()).open().registerEvents(new IBotEvent());
connected = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ public class McBotChatEvents {
* 当玩家发送一条消息(并转发到QQ)后触发。
* 包含发送消息的玩家和message_id
*/
public static final Event<PlayerChat> ON_CHAT = EventFactory.createArrayBacked(PlayerChat.class, callbacks -> (player, message_id) -> {
public static final Event<PlayerChat> ON_CHAT = EventFactory.createArrayBacked(PlayerChat.class, callbacks -> (player, message_id, message) -> {
for (PlayerChat callback : callbacks) {
callback.onChat(player, message_id);
callback.onChat(player, message_id, message);
}
});

@FunctionalInterface
public interface PlayerChat {
void onChat(ServerPlayer player, int message_id);
void onChat(ServerPlayer player, int message_id, String message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ public KeepAlive() {
}

public void onHeartbeat(@NotNull HeartbeatMetaEvent event) {
heartBeatQueue.add(event);
try {
heartBeatQueue.add(event);
} catch (IllegalStateException ignored) {
heartBeatQueue.poll();
onHeartbeat(event);
}
}

public void register() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void submit(long groupId, Callable<String> msg, boolean autoEscape, Serve
val message = msg.call();
Const.LOGGER.debug("转发游戏消息: {}", message);
McBotChatEvents.ON_CHAT.invoker().onChat(player,
McBot.onebot.getBot().sendGroupMsg(groupId, message, autoEscape).getData().getMessageId()
McBot.onebot.getBot().sendGroupMsg(groupId, message, autoEscape).getData().getMessageId(),
message
);
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit f425f65

Please sign in to comment.