Code format.

This commit is contained in:
md_5 2014-04-13 14:15:41 +10:00
parent 3b71a2b570
commit dc2da29c16
15 changed files with 46 additions and 32 deletions

View File

@ -85,7 +85,9 @@ public interface CommandSender
/** /**
* Get all Permissions which this CommandSender has * Get all Permissions which this CommandSender has
* @return a unmodifiable Collection of Strings which represent their permissions *
* @return a unmodifiable Collection of Strings which represent their
* permissions
*/ */
public Collection<String> getPermissions(); public Collection<String> getPermissions();
} }

View File

@ -47,7 +47,10 @@ public class TextComponent extends BaseComponent
c += 32; c += 32;
} }
ChatColor format = ChatColor.getByChar( c ); ChatColor format = ChatColor.getByChar( c );
if ( format == null ) continue; if ( format == null )
{
continue;
}
if ( builder.length() > 0 ) if ( builder.length() > 0 )
{ {
TextComponent old = component; TextComponent old = component;
@ -145,14 +148,15 @@ public class TextComponent extends BaseComponent
} }
/** /**
* Creates a TextComponent with blank text and the extras set * Creates a TextComponent with blank text and the extras set to the passed
* to the passed array * array
* *
* @param extras the extras to set * @param extras the extras to set
*/ */
public TextComponent(BaseComponent ...extras) { public TextComponent(BaseComponent... extras)
{
setText( "" ); setText( "" );
setExtra( Arrays.asList(extras) ); setExtra( Arrays.asList( extras ) );
} }
@Override @Override

View File

@ -75,9 +75,10 @@ public class BaseComponentSerializer
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context) protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context)
{ {
boolean first = false; boolean first = false;
if ( ComponentSerializer.serializedComponents.get() == null ) { if ( ComponentSerializer.serializedComponents.get() == null )
{
first = true; first = true;
ComponentSerializer.serializedComponents.set( new HashSet<BaseComponent>( ) ); ComponentSerializer.serializedComponents.set( new HashSet<BaseComponent>() );
} }
try try
{ {
@ -131,7 +132,8 @@ public class BaseComponentSerializer
} finally } finally
{ {
ComponentSerializer.serializedComponents.get().remove( component ); ComponentSerializer.serializedComponents.get().remove( component );
if (first) { if ( first )
{
ComponentSerializer.serializedComponents.set( null ); ComponentSerializer.serializedComponents.set( null );
} }
} }

View File

@ -31,7 +31,7 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context) public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
{ {
List<BaseComponent> extra = src.getExtra(); List<BaseComponent> extra = src.getExtra();
if ( !src.hasFormatting() && (extra == null || extra.size() == 0) ) if ( !src.hasFormatting() && ( extra == null || extra.size() == 0 ) )
{ {
return new JsonPrimitive( src.getText() ); return new JsonPrimitive( src.getText() );
} }

View File

@ -56,20 +56,20 @@ public class YamlConfiguration extends ConfigurationProvider
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Configuration load(Reader reader) public Configuration load(Reader reader)
{ {
Map<String,Object> map = yaml.get().loadAs( reader, LinkedHashMap.class ); Map<String, Object> map = yaml.get().loadAs( reader, LinkedHashMap.class );
if( map == null ) if ( map == null )
{ {
map = new LinkedHashMap<>(); map = new LinkedHashMap<>();
} }
return new Configuration( map , null ); return new Configuration( map, null );
} }
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Configuration load(String string) public Configuration load(String string)
{ {
Map<String,Object> map = yaml.get().loadAs( string, LinkedHashMap.class ); Map<String, Object> map = yaml.get().loadAs( string, LinkedHashMap.class );
if( map == null ) if ( map == null )
{ {
map = new LinkedHashMap<>(); map = new LinkedHashMap<>();
} }

View File

@ -2,11 +2,13 @@ package net.md_5.bungee.module.cmd.alert;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
public class PluginAlert extends Plugin { public class PluginAlert extends Plugin
{
@Override @Override
public void onEnable() { public void onEnable()
getProxy().getPluginManager().registerCommand(this, new CommandAlert()); {
getProxy().getPluginManager().registerCommand(this, new CommandAlertRaw()); getProxy().getPluginManager().registerCommand( this, new CommandAlert() );
getProxy().getPluginManager().registerCommand( this, new CommandAlertRaw() );
} }
} }

View File

@ -95,8 +95,14 @@ public class CommandSend extends Command implements TabExecutor
matches.add( player.getName() ); matches.add( player.getName() );
} }
} }
if ( "all".startsWith( search ) ) matches.add( "all" ); if ( "all".startsWith( search ) )
if ( "current".startsWith( search ) ) matches.add( "current" ); {
matches.add( "all" );
}
if ( "current".startsWith( search ) )
{
matches.add( "current" );
}
} else } else
{ {
String search = args[1].toLowerCase(); String search = args[1].toLowerCase();

View File

@ -48,7 +48,7 @@ public class CommandServer extends Command implements TabExecutor
if ( server.canAccess( player ) ) if ( server.canAccess( player ) )
{ {
TextComponent serverTextComponent = new TextComponent( first ? server.getName() : ", " + server.getName() ); TextComponent serverTextComponent = new TextComponent( first ? server.getName() : ", " + server.getName() );
serverTextComponent.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(server.getPlayers().size() + " players").create() ) ); serverTextComponent.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( server.getPlayers().size() + " players" ).create() ) );
serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) ); serverTextComponent.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
serverList.addExtra( serverTextComponent ); serverList.addExtra( serverTextComponent );
first = false; first = false;

