feat: 在 Redis 锁定服务器 ID
This commit is contained in:
@@ -5,10 +5,13 @@ import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerType;
|
||||
import cn.hamster3.mc.plugin.core.common.config.ConfigSection;
|
||||
import cn.hamster3.mc.plugin.core.common.config.YamlConfig;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -31,6 +34,14 @@ public class BallBungeeCordAPI extends BallAPI {
|
||||
|
||||
@Override
|
||||
public void enable() throws SQLException, InterruptedException {
|
||||
for (ListenerInfo listenerInfo : ProxyServer.getInstance().getConfig().getListeners()) {
|
||||
if (!(listenerInfo.getSocketAddress() instanceof InetSocketAddress)) {
|
||||
continue;
|
||||
}
|
||||
InetSocketAddress address = (InetSocketAddress) listenerInfo.getSocketAddress();
|
||||
instance.getLocalServerInfo().setHost(address.getHostString());
|
||||
instance.getLocalServerInfo().setPort(address.getPort());
|
||||
}
|
||||
super.enable();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user