Skip to content

Commit

Permalink
Changes to ensure GeyserConnect still works despite internal changes in
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris authored May 10, 2024
1 parent 1c8c038 commit 9733781
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
@Subscribe
public void onSessionInitialize(SessionInitializeEvent event) {
GeyserSession session = (GeyserSession) event.connection();
if (config().hardPlayerLimit()) {
if (session.getGeyser().getSessionManager().size() >= session.getGeyser().getConfig().getMaxPlayers()) {
session.disconnect("disconnectionScreen.serverFull");
}
}

// Change the packet handler to our own
BedrockPacketHandler packetHandler = session.getUpstream().getSession().getPacketHandler();
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/org/geysermc/extension/connect/PacketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

import org.cloudburstmc.protocol.bedrock.data.AttributeData;
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacketHandler;
import org.cloudburstmc.protocol.bedrock.packet.LoginPacket;
import org.cloudburstmc.protocol.bedrock.packet.NetworkStackLatencyPacket;
import org.cloudburstmc.protocol.bedrock.packet.ResourcePackChunkRequestPacket;
import org.cloudburstmc.protocol.bedrock.packet.ResourcePackClientResponsePacket;
import org.cloudburstmc.protocol.bedrock.packet.SetLocalPlayerAsInitializedPacket;
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
import org.cloudburstmc.protocol.common.PacketSignal;
Expand Down Expand Up @@ -74,19 +75,6 @@ public void onDisconnect(String reason) {
}
}

@Override
public PacketSignal handle(LoginPacket loginPacket) {
// Check to see if the server is full and we have a hard player cap
if (geyserConnect.config().hardPlayerLimit()) {
if (session.getGeyser().getSessionManager().size() >= session.getGeyser().getConfig().getMaxPlayers()) {
session.disconnect("disconnectionScreen.serverFull");
return PacketSignal.HANDLED;
}
}

return super.handle(loginPacket);
}

@Override
public PacketSignal handle(SetLocalPlayerAsInitializedPacket packet) {
geyserConnect.logger().debug("Player initialized: " + Utils.displayName(session));
Expand Down Expand Up @@ -165,5 +153,15 @@ public PacketSignal handle(NetworkStackLatencyPacket packet) {

return super.handle(packet);
}

@Override
public PacketSignal handle(ResourcePackClientResponsePacket packet) {
return originalPacketHandler.handle(packet);
}

@Override
public PacketSignal handle(ResourcePackChunkRequestPacket packet) {
return originalPacketHandler.handle(packet);
}
}

0 comments on commit 9733781

Please sign in to comment.