feat: 新增 Velocity 支持
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package cn.hamster3.service.velocity;
|
||||
|
||||
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
||||
import cn.hamster3.service.common.util.ServiceLogUtils;
|
||||
import cn.hamster3.service.velocity.listener.BridgeListener;
|
||||
import cn.hamster3.service.velocity.listener.ServiceMainListener;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Plugin(
|
||||
id = "hamster-service",
|
||||
name = "HamsterService",
|
||||
version = BuildConstants.VERSION,
|
||||
description = BuildConstants.DESCRIPTION,
|
||||
authors = {"MiniDay"},
|
||||
dependencies = @Dependency(id = "hamster-ball")
|
||||
)
|
||||
public class BallBridgePlugin {
|
||||
private static BallBridgePlugin instance;
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
@Inject
|
||||
public BallBridgePlugin(ProxyServer proxyServer) {
|
||||
this.proxyServer = proxyServer;
|
||||
instance = this;
|
||||
ServiceLogUtils.setLogger(Logger.getLogger("HamsterService"));
|
||||
}
|
||||
|
||||
public static BallBridgePlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ProxyServer getProxyServer() {
|
||||
return proxyServer;
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(priority = 0)
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
BallAPI.getInstance().subscribeRaw("HamsterService");
|
||||
BallAPI.getInstance().getEventBus().register(BridgeListener.INSTANCE);
|
||||
proxyServer.getEventManager().register(this, ServiceMainListener.INSTANCE);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user