2424import com .velocitypowered .proxy .util .except .QuietDecoderException ;
2525import io .netty .buffer .ByteBuf ;
2626
27+ import java .util .Arrays ;
28+ import java .util .Objects ;
29+
2730public class KnownPacksPacket implements MinecraftPacket {
2831
2932 private static final int MAX_LENGTH_PACKS = Integer .getInteger ("velocity.max-known-packs" , 64 );
@@ -36,6 +39,10 @@ public KnownPacksPacket() {
3639 packs = new KnownPack [0 ];
3740 }
3841
42+ public KnownPacksPacket (KnownPack [] packs ) {
43+ this .packs = packs ;
44+ }
45+
3946 @ Override
4047 public void decode (ByteBuf buf , ProtocolUtils .Direction direction ,
4148 ProtocolVersion protocolVersion ) {
@@ -68,6 +75,17 @@ public boolean handle(MinecraftSessionHandler handler) {
6875 return handler .handle (this );
6976 }
7077
78+ public KnownPack [] getPacks () {
79+ return packs ;
80+ }
81+
82+ @ Override
83+ public String toString () {
84+ return "KnownPacksPacket{" +
85+ "packs=" + Arrays .toString (packs ) +
86+ '}' ;
87+ }
88+
7189 public record KnownPack (String namespace , String id , String version ) {
7290 private static KnownPack read (ByteBuf buf ) {
7391 return new KnownPack (ProtocolUtils .readString (buf ), ProtocolUtils .readString (buf ), ProtocolUtils .readString (buf ));
@@ -78,5 +96,26 @@ private void write(ByteBuf buf) {
7896 ProtocolUtils .writeString (buf , id );
7997 ProtocolUtils .writeString (buf , version );
8098 }
99+
100+ @ Override
101+ public boolean equals (Object o ) {
102+ if (o == null || getClass () != o .getClass ()) return false ;
103+ KnownPack knownPack = (KnownPack ) o ;
104+ return Objects .equals (id , knownPack .id ) && Objects .equals (version , knownPack .version ) && Objects .equals (namespace , knownPack .namespace );
105+ }
106+
107+ @ Override
108+ public int hashCode () {
109+ return Objects .hash (namespace , id , version );
110+ }
111+
112+ @ Override
113+ public String toString () {
114+ return "KnownPack{" +
115+ "namespace='" + namespace + '\'' +
116+ ", id='" + id + '\'' +
117+ ", version='" + version + '\'' +
118+ '}' ;
119+ }
81120 }
82121}
0 commit comments