This commit is contained in:
parent
0e9e0b58d2
commit
bccce74c3c
@ -1,9 +1,6 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -31,8 +28,10 @@ public class Team extends DefinedPacket
|
||||
private Either<String, BaseComponent> displayName;
|
||||
private Either<String, BaseComponent> prefix;
|
||||
private Either<String, BaseComponent> suffix;
|
||||
private NameTagVisibility nameTagVisibility;
|
||||
private CollisionRule collisionRule;
|
||||
//
|
||||
private Either<String, NameTagVisibility> nameTagVisibility;
|
||||
private Either<String, CollisionRule> collisionRule;
|
||||
//
|
||||
private int color;
|
||||
private byte friendlyFire;
|
||||
private String[] players;
|
||||
@ -67,15 +66,14 @@ public class Team extends DefinedPacket
|
||||
friendlyFire = buf.readByte();
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_5 )
|
||||
{
|
||||
nameTagVisibility = NameTagVisibility.BY_ID[readVarInt( buf )];
|
||||
collisionRule = CollisionRule.BY_ID[readVarInt( buf )];
|
||||
nameTagVisibility = Either.right( NameTagVisibility.BY_ID[readVarInt( buf )] );
|
||||
collisionRule = Either.right( CollisionRule.BY_ID[readVarInt( buf )] );
|
||||
} else
|
||||
{
|
||||
nameTagVisibility = readStringMapKey( buf, NameTagVisibility.BY_NAME );
|
||||
|
||||
nameTagVisibility = Either.left( readString( buf ) );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||
{
|
||||
collisionRule = readStringMapKey( buf, CollisionRule.BY_NAME );
|
||||
collisionRule = Either.left( readString( buf ) );
|
||||
}
|
||||
}
|
||||
color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte();
|
||||
@ -112,14 +110,14 @@ public class Team extends DefinedPacket
|
||||
buf.writeByte( friendlyFire );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_5 )
|
||||
{
|
||||
writeVarInt( nameTagVisibility.ordinal(), buf );
|
||||
writeVarInt( collisionRule.ordinal(), buf );
|
||||
writeVarInt( nameTagVisibility.getRight().ordinal(), buf );
|
||||
writeVarInt( collisionRule.getRight().ordinal(), buf );
|
||||
} else
|
||||
{
|
||||
writeString( nameTagVisibility.getKey(), buf );
|
||||
writeString( nameTagVisibility.getLeft(), buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||
{
|
||||
writeString( collisionRule.getKey(), buf );
|
||||
writeString( collisionRule.getLeft(), buf );
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,29 +155,11 @@ public class Team extends DefinedPacket
|
||||
ALWAYS( "always" ),
|
||||
NEVER( "never" ),
|
||||
HIDE_FOR_OTHER_TEAMS( "hideForOtherTeams" ),
|
||||
HIDE_FOR_OWN_TEAM( "hideForOwnTeam" ),
|
||||
// 1.9 (and possibly other versions) appear to treat unknown values differently (always render rather than subject to spectator mode, friendly invisibles, etc).
|
||||
// we allow the empty value to achieve this in case it is potentially useful even though this is unsupported and its usage may be a bug (#3780).
|
||||
UNKNOWN( "" );
|
||||
HIDE_FOR_OWN_TEAM( "hideForOwnTeam" );
|
||||
//
|
||||
private final String key;
|
||||
//
|
||||
private static final Map<String, NameTagVisibility> BY_NAME;
|
||||
private static final NameTagVisibility[] BY_ID;
|
||||
|
||||
static
|
||||
{
|
||||
NameTagVisibility[] values = NameTagVisibility.values();
|
||||
ImmutableMap.Builder<String, NameTagVisibility> builder = ImmutableMap.builderWithExpectedSize( values.length );
|
||||
|
||||
for ( NameTagVisibility e : values )
|
||||
{
|
||||
builder.put( e.key, e );
|
||||
}
|
||||
|
||||
BY_NAME = builder.build();
|
||||
BY_ID = Arrays.copyOf( values, values.length - 1 ); // Ignore dummy UNKNOWN value
|
||||
}
|
||||
private static final NameTagVisibility[] BY_ID = values();
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ -194,20 +174,6 @@ public class Team extends DefinedPacket
|
||||
//
|
||||
private final String key;
|
||||
//
|
||||
private static final Map<String, CollisionRule> BY_NAME;
|
||||
private static final CollisionRule[] BY_ID;
|
||||
|
||||
static
|
||||
{
|
||||
CollisionRule[] values = BY_ID = CollisionRule.values();
|
||||
ImmutableMap.Builder<String, CollisionRule> builder = ImmutableMap.builderWithExpectedSize( values.length );
|
||||
|
||||
for ( CollisionRule e : values )
|
||||
{
|
||||
builder.put( e.key, e );
|
||||
}
|
||||
|
||||
BY_NAME = builder.build();
|
||||
}
|
||||
private static final CollisionRule[] BY_ID = CollisionRule.values();
|
||||
}
|
||||
}
|
||||
|
@ -284,11 +284,11 @@ public class DownstreamBridge extends PacketHandler
|
||||
t.setPrefix( team.getPrefix().getLeftOrCompute( (component) -> con.getChatSerializer().toString( component ) ) );
|
||||
t.setSuffix( team.getSuffix().getLeftOrCompute( (component) -> con.getChatSerializer().toString( component ) ) );
|
||||
t.setFriendlyFire( team.getFriendlyFire() );
|
||||
t.setNameTagVisibility( team.getNameTagVisibility().getKey() );
|
||||
t.setNameTagVisibility( team.getNameTagVisibility().isLeft() ? team.getNameTagVisibility().getLeft() : team.getNameTagVisibility().getRight().getKey() );
|
||||
t.setColor( team.getColor() );
|
||||
if ( team.getCollisionRule() != null )
|
||||
{
|
||||
t.setCollisionRule( team.getCollisionRule().getKey() );
|
||||
t.setCollisionRule( team.getCollisionRule().isLeft() ? team.getCollisionRule().getLeft() : team.getCollisionRule().getRight().getKey() );
|
||||
}
|
||||
}
|
||||
if ( team.getPlayers() != null )
|
||||
|
Loading…
Reference in New Issue
Block a user