Search in sources :

Example 1 with ConnectListener

use of com.github.games647.fastlogin.velocity.listener.ConnectListener in project ChangeSkin by games647.

the class ChangeSkinBungee method onEnable.

@Override
public void onEnable() {
    logger = CommonUtil.createLoggerFromJDK(getLogger());
    core = new ChangeSkinCore(this);
    try {
        core.load(true);
    } catch (Exception ioExc) {
        logger.error("Error initializing plugin. Disabling...", ioExc);
        return;
    }
    PluginManager pluginManager = getProxy().getPluginManager();
    pluginManager.registerListener(this, new ConnectListener(this));
    pluginManager.registerListener(this, new ServerSwitchListener(this));
    // this is required to listen to incoming messages from the server
    getProxy().registerChannel(new NamespaceKey(getName(), PERMISSION_RESULT_CHANNEL).getCombinedName());
    getProxy().registerChannel(new NamespaceKey(getName(), FORWARD_COMMAND_CHANNEL).getCombinedName());
    pluginManager.registerListener(this, new PluginMessageListener(this));
    // register commands
    pluginManager.registerCommand(this, new SetCommand(this));
    pluginManager.registerCommand(this, new InvalidateCommand(this));
    pluginManager.registerCommand(this, new UploadCommand(this));
    pluginManager.registerCommand(this, new SelectCommand(this));
    pluginManager.registerCommand(this, new InfoCommand(this));
}
Also used : PluginManager(net.md_5.bungee.api.plugin.PluginManager) ChangeSkinCore(com.github.games647.changeskin.core.ChangeSkinCore) NamespaceKey(com.github.games647.changeskin.core.message.NamespaceKey) ServerSwitchListener(com.github.games647.changeskin.bungee.listener.ServerSwitchListener) UploadCommand(com.github.games647.changeskin.bungee.command.UploadCommand) InfoCommand(com.github.games647.changeskin.bungee.command.InfoCommand) PluginMessageListener(com.github.games647.changeskin.bungee.listener.PluginMessageListener) SelectCommand(com.github.games647.changeskin.bungee.command.SelectCommand) ConnectListener(com.github.games647.changeskin.bungee.listener.ConnectListener) InvalidateCommand(com.github.games647.changeskin.bungee.command.InvalidateCommand) SetCommand(com.github.games647.changeskin.bungee.command.SetCommand)

Example 2 with ConnectListener

use of com.github.games647.fastlogin.velocity.listener.ConnectListener in project FastLogin by games647.

the class FastLoginBungee method onEnable.

@Override
public void onEnable() {
    logger = CommonUtil.initializeLoggerService(getLogger());
    scheduler = new AsyncScheduler(logger, task -> getProxy().getScheduler().runAsync(this, task));
    core = new FastLoginCore<>(this);
    core.load();
    if (!core.setupDatabase()) {
        return;
    }
    if (isPluginInstalled("floodgate")) {
        floodgateService = new FloodgateService(FloodgateApi.getInstance(), core);
    }
    if (isPluginInstalled("Geyser-BungeeCord")) {
        geyserService = new GeyserService(GeyserImpl.getInstance(), core);
    }
    // events
    PluginManager pluginManager = getProxy().getPluginManager();
    ConnectListener connectListener = new ConnectListener(this, core.getRateLimiter());
    pluginManager.registerListener(this, connectListener);
    pluginManager.registerListener(this, new PluginMessageListener(this));
    // this is required to listen to incoming messages from the server
    getProxy().registerChannel(NamespaceKey.getCombined(getName(), ChangePremiumMessage.CHANGE_CHANNEL));
    getProxy().registerChannel(NamespaceKey.getCombined(getName(), SuccessMessage.SUCCESS_CHANNEL));
    registerHook();
}
Also used : ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) AsyncScheduler(com.github.games647.fastlogin.core.AsyncScheduler) Arrays(java.util.Arrays) FloodgateService(com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService) BungeeCordAuthenticatorBungeeHook(com.github.games647.fastlogin.bungee.hook.BungeeCordAuthenticatorBungeeHook) AuthPlugin(com.github.games647.fastlogin.core.hooks.AuthPlugin) SuccessMessage(com.github.games647.fastlogin.core.message.SuccessMessage) BedrockService(com.github.games647.fastlogin.core.hooks.bedrock.BedrockService) ConcurrentMap(java.util.concurrent.ConcurrentMap) TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) GroupedThreadFactory(net.md_5.bungee.api.scheduler.GroupedThreadFactory) PluginMessageListener(com.github.games647.fastlogin.bungee.listener.PluginMessageListener) FastLoginCore(com.github.games647.fastlogin.core.shared.FastLoginCore) GeyserService(com.github.games647.fastlogin.core.hooks.bedrock.GeyserService) GeyserImpl(org.geysermc.geyser.GeyserImpl) ThreadFactory(java.util.concurrent.ThreadFactory) BungeeAuthHook(com.github.games647.fastlogin.bungee.hook.BungeeAuthHook) Path(java.nio.file.Path) ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) ChannelMessage(com.github.games647.fastlogin.core.message.ChannelMessage) CommandSender(net.md_5.bungee.api.CommandSender) FloodgateApi(org.geysermc.floodgate.api.FloodgateApi) Logger(org.slf4j.Logger) SodionAuthHook(com.github.games647.fastlogin.bungee.hook.SodionAuthHook) CommonUtil(com.github.games647.fastlogin.core.CommonUtil) NamespaceKey(com.github.games647.fastlogin.core.message.NamespaceKey) PlatformPlugin(com.github.games647.fastlogin.core.shared.PlatformPlugin) List(java.util.List) ConnectListener(com.github.games647.fastlogin.bungee.listener.ConnectListener) PendingConnection(net.md_5.bungee.api.connection.PendingConnection) Server(net.md_5.bungee.api.connection.Server) ByteStreams(com.google.common.io.ByteStreams) ChangePremiumMessage(com.github.games647.fastlogin.core.message.ChangePremiumMessage) Plugin(net.md_5.bungee.api.plugin.Plugin) MapMaker(com.google.common.collect.MapMaker) PluginManager(net.md_5.bungee.api.plugin.PluginManager) PluginManager(net.md_5.bungee.api.plugin.PluginManager) AsyncScheduler(com.github.games647.fastlogin.core.AsyncScheduler) FloodgateService(com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService) GeyserService(com.github.games647.fastlogin.core.hooks.bedrock.GeyserService) PluginMessageListener(com.github.games647.fastlogin.bungee.listener.PluginMessageListener) ConnectListener(com.github.games647.fastlogin.bungee.listener.ConnectListener)

