mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-24 17:47:41 +01:00
Will do final tests tomorrow, but all seems to work. Yay for efficiency and options for plugin developers!
This commit is contained in:
parent
d82b29e15a
commit
9c35cad824
@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.packet.forge.Forge1Login;
|
||||
import net.md_5.bungee.protocol.skip.PacketReader;
|
||||
|
||||
public class Forge extends Vanilla
|
||||
{
|
||||
@ -11,9 +12,10 @@ public class Forge extends Vanilla
|
||||
@Getter
|
||||
private static final Forge instance = new Forge();
|
||||
|
||||
|
||||
public Forge()
|
||||
{
|
||||
classes[0x01] = Forge1Login.class;
|
||||
skipper = new PacketReader( this ); // TODO: :(
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,10 +43,10 @@ public class Vanilla implements Protocol
|
||||
@Getter
|
||||
private Constructor<? extends DefinedPacket>[] constructors = new Constructor[ 256 ];
|
||||
@Getter
|
||||
private final PacketReader skipper = new PacketReader( this );
|
||||
protected PacketReader skipper;
|
||||
/*========================================================================*/
|
||||
|
||||
|
||||
public Vanilla()
|
||||
{
|
||||
classes[0x00] = Packet0KeepAlive.class;
|
||||
classes[0x01] = Packet1Login.class;
|
||||
@ -65,6 +65,7 @@ public class Vanilla implements Protocol
|
||||
classes[0xFD] = PacketFDEncryptionRequest.class;
|
||||
classes[0xFE] = PacketFEPing.class;
|
||||
classes[0xFF] = PacketFFKick.class;
|
||||
skipper = new PacketReader( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +39,7 @@ public abstract class DefinedPacket
|
||||
public void writeArray(byte[] b, ByteBuf buf)
|
||||
{
|
||||
// TODO: Check len - use Guava?
|
||||
buf.writeByte( b.length );
|
||||
buf.writeShort( b.length );
|
||||
buf.writeBytes( b );
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class Packet1Login extends DefinedPacket
|
||||
|
||||
public Packet1Login(int entityId, String levelType, byte gameMode, byte dimension, byte difficulty, byte unused, byte maxPlayers)
|
||||
{
|
||||
this( entityId, levelType, gameMode, entityId, difficulty, unused, maxPlayers );
|
||||
this( entityId, levelType, gameMode, (int) dimension, difficulty, unused, maxPlayers );
|
||||
}
|
||||
|
||||
public Packet1Login(int entityId, String levelType, byte gameMode, int dimension, byte difficulty, byte unused, byte maxPlayers)
|
||||
|
@ -13,14 +13,14 @@ public class PacketC9PlayerListItem extends DefinedPacket
|
||||
|
||||
private String username;
|
||||
private boolean online;
|
||||
private int ping;
|
||||
private short ping;
|
||||
|
||||
private PacketC9PlayerListItem()
|
||||
{
|
||||
super( 0xC9 );
|
||||
}
|
||||
|
||||
public PacketC9PlayerListItem(String username, boolean online, int ping)
|
||||
public PacketC9PlayerListItem(String username, boolean online, short ping)
|
||||
{
|
||||
super( 0xC9 );
|
||||
this.username = username;
|
||||
@ -33,7 +33,7 @@ public class PacketC9PlayerListItem extends DefinedPacket
|
||||
{
|
||||
username = readString( buf );
|
||||
online = buf.readBoolean();
|
||||
ping = buf.readInt();
|
||||
ping = buf.readShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +41,7 @@ public class PacketC9PlayerListItem extends DefinedPacket
|
||||
{
|
||||
writeString( username, buf );
|
||||
buf.writeBoolean( online );
|
||||
buf.writeInt( ping );
|
||||
buf.writeShort(ping );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +33,7 @@ public class PacketCCSettings extends DefinedPacket
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
locale = readString( buf );
|
||||
writeString( locale, buf );
|
||||
buf.writeByte( viewDistance );
|
||||
buf.writeByte( chatFlags );
|
||||
buf.writeByte( difficulty );
|
||||
|
@ -31,14 +31,12 @@ import net.md_5.bungee.protocol.Forge;
|
||||
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.packet.Packet1Login;
|
||||
import net.md_5.bungee.protocol.packet.Packet9Respawn;
|
||||
import net.md_5.bungee.protocol.packet.PacketCDClientStatus;
|
||||
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
|
||||
import net.md_5.bungee.protocol.packet.PacketD1Team;
|
||||
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.PacketFCEncryptionResponse;
|
||||
import net.md_5.bungee.protocol.packet.PacketFDEncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.PacketFFKick;
|
||||
import net.md_5.bungee.protocol.Vanilla;
|
||||
import net.md_5.bungee.protocol.packet.forge.Forge1Login;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@ -62,7 +60,7 @@ public class ServerConnector extends PacketHandler
|
||||
@Override
|
||||
public void exception(Throwable t) throws Exception
|
||||
{
|
||||
String message = "Exception Connectiong:" + Util.exception( t );
|
||||
String message = "Exception Connecting:" + Util.exception( t );
|
||||
if ( user.getServer() == null )
|
||||
{
|
||||
user.disconnect( message );
|
||||
|
@ -20,9 +20,9 @@ public class Global implements TabListHandler
|
||||
UserConnection con = (UserConnection) player;
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() )
|
||||
{
|
||||
con.sendPacket( new PacketC9PlayerListItem( p.getDisplayName(), true, p.getPing() ) );
|
||||
con.sendPacket( new PacketC9PlayerListItem( p.getDisplayName(), true, (short) p.getPing() ) );
|
||||
}
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, player.getPing() ) );
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, (short) player.getPing() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,7 +30,7 @@ public class Global implements TabListHandler
|
||||
{
|
||||
if ( !sentPings.contains( player ) )
|
||||
{
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, player.getPing() ) );
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, (short) player.getPing() ) );
|
||||
sentPings.add( player );
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class Global implements TabListHandler
|
||||
@Override
|
||||
public void onDisconnect(ProxiedPlayer player)
|
||||
{
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), false, 9999 ) );
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), false, (short) 9999 ) );
|
||||
sentPings.remove( player );
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class GlobalPing extends Global
|
||||
int lastPing = lastPings.get( player );
|
||||
if ( ping - PING_THRESHOLD > lastPing && ping + PING_THRESHOLD < lastPing )
|
||||
{
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, ping ) );
|
||||
BungeeCord.getInstance().broadcast( new PacketC9PlayerListItem( player.getDisplayName(), true, (short) ping ) );
|
||||
lastPings.put( player, ping );
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class ServerUnique implements TabListHandler
|
||||
{
|
||||
for ( String username : usernames )
|
||||
{
|
||||
( (UserConnection) player ).sendPacket( new PacketC9PlayerListItem( username, false, 9999 ) );
|
||||
( (UserConnection) player ).sendPacket( new PacketC9PlayerListItem( username, false, (short) 9999 ) );
|
||||
}
|
||||
usernames.clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user