Search in sources :

Example 21 with Listener

use of net.md_5.bungee.api.plugin.Listener in project BungeeFoundation by kangarko.

the class SimplePlugin method reload.

// ----------------------------------------------------------------------------------------
// Reload
// ----------------------------------------------------------------------------------------
/**
 * Attempts to reload the plugin
 */
public final void reload() {
    final String oldLogPrefix = Common.getLogPrefix();
    Common.setLogPrefix("");
    Common.log(Common.consoleLineSmooth());
    Common.log(" ");
    Common.log("Reloading plugin " + this.getDataFolder().getName() + " v" + getVersion());
    Common.log(" ");
    reloading = true;
    try {
        for (final Listener listener : this.listeners) ProxyServer.getInstance().getPluginManager().unregisterListener(listener);
        this.listeners.clear();
        Debugger.detectDebugMode();
        this.unregisterReloadables();
        FileConfig.clearLoadedSections();
        this.onPluginPreReload();
        Common.setTellPrefix(SimpleSettings.PLUGIN_PREFIX);
        this.onPluginReload();
        // Something went wrong in the reload pipeline
        if (!enabled)
            return;
        // Register classes
        AutoRegisterScanner.scanAndRegister();
        Lang.reloadLang();
        Lang.loadPrefixes();
        this.onReloadablesStart();
        Common.log(Common.consoleLineSmooth());
    } catch (final Throwable t) {
        Common.throwError(t, "Error reloading " + this.getDataFolder().getName() + " " + getVersion());
    } finally {
        Common.setLogPrefix(oldLogPrefix);
        reloading = false;
    }
}
Also used : Listener(net.md_5.bungee.api.plugin.Listener) BungeeListener(org.mineacademy.bfo.bungee.BungeeListener)

Example 22 with Listener

use of net.md_5.bungee.api.plugin.Listener in project BungeeTabListPlus by CodeCrafter47.

the class TabListListener method onPlayerJoin.

@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PostLoginEvent e) {
    try {
        BungeePlayer player = btlp.getBungeePlayerProvider().onPlayerConnected(e.getPlayer());
        TabView tabView = btlp.getTabViewManager().onPlayerJoin(e.getPlayer());
        tabView.getTabOverlayProviders().addProvider(new ExcludedServersTabOverlayProvider(player, btlp));
        for (EventListener listener : btlp.getListeners()) {
            listener.onTabViewAdded(tabView, player);
        }
    } catch (Throwable th) {
        BungeeTabListPlus.getInstance().reportError(th);
    }
}
Also used : BungeePlayer(codecrafter47.bungeetablistplus.player.BungeePlayer) TabView(de.codecrafter47.taboverlay.TabView) ExcludedServersTabOverlayProvider(codecrafter47.bungeetablistplus.tablist.ExcludedServersTabOverlayProvider) EventListener(de.codecrafter47.taboverlay.config.platform.EventListener) EventHandler(net.md_5.bungee.event.EventHandler)

Example 23 with Listener

use of net.md_5.bungee.api.plugin.Listener in project BungeeTabListPlus by CodeCrafter47.

the class TabListListener method onPlayerDisconnect.

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDisconnect(PlayerDisconnectEvent e) {
    try {
        TabView tabView = btlp.getTabViewManager().onPlayerDisconnect(e.getPlayer());
        tabView.deactivate();
        for (EventListener listener : btlp.getListeners()) {
            listener.onTabViewRemoved(tabView);
        }
        btlp.getBungeePlayerProvider().onPlayerDisconnected(e.getPlayer());
        // hack to revert changes from https://github.com/SpigotMC/BungeeCord/commit/830f18a35725f637d623594eaaad50b566376e59
        Server server = e.getPlayer().getServer();
        if (server != null) {
            server.disconnect("Quitting");
        }
        ((UserConnection) e.getPlayer()).setServer(null);
    } catch (Throwable th) {
        BungeeTabListPlus.getInstance().reportError(th);
    }
}
Also used : Server(net.md_5.bungee.api.connection.Server) TabView(de.codecrafter47.taboverlay.TabView) EventListener(de.codecrafter47.taboverlay.config.platform.EventListener) UserConnection(net.md_5.bungee.UserConnection) EventHandler(net.md_5.bungee.event.EventHandler)

Example 24 with Listener

use of net.md_5.bungee.api.plugin.Listener in project BungeeTabListPlus by CodeCrafter47.

the class TabViewManager method onServerConnected.

