Minecraft 25w20a protocol support
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<artifactId>bungeecord-serializer</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@@ -2,6 +2,7 @@ package net.md_5.bungee.protocol;
|
||||
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClearDialog;
|
||||
import net.md_5.bungee.protocol.packet.ClearTitles;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
@@ -10,6 +11,7 @@ import net.md_5.bungee.protocol.packet.ClientStatus;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import net.md_5.bungee.protocol.packet.CookieRequest;
|
||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
||||
import net.md_5.bungee.protocol.packet.CustomClickAction;
|
||||
import net.md_5.bungee.protocol.packet.DisconnectReportDetails;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
@@ -41,6 +43,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||
import net.md_5.bungee.protocol.packet.ServerData;
|
||||
import net.md_5.bungee.protocol.packet.ServerLinks;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.protocol.packet.ShowDialog;
|
||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
@@ -278,4 +281,16 @@ public abstract class AbstractPacketHandler
|
||||
public void handle(ServerLinks serverLinks) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(ShowDialog showDialog) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(ClearDialog clearDialog) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(CustomClickAction customClickAction) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClearDialog;
|
||||
import net.md_5.bungee.protocol.packet.ClearTitles;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
@@ -18,6 +19,7 @@ import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import net.md_5.bungee.protocol.packet.CookieRequest;
|
||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
||||
import net.md_5.bungee.protocol.packet.CustomClickAction;
|
||||
import net.md_5.bungee.protocol.packet.DisconnectReportDetails;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
@@ -47,6 +49,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||
import net.md_5.bungee.protocol.packet.ServerData;
|
||||
import net.md_5.bungee.protocol.packet.ServerLinks;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.protocol.packet.ShowDialog;
|
||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
@@ -559,6 +562,16 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_21, 0x7B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x82 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ClearDialog.class,
|
||||
ClearDialog::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x84 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ShowDialog.class,
|
||||
ShowDialog::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x85 )
|
||||
);
|
||||
|
||||
TO_SERVER.registerPacket(
|
||||
KeepAlive.class,
|
||||
@@ -578,7 +591,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x18 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1A )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x1B )
|
||||
);
|
||||
TO_SERVER.registerPacket( Chat.class,
|
||||
Chat::new,
|
||||
@@ -595,14 +609,15 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x06 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x06 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x07 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
UnsignedClientCommand.class,
|
||||
UnsignedClientCommand::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x05 )
|
||||
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x05 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x06 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
ClientChat.class,
|
||||
@@ -610,7 +625,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x06 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x07 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x07 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x08 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
TabCompleteRequest.class,
|
||||
@@ -627,7 +643,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0D )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x0E )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
ClientSettings.class,
|
||||
@@ -643,7 +660,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0C )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x0D )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
PluginMessage.class,
|
||||
@@ -662,20 +680,28 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x12 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x14 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x14 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x15 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
StartConfiguration.class,
|
||||
StartConfiguration::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0E )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x0F )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
CookieResponse.class,
|
||||
CookieResponse::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x13 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x13 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x14 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
CustomClickAction.class,
|
||||
CustomClickAction::new,
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x41 )
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@@ -50,7 +50,7 @@ public class ProtocolConstants
|
||||
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_5 = 770;
|
||||
public static final int MINECRAFT_1_21_6 = 1073742073;
|
||||
public static final int MINECRAFT_1_21_6 = 1073742074;
|
||||
public static final List<String> SUPPORTED_VERSIONS;
|
||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||
|
||||
|
@@ -0,0 +1,32 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ClearDialog extends DefinedPacket
|
||||
{
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -745,8 +745,8 @@ public class Commands extends DefinedPacket
|
||||
get( "minecraft:resource_key", RAW_STRING ),
|
||||
get( "minecraft:template_mirror", VOID ),
|
||||
get( "minecraft:template_rotation", VOID ),
|
||||
get( "minecraft:uuid", VOID ),
|
||||
get( "minecraft:heightmap", VOID )
|
||||
get( "minecraft:heightmap", VOID ),
|
||||
get( "minecraft:uuid", VOID )
|
||||
};
|
||||
|
||||
IDS_1_20_3 = new ArgumentSerializer[]
|
||||
@@ -799,8 +799,8 @@ public class Commands extends DefinedPacket
|
||||
get( "minecraft:resource_key", RAW_STRING ),
|
||||
get( "minecraft:template_mirror", VOID ),
|
||||
get( "minecraft:template_rotation", VOID ),
|
||||
get( "minecraft:uuid", VOID ),
|
||||
get( "minecraft:heightmap", VOID )
|
||||
get( "minecraft:heightmap", VOID ),
|
||||
get( "minecraft:uuid", VOID )
|
||||
};
|
||||
|
||||
IDS_1_20_5 = new ArgumentSerializer[]
|
||||
@@ -854,11 +854,11 @@ public class Commands extends DefinedPacket
|
||||
get( "minecraft:resource_key", RAW_STRING ),
|
||||
get( "minecraft:template_mirror", VOID ),
|
||||
get( "minecraft:template_rotation", VOID ),
|
||||
get( "minecraft:uuid", VOID ),
|
||||
get( "minecraft:heightmap", VOID ),
|
||||
get( "minecraft:loot_table", VOID ),
|
||||
get( "minecraft:loot_predicate", VOID ),
|
||||
get( "minecraft:loot_modifier", VOID )
|
||||
get( "minecraft:loot_modifier", VOID ),
|
||||
get( "minecraft:uuid", VOID )
|
||||
};
|
||||
|
||||
IDS_1_21_5 = new ArgumentSerializer[]
|
||||
@@ -913,11 +913,11 @@ public class Commands extends DefinedPacket
|
||||
get( "minecraft:resource_selector", RAW_STRING ),
|
||||
get( "minecraft:template_mirror", VOID ),
|
||||
get( "minecraft:template_rotation", VOID ),
|
||||
get( "minecraft:uuid", VOID ),
|
||||
get( "minecraft:heightmap", VOID ),
|
||||
get( "minecraft:loot_table", VOID ),
|
||||
get( "minecraft:loot_predicate", VOID ),
|
||||
get( "minecraft:loot_modifier", VOID )
|
||||
get( "minecraft:loot_modifier", VOID ),
|
||||
get( "minecraft:uuid", VOID )
|
||||
};
|
||||
|
||||
IDS_1_21_6 = new ArgumentSerializer[]
|
||||
@@ -973,11 +973,12 @@ public class Commands extends DefinedPacket
|
||||
get( "minecraft:resource_selector", RAW_STRING ),
|
||||
get( "minecraft:template_mirror", VOID ),
|
||||
get( "minecraft:template_rotation", VOID ),
|
||||
get( "minecraft:uuid", VOID ),
|
||||
get( "minecraft:heightmap", VOID ),
|
||||
get( "minecraft:loot_table", VOID ),
|
||||
get( "minecraft:loot_predicate", VOID ),
|
||||
get( "minecraft:loot_modifier", VOID )
|
||||
get( "minecraft:loot_modifier", VOID ),
|
||||
get( "minecraft:dialog", VOID ),
|
||||
get( "minecraft:uuid", VOID )
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,47 @@
|
||||
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.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CustomClickAction extends DefinedPacket
|
||||
{
|
||||
|
||||
private String id;
|
||||
private String data;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, Protocol protocol, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
id = readString( buf );
|
||||
data = readNullable( DefinedPacket::readString, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, Protocol protocol, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( id, buf );
|
||||
writeNullable( data, DefinedPacket::writeString, buf );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.api.dialog.Dialog;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ChatSerializer;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Either;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.TagUtil;
|
||||
import se.llbit.nbt.SpecificTag;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ShowDialog extends DefinedPacket
|
||||
{
|
||||
|
||||
protected Either<Integer, Dialog> dialog;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
int id = readVarInt( buf );
|
||||
if ( id == 0 )
|
||||
{
|
||||
dialog = Either.right( readDialog( buf, direction, protocolVersion ) );
|
||||
} else
|
||||
{
|
||||
dialog = Either.left( id );
|
||||
}
|
||||
}
|
||||
|
||||
protected static Dialog readDialog(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
SpecificTag nbt = (SpecificTag) readTag( buf, protocolVersion );
|
||||
JsonElement json = TagUtil.toJson( nbt );
|
||||
return ChatSerializer.forVersion( protocolVersion ).getDialogSerializer().deserialize( json );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( dialog.isLeft() )
|
||||
{
|
||||
writeVarInt( dialog.getLeft(), buf );
|
||||
} else
|
||||
{
|
||||
writeVarInt( 0, buf );
|
||||
writeDialog( dialog.getRight(), buf, direction, protocolVersion );
|
||||
}
|
||||
}
|
||||
|
||||
protected static void writeDialog(Dialog dialog, ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
JsonElement json = ChatSerializer.forVersion( protocolVersion ).getDialogSerializer().toJson( dialog );
|
||||
SpecificTag nbt = TagUtil.fromJson( json );
|
||||
|
||||
writeTag( nbt, buf, protocolVersion );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.api.dialog.Dialog;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.Either;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ShowDialogDirect extends ShowDialog
|
||||
{
|
||||
|
||||
public ShowDialogDirect(Dialog dialog)
|
||||
{
|
||||
super( Either.right( dialog ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
dialog = Either.right( readDialog( buf, direction, protocolVersion ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeDialog( dialog.getRight(), buf, direction, protocolVersion );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user