View File

@ -37,7 +37,6 @@ public enum Protocol
HANDSHAKE HANDSHAKE
{ {
{ {
TO_SERVER.registerPacket( 0x00, Handshake.class ); TO_SERVER.registerPacket( 0x00, Handshake.class );
} }
@ -46,7 +45,6 @@ public enum Protocol
GAME GAME
{ {
{ {
TO_CLIENT.registerPacket( 0x00, KeepAlive.class ); TO_CLIENT.registerPacket( 0x00, KeepAlive.class );
TO_CLIENT.registerPacket( 0x01, Login.class ); TO_CLIENT.registerPacket( 0x01, Login.class );
@ -72,7 +70,6 @@ public enum Protocol
STATUS STATUS
{ {
{ {
TO_CLIENT.registerPacket( 0x00, StatusResponse.class ); TO_CLIENT.registerPacket( 0x00, StatusResponse.class );
TO_CLIENT.registerPacket( 0x01, PingPacket.class ); TO_CLIENT.registerPacket( 0x01, PingPacket.class );
@ -85,7 +82,6 @@ public enum Protocol
LOGIN LOGIN
{ {
{ {
TO_CLIENT.registerPacket( 0x00, Kick.class ); TO_CLIENT.registerPacket( 0x00, Kick.class );
TO_CLIENT.registerPacket( 0x01, EncryptionRequest.class ); TO_CLIENT.registerPacket( 0x01, EncryptionRequest.class );

View File

@ -163,7 +163,7 @@ public class EntityMap
packet.readerIndex( readerIndex ); packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength ); packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeString( player.getUniqueId().toString(), packet ); DefinedPacket.writeString( player.getUniqueId().toString(), packet );
DefinedPacket.writeString( username, packet); DefinedPacket.writeString( username, packet );
DefinedPacket.writeVarInt( profile.getProperties().length, packet ); DefinedPacket.writeVarInt( profile.getProperties().length, packet );
for ( LoginResult.Property property : profile.getProperties() ) for ( LoginResult.Property property : profile.getProperties() )
{ {

View File

@ -28,7 +28,7 @@ public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInf
JsonObject js = json.getAsJsonObject(); JsonObject js = json.getAsJsonObject();
ServerPing.PlayerInfo info = new ServerPing.PlayerInfo( js.get( "name" ).getAsString(), (UUID) null ); ServerPing.PlayerInfo info = new ServerPing.PlayerInfo( js.get( "name" ).getAsString(), (UUID) null );
String id = js.get( "id" ).getAsString(); String id = js.get( "id" ).getAsString();
if ( protocol == 4 || !id.contains( "-" )) if ( protocol == 4 || !id.contains( "-" ) )
{ {
info.setId( id ); info.setId( id );
} else } else

View File

@ -5,7 +5,8 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
/** /**
* Command to terminate the proxy instance. May only be used by the console by default. * Command to terminate the proxy instance. May only be used by the console by
* default.
*/ */
public class CommandEnd extends Command public class CommandEnd extends Command
{ {

View File

@ -20,7 +20,7 @@ public class CommandReload extends Command
BungeeCord.getInstance().config.load(); BungeeCord.getInstance().config.load();
BungeeCord.getInstance().stopListeners(); BungeeCord.getInstance().stopListeners();
BungeeCord.getInstance().startListeners(); BungeeCord.getInstance().startListeners();
BungeeCord.getInstance().getPluginManager().callEvent(new ProxyReloadEvent(sender)); BungeeCord.getInstance().getPluginManager().callEvent( new ProxyReloadEvent( sender ) );
sender.sendMessage( ChatColor.BOLD.toString() + ChatColor.RED.toString() + "BungeeCord has been reloaded." sender.sendMessage( ChatColor.BOLD.toString() + ChatColor.RED.toString() + "BungeeCord has been reloaded."
+ " This is NOT advisable and you will not be supported with any issues that arise! Please restart BungeeCord ASAP." ); + " This is NOT advisable and you will not be supported with any issues that arise! Please restart BungeeCord ASAP." );

View File

@ -172,7 +172,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if ( forced != null && listener.isPingPassthrough() ) if ( forced != null && listener.isPingPassthrough() )
{ {
((BungeeServerInfo) forced).ping( pingBack, handshake.getProtocolVersion() ); ( (BungeeServerInfo) forced ).ping( pingBack, handshake.getProtocolVersion() );
} else } else
{ {
int protocol = ( Protocol.supportedVersions.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : -1; int protocol = ( Protocol.supportedVersions.contains( handshake.getProtocolVersion() ) ) ? handshake.getProtocolVersion() : -1;

View File

@ -13,7 +13,8 @@ public class LoginResult
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public static class Property { public static class Property
{
private String name; private String name;
private String value; private String value;