Minecraft 1.20.3-pre2 support
This commit is contained in:
parent
0925c06f9b
commit
197bf13a28
@ -34,6 +34,7 @@ import net.md_5.bungee.protocol.packet.Respawn;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
|
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
import net.md_5.bungee.protocol.packet.ServerData;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||||
@ -143,6 +144,10 @@ public abstract class AbstractPacketHandler
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void handle(ScoreboardScoreReset scoreboardScoreReset) throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void handle(EncryptionRequest encryptionRequest) throws Exception
|
public void handle(EncryptionRequest encryptionRequest) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol;
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -15,6 +16,7 @@ import java.util.BitSet;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
@ -27,6 +29,23 @@ import se.llbit.nbt.Tag;
|
|||||||
public abstract class DefinedPacket
|
public abstract class DefinedPacket
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public <T> T readNullable(Function<ByteBuf, T> reader, ByteBuf buf)
|
||||||
|
{
|
||||||
|
return buf.readBoolean() ? reader.apply( buf ) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void writeNullable(T t0, BiConsumer<T, ByteBuf> writer, ByteBuf buf)
|
||||||
|
{
|
||||||
|
if ( t0 != null )
|
||||||
|
{
|
||||||
|
buf.writeBoolean( true );
|
||||||
|
writer.accept( t0, buf );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
buf.writeBoolean( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void writeString(String s, ByteBuf buf)
|
public static void writeString(String s, ByteBuf buf)
|
||||||
{
|
{
|
||||||
writeString( s, buf, Short.MAX_VALUE );
|
writeString( s, buf, Short.MAX_VALUE );
|
||||||
@ -351,6 +370,38 @@ public abstract class DefinedPacket
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void writeNumberFormat(NumberFormat format, ByteBuf buf, int protocolVersion)
|
||||||
|
{
|
||||||
|
writeVarInt( format.getType().ordinal(), buf );
|
||||||
|
switch ( format.getType() )
|
||||||
|
{
|
||||||
|
case BLANK:
|
||||||
|
break;
|
||||||
|
case STYLED:
|
||||||
|
writeBaseComponent( (BaseComponent) format.getValue(), buf, protocolVersion ); // TODO: style
|
||||||
|
break;
|
||||||
|
case FIXED:
|
||||||
|
writeBaseComponent( (BaseComponent) format.getValue(), buf, protocolVersion );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NumberFormat readNumberFormat(ByteBuf buf, int protocolVersion)
|
||||||
|
{
|
||||||
|
int format = readVarInt( buf );
|
||||||
|
switch ( format )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return new NumberFormat( NumberFormat.Type.BLANK, null );
|
||||||
|
case 1:
|
||||||
|
return new NumberFormat( NumberFormat.Type.STYLED, readBaseComponent( buf, protocolVersion ) ); // TODO: style
|
||||||
|
case 2:
|
||||||
|
return new NumberFormat( NumberFormat.Type.FIXED, readBaseComponent( buf, protocolVersion ) );
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException( "Unknown number format " + format );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Tag readTag(ByteBuf input, int protocolVersion)
|
public static Tag readTag(ByteBuf input, int protocolVersion)
|
||||||
{
|
{
|
||||||
DataInputStream in = new DataInputStream( new ByteBufInputStream( input ) );
|
DataInputStream in = new DataInputStream( new ByteBufInputStream( input ) );
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class NumberFormat
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Type type;
|
||||||
|
private final Object value;
|
||||||
|
|
||||||
|
public enum Type
|
||||||
|
{
|
||||||
|
BLANK,
|
||||||
|
STYLED,
|
||||||
|
FIXED;
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,7 @@ import net.md_5.bungee.protocol.packet.Respawn;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
|
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
import net.md_5.bungee.protocol.packet.ServerData;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||||
@ -134,7 +135,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
BossBar.class,
|
BossBar.class,
|
||||||
@ -192,7 +194,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardScore.class,
|
ScoreboardScore.class,
|
||||||
@ -208,7 +211,13 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F )
|
||||||
|
);
|
||||||
|
TO_CLIENT.registerPacket(
|
||||||
|
ScoreboardScoreReset.class,
|
||||||
|
ScoreboardScoreReset::new,
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardDisplay.class,
|
ScoreboardDisplay.class,
|
||||||
@ -224,7 +233,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Team.class,
|
Team.class,
|
||||||
@ -240,7 +250,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
@ -291,7 +302,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ClearTitles.class,
|
ClearTitles.class,
|
||||||
@ -310,7 +322,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
TitleTimes.class,
|
TitleTimes.class,
|
||||||
@ -320,7 +333,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
SystemChat.class,
|
SystemChat.class,
|
||||||
@ -329,7 +343,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListHeaderFooter.class,
|
PlayerListHeaderFooter.class,
|
||||||
@ -349,7 +364,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
EntityStatus.class,
|
EntityStatus.class,
|
||||||
@ -405,7 +421,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ServerData.class,
|
ServerData.class,
|
||||||
@ -414,7 +431,8 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListItemRemove.class,
|
PlayerListItemRemove.class,
|
||||||
@ -433,7 +451,8 @@ public enum Protocol
|
|||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
StartConfiguration.class,
|
StartConfiguration.class,
|
||||||
StartConfiguration::new,
|
StartConfiguration::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 )
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ),
|
||||||
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 )
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
|
@ -44,7 +44,7 @@ public class ProtocolConstants
|
|||||||
public static final int MINECRAFT_1_19_4 = 762;
|
public static final int MINECRAFT_1_19_4 = 762;
|
||||||
public static final int MINECRAFT_1_20 = 763;
|
public static final int MINECRAFT_1_20 = 763;
|
||||||
public static final int MINECRAFT_1_20_2 = 764;
|
public static final int MINECRAFT_1_20_2 = 764;
|
||||||
public static final int MINECRAFT_1_20_3 = 1073741986;
|
public static final int MINECRAFT_1_20_3 = 1073741989;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -310,6 +310,7 @@ public class Commands extends DefinedPacket
|
|||||||
private static final ArgumentSerializer[] IDS_1_19;
|
private static final ArgumentSerializer[] IDS_1_19;
|
||||||
private static final ArgumentSerializer[] IDS_1_19_3;
|
private static final ArgumentSerializer[] IDS_1_19_3;
|
||||||
private static final ArgumentSerializer[] IDS_1_19_4;
|
private static final ArgumentSerializer[] IDS_1_19_4;
|
||||||
|
private static final ArgumentSerializer[] IDS_1_20_3;
|
||||||
private static final Map<Class<?>, ProperArgumentSerializer<?>> PROPER_PROVIDERS = new HashMap<>();
|
private static final Map<Class<?>, ProperArgumentSerializer<?>> PROPER_PROVIDERS = new HashMap<>();
|
||||||
//
|
//
|
||||||
private static final ArgumentSerializer<Void> VOID = new ArgumentSerializer<Void>()
|
private static final ArgumentSerializer<Void> VOID = new ArgumentSerializer<Void>()
|
||||||
@ -744,6 +745,60 @@ public class Commands extends DefinedPacket
|
|||||||
get( "minecraft:uuid", VOID ),
|
get( "minecraft:uuid", VOID ),
|
||||||
get( "minecraft:heightmap", VOID )
|
get( "minecraft:heightmap", VOID )
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IDS_1_20_3 = new ArgumentSerializer[]
|
||||||
|
{
|
||||||
|
get( "brigadier:bool", VOID ),
|
||||||
|
get( "brigadier:float", FLOAT_RANGE ),
|
||||||
|
get( "brigadier:double", DOUBLE_RANGE ),
|
||||||
|
get( "brigadier:integer", INTEGER_RANGE ),
|
||||||
|
get( "brigadier:long", LONG_RANGE ),
|
||||||
|
get( "brigadier:string", STRING ),
|
||||||
|
get( "minecraft:entity", BYTE ),
|
||||||
|
get( "minecraft:game_profile", VOID ),
|
||||||
|
get( "minecraft:block_pos", VOID ),
|
||||||
|
get( "minecraft:column_pos", VOID ),
|
||||||
|
get( "minecraft:vec3", VOID ),
|
||||||
|
get( "minecraft:vec2", VOID ),
|
||||||
|
get( "minecraft:block_state", VOID ),
|
||||||
|
get( "minecraft:block_predicate", VOID ),
|
||||||
|
get( "minecraft:item_stack", VOID ),
|
||||||
|
get( "minecraft:item_predicate", VOID ),
|
||||||
|
get( "minecraft:color", VOID ),
|
||||||
|
get( "minecraft:component", VOID ),
|
||||||
|
get( "minecraft:style", VOID ),
|
||||||
|
get( "minecraft:message", VOID ),
|
||||||
|
get( "minecraft:nbt_compound_tag", VOID ),
|
||||||
|
get( "minecraft:nbt_tag", VOID ),
|
||||||
|
get( "minecraft:nbt_path", VOID ),
|
||||||
|
get( "minecraft:objective", VOID ),
|
||||||
|
get( "minecraft:objective_criteria", VOID ),
|
||||||
|
get( "minecraft:operation", VOID ),
|
||||||
|
get( "minecraft:particle", VOID ),
|
||||||
|
get( "minecraft:angle", VOID ),
|
||||||
|
get( "minecraft:rotation", VOID ),
|
||||||
|
get( "minecraft:scoreboard_slot", VOID ),
|
||||||
|
get( "minecraft:score_holder", BYTE ),
|
||||||
|
get( "minecraft:swizzle", VOID ),
|
||||||
|
get( "minecraft:team", VOID ),
|
||||||
|
get( "minecraft:item_slot", VOID ),
|
||||||
|
get( "minecraft:resource_location", VOID ),
|
||||||
|
get( "minecraft:function", VOID ),
|
||||||
|
get( "minecraft:entity_anchor", VOID ),
|
||||||
|
get( "minecraft:int_range", VOID ),
|
||||||
|
get( "minecraft:float_range", VOID ),
|
||||||
|
get( "minecraft:dimension", VOID ),
|
||||||
|
get( "minecraft:gamemode", VOID ),
|
||||||
|
get( "minecraft:time", INTEGER ),
|
||||||
|
get( "minecraft:resource_or_tag", RAW_STRING ),
|
||||||
|
get( "minecraft:resource_or_tag_key", RAW_STRING ),
|
||||||
|
get( "minecraft:resource", RAW_STRING ),
|
||||||
|
get( "minecraft:resource_key", RAW_STRING ),
|
||||||
|
get( "minecraft:template_mirror", VOID ),
|
||||||
|
get( "minecraft:template_rotation", VOID ),
|
||||||
|
get( "minecraft:uuid", VOID ),
|
||||||
|
get( "minecraft:heightmap", VOID )
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(String name, ArgumentSerializer serializer)
|
private static void register(String name, ArgumentSerializer serializer)
|
||||||
@ -765,7 +820,10 @@ public class Commands extends DefinedPacket
|
|||||||
{
|
{
|
||||||
key = readVarInt( buf );
|
key = readVarInt( buf );
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
reader = IDS_1_20_3[(Integer) key];
|
||||||
|
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
||||||
{
|
{
|
||||||
reader = IDS_1_19_4[(Integer) key];
|
reader = IDS_1_19_4[(Integer) key];
|
||||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||||
|
@ -10,6 +10,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.Either;
|
import net.md_5.bungee.protocol.Either;
|
||||||
|
import net.md_5.bungee.protocol.NumberFormat;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -26,6 +27,7 @@ public class ScoreboardObjective extends DefinedPacket
|
|||||||
* 0 to create, 1 to remove, 2 to update display text.
|
* 0 to create, 1 to remove, 2 to update display text.
|
||||||
*/
|
*/
|
||||||
private byte action;
|
private byte action;
|
||||||
|
private NumberFormat numberFormat;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
@ -43,6 +45,10 @@ public class ScoreboardObjective extends DefinedPacket
|
|||||||
value = readEitherBaseComponent( buf, protocolVersion, true );
|
value = readEitherBaseComponent( buf, protocolVersion, true );
|
||||||
type = HealthDisplay.fromString( readString( buf ) );
|
type = HealthDisplay.fromString( readString( buf ) );
|
||||||
}
|
}
|
||||||
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
numberFormat = readNullable( (b) -> readNumberFormat( b, protocolVersion ), buf );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +67,10 @@ public class ScoreboardObjective extends DefinedPacket
|
|||||||
{
|
{
|
||||||
writeString( type.toString(), buf );
|
writeString( type.toString(), buf );
|
||||||
}
|
}
|
||||||
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
writeNullable( numberFormat, (s, b) -> DefinedPacket.writeNumberFormat( s, b, protocolVersion ), buf );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,10 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
|
import net.md_5.bungee.protocol.NumberFormat;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -23,29 +25,51 @@ public class ScoreboardScore extends DefinedPacket
|
|||||||
private byte action;
|
private byte action;
|
||||||
private String scoreName;
|
private String scoreName;
|
||||||
private int value;
|
private int value;
|
||||||
|
private BaseComponent displayName;
|
||||||
|
private NumberFormat numberFormat;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
itemName = readString( buf );
|
itemName = readString( buf );
|
||||||
action = buf.readByte();
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
action = 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
action = buf.readByte();
|
||||||
|
}
|
||||||
scoreName = readString( buf );
|
scoreName = readString( buf );
|
||||||
if ( action != 1 )
|
if ( action != 1 )
|
||||||
{
|
{
|
||||||
value = readVarInt( buf );
|
value = readVarInt( buf );
|
||||||
}
|
}
|
||||||
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
displayName = readNullable( (b) -> readBaseComponent( b, protocolVersion ), buf );
|
||||||
|
numberFormat = readNullable( (b) -> readNumberFormat( b, protocolVersion ), buf );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
writeString( itemName, buf );
|
writeString( itemName, buf );
|
||||||
|
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
buf.writeByte( action );
|
||||||
|
}
|
||||||
buf.writeByte( action );
|
buf.writeByte( action );
|
||||||
writeString( scoreName, buf );
|
writeString( scoreName, buf );
|
||||||
if ( action != 1 )
|
if ( action != 1 || protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
{
|
{
|
||||||
writeVarInt( value, buf );
|
writeVarInt( value, buf );
|
||||||
}
|
}
|
||||||
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
writeNullable( displayName, (s, b) -> DefinedPacket.writeBaseComponent( s, b, protocolVersion ), buf );
|
||||||
|
writeNullable( numberFormat, (s, b) -> DefinedPacket.writeNumberFormat( s, b, protocolVersion ), buf );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class ScoreboardScoreReset extends DefinedPacket
|
||||||
|
{
|
||||||
|
|
||||||
|
private String itemName;
|
||||||
|
private String scoreName;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
|
{
|
||||||
|
itemName = readString( buf );
|
||||||
|
scoreName = readNullable( DefinedPacket::readString, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
|
{
|
||||||
|
writeString( itemName, buf );
|
||||||
|
writeNullable( scoreName, DefinedPacket::writeString, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AbstractPacketHandler handler) throws Exception
|
||||||
|
{
|
||||||
|
handler.handle( this );
|
||||||
|
}
|
||||||
|
}
|
@ -53,6 +53,7 @@ import net.md_5.bungee.protocol.packet.PluginMessage;
|
|||||||
import net.md_5.bungee.protocol.packet.Respawn;
|
import net.md_5.bungee.protocol.packet.Respawn;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
|
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
@ -284,12 +285,18 @@ public class ServerConnector extends PacketHandler
|
|||||||
objective.getName(),
|
objective.getName(),
|
||||||
( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ) ? Either.right( ComponentSerializer.deserialize( objective.getValue() ) ) : Either.left( objective.getValue() ),
|
( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ) ? Either.right( ComponentSerializer.deserialize( objective.getValue() ) ) : Either.left( objective.getValue() ),
|
||||||
ScoreboardObjective.HealthDisplay.fromString( objective.getType() ),
|
ScoreboardObjective.HealthDisplay.fromString( objective.getType() ),
|
||||||
(byte) 1 )
|
(byte) 1, null )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for ( Score score : serverScoreboard.getScores() )
|
for ( Score score : serverScoreboard.getScores() )
|
||||||
{
|
{
|
||||||
user.unsafe().sendPacket( new ScoreboardScore( score.getItemName(), (byte) 1, score.getScoreName(), score.getValue() ) );
|
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_3 )
|
||||||
|
{
|
||||||
|
user.unsafe().sendPacket( new ScoreboardScoreReset( score.getItemName(), null ) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
user.unsafe().sendPacket( new ScoreboardScore( score.getItemName(), (byte) 1, score.getScoreName(), score.getValue(), null, null ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for ( Team team : serverScoreboard.getTeams() )
|
for ( Team team : serverScoreboard.getTeams() )
|
||||||
{
|
{
|
||||||
|
@ -67,6 +67,7 @@ import net.md_5.bungee.protocol.packet.Respawn;
|
|||||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
|
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
import net.md_5.bungee.protocol.packet.ServerData;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
@ -220,6 +221,18 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(ScoreboardScoreReset scoreboardScoreReset) throws Exception
|
||||||
|
{
|
||||||
|
Scoreboard serverScoreboard = con.getServerSentScoreboard();
|
||||||
|
|
||||||
|
// TODO: Expand score API to handle objective values. Shouldn't matter currently as only used for removing score entries.
|
||||||
|
if ( scoreboardScoreReset.getScoreName() == null )
|
||||||
|
{
|
||||||
|
serverScoreboard.removeScore( scoreboardScoreReset.getItemName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(ScoreboardDisplay displayScoreboard) throws Exception
|
public void handle(ScoreboardDisplay displayScoreboard) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -172,10 +172,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
|||||||
} );
|
} );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - could not decode packet! {1}", new Object[]
|
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - could not decode packet!", cause );
|
||||||
{
|
|
||||||
handler, cause
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
} else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) )
|
} else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user