Search in sources :

Example 1 with ProxyObject

use of cloud.timo.TimoCloud.api.objects.ProxyObject in project TimoCloud by TimoCloud.

the class TimoCloudUniversalAPIStorageUpdateListener method onProxyUnregisterEvent.

@EventHandler
public void onProxyUnregisterEvent(ProxyUnregisterEvent event) {
    ProxyObject proxy = event.getProxy();
    api.getProxyStorage().remove(proxy);
    ((ProxyGroupObjectBasicImplementation) proxy.getGroup()).removeProxyInternally(((ProxyObjectBasicImplementation) proxy).toLink());
}
Also used : ProxyObject(cloud.timo.TimoCloud.api.objects.ProxyObject) EventHandler(cloud.timo.TimoCloud.api.events.EventHandler)

Example 2 with ProxyObject

use of cloud.timo.TimoCloud.api.objects.ProxyObject in project TimoCloud by TimoCloud.

the class TimoCloudUniversalAPIStorageUpdateListener method onProxyRegisterEvent.

@EventHandler
public void onProxyRegisterEvent(ProxyRegisterEvent event) {
    ProxyObject proxy = event.getProxy();
    api.getProxyStorage().add(proxy);
    ((ProxyGroupObjectBasicImplementation) proxy.getGroup()).addProxyInternally(((ProxyObjectBasicImplementation) proxy).toLink());
}
Also used : ProxyObject(cloud.timo.TimoCloud.api.objects.ProxyObject) EventHandler(cloud.timo.TimoCloud.api.events.EventHandler)

Example 3 with ProxyObject

use of cloud.timo.TimoCloud.api.objects.ProxyObject in project TimoCloud by TimoCloud.

the class ProxyPing method onProxyPingEvent.

@Subscribe(order = PostOrder.EARLY)
public void onProxyPingEvent(ProxyPingEvent event) {
    ProxyObject proxyObject = TimoCloudAPI.getBungeeAPI().getThisProxy();
    ServerPing serverPing = event.getPing();
    serverPing = serverPing.asBuilder().maximumPlayers(proxyObject.getGroup().getMaxPlayerCount()).onlinePlayers(proxyObject.getGroup().getOnlinePlayerCount()).build();
    if (TimoCloudVelocity.getInstance().getFileManager().getConfig().getBoolean("useGlobalMotd"))
        serverPing = serverPing.asBuilder().description(Component.text(ChatColorUtil.translateAlternateColorCodes('&', proxyObject.getGroup().getMotd()))).build();
    event.setPing(serverPing);
}
Also used : ProxyObject(cloud.timo.TimoCloud.api.objects.ProxyObject) ServerPing(com.velocitypowered.api.proxy.server.ServerPing) Subscribe(com.velocitypowered.api.event.Subscribe)

Example 4 with ProxyObject

use of cloud.timo.TimoCloud.api.objects.ProxyObject in project TimoCloud by TimoCloud.

the class CoreEventManager method onPlayerDisconnect.

@EventHandler
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
    ((PlayerObjectBasicImplementation) event.getPlayer()).setOnline(false);
    ProxyObject proxyObject = event.getPlayer().getProxy();
    if (proxyObject != null) {
        Proxy proxy = TimoCloudCore.getInstance().getInstanceManager().getProxyByProxyObject(proxyObject);
        if (proxy != null)
            proxy.onPlayerDisconnect(event.getPlayer());
    }
    ServerObject serverObject = event.getPlayer().getServer();
    if (serverObject != null) {
        Server server = TimoCloudCore.getInstance().getInstanceManager().getServerByServerObject(serverObject);
        if (server != null)
            server.onPlayerDisconnect(event.getPlayer());
    }
}
Also used : PlayerObjectBasicImplementation(cloud.timo.TimoCloud.api.implementations.objects.PlayerObjectBasicImplementation) ProxyObject(cloud.timo.TimoCloud.api.objects.ProxyObject) Proxy(cloud.timo.TimoCloud.core.objects.Proxy) Server(cloud.timo.TimoCloud.core.objects.Server) ServerObject(cloud.timo.TimoCloud.api.objects.ServerObject) EventHandler(cloud.timo.TimoCloud.api.events.EventHandler)

Example 5 with ProxyObject

use of cloud.timo.TimoCloud.api.objects.ProxyObject in project TimoCloud by TimoCloud.

the class CoreEventManager method onPlayerConnectEvent.

@EventHandler
public void onPlayerConnectEvent(PlayerConnectEvent event) {
    ProxyObject proxyObject = event.getPlayer().getProxy();
    if (proxyObject != null) {
        Proxy proxy = TimoCloudCore.getInstance().getInstanceManager().getProxyByProxyObject(proxyObject);
        if (proxy != null)
            proxy.onPlayerConnect(event.getPlayer());
    }
    ServerObject serverObject = event.getPlayer().getServer();
    if (serverObject != null) {
        Server server = TimoCloudCore.getInstance().getInstanceManager().getServerByServerObject(serverObject);
        if (server != null)
            server.onPlayerConnect(event.getPlayer());
    }
}
Also used : ProxyObject(cloud.timo.TimoCloud.api.objects.ProxyObject) Proxy(cloud.timo.TimoCloud.core.objects.Proxy) Server(cloud.timo.TimoCloud.core.objects.Server) ServerObject(cloud.timo.TimoCloud.api.objects.ServerObject) EventHandler(cloud.timo.TimoCloud.api.events.EventHandler)

Aggregations

ProxyObject (cloud.timo.TimoCloud.api.objects.ProxyObject)8 EventHandler (cloud.timo.TimoCloud.api.events.EventHandler)4 ServerObject (cloud.timo.TimoCloud.api.objects.ServerObject)2 Proxy (cloud.timo.TimoCloud.core.objects.Proxy)2 Server (cloud.timo.TimoCloud.core.objects.Server)2 PlayerObjectBasicImplementation (cloud.timo.TimoCloud.api.implementations.objects.PlayerObjectBasicImplementation)1 ProxyGroupObject (cloud.timo.TimoCloud.api.objects.ProxyGroupObject)1 Message (cloud.timo.TimoCloud.common.protocol.Message)1 MessageType (cloud.timo.TimoCloud.common.protocol.MessageType)1 TimoCloudCord (cloud.timo.TimoCloud.cord.TimoCloudCord)1 ConnectionState (cloud.timo.TimoCloud.cord.objects.ConnectionState)1 PacketUtil (cloud.timo.TimoCloud.cord.utils.PacketUtil)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 ServerPing (com.velocitypowered.api.proxy.server.ServerPing)1 Bootstrap (io.netty.bootstrap.Bootstrap)1 ByteBuf (io.netty.buffer.ByteBuf)1 io.netty.channel (io.netty.channel)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 InetSocketAddress (java.net.InetSocketAddress)1 ServerPing (net.md_5.bungee.api.ServerPing)1