fix: 修复已知问题
This commit is contained in:
@@ -26,6 +26,7 @@ public class HamsterBallPlugin extends JavaPlugin {
|
||||
logger.info("BallBukkitAPI 已初始化.");
|
||||
try {
|
||||
BallBukkitAPI.getInstance().enable();
|
||||
logger.info("BallBukkitAPI 已启动.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sync(Bukkit::shutdown);
|
||||
|
@@ -14,7 +14,7 @@ dependencies {
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
filesMatching("plugin.yml") {
|
||||
filesMatching("bungee.yml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||
|
@@ -19,9 +19,10 @@ public class HamsterBallPlugin extends Plugin {
|
||||
instance = this;
|
||||
Logger logger = getLogger();
|
||||
BallBungeeCordAPI.init();
|
||||
logger.info("BallBukkitAPI 已初始化.");
|
||||
logger.info("BallBungeeCordAPI 已初始化.");
|
||||
try {
|
||||
BallBungeeCordAPI.getInstance().enable();
|
||||
logger.info("BallBungeeCordAPI 已启动.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ProxyServer.getInstance().stop();
|
||||
@@ -32,7 +33,7 @@ public class HamsterBallPlugin extends Plugin {
|
||||
public void onEnable() {
|
||||
Logger logger = getLogger();
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(this, BallBungeeCordListener.INSTANCE);
|
||||
logger.info("已注册 BallBukkitListener.");
|
||||
logger.info("已注册 BallBungeeCordListener.");
|
||||
logger.info("HamsterBall 已启动.");
|
||||
}
|
||||
|
||||
|
@@ -7,14 +7,10 @@ import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
||||
import cn.hamster3.mc.plugin.core.bungee.HamsterBallPlugin;
|
||||
import cn.hamster3.mc.plugin.core.bungee.listener.BallBungeeCordListener;
|
||||
import cn.hamster3.mc.plugin.core.bungee.util.BungeeCordUtils;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BallBungeeCordAPI extends BallAPI {
|
||||
public BallBungeeCordAPI(@NotNull BallConfig config) {
|
||||
@@ -25,22 +21,19 @@ public class BallBungeeCordAPI extends BallAPI {
|
||||
return (BallBungeeCordAPI) instance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void init() {
|
||||
if (instance != null) {
|
||||
return;
|
||||
}
|
||||
HamsterBallPlugin plugin = HamsterBallPlugin.getInstance();
|
||||
Configuration pluginConfig = BungeeCordUtils.getPluginConfig(plugin);
|
||||
Optional<InetSocketAddress> address = ProxyServer.getInstance().getConfig().getListeners().stream().findFirst().map(ListenerInfo::getHost);
|
||||
String host = pluginConfig.getString("server-info.name.host", address.map(InetSocketAddress::getHostName).orElse(""));
|
||||
BallConfig config = new BallConfig(
|
||||
new BallServerInfo(
|
||||
pluginConfig.getString("server-info.id"),
|
||||
pluginConfig.getString("server-info.name"),
|
||||
BallServerType.GAME,
|
||||
host.isEmpty() ? "127.0.0.1" : host,
|
||||
pluginConfig.getInt("server-info.name.port", address.map(InetSocketAddress::getPort).orElse(25577))
|
||||
pluginConfig.getString("server-info.host", ""),
|
||||
pluginConfig.getInt("server-info.port", 25577)
|
||||
),
|
||||
pluginConfig.getString("ball-server.host"),
|
||||
pluginConfig.getInt("ball-server.port"),
|
||||
|
@@ -8,3 +8,5 @@ server-info:
|
||||
id: "BungeeCord"
|
||||
# 服务端名称,用于展示给玩家看
|
||||
name: "代理端"
|
||||
host: 0.0.0.0
|
||||
port: 25577
|
||||
|
Reference in New Issue
Block a user