Skip to content

Commit 0d573bb

Browse files
committed
Add final static packet instance for ServerboundAcceptCodeOfConductPacket / ServerboundFinishConfigurationPacket
1 parent c3da4f2 commit 0d573bb

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/ClientListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void packetReceived(Session session, Packet packet) {
155155
session.send(new ServerboundKeepAlivePacket(keepAlivePacket.getPingId()));
156156
} else if (packet instanceof ClientboundFinishConfigurationPacket) {
157157
session.switchInboundState(() -> protocol.setInboundState(ProtocolState.GAME));
158-
session.send(new ServerboundFinishConfigurationPacket());
158+
session.send(ServerboundFinishConfigurationPacket.INSTANCE);
159159
session.switchOutboundState(() -> protocol.setOutboundState(ProtocolState.GAME));
160160
} else if (packet instanceof ClientboundSelectKnownPacks) {
161161
if (session.getFlag(MinecraftConstants.SEND_BLANK_KNOWN_PACKS_RESPONSE, true)) {

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@ public class MinecraftCodec {
277277
.registerServerboundPacket(ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new)
278278
.registerServerboundPacket(ServerboundCookieResponsePacket.class, ServerboundCookieResponsePacket::new)
279279
.registerServerboundPacket(ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new)
280-
.registerServerboundPacket(ServerboundFinishConfigurationPacket.class, ServerboundFinishConfigurationPacket::new)
280+
.registerServerboundPacket(ServerboundFinishConfigurationPacket.class, (buf) -> ServerboundFinishConfigurationPacket.INSTANCE)
281281
.registerServerboundPacket(ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new)
282282
.registerServerboundPacket(ServerboundPongPacket.class, ServerboundPongPacket::new)
283283
.registerServerboundPacket(ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new)
284284
.registerServerboundPacket(ServerboundSelectKnownPacks.class, ServerboundSelectKnownPacks::new)
285285
.registerServerboundPacket(ServerboundCustomClickActionPacket.class, ServerboundCustomClickActionPacket::new)
286-
.registerServerboundPacket(ServerboundAcceptCodeOfConductPacket.class, ServerboundAcceptCodeOfConductPacket::new)
286+
.registerServerboundPacket(ServerboundAcceptCodeOfConductPacket.class, (buf) -> ServerboundAcceptCodeOfConductPacket.INSTANCE)
287287
).state(ProtocolState.GAME, MinecraftPacketRegistry.builder()
288288
.registerClientboundPacket(ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new)
289289
.registerClientboundPacket(ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new)

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/configuration/serverbound/ServerboundAcceptCodeOfConductPacket.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package org.geysermc.mcprotocollib.protocol.packet.configuration.serverbound;
22

33
import io.netty.buffer.ByteBuf;
4+
import lombok.AccessLevel;
5+
import lombok.NoArgsConstructor;
46
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
7+
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundClientTickEndPacket;
58

9+
@NoArgsConstructor(access = AccessLevel.PRIVATE)
610
public class ServerboundAcceptCodeOfConductPacket implements MinecraftPacket {
7-
8-
public ServerboundAcceptCodeOfConductPacket(ByteBuf in) {}
11+
public static final ServerboundAcceptCodeOfConductPacket INSTANCE = new ServerboundAcceptCodeOfConductPacket();
912

1013
@Override
1114
public void serialize(ByteBuf out) {}

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/configuration/serverbound/ServerboundFinishConfigurationPacket.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package org.geysermc.mcprotocollib.protocol.packet.configuration.serverbound;
22

33
import io.netty.buffer.ByteBuf;
4+
import lombok.AccessLevel;
45
import lombok.Data;
56
import lombok.NoArgsConstructor;
67
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
78

89
@Data
9-
@NoArgsConstructor
10+
@NoArgsConstructor(access = AccessLevel.PRIVATE)
1011
public class ServerboundFinishConfigurationPacket implements MinecraftPacket {
11-
12-
public ServerboundFinishConfigurationPacket(ByteBuf in) {
13-
}
12+
public static final ServerboundFinishConfigurationPacket INSTANCE = new ServerboundFinishConfigurationPacket();
1413

1514
public void serialize(ByteBuf out) {
1615
}

0 commit comments

Comments
 (0)