@EventHandler
public void onServerConnected(ServerSwitchEvent event) {
    try {
        ProxiedPlayer player = event.getPlayer();
        PlayerTabView tabView = playerTabViewMap.get(player);
        if (tabView == null) {
            throw new AssertionError("Received ServerSwitchEvent for non-existent player " + player.getName());
        }
        ServerConnection server = (ServerConnection) event.getPlayer().getServer();
        ChannelWrapper wrapper = server.getCh();
        PacketHandler packetHandler = tabView.packetHandler;
        PacketListener packetListener = new PacketListener(server, packetHandler, player);
        wrapper.getHandle().pipeline().addBefore(PipelineUtils.BOSS_HANDLER, "btlp-packet-listener", packetListener);
        packetHandler.onServerSwitch(protocolVersionProvider.has113OrLater(player));
    } catch (Exception ex) {
        btlp.getLogger().log(Level.SEVERE, "Failed to inject packet listener", ex);
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) PacketHandler(codecrafter47.bungeetablistplus.protocol.PacketHandler) ServerConnection(net.md_5.bungee.ServerConnection) ChannelWrapper(net.md_5.bungee.netty.ChannelWrapper) PacketListener(codecrafter47.bungeetablistplus.protocol.PacketListener) EventHandler(net.md_5.bungee.event.EventHandler)

Example 25 with Listener

use of net.md_5.bungee.api.plugin.Listener in project Geyser by GeyserMC.

the class GeyserBungeePlugin method onEnable.

@Override
public void onEnable() {
    GeyserLocale.init(this);
    if (!getDataFolder().exists())
        getDataFolder().mkdir();
    try {
        if (!getDataFolder().exists())
            getDataFolder().mkdir();
        File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()), this);
        this.geyserConfig = FileUtils.loadConfig(configFile, GeyserBungeeConfiguration.class);
    } catch (IOException ex) {
        getLogger().log(Level.SEVERE, GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
        ex.printStackTrace();
        return;
    }
    if (getProxy().getConfig().getListeners().size() == 1) {
        ListenerInfo listener = getProxy().getConfig().getListeners().toArray(new ListenerInfo[0])[0];
        InetSocketAddress javaAddr = listener.getHost();
        // By default this should be localhost but may need to be changed in some circumstances
        if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
            this.geyserConfig.setAutoconfiguredRemote(true);
            // Don't use localhost if not listening on all interfaces
            if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
                this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
            }
            this.geyserConfig.getRemote().setPort(javaAddr.getPort());
        }
        if (geyserConfig.getBedrock().isCloneRemotePort()) {
            geyserConfig.getBedrock().setPort(javaAddr.getPort());
        }
    }
    this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
    GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
    // Remove this in like a year
    if (getProxy().getPluginManager().getPlugin("floodgate-bungee") != null) {
        geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.outdated", "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"));
        return;
    }
    if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) {
        geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
        return;
    } else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate") != null) {
        // Floodgate installed means that the user wants Floodgate authentication
        geyserLogger.debug("Auto-setting to Floodgate authentication.");
        geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE);
    }
    geyserConfig.loadFloodgate(this);
    this.geyser = GeyserImpl.start(PlatformType.BUNGEECORD, this);
    this.geyserInjector = new GeyserBungeeInjector(this);
    this.geyserInjector.initializeLocalChannel(this);
    this.geyserCommandManager = new GeyserBungeeCommandManager(geyser);
    if (geyserConfig.isLegacyPingPassthrough()) {
        this.geyserBungeePingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
    } else {
        this.geyserBungeePingPassthrough = new GeyserBungeePingPassthrough(getProxy());
    }
    this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor(geyser));
}
Also used : ListenerInfo(net.md_5.bungee.api.config.ListenerInfo) GeyserBungeeCommandManager(org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandManager) InetSocketAddress(java.net.InetSocketAddress) GeyserBungeeCommandExecutor(org.geysermc.geyser.platform.bungeecord.command.GeyserBungeeCommandExecutor) IOException(java.io.IOException) File(java.io.File)

Aggregations

ListenerInfo (net.md_5.bungee.api.config.ListenerInfo)9 Player (org.bukkit.entity.Player)7 Listener (net.md_5.bungee.api.plugin.Listener)6 TextComponent (net.md_5.bungee.api.chat.TextComponent)5 EventHandler (net.md_5.bungee.event.EventHandler)5 ChannelFuture (io.netty.channel.ChannelFuture)4 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)3 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)3 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)3 AdvancedCoreUser (com.bencodez.advancedcore.api.user.AdvancedCoreUser)3 BookManager (com.bencodez.advancedcore.api.valuerequest.book.BookManager)3 BookSign (com.bencodez.advancedcore.api.valuerequest.book.BookSign)3 ChannelFutureListener (io.netty.channel.ChannelFutureListener)3 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)3 BungeePlayer (codecrafter47.bungeetablistplus.player.BungeePlayer)2 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)2 PromptManager (com.bencodez.advancedcore.api.valuerequest.prompt.PromptManager)2 PromptReturnString (com.bencodez.advancedcore.api.valuerequest.prompt.PromptReturnString)2 TabView (de.codecrafter47.taboverlay.TabView)2 EventListener (de.codecrafter47.taboverlay.config.platform.EventListener)2