build: 移除无效项目
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
version = '1.1.0'
|
|
||||||
setArchivesBaseName("HamsterAuto-ServerInfo")
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compileOnly "cn.hamster3.mc.plugin:ball-bungee:${hamster_ball_version}"
|
|
||||||
}
|
|
@@ -1,36 +0,0 @@
|
|||||||
package cn.hamster3.mc.plugin.auto.server.info;
|
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.auto.server.info.listener.ServerInfoListener;
|
|
||||||
import cn.hamster3.mc.plugin.auto.server.info.util.ServerInfoUtils;
|
|
||||||
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 net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
|
|
||||||
public class ServerInfoPlugin extends Plugin {
|
|
||||||
private static ServerInfoPlugin instance;
|
|
||||||
|
|
||||||
public static ServerInfoPlugin getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
ProxyServer.getInstance().getServers().clear();
|
|
||||||
getLogger().info("已清除配置文件中子服接入点配置.");
|
|
||||||
for (BallServerInfo serverInfo : BallAPI.getInstance().getAllServerInfo().values()) {
|
|
||||||
if (serverInfo.getType() != BallServerType.GAME) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ProxyServer.getInstance().getServers().put(serverInfo.getId(), ServerInfoUtils.getServerInfo(serverInfo));
|
|
||||||
getLogger().info("已添加子服 " + serverInfo.getId() + " 的接入点配置.");
|
|
||||||
}
|
|
||||||
BallAPI.getInstance().getEventBus().register(ServerInfoListener.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
package cn.hamster3.mc.plugin.auto.server.info.listener;
|
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.auto.server.info.ServerInfoPlugin;
|
|
||||||
import cn.hamster3.mc.plugin.auto.server.info.util.ServerInfoUtils;
|
|
||||||
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.ServerOfflineEvent;
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.event.server.ServerOnlineEvent;
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ServerInfoListener {
|
|
||||||
public static final ServerInfoListener INSTANCE = new ServerInfoListener();
|
|
||||||
|
|
||||||
private ServerInfoListener() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onServerOnline(ServerOnlineEvent event) {
|
|
||||||
BallServerInfo serverInfo = event.getServerInfo();
|
|
||||||
if (serverInfo.getType() != BallServerType.GAME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProxyServer.getInstance().getServers().put(serverInfo.getId(), ServerInfoUtils.getServerInfo(serverInfo));
|
|
||||||
ServerInfoPlugin.getInstance().getLogger().info("已添加子服 " + serverInfo.getId() + " 的接入点配置");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onServerOffline(ServerOfflineEvent event) {
|
|
||||||
BallServerInfo info = event.getServerInfo();
|
|
||||||
String id = info.getId();
|
|
||||||
Map<String, ServerInfo> map = ProxyServer.getInstance().getServers();
|
|
||||||
if (map.remove(id) != null) {
|
|
||||||
ServerInfoPlugin.getInstance().getLogger().info("已移除子服 " + id + " 的接入点配置");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,18 +0,0 @@
|
|||||||
package cn.hamster3.mc.plugin.auto.server.info.util;
|
|
||||||
|
|
||||||
import cn.hamster3.mc.plugin.ball.common.entity.BallServerInfo;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
public final class ServerInfoUtils {
|
|
||||||
public static ServerInfo getServerInfo(BallServerInfo serverInfo) {
|
|
||||||
return ProxyServer.getInstance().constructServerInfo(
|
|
||||||
serverInfo.getId(),
|
|
||||||
new InetSocketAddress(serverInfo.getHost(), serverInfo.getPort()),
|
|
||||||
serverInfo.getName(),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +0,0 @@
|
|||||||
name: HamsterAuto-ServerInfo
|
|
||||||
main: cn.hamster3.mc.plugin.auto.server.info.ServerInfoPlugin
|
|
||||||
version: ${version}
|
|
||||||
|
|
||||||
author: MiniDay
|
|
||||||
description: 自动将接入仓鼠球的子服注册到连接配置中
|
|
@@ -3,7 +3,6 @@ rootProject.name = 'hamster-little-plugins'
|
|||||||
include 'hamster-auto-game-rule'
|
include 'hamster-auto-game-rule'
|
||||||
include 'hamster-auto-log-clear'
|
include 'hamster-auto-log-clear'
|
||||||
include 'hamster-auto-restart'
|
include 'hamster-auto-restart'
|
||||||
include 'hamster-auto-server-info'
|
|
||||||
include 'hamster-chain-break'
|
include 'hamster-chain-break'
|
||||||
include 'hamster-join-message'
|
include 'hamster-join-message'
|
||||||
include 'hamster-lobby'
|
include 'hamster-lobby'
|
||||||
|
Reference in New Issue
Block a user