Fix formatting

This commit is contained in:
md_5
2016-04-24 22:31:04 +10:00
parent 1cd3e42182
commit 80b3135a93
24 changed files with 356 additions and 347 deletions

View File

@@ -13,7 +13,7 @@ public class ConnectionThrottle
public ConnectionThrottle(int throttleTime)
{
this.throttleTime = throttleTime;
this.throttleTime = throttleTime;
this.throttle = CacheBuilder.newBuilder()
.concurrencyLevel( Runtime.getRuntime().availableProcessors() )
.initialCapacity( 100 )

View File

@@ -14,6 +14,7 @@ import java.util.UUID;
public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInfo>, JsonDeserializer<ServerPing.PlayerInfo>
{
@Override
public ServerPing.PlayerInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{

View File

@@ -41,20 +41,17 @@ public abstract class EntityMap
{
if ( varint )
{
clientboundVarInts[ id ] = true;
clientboundVarInts[id] = true;
} else
{
clientboundInts[ id ] = true;
clientboundInts[id] = true;
}
} else if ( varint )
{
serverboundVarInts[id] = true;
} else
{
if ( varint )
{
serverboundVarInts[ id ] = true;
} else
{
serverboundInts[ id ] = true;
}
serverboundInts[id] = true;
}
}
@@ -104,10 +101,10 @@ public abstract class EntityMap
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;
if ( ints[ packetId ] )
if ( ints[packetId] )
{
rewriteInt( packet, oldId, newId, readerIndex + packetIdLength );
} else if ( varints[ packetId ] )
} else if ( varints[packetId] )
{
rewriteVarInt( packet, oldId, newId, readerIndex + packetIdLength );
}

View File

@@ -12,6 +12,7 @@ import java.util.UUID;
class EntityMap_1_9 extends EntityMap
{
static final EntityMap_1_9 INSTANCE = new EntityMap_1_9();
EntityMap_1_9()

View File

@@ -4,7 +4,6 @@ import java.util.Map;
import net.md_5.bungee.ServerConnector;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.forge.ForgeLogger.LogDirection;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.PluginMessage;
/**
@@ -25,22 +24,22 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler<ForgeClientH
* Requires: {@link UserConnection}.
*/
START
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( LogDirection.RECEIVED, this.name(), message );
con.unsafe().sendPacket( message );
con.getForgeClientHandler().setState( HELLO );
return HELLO;
}
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( LogDirection.RECEIVED, this.name(), message );
con.unsafe().sendPacket( message );
con.getForgeClientHandler().setState( HELLO );
return HELLO;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
return HELLO;
}
},
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
return HELLO;
}
},
/**
* Waiting to receive a client HELLO and the mod list. Upon receiving the
* mod list, return the mod list of the server.
@@ -54,157 +53,157 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler<ForgeClientH
* {@link PluginMessage}, {@link UserConnection}, {@link ServerConnector}
*/
HELLO
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( LogDirection.RECEIVED, this.name(), message );
// Server Hello.
if ( message.getData()[0] == 0 )
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( LogDirection.RECEIVED, this.name(), message );
// Server Hello.
if ( message.getData()[0] == 0 )
{
con.unsafe().sendPacket( message );
}
con.unsafe().sendPacket( message );
}
return this;
return this;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// Client Hello.
if ( message.getData()[0] == 1 )
{
return this;
}
// Mod list.
if ( message.getData()[0] == 2 )
{
if ( con.getForgeClientHandler().getClientModList() == null )
{
// This is the first Forge connection - so get the mods now.
// Once we've done it, no point doing it again.
Map<String, String> clientModList = ForgeUtils.readModList( message );
con.getForgeClientHandler().setClientModList( clientModList );
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// Client Hello.
if ( message.getData()[0] == 1 )
{
return this;
}
return WAITINGSERVERDATA;
}
// Mod list.
if ( message.getData()[0] == 2 )
{
if ( con.getForgeClientHandler().getClientModList() == null )
{
// This is the first Forge connection - so get the mods now.
// Once we've done it, no point doing it again.
Map<String, String> clientModList = ForgeUtils.readModList( message );
con.getForgeClientHandler().setClientModList( clientModList );
}
return this;
}
return WAITINGSERVERDATA;
}
return this;
}
},
},
WAITINGSERVERDATA
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
// Mod list.
if ( message.getData()[0] == 2 )
{
con.unsafe().sendPacket( message );
}
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
// Mod list.
if ( message.getData()[0] == 2 )
{
con.unsafe().sendPacket( message );
}
return this;
}
return this;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// ACK
return WAITINGSERVERCOMPLETE;
}
},
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// ACK
return WAITINGSERVERCOMPLETE;
}
},
WAITINGSERVERCOMPLETE
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
// Mod ID's.
if ( message.getData()[0] == 3 )
{
con.unsafe().sendPacket( message );
return this;
}
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
// Mod ID's.
if ( message.getData()[0] == 3 )
{
con.unsafe().sendPacket( message );
return this;
}
con.unsafe().sendPacket( message ); // pass everything else
return this;
}
con.unsafe().sendPacket( message ); // pass everything else
return this;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// Send ACK.
return PENDINGCOMPLETE;
}
},
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// Send ACK.
return PENDINGCOMPLETE;
}
},
PENDINGCOMPLETE
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
// Ack.
if ( message.getData()[0] == -1 )
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
con.unsafe().sendPacket( message );
}
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
// Ack.
if ( message.getData()[0] == -1 )
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
con.unsafe().sendPacket( message );
}
return this;
}
return this;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// Send an ACK
return COMPLETE;
}
},
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
// Send an ACK
return COMPLETE;
}
},
COMPLETE
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
// Ack.
if ( message.getData()[0] == -1 )
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
con.unsafe().sendPacket( message );
}
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
// Ack.
if ( message.getData()[0] == -1 )
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
con.unsafe().sendPacket( message );
}
return this;
}
return this;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
return DONE;
}
},
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
return DONE;
}
},
/**
* Handshake has been completed. Ignores any future handshake packets.
*/
DONE
{
{
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
return this;
}
@Override
public ForgeClientHandshakeState handle(PluginMessage message, UserConnection con)
{
ForgeLogger.logClient( ForgeLogger.LogDirection.RECEIVED, this.name(), message );
return this;
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
return this;
}
}
@Override
public ForgeClientHandshakeState send(PluginMessage message, UserConnection con)
{
return this;
}
}
}

