1.6.4 ping support
This commit is contained in:
@@ -17,6 +17,7 @@ import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.Respawn;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
@@ -27,6 +28,10 @@ import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
public abstract class AbstractPacketHandler
|
||||
{
|
||||
|
||||
public void handle(LegacyPing ping) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(TabCompleteResponse tabResponse) throws Exception
|
||||
{
|
||||
}
|
||||
|
@@ -0,0 +1,20 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class KickStringWriter extends MessageToByteEncoder<String>
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, String msg, ByteBuf out) throws Exception
|
||||
{
|
||||
out.writeByte( 0xFF );
|
||||
out.writeShort( msg.length() );
|
||||
for ( char c : msg.toCharArray() )
|
||||
{
|
||||
out.writeChar( c );
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import java.util.List;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
|
||||
public class LegacyDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
|
||||
{
|
||||
if ( in.readableBytes() < 3 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = in.readerIndex();
|
||||
short b1 = in.getUnsignedByte( i++ );
|
||||
short b2 = in.getUnsignedByte( i++ );
|
||||
short b3 = in.getUnsignedByte( i++ );
|
||||
|
||||
if ( b1 == 0xFE && b2 == 0x01 && b3 == 0xFA )
|
||||
{
|
||||
out.add( new PacketWrapper( new LegacyPing(), Unpooled.EMPTY_BUFFER ) );
|
||||
}
|
||||
ctx.pipeline().remove( this );
|
||||
}
|
||||
}
|
@@ -31,8 +31,7 @@ public class MinecraftDecoder extends ByteToMessageDecoder
|
||||
packet.read( in );
|
||||
if ( in.readableBytes() != 0 )
|
||||
{
|
||||
System.out.println( in.toString( Charsets.UTF_8 ) );
|
||||
// throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot );
|
||||
throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot );
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
@@ -0,0 +1,46 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
|
||||
public class LegacyPing extends DefinedPacket
|
||||
{
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user