Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary bad fix for command crashing #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
@Setter
private @Nullable ItemData currentBook = null;

/**
* Stores if we've sent AvailibleCommandsPacket to the client due to it crashing if sent twice on 1.20.70/71
* Hopefully bedrock will have a hotfix so we can remove this
*/
@Setter
private boolean sentAvailibleCommands = false;

private final GeyserCameraData cameraData;

private final GeyserEntityData entityData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.geysermc.geyser.api.event.java.ServerDefineCommandsEvent;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.inventory.item.Enchantment;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.session.GeyserSession;
Expand Down Expand Up @@ -115,6 +116,12 @@ public void translate(GeyserSession session, ClientboundCommandsPacket packet) {
return;
}

// Don't send command suggestions if they are already sent and the client is 1.20.70 or higher due to crash bug
// TODO: Remove this check when the crash bug is fixed
if (session.isSentAvailibleCommands() && !GameProtocol.isPre1_20_70(session)) {
return;
}

GeyserCommandManager manager = session.getGeyser().commandManager();
CommandNode[] nodes = packet.getNodes();
List<CommandData> commandData = new ArrayList<>();
Expand Down Expand Up @@ -191,6 +198,7 @@ public void translate(GeyserSession session, ClientboundCommandsPacket packet) {

// Finally, send the commands to the client
session.sendUpstreamPacket(availableCommandsPacket);
session.setSentAvailibleCommands(true);
}

/**
Expand Down
Loading