View File

@@ -17,122 +17,122 @@ public enum ForgeServerHandshakeState implements IForgeServerPacketHandler<Forge
*
*/
START
{
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
{
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
// Send custom channel registration. Send Hello.
return HELLO;
}
},
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
// Send custom channel registration. Send Hello.
return HELLO;
}
},
HELLO
{
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
if ( message.getData()[0] == 1 ) // Client Hello
{
ch.write( message );
}
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
if ( message.getData()[0] == 1 ) // Client Hello
{
ch.write( message );
}
if ( message.getData()[0] == 2 ) // Client ModList
{
ch.write( message );
}
if ( message.getData()[0] == 2 ) // Client ModList
{
ch.write( message );
}
return this;
}
return this;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
// Send Server Mod List.
return WAITINGCACK;
}
},
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
// Send Server Mod List.
return WAITINGCACK;
}
},
WAITINGCACK
{
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
if ( message.getData()[0] == 3 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) )
{
con.getForgeClientHandler().setServerIdList( message );
return this;
}
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
if ( message.getData()[0] == -1 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) // transition to COMPLETE after sending ACK
{
return this;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
if ( message.getData()[0] == 3 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) )
{
con.getForgeClientHandler().setServerIdList( message );
return this;
}
if ( message.getTag().equals( ForgeConstants.FORGE_REGISTER ) ) // wait for Forge channel registration
{
return COMPLETE;
}
if ( message.getData()[0] == -1 && message.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) ) // transition to COMPLETE after sending ACK
{
return this;
}
if ( message.getTag().equals( ForgeConstants.FORGE_REGISTER ) ) // wait for Forge channel registration
{
return COMPLETE;
}
return this;
}
},
return this;
}
},
COMPLETE
{
{
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
// Wait for ACK
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
// Wait for ACK
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
// Send ACK
return DONE;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
// Send ACK
return DONE;
}
},
},
/**
* Handshake has been completed. Do not respond to any more handshake
* packets.
*/
DONE
{
{
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
// RECEIVE 2 ACKS
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
@Override
public ForgeServerHandshakeState handle(PluginMessage message, ChannelWrapper ch)
{
// RECEIVE 2 ACKS
ForgeLogger.logServer( LogDirection.RECEIVED, this.name(), message );
ch.write( message );
return this;
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
return this;
}
}
@Override
public ForgeServerHandshakeState send(PluginMessage message, UserConnection con)
{
return this;
}
}
}

View File

