Update to latest snapshot.

This commit is contained in:
md_5 2013-09-28 17:03:18 +10:00
parent edc5b4dc91
commit 96acdb97fd
8 changed files with 107 additions and 33 deletions

View File

@ -36,4 +36,11 @@ public interface PendingConnection extends Connection
* @return the accepting listener * @return the accepting listener
*/ */
ListenerInfo getListener(); ListenerInfo getListener();
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
String getUUID();
} }

View File

@ -99,4 +99,11 @@ public interface ProxiedPlayer extends Connection, CommandSender
* @param server the server to set * @param server the server to set
*/ */
void setReconnectServer(ServerInfo server); void setReconnectServer(ServerInfo server);
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
String getUUID();
} }

View File

@ -30,8 +30,8 @@ import net.md_5.bungee.protocol.skip.PacketReader;
public class Vanilla implements Protocol public class Vanilla implements Protocol
{ {
public static final byte PROTOCOL_VERSION = 78; public static final byte PROTOCOL_VERSION = 80;
public static final String GAME_VERSION = "1.6.4"; public static final String GAME_VERSION = "13w39b";
@Getter @Getter
private static final Vanilla instance = new Vanilla(); private static final Vanilla instance = new Vanilla();
/*========================================================================*/ /*========================================================================*/
@ -188,7 +188,7 @@ public class Vanilla implements Protocol
}; };
opCodes[0x14] = new OpCode[] opCodes[0x14] = new OpCode[]
{ {
INT, STRING, INT, INT, INT, BYTE, BYTE, SHORT, METADATA INT, STRING, STRING, INT, INT, INT, BYTE, BYTE, SHORT, METADATA
}; };
opCodes[0x16] = new OpCode[] opCodes[0x16] = new OpCode[]
{ {
@ -304,7 +304,7 @@ public class Vanilla implements Protocol
}; };
opCodes[0x3E] = new OpCode[] opCodes[0x3E] = new OpCode[]
{ {
STRING, INT, INT, INT, FLOAT, BYTE STRING, INT, INT, INT, FLOAT, BYTE, BYTE
}; };
opCodes[0x3F] = new OpCode[] opCodes[0x3F] = new OpCode[]
{ {
@ -312,7 +312,7 @@ public class Vanilla implements Protocol
}; };
opCodes[0x46] = new OpCode[] opCodes[0x46] = new OpCode[]
{ {
BYTE, BYTE BYTE, FLOAT
}; };
opCodes[0x47] = new OpCode[] opCodes[0x47] = new OpCode[]
{ {
@ -374,10 +374,6 @@ public class Vanilla implements Protocol
{ {
SHORT, SHORT, INT_BYTE SHORT, SHORT, INT_BYTE
}; };
opCodes[0xC8] = new OpCode[]
{
INT, INT
};
opCodes[0xCA] = new OpCode[] opCodes[0xCA] = new OpCode[]
{ {
BYTE, FLOAT, FLOAT BYTE, FLOAT, FLOAT

View File

@ -27,6 +27,10 @@ public abstract class AbstractPacketHandler
{ {
} }
public void handle(PacketC8Statistic statistic) throws Exception
{
}
public void handle(PacketC9PlayerListItem playerList) throws Exception public void handle(PacketC9PlayerListItem playerList) throws Exception
{ {
} }

View File

@ -0,0 +1,41 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@Getter
@ToString
@EqualsAndHashCode(callSuper = false)
public class PacketC8Statistic extends DefinedPacket
{
public PacketC8Statistic()
{
super( 0xC8 );
}
@Override
public void read(ByteBuf buf)
{
int len = buf.readInt();
for ( int i = 0; i < len; i++ )
{
readString( buf );
buf.readInt();
}
}
@Override
public void write(ByteBuf buf)
{
throw new UnsupportedOperationException();
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -357,4 +357,10 @@ public final class UserConnection implements ProxiedPlayer
{ {
return unsafe; return unsafe;
} }
@Override
public String getUUID()
{
return getPendingConnection().getUUID();
}
} }

View File

@ -1,6 +1,8 @@
package net.md_5.bungee.connection; package net.md_5.bungee.connection;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.netty.util.concurrent.ScheduledFuture; import io.netty.util.concurrent.ScheduledFuture;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -86,6 +88,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
private ScheduledFuture<?> pingFuture; private ScheduledFuture<?> pingFuture;
private InetSocketAddress vHost; private InetSocketAddress vHost;
private byte version = -1; private byte version = -1;
@Getter
private String UUID;
private enum State private enum State
{ {
@ -250,18 +254,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if ( this.onlineMode ) if ( this.onlineMode )
{ {
String encName = URLEncoder.encode( InitialHandler.this.getName(), "UTF-8" ); String encName = URLEncoder.encode( InitialHandler.this.getName(), "UTF-8" );
String encID = URLEncoder.encode( InitialHandler.this.request.getServerId(), "UTF-8" );
MessageDigest sha = MessageDigest.getInstance( "SHA-1" ); String authURL = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username=" + encName + "&serverId=" + encID;
for ( byte[] bit : new byte[][]
{
request.getServerId().getBytes( "ISO_8859_1" ), sharedKey.getEncoded(), EncryptionUtil.keys.getPublic().getEncoded()
} )
{
sha.update( bit );
}
String encodedHash = URLEncoder.encode( new BigInteger( sha.digest() ).toString( 16 ), "UTF-8" );
String authURL = "http://session.minecraft.net/game/checkserver.jsp?user=" + encName + "&serverId=" + encodedHash;
Callback<String> handler = new Callback<String>() Callback<String> handler = new Callback<String>()
{ {
@ -270,13 +265,18 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{ {
if ( error == null ) if ( error == null )
{ {
if ( "YES".equals( result ) ) JsonObject obj = BungeeCord.getInstance().gson.fromJson( result, JsonObject.class );
if ( obj != null )
{ {
JsonElement id = obj.get( "id" );
if ( id != null )
{
UUID = id.getAsString();
finish(); finish();
} else return;
{
disconnect( "Not authenticated with Minecraft.net" );
} }
}
disconnect( "Not authenticated with Minecraft.net" );
} else } else
{ {
disconnect( bungee.getTranslation( "mojang_fail" ) ); disconnect( bungee.getTranslation( "mojang_fail" ) );

View File

@ -36,7 +36,15 @@ public class HttpHandler extends SimpleChannelInboundHandler<HttpObject>
if ( msg instanceof HttpResponse ) if ( msg instanceof HttpResponse )
{ {
HttpResponse response = (HttpResponse) msg; HttpResponse response = (HttpResponse) msg;
if ( response.getStatus().code() != 200 ) int responseCode = response.getStatus().code();
if ( responseCode == HttpResponseStatus.NO_CONTENT.code() )
{
done( ctx );
return;
}
if ( responseCode != HttpResponseStatus.OK.code() )
{ {
throw new IllegalStateException( "Expected HTTP response 200 OK, got " + response.getStatus() ); throw new IllegalStateException( "Expected HTTP response 200 OK, got " + response.getStatus() );
} }
@ -47,6 +55,13 @@ public class HttpHandler extends SimpleChannelInboundHandler<HttpObject>
buffer.append( content.content().toString( Charset.forName( "UTF-8" ) ) ); buffer.append( content.content().toString( Charset.forName( "UTF-8" ) ) );
if ( msg instanceof LastHttpContent ) if ( msg instanceof LastHttpContent )
{
done( ctx );
}
}
}
private void done(ChannelHandlerContext ctx)
{ {
try try
{ {
@ -57,5 +72,3 @@ public class HttpHandler extends SimpleChannelInboundHandler<HttpObject>
} }
} }
} }
}
}