Remove any tracked bossbars when a client switches servers.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.ClientStatus;
|
||||
@@ -143,4 +144,8 @@ public abstract class AbstractPacketHandler
|
||||
public void handle(SetCompression setCompression) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(BossBar bossBar) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
@@ -58,6 +59,7 @@ public enum Protocol
|
||||
TO_CLIENT.registerPacket( 0x01, 0x23, Login.class );
|
||||
TO_CLIENT.registerPacket( 0x02, 0x0F, Chat.class );
|
||||
TO_CLIENT.registerPacket( 0x07, 0x33, Respawn.class );
|
||||
TO_CLIENT.registerPacket( 0x0C, 0x0C, BossBar.class, true );
|
||||
TO_CLIENT.registerPacket( 0x38, 0x2D, PlayerListItem.class ); // PlayerInfo
|
||||
TO_CLIENT.registerPacket( 0x3A, 0x0E, TabCompleteResponse.class );
|
||||
TO_CLIENT.registerPacket( 0x3B, 0x3F, ScoreboardObjective.class );
|
||||
@@ -165,6 +167,12 @@ public enum Protocol
|
||||
}
|
||||
|
||||
protected final void registerPacket(int id, int newId, Class<? extends DefinedPacket> packetClass)
|
||||
{
|
||||
registerPacket( id, newId, packetClass, false );
|
||||
|
||||
}
|
||||
|
||||
protected final void registerPacket(int id, int newId, Class<? extends DefinedPacket> packetClass, boolean newOnly)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -176,8 +184,12 @@ public enum Protocol
|
||||
packetClasses[id] = packetClass;
|
||||
packetMap.put( packetClass, id );
|
||||
|
||||
packetRemap.get( ProtocolConstants.MINECRAFT_1_8 ).put( id, id );
|
||||
packetRemapInv.get( ProtocolConstants.MINECRAFT_1_8 ).put( id, id );
|
||||
if ( !newOnly )
|
||||
{
|
||||
packetRemap.get( ProtocolConstants.MINECRAFT_1_8 ).put( id, id );
|
||||
packetRemapInv.get( ProtocolConstants.MINECRAFT_1_8 ).put( id, id );
|
||||
}
|
||||
|
||||
packetRemap.get( ProtocolConstants.MINECRAFT_1_9 ).put( newId, id );
|
||||
packetRemapInv.get( ProtocolConstants.MINECRAFT_1_9 ).put( id, newId );
|
||||
}
|
||||
|
@@ -0,0 +1,110 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class BossBar extends DefinedPacket
|
||||
{
|
||||
|
||||
private UUID uuid;
|
||||
private int action;
|
||||
private String title;
|
||||
private float health;
|
||||
private int color;
|
||||
private int division;
|
||||
private byte flags;
|
||||
|
||||
public BossBar(UUID uuid, int action)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
uuid = readUUID( buf );
|
||||
action = readVarInt( buf );
|
||||
|
||||
switch ( action )
|
||||
{
|
||||
// Add
|
||||
case 0:
|
||||
title = readString( buf );
|
||||
health = buf.readFloat();
|
||||
color = readVarInt( buf );
|
||||
division = readVarInt( buf );
|
||||
flags = buf.readByte();
|
||||
break;
|
||||
// Health
|
||||
case 2:
|
||||
health = buf.readFloat();
|
||||
break;
|
||||
// Title
|
||||
case 3:
|
||||
title = readString( buf );
|
||||
break;
|
||||
// Style
|
||||
case 4:
|
||||
color = readVarInt( buf );
|
||||
division = readVarInt( buf );
|
||||
break;
|
||||
// Flags
|
||||
case 5:
|
||||
flags = buf.readByte();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeUUID( uuid, buf );
|
||||
writeVarInt( action, buf );
|
||||
|
||||
switch ( action )
|
||||
{
|
||||
// Add
|
||||
case 0:
|
||||
writeString( title, buf );
|
||||
buf.writeFloat( health );
|
||||
writeVarInt( color, buf );
|
||||
writeVarInt( division, buf );
|
||||
buf.writeByte( flags );
|
||||
break;
|
||||
// Health
|
||||
case 2:
|
||||
buf.writeFloat( health );
|
||||
break;
|
||||
// Title
|
||||
case 3:
|
||||
writeString( title, buf );
|
||||
break;
|
||||
// Style
|
||||
case 4:
|
||||
writeVarInt( color, buf );
|
||||
writeVarInt( division, buf );
|
||||
break;
|
||||
// Flags
|
||||
case 5:
|
||||
buf.writeByte( flags );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user