Skip to content

Commit

Permalink
Fix logging into a server with Fabric Networking API (GeyserMC#1995)
Browse files Browse the repository at this point in the history
* Fix logging into a server with Fabric Networking API

Turns out we prevented the response to LoginPluginRequestPacket. Fabric API 0.28 and later will not let a client join without this response.

* Switch back to Jitpack just for Protocol to prevent weird errors

* Re-add sub protocol check

* Simplify check
  • Loading branch information
Camotoy authored Mar 3, 2021
1 parent 88d4903 commit e4e9758
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nukkitx.protocol</groupId>
<groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-v422</artifactId>
<version>2.6.2-20210228.150048-4</version>
<version>42da92f</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
import com.github.steveice10.mc.protocol.packet.login.client.LoginPluginResponsePacket;
import com.github.steveice10.mc.protocol.packet.login.server.LoginSuccessPacket;
import com.github.steveice10.packetlib.BuiltinFlags;
import com.github.steveice10.packetlib.Client;
Expand Down Expand Up @@ -69,10 +70,10 @@
import org.geysermc.common.window.CustomFormWindow;
import org.geysermc.common.window.FormWindow;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.entity.Tickable;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.common.AuthType;
import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.Tickable;
import org.geysermc.connector.entity.player.SessionPlayerEntity;
import org.geysermc.connector.entity.player.SkullPlayerEntity;
import org.geysermc.connector.inventory.PlayerInventory;
Expand Down Expand Up @@ -956,7 +957,7 @@ public void sendUpstreamPacketImmediately(BedrockPacket packet) {
* @param packet the java edition packet from MCProtocolLib
*/
public void sendDownstreamPacket(Packet packet) {
if (downstream != null && downstream.getSession() != null && protocol.getSubProtocol().equals(SubProtocol.GAME)) {
if (downstream != null && downstream.getSession() != null && (protocol.getSubProtocol().equals(SubProtocol.GAME) || packet.getClass() == LoginPluginResponsePacket.class)) {
downstream.getSession().send(packet);
} else {
connector.getLogger().debug("Tried to send downstream packet " + packet.getClass().getSimpleName() + " before connected to the server");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
import com.github.steveice10.mc.protocol.packet.login.server.LoginPluginRequestPacket;

@Translator(packet = LoginPluginRequestPacket.class)
public class JavaLoginPluginMessageTranslator extends PacketTranslator<LoginPluginRequestPacket> {
public class JavaLoginPluginRequestTranslator extends PacketTranslator<LoginPluginRequestPacket> {
@Override
public void translate(LoginPluginRequestPacket packet, GeyserSession session) {
// A vanilla client doesn't know any PluginMessage in the Login state, so we don't know any either.
// Note: Fabric Networking API v1 will not let the client log in without sending this
session.sendDownstreamPacket(
new LoginPluginResponsePacket(packet.getMessageId(), null)
);
Expand Down

0 comments on commit e4e9758

Please sign in to comment.