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;
}
}
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);
}
}
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);
}
}
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);
}
}
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));
}
Aggregations