Example 3 with ConnectListener

use of com.github.games647.fastlogin.velocity.listener.ConnectListener in project FastLogin by games647.

the class FastLoginVelocity method onProxyInitialization.

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
    scheduler = new AsyncScheduler(logger, task -> server.getScheduler().buildTask(this, task).schedule());
    core = new FastLoginCore<>(this);
    core.load();
    loadOrGenerateProxyId();
    if (!core.setupDatabase() || proxyId == null) {
        return;
    }
    server.getEventManager().register(this, new ConnectListener(this, core.getRateLimiter()));
    server.getEventManager().register(this, new PluginMessageListener(this));
    server.getChannelRegistrar().register(MinecraftChannelIdentifier.create(getName(), ChangePremiumMessage.CHANGE_CHANNEL));
    server.getChannelRegistrar().register(MinecraftChannelIdentifier.create(getName(), SuccessMessage.SUCCESS_CHANNEL));
}
Also used : MinecraftChannelIdentifier(com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier) AsyncScheduler(com.github.games647.fastlogin.core.AsyncScheduler) Inject(com.google.inject.Inject) SuccessMessage(com.github.games647.fastlogin.core.message.SuccessMessage) BedrockService(com.github.games647.fastlogin.core.hooks.bedrock.BedrockService) ProxyShutdownEvent(com.velocitypowered.api.event.proxy.ProxyShutdownEvent) ConcurrentMap(java.util.concurrent.ConcurrentMap) FastLoginCore(com.github.games647.fastlogin.core.shared.FastLoginCore) ConnectListener(com.github.games647.fastlogin.velocity.listener.ConnectListener) Player(com.velocitypowered.api.proxy.Player) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) ProxyInitializeEvent(com.velocitypowered.api.event.proxy.ProxyInitializeEvent) LegacyComponentSerializer(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer) Path(java.nio.file.Path) ByteArrayDataOutput(com.google.common.io.ByteArrayDataOutput) Plugin(com.velocitypowered.api.plugin.Plugin) ChannelMessage(com.github.games647.fastlogin.core.message.ChannelMessage) Logger(org.slf4j.Logger) Files(java.nio.file.Files) StandardOpenOption(java.nio.file.StandardOpenOption) IOException(java.io.IOException) PlatformPlugin(com.github.games647.fastlogin.core.shared.PlatformPlugin) UUID(java.util.UUID) RegisteredServer(com.velocitypowered.api.proxy.server.RegisteredServer) InetSocketAddress(java.net.InetSocketAddress) StandardCharsets(java.nio.charset.StandardCharsets) PluginMessageListener(com.github.games647.fastlogin.velocity.listener.PluginMessageListener) DataDirectory(com.velocitypowered.api.plugin.annotation.DataDirectory) List(java.util.List) ByteStreams(com.google.common.io.ByteStreams) Subscribe(com.velocitypowered.api.event.Subscribe) ChangePremiumMessage(com.github.games647.fastlogin.core.message.ChangePremiumMessage) MapMaker(com.google.common.collect.MapMaker) CommandSource(com.velocitypowered.api.command.CommandSource) Collections(java.util.Collections) AsyncScheduler(com.github.games647.fastlogin.core.AsyncScheduler) PluginMessageListener(com.github.games647.fastlogin.velocity.listener.PluginMessageListener) ConnectListener(com.github.games647.fastlogin.velocity.listener.ConnectListener) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

AsyncScheduler (com.github.games647.fastlogin.core.AsyncScheduler)2 BedrockService (com.github.games647.fastlogin.core.hooks.bedrock.BedrockService)2 ChangePremiumMessage (com.github.games647.fastlogin.core.message.ChangePremiumMessage)2 ChannelMessage (com.github.games647.fastlogin.core.message.ChannelMessage)2 SuccessMessage (com.github.games647.fastlogin.core.message.SuccessMessage)2 FastLoginCore (com.github.games647.fastlogin.core.shared.FastLoginCore)2 PlatformPlugin (com.github.games647.fastlogin.core.shared.PlatformPlugin)2 MapMaker (com.google.common.collect.MapMaker)2 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)2 ByteStreams (com.google.common.io.ByteStreams)2 Path (java.nio.file.Path)2 List (java.util.List)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 PluginManager (net.md_5.bungee.api.plugin.PluginManager)2 InfoCommand (com.github.games647.changeskin.bungee.command.InfoCommand)1 InvalidateCommand (com.github.games647.changeskin.bungee.command.InvalidateCommand)1 SelectCommand (com.github.games647.changeskin.bungee.command.SelectCommand)1 SetCommand (com.github.games647.changeskin.bungee.command.SetCommand)1 UploadCommand (com.github.games647.changeskin.bungee.command.UploadCommand)1 ConnectListener (com.github.games647.changeskin.bungee.listener.ConnectListener)1