Skip to content

Commit

Permalink
Fix settings not displaying due to bedrock bug by delaying 1s (Geyser…
Browse files Browse the repository at this point in the history
…MC#2010)

* Fix settings not displaying due to bedrock bug by delaying 1s

* Update BedrockServerSettingsRequestTranslator.java
  • Loading branch information
rtm516 authored Mar 8, 2021
1 parent e4cff74 commit efc7e43
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,21 @@
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.utils.SettingsUtils;

import java.util.concurrent.TimeUnit;

@Translator(packet = ServerSettingsRequestPacket.class)
public class BedrockServerSettingsRequestTranslator extends PacketTranslator<ServerSettingsRequestPacket> {

@Override
public void translate(ServerSettingsRequestPacket packet, GeyserSession session) {
SettingsUtils.buildForm(session);

ServerSettingsResponsePacket serverSettingsResponsePacket = new ServerSettingsResponsePacket();
serverSettingsResponsePacket.setFormData(session.getSettingsForm().getJSONData());
serverSettingsResponsePacket.setFormId(SettingsUtils.SETTINGS_FORM_ID);
session.sendUpstreamPacket(serverSettingsResponsePacket);
// Fixes https://bugs.mojang.com/browse/MCPE-94012 because of the delay
session.getConnector().getGeneralThreadPool().schedule(() -> {
ServerSettingsResponsePacket serverSettingsResponsePacket = new ServerSettingsResponsePacket();
serverSettingsResponsePacket.setFormData(session.getSettingsForm().getJSONData());
serverSettingsResponsePacket.setFormId(SettingsUtils.SETTINGS_FORM_ID);
session.sendUpstreamPacket(serverSettingsResponsePacket);
}, 1, TimeUnit.SECONDS);
}
}

0 comments on commit efc7e43

Please sign in to comment.