3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Show form window immediately after spawn (#606)

Dieser Commit ist enthalten in:
Creeperface01 2020-05-20 17:12:03 +02:00 committet von GitHub
Ursprung 3ab5c697c1
Commit 5fe38fa83f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 13 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -110,7 +110,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
} }
@Override @Override
public boolean handle(MovePlayerPacket packet) { public boolean handle(SetLocalPlayerAsInitializedPacket packet) {
if (!session.isLoggedIn() && !session.isLoggingIn() && session.getConnector().getAuthType() == AuthType.ONLINE) { if (!session.isLoggedIn() && !session.isLoggingIn() && session.getConnector().getAuthType() == AuthType.ONLINE) {
// TODO it is safer to key authentication on something that won't change (UUID, not username) // TODO it is safer to key authentication on something that won't change (UUID, not username)
if (!couldLoginUserByName(session.getAuthData().getName())) { if (!couldLoginUserByName(session.getAuthData().getName())) {
@ -119,6 +119,11 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
// else we were able to log the user in // else we were able to log the user in
return true; return true;
} }
return translateAndDefault(packet);
}
@Override
public boolean handle(MovePlayerPacket packet) {
if (session.isLoggingIn()) { if (session.isLoggingIn()) {
session.sendMessage("Please wait until you are logged in..."); session.sendMessage("Please wait until you are logged in...");
} }

Datei anzeigen

@ -34,7 +34,6 @@ import com.nukkitx.network.util.Preconditions;
import com.nukkitx.protocol.bedrock.packet.LoginPacket; import com.nukkitx.protocol.bedrock.packet.LoginPacket;
import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket; import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket;
import com.nukkitx.protocol.bedrock.util.EncryptionUtils; import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
import org.geysermc.common.window.CustomFormBuilder; import org.geysermc.common.window.CustomFormBuilder;
import org.geysermc.common.window.CustomFormWindow; import org.geysermc.common.window.CustomFormWindow;
import org.geysermc.common.window.FormWindow; import org.geysermc.common.window.FormWindow;
@ -193,18 +192,22 @@ public class LoginEncryptionUtils {
String password = response.getInputResponses().get(2); String password = response.getInputResponses().get(2);
session.authenticate(email, password); session.authenticate(email, password);
} else {
showLoginDetailsWindow(session);
} }
// Clear windows so authentication data isn't accidentally cached // Clear windows so authentication data isn't accidentally cached
windowCache.getWindows().clear(); windowCache.getWindows().clear();
} else if (formId == AUTH_FORM_ID && window instanceof SimpleFormWindow) { } else if (formId == AUTH_FORM_ID && window instanceof SimpleFormWindow) {
SimpleFormResponse response = (SimpleFormResponse) window.getResponse(); SimpleFormResponse response = (SimpleFormResponse) window.getResponse();
if(response != null) { if (response != null) {
if(response.getClickedButtonId() == 0) { if (response.getClickedButtonId() == 0) {
showLoginDetailsWindow(session); showLoginDetailsWindow(session);
} else if(response.getClickedButtonId() == 1) { } else if (response.getClickedButtonId() == 1) {
session.disconnect("Login is required"); session.disconnect("Login is required");
} }
} else {
showLoginWindow(session);
} }
} }
} }