public void reloadMessages() { File file = new File( "messages.properties" ); if ( file.isFile() ) { try ( FileReader rd = new FileReader( file ) ) { customBundle = new PropertyResourceBundle( rd ); } catch ( IOException ex ) { getLogger().log( Level.SEVERE, "Could not load custom messages.properties", ex ); } } }
@Override public void operationComplete(ChannelFuture future) throws Exception { if ( future.isSuccess() ) { listeners.add( future.channel() ); getLogger().log( Level.INFO, "Started query on {0}", future.channel().localAddress() ); } else { getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() ); } } };
@Override public void operationComplete(ChannelFuture future) throws Exception { if ( future.isSuccess() ) { listeners.add( future.channel() ); getLogger().log( Level.INFO, "Listening on {0}", info.getHost() ); } else { getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() ); } } };
static void logServer(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Server -> Bungee" : "Server <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
static void logClient(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Client -> Bungee" : "Client <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
getLogger().info( "Closing pending connections" ); getLogger().log( Level.INFO, "Disconnecting {0} connections", connections.size() ); for ( UserConnection user : connections.values() ) getLogger().info( "Saving reconnect locations" ); reconnectHandler.save(); reconnectHandler.close(); getLogger().info( "Disabling plugins" ); for ( Plugin plugin : Lists.reverse( new ArrayList<>( pluginManager.getPlugins() ) ) ) getLogger().log( Level.SEVERE, "Exception disabling plugin " + plugin.getDescription().getName(), t ); getLogger().info( "Closing IO threads" ); eventLoops.shutdownGracefully(); try getLogger().info( "Thank you and goodbye" ); for ( Handler handler : getLogger().getHandlers() )
bungee.getLogger().info( "Enabled BungeeCord version " + bungee.getVersion() ); bungee.start();
getLogger().log( Level.WARNING, "Using PROXY protocol for listener {0}, please ensure this listener is adequately firewalled.", info.getHost() );
registerChannel( ForgeConstants.FORGE_REGISTER ); getLogger().warning( "MinecraftForge support is currently unmaintained and may have unresolved issues. Please use at your own risk." );
@Override public void done(ServerPing result, Throwable error) { if ( error != null ) { result = new ServerPing(); result.setDescription( bungee.getTranslation( "ping_cannot_connect" ) ); bungee.getLogger().log( Level.WARNING, "Error pinging remote server", error ); } Callback<ProxyPingEvent> callback = new Callback<ProxyPingEvent>() { @Override public void done(ProxyPingEvent pingResult, Throwable error) { Gson gson = BungeeCord.getInstance().gson; unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) ); if ( bungee.getConnectionThrottle() != null ) { bungee.getConnectionThrottle().unthrottle( getAddress().getAddress() ); } } }; bungee.getPluginManager().callEvent( new ProxyPingEvent( InitialHandler.this, result, callback ) ); } };
@Override public void done(String result, Throwable error) { if ( error == null ) { LoginResult obj = BungeeCord.getInstance().gson.fromJson( result, LoginResult.class ); if ( obj != null && obj.getId() != null ) { loginProfile = obj; name = obj.getName(); uniqueId = Util.getUUID( obj.getId() ); finish(); return; } disconnect( bungee.getTranslation( "offline_mode_player" ) ); } else { disconnect( bungee.getTranslation( "mojang_fail" ) ); bungee.getLogger().log( Level.SEVERE, "Error authenticating " + getName() + " with minecraft.net", error ); } } };
@Override public void operationComplete(ChannelFuture future) throws Exception { if ( future.isSuccess() ) { listeners.add( future.channel() ); getLogger().log( Level.INFO, "Started query on {0}", future.channel().localAddress() ); } else { getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() ); } } };
@Override public void operationComplete(ChannelFuture future) throws Exception { if ( future.isSuccess() ) { listeners.add( future.channel() ); getLogger().log( Level.INFO, "Listening on {0}", info.getHost() ); } else { getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() ); } } };
static void logClient(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Client -> Bungee" : "Client <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
static void logServer(LogDirection direction, String stateName, PluginMessage message) { String dir = direction == LogDirection.SENDING ? "Server -> Bungee" : "Server <- Bungee"; String log = "[" + stateName + " " + dir + "][" + direction.name() + ": " + getNameFromDiscriminator( message.getTag(), message ) + "]"; BungeeCord.getInstance().getLogger().log( Level.FINE, log ); }
@Override public void done(String result, Throwable error) { if ( error == null ) { LoginResult obj = BungeeCord.getInstance().gson.fromJson( result, LoginResult.class ); if ( obj != null ) { loginProfile = obj; uniqueId = Util.getUUID( obj.getId() ); finish(); return; } disconnect( "Not authenticated with Minecraft.net" ); } else { disconnect( bungee.getTranslation( "mojang_fail" ) ); bungee.getLogger().log( Level.SEVERE, "Error authenticating " + getName() + " with minecraft.net", error ); } } };
public static void main(String[] args) throws Exception { BungeeCord bungee = new BungeeCord(); ProxyServer.setInstance( bungee ); bungee.getLogger().info( "Enabled BungeeCord version " + bungee.getVersion() ); bungee.start(); while ( bungee.isRunning ) { String line = bungee.getConsoleReader().readLine( ">" ); if ( line != null ) { if ( !bungee.getPluginManager().dispatchCommand( ConsoleCommandSender.getInstance(), line ) ) { bungee.getConsole().sendMessage( ChatColor.RED + "Command not found" ); } } } } }