Skip to content

Commit

Permalink
+ fix #93
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlimiter committed May 22, 2023
1 parent ee1effa commit de64a5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
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
@@ -1,12 +1,9 @@
package cn.evole.mods.mcbot;

import cn.evole.mods.mcbot.init.callbacks.IEvents;
import cn.evole.mods.mcbot.init.event.IChatEvent;
import cn.evole.mods.mcbot.init.event.ICmdEvent;
import cn.evole.mods.mcbot.init.event.IPlayerEvent;
import cn.evole.mods.mcbot.init.event.*;
import cn.evole.mods.mcbot.init.handler.ConfigHandler;
import cn.evole.mods.mcbot.init.handler.CustomCmdHandler;
import cn.evole.mods.mcbot.init.event.IBotEvent;
import cn.evole.mods.mcbot.util.locale.I18n;
import cn.evole.onebot.client.connection.ConnectFactory;
import cn.evole.onebot.client.core.Bot;
Expand All @@ -20,6 +17,7 @@
//$$ 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;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.MinecraftServer;

Expand Down Expand Up @@ -62,6 +60,8 @@ public void onInitialize() {
ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStopping);
ServerLifecycleEvents.SERVER_STOPPED.register(this::onServerStopped);

ServerTickEvents.END_SERVER_TICK.register(ITickEvent::register);

IEvents.PLAYER_LOGGED_IN.register(IPlayerEvent::loggedIn);
IEvents.PLAYER_LOGGED_OUT.register(IPlayerEvent::loggedOut);
IEvents.PLAYER_ADVANCEMENT.register(IPlayerEvent::advancement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onMessage(GroupMessageEvent event) {
? String.format("§b[§l%s§r(§5%s§b)]§a<%s>§f %s", ConfigHandler.cached().getCmd().getQqGamePrefix(), event.getGroupId(), groupNick, send)
: String.format("§b[§l%s§b]§a<%s>§f %s", ConfigHandler.cached().getCmd().getQqGamePrefix(), groupNick, send)
: String.format("§a<%s>§f %s", groupNick, send);
ITickEvent.getToSendQueue().add(toSend);
ITickEvent.getSendQueue().add(toSend);
}
}
});
Expand Down Expand Up @@ -135,7 +135,7 @@ public void onMessage(GuildMessageEvent event) {
? String.format("§b[§l%s§r(§5%s§b)]§a<%s>§f %s", ConfigHandler.cached().getCmd().getGuildGamePrefix(), event.getChannelId(), guildNick, send)
: String.format("§b[§l%s§b]§a<%s>§f %s", ConfigHandler.cached().getCmd().getGuildGamePrefix(), guildNick, send)
: String.format("§a<%s>§f %s", guildNick, send);
ITickEvent.getToSendQueue().add(toSend);
ITickEvent.getSendQueue().add(toSend);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
* Version: 1.0
*/
public class ITickEvent {
private static final Queue<String> toSendQueue = new LinkedList<>();
;
private static final Queue<String> SEND_QUEUE = new LinkedList<>();

public static Queue<String> getToSendQueue() {
return toSendQueue;
public static Queue<String> getSendQueue() {
return SEND_QUEUE;
}


public static void init(MinecraftServer server) {
String toSend = toSendQueue.poll();
public static void register(MinecraftServer server) {
String toSend = SEND_QUEUE.poll();
if (ConfigHandler.cached() != null
&& server.isDedicatedServer()
&& toSend != null
Expand Down

0 comments on commit de64a5b

Please sign in to comment.