Minecraft 25w05a protocol support
This commit is contained in:
parent
9dd5fb626d
commit
508c2f7ac3
2
pom.xml
2
pom.xml
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<build.number>unknown</build.number>
|
<build.number>unknown</build.number>
|
||||||
<lombok.version>1.18.32</lombok.version>
|
<lombok.version>1.18.36</lombok.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -15,6 +15,7 @@ import java.util.Arrays;
|
|||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -69,6 +70,15 @@ public abstract class DefinedPacket
|
|||||||
buf.writeBytes( b );
|
buf.writeBytes( b );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T readStringMapKey(ByteBuf buf, Map<String, T> map)
|
||||||
|
{
|
||||||
|
String string = readString( buf );
|
||||||
|
T result = map.get( string );
|
||||||
|
Preconditions.checkArgument( result != null, "Unknown string key %s", string );
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static String readString(ByteBuf buf)
|
public static String readString(ByteBuf buf)
|
||||||
{
|
{
|
||||||
return readString( buf, Short.MAX_VALUE );
|
return readString( buf, Short.MAX_VALUE );
|
||||||
|
@ -49,7 +49,7 @@ public class ProtocolConstants
|
|||||||
public static final int MINECRAFT_1_21 = 767;
|
public static final int MINECRAFT_1_21 = 767;
|
||||||
public static final int MINECRAFT_1_21_2 = 768;
|
public static final int MINECRAFT_1_21_2 = 768;
|
||||||
public static final int MINECRAFT_1_21_4 = 769;
|
public static final int MINECRAFT_1_21_4 = 769;
|
||||||
public static final int MINECRAFT_1_21_5 = 1073742055;
|
public static final int MINECRAFT_1_21_5 = 1073742056;
|
||||||
public static final List<String> SUPPORTED_VERSIONS;
|
public static final List<String> SUPPORTED_VERSIONS;
|
||||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.util.Map;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -26,8 +28,8 @@ public class Team extends DefinedPacket
|
|||||||
private Either<String, BaseComponent> displayName;
|
private Either<String, BaseComponent> displayName;
|
||||||
private Either<String, BaseComponent> prefix;
|
private Either<String, BaseComponent> prefix;
|
||||||
private Either<String, BaseComponent> suffix;
|
private Either<String, BaseComponent> suffix;
|
||||||
private String nameTagVisibility;
|
private NameTagVisibility nameTagVisibility;
|
||||||
private String collisionRule;
|
private CollisionRule collisionRule;
|
||||||
private int color;
|
private int color;
|
||||||
private byte friendlyFire;
|
private byte friendlyFire;
|
||||||
private String[] players;
|
private String[] players;
|
||||||
@ -60,10 +62,18 @@ public class Team extends DefinedPacket
|
|||||||
displayName = readEitherBaseComponent( buf, protocolVersion, false );
|
displayName = readEitherBaseComponent( buf, protocolVersion, false );
|
||||||
}
|
}
|
||||||
friendlyFire = buf.readByte();
|
friendlyFire = buf.readByte();
|
||||||
nameTagVisibility = readString( buf );
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_5 )
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
||||||
{
|
{
|
||||||
collisionRule = readString( buf );
|
nameTagVisibility = NameTagVisibility.values()[readVarInt( buf )];
|
||||||
|
collisionRule = CollisionRule.values()[readVarInt( buf )];
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
nameTagVisibility = readStringMapKey( buf, NameTagVisibility.BY_NAME );
|
||||||
|
|
||||||
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||||
|
{
|
||||||
|
collisionRule = readStringMapKey( buf, CollisionRule.BY_NAME );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte();
|
color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte();
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||||
@ -97,10 +107,17 @@ public class Team extends DefinedPacket
|
|||||||
writeEitherBaseComponent( suffix, buf, protocolVersion );
|
writeEitherBaseComponent( suffix, buf, protocolVersion );
|
||||||
}
|
}
|
||||||
buf.writeByte( friendlyFire );
|
buf.writeByte( friendlyFire );
|
||||||
writeString( nameTagVisibility, buf );
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_5 )
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
||||||
{
|
{
|
||||||
writeString( collisionRule, buf );
|
writeVarInt( nameTagVisibility.ordinal(), buf );
|
||||||
|
writeVarInt( collisionRule.ordinal(), buf );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
writeString( nameTagVisibility.getKey(), buf );
|
||||||
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||||
|
{
|
||||||
|
writeString( collisionRule.getKey(), buf );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||||
@ -128,4 +145,76 @@ public class Team extends DefinedPacket
|
|||||||
{
|
{
|
||||||
handler.handle( this );
|
handler.handle( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum NameTagVisibility
|
||||||
|
{
|
||||||
|
|
||||||
|
ALWAYS( "always" ),
|
||||||
|
NEVER( "never" ),
|
||||||
|
HIDE_FOR_OTHER_TEAMS( "hideForOtherTeams" ),
|
||||||
|
HIDE_FOR_OWN_TEAM( "hideForOwnTeam" );
|
||||||
|
//
|
||||||
|
private final String key;
|
||||||
|
//
|
||||||
|
private static final Map<String, NameTagVisibility> BY_NAME;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
private NameTagVisibility(String name)
|
||||||
|
{
|
||||||
|
this.key = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey()
|
||||||
|
{
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CollisionRule
|
||||||
|
{
|
||||||
|
|
||||||
|
ALWAYS( "always" ),
|
||||||
|
NEVER( "never" ),
|
||||||
|
PUSH_OTHER_TEAMS( "pushOtherTeams" ),
|
||||||
|
PUSH_OWN_TEAM( "pushOwnTeam" );
|
||||||
|
//
|
||||||
|
private final String key;
|
||||||
|
//
|
||||||
|
private static final Map<String, CollisionRule> BY_NAME;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
CollisionRule[] values = 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 CollisionRule(String name)
|
||||||
|
{
|
||||||
|
this.key = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey()
|
||||||
|
{
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,8 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
t.setPrefix( team.getPrefix().getLeftOrCompute( ComponentSerializer::toString ) );
|
t.setPrefix( team.getPrefix().getLeftOrCompute( ComponentSerializer::toString ) );
|
||||||
t.setSuffix( team.getSuffix().getLeftOrCompute( ComponentSerializer::toString ) );
|
t.setSuffix( team.getSuffix().getLeftOrCompute( ComponentSerializer::toString ) );
|
||||||
t.setFriendlyFire( team.getFriendlyFire() );
|
t.setFriendlyFire( team.getFriendlyFire() );
|
||||||
t.setNameTagVisibility( team.getNameTagVisibility() );
|
t.setNameTagVisibility( team.getNameTagVisibility().getKey() );
|
||||||
t.setCollisionRule( team.getCollisionRule() );
|
t.setCollisionRule( team.getCollisionRule().getKey() );
|
||||||
t.setColor( team.getColor() );
|
t.setColor( team.getColor() );
|
||||||
}
|
}
|
||||||
if ( team.getPlayers() != null )
|
if ( team.getPlayers() != null )
|
||||||
|
Loading…
Reference in New Issue
Block a user