Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2025-01-11 15:41:08 +01:00
Update Geyser to use the latest features of Cumulus 1.1
Dieser Commit ist enthalten in:
Ursprung
f702fb45b4
Commit
3011d89db6
@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc.cumulus</groupId>
|
<groupId>org.geysermc.cumulus</groupId>
|
||||||
<artifactId>cumulus</artifactId>
|
<artifactId>cumulus</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
@ -76,7 +76,7 @@ import lombok.Getter;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.common.PlatformType;
|
import org.geysermc.common.PlatformType;
|
||||||
import org.geysermc.cumulus.Form;
|
import org.geysermc.cumulus.form.Form;
|
||||||
import org.geysermc.cumulus.util.FormBuilder;
|
import org.geysermc.cumulus.util.FormBuilder;
|
||||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||||
import org.geysermc.floodgate.util.BedrockData;
|
import org.geysermc.floodgate.util.BedrockData;
|
||||||
@ -1183,7 +1183,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
formCache.showForm(form);
|
formCache.showForm(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendForm(FormBuilder<?, ?> formBuilder) {
|
public void sendForm(FormBuilder<?, ?, ?> formBuilder) {
|
||||||
formCache.showForm(formBuilder.build());
|
formCache.showForm(formBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +29,12 @@ import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
|||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSeenAdvancementsPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSeenAdvancementsPacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.cumulus.form.SimpleForm;
|
||||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
|
||||||
import org.geysermc.geyser.level.GeyserAdvancement;
|
import org.geysermc.geyser.level.GeyserAdvancement;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.text.MinecraftLocale;
|
import org.geysermc.geyser.text.MinecraftLocale;
|
||||||
import org.geysermc.cumulus.SimpleForm;
|
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||||
import org.geysermc.cumulus.response.SimpleFormResponse;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -87,18 +86,13 @@ public class AdvancementsCache {
|
|||||||
builder.content("advancements.empty");
|
builder.content("advancements.empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.responseHandler((form, responseData) -> {
|
builder.validResultHandler((form, response) -> {
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
|
||||||
if (!response.isCorrect()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String id = "";
|
String id = "";
|
||||||
|
|
||||||
int advancementIndex = 0;
|
int advancementIndex = 0;
|
||||||
for (Map.Entry<String, GeyserAdvancement> advancement : storedAdvancements.entrySet()) {
|
for (Map.Entry<String, GeyserAdvancement> advancement : storedAdvancements.entrySet()) {
|
||||||
if (advancement.getValue().getParentId() == null) { // Root advancement
|
if (advancement.getValue().getParentId() == null) { // Root advancement
|
||||||
if (advancementIndex == response.getClickedButtonId()) {
|
if (advancementIndex == response.clickedButtonId()) {
|
||||||
id = advancement.getKey();
|
id = advancement.getKey();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -148,21 +142,18 @@ public class AdvancementsCache {
|
|||||||
|
|
||||||
builder.button(GeyserLocale.getPlayerLocaleString("gui.back", language));
|
builder.button(GeyserLocale.getPlayerLocaleString("gui.back", language));
|
||||||
|
|
||||||
builder.responseHandler((form, responseData) -> {
|
builder.closedResultHandler(form -> {
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
// Indicate that we have closed the current advancement tab
|
||||||
if (!response.isCorrect()) {
|
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
|
||||||
// Indicate that we have closed the current advancement tab
|
|
||||||
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}).validResultHandler((form, response) -> {
|
||||||
GeyserAdvancement advancement = null;
|
GeyserAdvancement advancement = null;
|
||||||
int advancementIndex = 0;
|
int advancementIndex = 0;
|
||||||
// Loop around to find the advancement that the client pressed
|
// Loop around to find the advancement that the client pressed
|
||||||
for (GeyserAdvancement advancementEntry : storedAdvancements.values()) {
|
for (GeyserAdvancement advancementEntry : storedAdvancements.values()) {
|
||||||
if (advancementEntry.getParentId() != null &&
|
if (advancementEntry.getParentId() != null &&
|
||||||
currentAdvancementCategoryId.equals(advancementEntry.getRootId(this))) {
|
currentAdvancementCategoryId.equals(advancementEntry.getRootId(this))) {
|
||||||
if (advancementIndex == response.getClickedButtonId()) {
|
if (advancementIndex == response.clickedButtonId()) {
|
||||||
advancement = advancementEntry;
|
advancement = advancementEntry;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -219,12 +210,7 @@ public class AdvancementsCache {
|
|||||||
.title(MessageTranslator.convertMessage(advancement.getDisplayData().getTitle()))
|
.title(MessageTranslator.convertMessage(advancement.getDisplayData().getTitle()))
|
||||||
.content(content)
|
.content(content)
|
||||||
.button(GeyserLocale.getPlayerLocaleString("gui.back", language))
|
.button(GeyserLocale.getPlayerLocaleString("gui.back", language))
|
||||||
.responseHandler((form, responseData) -> {
|
.validResultHandler((form, response) -> buildAndShowListForm())
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
|
||||||
if (response.isCorrect()) {
|
|
||||||
buildAndShowListForm();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,17 +31,18 @@ import com.nukkitx.protocol.bedrock.packet.NetworkStackLatencyPacket;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.geysermc.cumulus.form.Form;
|
||||||
|
import org.geysermc.cumulus.form.SimpleForm;
|
||||||
|
import org.geysermc.cumulus.form.impl.FormDefinitions;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.cumulus.Form;
|
|
||||||
import org.geysermc.cumulus.SimpleForm;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class FormCache {
|
public class FormCache {
|
||||||
|
private final FormDefinitions formDefinitions = FormDefinitions.instance();
|
||||||
private final AtomicInteger formId = new AtomicInteger(0);
|
private final AtomicInteger formId = new AtomicInteger(0);
|
||||||
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
|
||||||
private final GeyserSession session;
|
private final GeyserSession session;
|
||||||
@ -61,9 +62,11 @@ public class FormCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendForm(int windowId, Form form) {
|
private void sendForm(int windowId, Form form) {
|
||||||
|
String jsonData = formDefinitions.codecFor(form).jsonData(form);
|
||||||
|
|
||||||
ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket();
|
ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket();
|
||||||
formRequestPacket.setFormId(windowId);
|
formRequestPacket.setFormId(windowId);
|
||||||
formRequestPacket.setFormData(form.getJsonData());
|
formRequestPacket.setFormData(jsonData);
|
||||||
session.sendUpstreamPacket(formRequestPacket);
|
session.sendUpstreamPacket(formRequestPacket);
|
||||||
|
|
||||||
// Hack to fix the (url) image loading bug
|
// Hack to fix the (url) image loading bug
|
||||||
@ -88,17 +91,11 @@ public class FormCache {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Consumer<String> responseConsumer = form.getResponseHandler();
|
try {
|
||||||
if (responseConsumer != null) {
|
formDefinitions.definitionFor(form)
|
||||||
try {
|
.handleFormResponse(form, response.getFormData());
|
||||||
responseConsumer.accept(response.getFormData());
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
GeyserImpl.getInstance().getLogger().error("Error while processing form response!", e);
|
||||||
GeyserImpl.getInstance().getLogger().error("Error while processing form response!", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeWindow(int id) {
|
|
||||||
return forms.remove(id) != null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,26 +27,31 @@ package org.geysermc.geyser.translator.protocol.bedrock;
|
|||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.ServerSettingsRequestPacket;
|
import com.nukkitx.protocol.bedrock.packet.ServerSettingsRequestPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.ServerSettingsResponsePacket;
|
import com.nukkitx.protocol.bedrock.packet.ServerSettingsResponsePacket;
|
||||||
|
import org.geysermc.cumulus.form.CustomForm;
|
||||||
|
import org.geysermc.cumulus.form.impl.FormDefinitions;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.geyser.util.SettingsUtils;
|
import org.geysermc.geyser.util.SettingsUtils;
|
||||||
import org.geysermc.cumulus.CustomForm;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Translator(packet = ServerSettingsRequestPacket.class)
|
@Translator(packet = ServerSettingsRequestPacket.class)
|
||||||
public class BedrockServerSettingsRequestTranslator extends PacketTranslator<ServerSettingsRequestPacket> {
|
public class BedrockServerSettingsRequestTranslator extends PacketTranslator<ServerSettingsRequestPacket> {
|
||||||
|
private final FormDefinitions formDefinitions = FormDefinitions.instance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ServerSettingsRequestPacket packet) {
|
public void translate(GeyserSession session, ServerSettingsRequestPacket packet) {
|
||||||
CustomForm window = SettingsUtils.buildForm(session);
|
CustomForm form = SettingsUtils.buildForm(session);
|
||||||
int windowId = session.getFormCache().addForm(window);
|
int formId = session.getFormCache().addForm(form);
|
||||||
|
|
||||||
|
String jsonData = formDefinitions.codecFor(form).jsonData(form);
|
||||||
|
|
||||||
// Fixes https://bugs.mojang.com/browse/MCPE-94012 because of the delay
|
// Fixes https://bugs.mojang.com/browse/MCPE-94012 because of the delay
|
||||||
session.scheduleInEventLoop(() -> {
|
session.scheduleInEventLoop(() -> {
|
||||||
ServerSettingsResponsePacket serverSettingsResponsePacket = new ServerSettingsResponsePacket();
|
ServerSettingsResponsePacket serverSettingsResponsePacket = new ServerSettingsResponsePacket();
|
||||||
serverSettingsResponsePacket.setFormData(window.getJsonData());
|
serverSettingsResponsePacket.setFormData(jsonData);
|
||||||
serverSettingsResponsePacket.setFormId(windowId);
|
serverSettingsResponsePacket.setFormId(formId);
|
||||||
session.sendUpstreamPacket(serverSettingsResponsePacket);
|
session.sendUpstreamPacket(serverSettingsResponsePacket);
|
||||||
}, 1, TimeUnit.SECONDS);
|
}, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
@ -25,19 +25,19 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.translator.protocol.java;
|
package org.geysermc.geyser.translator.protocol.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.nukkitx.protocol.bedrock.packet.TransferPacket;
|
import com.nukkitx.protocol.bedrock.packet.TransferPacket;
|
||||||
|
import org.geysermc.cumulus.Forms;
|
||||||
|
import org.geysermc.cumulus.form.Form;
|
||||||
|
import org.geysermc.cumulus.util.FormType;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
import org.geysermc.geyser.GeyserLogger;
|
||||||
import org.geysermc.geyser.session.auth.AuthType;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.auth.AuthType;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.cumulus.Form;
|
|
||||||
import org.geysermc.cumulus.Forms;
|
|
||||||
import org.geysermc.cumulus.util.FormType;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
@ -68,8 +68,7 @@ public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCus
|
|||||||
|
|
||||||
String dataString = new String(data, 3, data.length - 3, Charsets.UTF_8);
|
String dataString = new String(data, 3, data.length - 3, Charsets.UTF_8);
|
||||||
|
|
||||||
Form form = Forms.fromJson(dataString, type);
|
Form form = Forms.fromJson(dataString, type, (ignored, response) -> {
|
||||||
form.setResponseHandler(response -> {
|
|
||||||
byte[] raw = response.getBytes(StandardCharsets.UTF_8);
|
byte[] raw = response.getBytes(StandardCharsets.UTF_8);
|
||||||
byte[] finalData = new byte[raw.length + 2];
|
byte[] finalData = new byte[raw.length + 2];
|
||||||
|
|
||||||
|
@ -37,17 +37,15 @@ 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.cumulus.form.CustomForm;
|
||||||
|
import org.geysermc.cumulus.form.ModalForm;
|
||||||
|
import org.geysermc.cumulus.form.SimpleForm;
|
||||||
|
import org.geysermc.cumulus.response.result.ResultType;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.session.auth.AuthData;
|
import org.geysermc.geyser.session.auth.AuthData;
|
||||||
import org.geysermc.geyser.session.auth.BedrockClientData;
|
import org.geysermc.geyser.session.auth.BedrockClientData;
|
||||||
import org.geysermc.cumulus.CustomForm;
|
|
||||||
import org.geysermc.cumulus.ModalForm;
|
|
||||||
import org.geysermc.cumulus.SimpleForm;
|
|
||||||
import org.geysermc.cumulus.response.CustomFormResponse;
|
|
||||||
import org.geysermc.cumulus.response.ModalFormResponse;
|
|
||||||
import org.geysermc.cumulus.response.SimpleFormResponse;
|
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
@ -232,26 +230,24 @@ public class LoginEncryptionUtils {
|
|||||||
.optionalButton("geyser.auth.login.form.notice.btn_login.mojang", isPasswordAuthEnabled)
|
.optionalButton("geyser.auth.login.form.notice.btn_login.mojang", isPasswordAuthEnabled)
|
||||||
.button("geyser.auth.login.form.notice.btn_login.microsoft")
|
.button("geyser.auth.login.form.notice.btn_login.microsoft")
|
||||||
.button("geyser.auth.login.form.notice.btn_disconnect")
|
.button("geyser.auth.login.form.notice.btn_disconnect")
|
||||||
.responseHandler((form, responseData) -> {
|
.resultHandler(
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
(form, result) -> buildAndShowLoginWindow(session),
|
||||||
if (!response.isCorrect()) {
|
ResultType.CLOSED, ResultType.INVALID
|
||||||
buildAndShowLoginWindow(session);
|
)
|
||||||
return;
|
.validResultHandler((form, response) -> {
|
||||||
}
|
if (isPasswordAuthEnabled && response.clickedButtonId() == 0) {
|
||||||
|
|
||||||
if (isPasswordAuthEnabled && response.getClickedButtonId() == 0) {
|
|
||||||
session.setMicrosoftAccount(false);
|
session.setMicrosoftAccount(false);
|
||||||
buildAndShowLoginDetailsWindow(session);
|
buildAndShowLoginDetailsWindow(session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPasswordAuthEnabled && response.getClickedButtonId() == 1) {
|
if (isPasswordAuthEnabled && response.clickedButtonId() == 1) {
|
||||||
session.setMicrosoftAccount(true);
|
session.setMicrosoftAccount(true);
|
||||||
buildAndShowMicrosoftAuthenticationWindow(session);
|
buildAndShowMicrosoftAuthenticationWindow(session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.getClickedButtonId() == 0) {
|
if (response.clickedButtonId() == 0) {
|
||||||
// Just show the OAuth code
|
// Just show the OAuth code
|
||||||
session.authenticateWithMicrosoftCode();
|
session.authenticateWithMicrosoftCode();
|
||||||
return;
|
return;
|
||||||
@ -269,15 +265,11 @@ public class LoginEncryptionUtils {
|
|||||||
.label("geyser.auth.login.form.details.desc")
|
.label("geyser.auth.login.form.details.desc")
|
||||||
.input("geyser.auth.login.form.details.email", "account@geysermc.org", "")
|
.input("geyser.auth.login.form.details.email", "account@geysermc.org", "")
|
||||||
.input("geyser.auth.login.form.details.pass", "123456", "")
|
.input("geyser.auth.login.form.details.pass", "123456", "")
|
||||||
.responseHandler((form, responseData) -> {
|
.resultHandler(
|
||||||
CustomFormResponse response = form.parseResponse(responseData);
|
(form, result) -> buildAndShowLoginDetailsWindow(session),
|
||||||
if (!response.isCorrect()) {
|
ResultType.CLOSED, ResultType.INVALID
|
||||||
buildAndShowLoginDetailsWindow(session);
|
)
|
||||||
return;
|
.validResultHandler((form, response) -> session.authenticate(response.next(), response.next())));
|
||||||
}
|
|
||||||
|
|
||||||
session.authenticate(response.next(), response.next());
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,16 +283,14 @@ public class LoginEncryptionUtils {
|
|||||||
.button("geyser.auth.login.method.browser")
|
.button("geyser.auth.login.method.browser")
|
||||||
.button("geyser.auth.login.method.password")
|
.button("geyser.auth.login.method.password")
|
||||||
.button("geyser.auth.login.form.notice.btn_disconnect")
|
.button("geyser.auth.login.form.notice.btn_disconnect")
|
||||||
.responseHandler((form, responseData) -> {
|
.resultHandler(
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
(form, result) -> buildAndShowLoginWindow(session),
|
||||||
if (!response.isCorrect()) {
|
ResultType.CLOSED, ResultType.INVALID
|
||||||
buildAndShowLoginWindow(session);
|
)
|
||||||
return;
|
.validResultHandler((form, response) -> {
|
||||||
}
|
if (response.clickedButtonId() == 0) {
|
||||||
|
|
||||||
if (response.getClickedButtonId() == 0) {
|
|
||||||
session.authenticateWithMicrosoftCode();
|
session.authenticateWithMicrosoftCode();
|
||||||
} else if (response.getClickedButtonId() == 1) {
|
} else if (response.clickedButtonId() == 1) {
|
||||||
buildAndShowLoginDetailsWindow(session);
|
buildAndShowLoginDetailsWindow(session);
|
||||||
} else {
|
} else {
|
||||||
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.disconnect", session.getLocale()));
|
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.disconnect", session.getLocale()));
|
||||||
@ -318,14 +308,12 @@ public class LoginEncryptionUtils {
|
|||||||
.content("%xbox.signin.website\n%xbox.signin.url\n%xbox.signin.enterCode\n" + msCode.user_code)
|
.content("%xbox.signin.website\n%xbox.signin.url\n%xbox.signin.enterCode\n" + msCode.user_code)
|
||||||
.button1("%gui.done")
|
.button1("%gui.done")
|
||||||
.button2("%menu.disconnect")
|
.button2("%menu.disconnect")
|
||||||
.responseHandler((form, responseData) -> {
|
.resultHandler(
|
||||||
ModalFormResponse response = form.parseResponse(responseData);
|
(form, result) -> buildAndShowMicrosoftAuthenticationWindow(session),
|
||||||
if (!response.isCorrect()) {
|
ResultType.CLOSED, ResultType.INVALID
|
||||||
buildAndShowMicrosoftAuthenticationWindow(session);
|
)
|
||||||
return;
|
.validResultHandler((form, response) -> {
|
||||||
}
|
if (response.clickedButtonId() == 1) {
|
||||||
|
|
||||||
if (response.getClickedButtonId() == 1) {
|
|
||||||
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.disconnect", session.getLocale()));
|
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.disconnect", session.getLocale()));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -27,13 +27,12 @@ package org.geysermc.geyser.util;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||||
|
import org.geysermc.cumulus.component.DropdownComponent;
|
||||||
|
import org.geysermc.cumulus.form.CustomForm;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.level.GameRule;
|
import org.geysermc.geyser.level.GameRule;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
|
||||||
import org.geysermc.geyser.level.WorldManager;
|
import org.geysermc.geyser.level.WorldManager;
|
||||||
import org.geysermc.cumulus.CustomForm;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.cumulus.component.DropdownComponent;
|
|
||||||
import org.geysermc.cumulus.response.CustomFormResponse;
|
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.text.MinecraftLocale;
|
import org.geysermc.geyser.text.MinecraftLocale;
|
||||||
|
|
||||||
@ -115,12 +114,7 @@ public class SettingsUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.responseHandler((form, responseData) -> {
|
builder.validResultHandler((form, response) -> {
|
||||||
CustomFormResponse response = form.parseResponse(responseData);
|
|
||||||
if (response.isClosed() || response.isInvalid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showClientSettings) {
|
if (showClientSettings) {
|
||||||
// Client can only see its coordinates if reducedDebugInfo is disabled and coordinates are enabled in geyser config.
|
// Client can only see its coordinates if reducedDebugInfo is disabled and coordinates are enabled in geyser config.
|
||||||
if (session.getPreferencesCache().isAllowShowCoordinates()) {
|
if (session.getPreferencesCache().isAllowShowCoordinates()) {
|
||||||
|
@ -26,12 +26,11 @@
|
|||||||
package org.geysermc.geyser.util;
|
package org.geysermc.geyser.util;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.statistic.*;
|
import com.github.steveice10.mc.protocol.data.game.statistic.*;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.cumulus.form.SimpleForm;
|
||||||
|
import org.geysermc.cumulus.util.FormImage;
|
||||||
import org.geysermc.geyser.registry.BlockRegistries;
|
import org.geysermc.geyser.registry.BlockRegistries;
|
||||||
import org.geysermc.geyser.registry.type.ItemMappings;
|
import org.geysermc.geyser.registry.type.ItemMappings;
|
||||||
import org.geysermc.cumulus.SimpleForm;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.cumulus.response.SimpleFormResponse;
|
|
||||||
import org.geysermc.cumulus.util.FormImage;
|
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.text.MinecraftLocale;
|
import org.geysermc.geyser.text.MinecraftLocale;
|
||||||
|
|
||||||
@ -68,12 +67,7 @@ public class StatisticsUtils {
|
|||||||
.button("stat.itemsButton - stat_type.minecraft.dropped", FormImage.Type.PATH, "textures/ui/trash_default")
|
.button("stat.itemsButton - stat_type.minecraft.dropped", FormImage.Type.PATH, "textures/ui/trash_default")
|
||||||
.button("stat.mobsButton - geyser.statistics.killed", FormImage.Type.PATH, "textures/items/diamond_sword")
|
.button("stat.mobsButton - geyser.statistics.killed", FormImage.Type.PATH, "textures/items/diamond_sword")
|
||||||
.button("stat.mobsButton - geyser.statistics.killed_by", FormImage.Type.PATH, "textures/ui/wither_heart_flash")
|
.button("stat.mobsButton - geyser.statistics.killed_by", FormImage.Type.PATH, "textures/ui/wither_heart_flash")
|
||||||
.responseHandler((form, responseData) -> {
|
.validResultHandler((form, response) -> {
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
|
||||||
if (!response.isCorrect()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleForm.Builder builder =
|
SimpleForm.Builder builder =
|
||||||
SimpleForm.builder()
|
SimpleForm.builder()
|
||||||
.translator(StatisticsUtils::translate, language);
|
.translator(StatisticsUtils::translate, language);
|
||||||
@ -81,7 +75,7 @@ public class StatisticsUtils {
|
|||||||
List<String> content = new ArrayList<>();
|
List<String> content = new ArrayList<>();
|
||||||
|
|
||||||
ItemMappings mappings = session.getItemMappings();
|
ItemMappings mappings = session.getItemMappings();
|
||||||
switch (response.getClickedButtonId()) {
|
switch (response.clickedButtonId()) {
|
||||||
case 0:
|
case 0:
|
||||||
builder.title("stat.generalButton");
|
builder.title("stat.generalButton");
|
||||||
|
|
||||||
@ -202,12 +196,7 @@ public class StatisticsUtils {
|
|||||||
session.sendForm(
|
session.sendForm(
|
||||||
builder.content(assembledContent.toString())
|
builder.content(assembledContent.toString())
|
||||||
.button("gui.back", FormImage.Type.PATH, "textures/gui/newgui/undo")
|
.button("gui.back", FormImage.Type.PATH, "textures/gui/newgui/undo")
|
||||||
.responseHandler((form1, subFormResponseData) -> {
|
.validResultHandler((form1, response1) -> buildAndSendStatisticsMenu(session)));
|
||||||
SimpleFormResponse response1 = form.parseResponse(subFormResponseData);
|
|
||||||
if (response1.isCorrect()) {
|
|
||||||
buildAndSendStatisticsMenu(session);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren