Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/WaterdogPE/WaterdogPE
Browse files Browse the repository at this point in the history
  • Loading branch information
AkmalFairuz committed Oct 24, 2024
2 parents d94345d + 06b6fa0 commit 2b9a872
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<raklib.version>1.0.0.CR3-SNAPSHOT</raklib.version>
<protocol.version>3.0.0.Beta2-SNAPSHOT</protocol.version>
<protocol.version>3.0.0.Beta5-SNAPSHOT</protocol.version>
<log4j2.version>2.17.1</log4j2.version>
<jline.version>3.23.0</jline.version>
<netty.version>4.1.89.Final</netty.version>
<netty.version>4.1.101.Final</netty.version>
</properties>

<repositories>
Expand Down Expand Up @@ -196,7 +196,7 @@
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.10.1</version>
<version>9.37.2</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

package dev.waterdog.waterdogpe.network.connection.codec.batch;

import org.cloudburstmc.protocol.bedrock.util.BatchFlag;
import org.cloudburstmc.protocol.bedrock.util.PacketFlag;

public enum BatchFlags implements BatchFlag {
public enum BatchFlags implements PacketFlag {
SKIP_QUEUE
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void decode(ChannelHandlerContext ctx, BedrockBatchWrapper msg, List<O
while (buffer.isReadable()) {
int packetLength = VarInts.readUnsignedInt(buffer);

BedrockPacketWrapper wrapper = new BedrockPacketWrapper();
BedrockPacketWrapper wrapper = BedrockPacketWrapper.create();
wrapper.setPacketBuffer(buffer.readRetainedSlice(packetLength));
msg.getPackets().add(wrapper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void onTick(ChannelHandlerContext ctx) {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof BedrockPacket packet) {
this.packetQueue.add(new BedrockPacketWrapper(0, 0, 0, ReferenceCountUtil.retain(packet), null));
this.packetQueue.add(BedrockPacketWrapper.create(0, 0, 0, ReferenceCountUtil.retain(packet), null));
} else if (msg instanceof BedrockPacketWrapper packet) {
this.packetQueue.add(ReferenceCountUtil.retain(packet));
} else if (msg instanceof BedrockBatchWrapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public final BedrockPacketCodec setCodecHelper(BedrockCodec codec, BedrockCodecH
this.helper = requireNonNull(helper, "Helper can not be null");

switch (this.inboundRecipient) {
case CLIENT -> this.helper.setEncodingSettings(EncodingSettings.CLIENT);
case CLIENT -> this.helper.setEncodingSettings(EncodingSettings.UNLIMITED); // we trust downstream
case SERVER -> this.helper.setEncodingSettings(EncodingSettings.SERVER);
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class ProtocolCodecs {
HANDLED_PACKETS.add(LevelChunkPacket.class);
HANDLED_PACKETS.add(ClientCheatAbilityPacket.class);
HANDLED_PACKETS.add(ToastRequestPacket.class);
HANDLED_PACKETS.add(MovementEffectPacket.class);
}

private static final List<ProtocolCodecUpdater> UPDATERS = new ObjectArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
import org.cloudburstmc.protocol.bedrock.codec.v649.Bedrock_v649;
import org.cloudburstmc.protocol.bedrock.codec.v662.Bedrock_v662;
import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671;
import org.cloudburstmc.protocol.bedrock.codec.v685.Bedrock_v685;
import org.cloudburstmc.protocol.bedrock.codec.v686.Bedrock_v686;
import org.cloudburstmc.protocol.bedrock.codec.v712.Bedrock_v712;
import org.cloudburstmc.protocol.bedrock.codec.v729.Bedrock_v729;
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;

@ToString(exclude = {"defaultCodec", "bedrockCodec"})
public enum ProtocolVersion {
Expand Down Expand Up @@ -103,7 +108,12 @@ public enum ProtocolVersion {
MINECRAFT_PE_1_20_50(630, Bedrock_v630.CODEC),
MINECRAFT_PE_1_20_60(649, Bedrock_v649.CODEC),
MINECRAFT_PE_1_20_70(662, Bedrock_v662.CODEC),
MINECRAFT_PE_1_20_80(671, Bedrock_v671.CODEC);
MINECRAFT_PE_1_20_80(671, Bedrock_v671.CODEC),
MINECRAFT_PE_1_21_0(685, Bedrock_v685.CODEC),
MINECRAFT_PE_1_21_2(686, Bedrock_v686.CODEC),
MINECRAFT_PE_1_21_20(712, Bedrock_v712.CODEC),
MINECRAFT_PE_1_21_30(729, Bedrock_v729.CODEC),
MINECRAFT_PE_1_21_40(748, Bedrock_v748.CODEC);

private static final ProtocolVersion[] VALUES = values();
private static final Int2ObjectMap<ProtocolVersion> VERSIONS = new Int2ObjectOpenHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ public PacketSignal handle(AnimateEntityPacket packet) {
return signal;
}

@Override
public PacketSignal handle(MovementEffectPacket packet) {
return rewriteId(packet.getEntityRuntimeId(), packet::setEntityRuntimeId);
}

private PacketSignal rewriteMetadata(EntityDataMap metadata) {
PacketSignal signal = PacketSignal.UNHANDLED;
for (EntityDataType<Long> data : ENTITY_DATA_FIELDS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void rebuildPackets() {

for (ResourcePack pack : this.packs.values()) {
ResourcePacksInfoPacket.Entry infoEntry = new ResourcePacksInfoPacket.Entry(pack.getPackId().toString(), pack.getVersion().toString(),
pack.getPackSize(), pack.getContentKey(), "", pack.getContentKey().equals("") ? "" : pack.getPackId().toString(), false, false);
pack.getPackSize(), pack.getContentKey(), "", pack.getContentKey().equals("") ? "" : pack.getPackId().toString(), false, false, false, null);
ResourcePackStackPacket.Entry stackEntry = new ResourcePackStackPacket.Entry(pack.getPackId().toString(), pack.getVersion().toString(), "");
if (pack.getType().equals(ResourcePack.TYPE_RESOURCES)) {
this.packsInfoPacket.getResourcePackInfos().add(infoEntry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class ProxiedPlayer implements CommandSender {
private final CompressionType compression;

private final AtomicBoolean disconnected = new AtomicBoolean(false);
private final AtomicBoolean loginCalled = new AtomicBoolean(false);
private final AtomicBoolean loginCompleted = new AtomicBoolean(false);
private volatile String disconnectReason;

Expand Down Expand Up @@ -119,6 +120,10 @@ public ProxiedPlayer(ProxyServer proxy, BedrockServerSession session, Compressio
* Called after sending LOGIN_SUCCESS in PlayStatusPacket.
*/
public void initPlayer() {
if (!this.loginCalled.compareAndSet(false, true)) {
return;
}

PlayerLoginEvent event = new PlayerLoginEvent(this);
this.proxy.getEventManager().callEvent(event).whenComplete((futureEvent, error) -> {
this.loginCompleted.set(true);
Expand Down Expand Up @@ -326,7 +331,7 @@ public void disconnect(TextContainer message) {
* @param reason The disconnect reason the player will see on his disconnect screen (Supports Color Codes)
*/
public void disconnect(String reason) {
if (!this.loginCompleted.get()) {
if (this.loginCalled.get() && !this.loginCompleted.get()) {
// Wait until PlayerLoginEvent completes
this.disconnectReason = reason;
return;
Expand Down

0 comments on commit 2b9a872

Please sign in to comment.