@@ -61,8 +61,8 @@ public class ForgeUtils
{
if ( modList.containsKey( "FML" ) )
{
String fmlVersion = modList.get( "FML" );
String fmlVersion = modList.get( "FML" );
// FML's version is hardcoded to this for builds beyond 1405 for 1.7.10 - if we see this, return Forge's build number.
if ( fmlVersion.equals( "7.10.99.99" ) )
{
@@ -72,8 +72,7 @@ public class ForgeUtils
// We know from the regex that we have an int.
return Integer.parseInt( matcher.group( 4 ) );
}
}
else
} else
{
Matcher matcher = ForgeConstants.FML_HANDSHAKE_VERSION_REGEX.matcher( fmlVersion );
if ( matcher.find() )

View File

@@ -53,7 +53,7 @@ public class ColouredWriter extends Handler
}
try
{
console.print( Ansi.ansi().eraseLine(Erase.ALL).toString() + ConsoleReader.RESET_LINE + s + Ansi.ansi().reset().toString() );
console.print( Ansi.ansi().eraseLine( Erase.ALL ).toString() + ConsoleReader.RESET_LINE + s + Ansi.ansi().reset().toString() );
console.drawLine();
console.flush();
} catch ( IOException ex )

View File

@@ -75,11 +75,11 @@ public class Global extends TabList
String[][] props = new String[ loginResult.getProperties().length ][];
for ( int j = 0; j < props.length; j++ )
{
props[ j ] = new String[]
props[j] = new String[]
{
loginResult.getProperties()[ j ].getName(),
loginResult.getProperties()[ j ].getValue(),
loginResult.getProperties()[ j ].getSignature()
loginResult.getProperties()[j].getName(),
loginResult.getProperties()[j].getValue(),
loginResult.getProperties()[j].getSignature()
};
}
item.setProperties( props );
@@ -103,11 +103,11 @@ public class Global extends TabList
String[][] props = new String[ loginResult.getProperties().length ][];
for ( int j = 0; j < props.length; j++ )
{
props[ j ] = new String[]
props[j] = new String[]
{
loginResult.getProperties()[ j ].getName(),
loginResult.getProperties()[ j ].getValue(),
loginResult.getProperties()[ j ].getSignature()
loginResult.getProperties()[j].getName(),
loginResult.getProperties()[j].getValue(),
loginResult.getProperties()[j].getSignature()
};
}
item.setProperties( props );

View File

@@ -41,11 +41,11 @@ public abstract class TabList
String[][] props = new String[ loginResult.getProperties().length ][];
for ( int i = 0; i < props.length; i++ )
{
props[ i ] = new String[]
props[i] = new String[]
{
loginResult.getProperties()[ i ].getName(),
loginResult.getProperties()[ i ].getValue(),
loginResult.getProperties()[ i ].getSignature()
loginResult.getProperties()[i].getName(),
loginResult.getProperties()[i].getValue(),
loginResult.getProperties()[i].getSignature()
};
}
item.setProperties( props );

View File

@@ -84,8 +84,8 @@ public class ComponentsTest
@Test
public void testBuilderReset()
{
BaseComponent[] components = new ComponentBuilder( "Hello " ).color(ChatColor.RED)
.append("World").reset().create();
BaseComponent[] components = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
.append( "World" ).reset().create();
Assert.assertEquals( components[0].getColor(), ChatColor.RED );
Assert.assertEquals( components[1].getColor(), ChatColor.WHITE );
@@ -113,7 +113,7 @@ public class ComponentsTest
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
BaseComponent[] eventRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
.event( testEvent ).event(testClickEvent).append("World", ComponentBuilder.FormatRetention.EVENTS).create();
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ).create();
Assert.assertEquals( eventRetention[0].getColor(), ChatColor.RED );
Assert.assertEquals( eventRetention[0].getHoverEvent(), testEvent );

View File

@@ -5,7 +5,8 @@ import org.junit.Test;
import static org.junit.Assert.*;
public class BoundedArrayListTest {
public class BoundedArrayListTest
{
@Test
public void testGoodAdd() throws Exception
@@ -63,7 +64,7 @@ public class BoundedArrayListTest {
@Test(expected = IllegalStateException.class)
public void testBadAddAll() throws Exception
{
BoundedArrayList<Object> list = new BoundedArrayList<>(0);
BoundedArrayList<Object> list = new BoundedArrayList<>( 0 );
list.addAll( ImmutableList.of( new Object() ) );
}
@@ -74,4 +75,4 @@ public class BoundedArrayListTest {
list.add( new Object() );
list.addAll( ImmutableList.of( new Object() ) );
}
}
}