fix: 将 ServerOnlineEvent 延后至 onEnable 发送

This commit is contained in:
2022-11-14 18:06:46 +08:00
parent 8ffe38f17e
commit 1bbe1f4bbe
3 changed files with 13 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ package cn.hamster3.mc.plugin.ball.bukkit;
import cn.hamster3.mc.plugin.ball.bukkit.api.BallBukkitAPI;
import cn.hamster3.mc.plugin.ball.bukkit.hook.PlaceholderHook;
import cn.hamster3.mc.plugin.ball.bukkit.listener.BallBukkitListener;
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.event.server.ServerOnlineEvent;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@@ -39,6 +41,11 @@ public class HamsterBallPlugin extends JavaPlugin {
Logger logger = getLogger();
Bukkit.getPluginManager().registerEvents(BallBukkitListener.INSTANCE, this);
logger.info("已注册 BallBukkitListener.");
BallAPI.getInstance().sendBallMessage(
BallAPI.BALL_CHANNEL,
ServerOnlineEvent.ACTION,
new ServerOnlineEvent(BallAPI.getInstance().getLocalServerInfo())
);
logger.info("HamsterBall 已启动.");
sync(() -> {
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {

View File

@@ -3,6 +3,7 @@ package cn.hamster3.mc.plugin.core.bungee;
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.entity.BallServerInfo;
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
import cn.hamster3.mc.plugin.ball.common.event.server.ServerOnlineEvent;
import cn.hamster3.mc.plugin.core.bungee.api.BallBungeeCordAPI;
import cn.hamster3.mc.plugin.core.bungee.listener.BallBungeeCordListener;
import cn.hamster3.mc.plugin.core.bungee.util.BallBungeeCordUtils;
@@ -45,6 +46,11 @@ public class HamsterBallPlugin extends Plugin {
ProxyServer.getInstance().getServers().put(serverInfo.getId(), BallBungeeCordUtils.getServerInfo(serverInfo));
HamsterBallPlugin.getInstance().getLogger().info("已添加子服 " + serverInfo.getId() + " 的接入点配置.");
}
BallAPI.getInstance().sendBallMessage(
BallAPI.BALL_CHANNEL,
ServerOnlineEvent.ACTION,
new ServerOnlineEvent(BallAPI.getInstance().getLocalServerInfo())
);
logger.info("HamsterBall 已启动.");
}

View File

@@ -220,8 +220,6 @@ public abstract class BallAPI {
}
}
sendBallMessage(new BallMessageInfo(BALL_CHANNEL, ServerOnlineEvent.ACTION, new ServerOnlineEvent(localInfo)), true);
}
protected void connect() throws InterruptedException {