Use new Cumulus methods

This commit is contained in:
Tim203 2022-05-29 23:39:40 +02:00
parent 84bcadc687
commit bd1cc26bf3
No known key found for this signature in database
GPG key ID: 064EE9F5BF7C3EE8
6 changed files with 28 additions and 48 deletions

View file

@ -84,7 +84,7 @@ import lombok.Setter;
import org.checkerframework.common.value.qual.IntRange;
import org.geysermc.common.PlatformType;
import org.geysermc.cumulus.form.Form;
import org.geysermc.cumulus.util.FormBuilder;
import org.geysermc.cumulus.form.util.FormBuilder;
import org.geysermc.floodgate.crypto.FloodgateCipher;
import org.geysermc.floodgate.util.BedrockData;
import org.geysermc.geyser.Constants;

View file

@ -87,7 +87,7 @@ public class AdvancementsCache {
builder.content("advancements.empty");
}
builder.validResultHandler((form, response) -> {
builder.validResultHandler((response) -> {
String id = "";
int advancementIndex = 0;
@ -143,11 +143,11 @@ public class AdvancementsCache {
builder.button(GeyserLocale.getPlayerLocaleString("gui.back", language));
builder.closedResultHandler(form -> {
builder.closedResultHandler(() -> {
// Indicate that we have closed the current advancement tab
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
}).validResultHandler((form, response) -> {
}).validResultHandler((response) -> {
GeyserAdvancement advancement = null;
int advancementIndex = 0;
// Loop around to find the advancement that the client pressed
@ -211,7 +211,7 @@ public class AdvancementsCache {
.title(MessageTranslator.convertMessage(advancement.getDisplayData().getTitle()))
.content(content)
.button(GeyserLocale.getPlayerLocaleString("gui.back", language))
.validResultHandler((form, response) -> buildAndShowListForm())
.validResultHandler((response) -> buildAndShowListForm())
);
}

View file

@ -31,7 +31,7 @@ import com.google.common.base.Charsets;
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.cumulus.form.util.FormType;
import org.geysermc.floodgate.pluginmessage.PluginMessageChannels;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;

View file

@ -42,7 +42,6 @@ import org.geysermc.cumulus.form.ModalForm;
import org.geysermc.cumulus.form.SimpleForm;
import org.geysermc.cumulus.response.SimpleFormResponse;
import org.geysermc.cumulus.response.result.FormResponseResult;
import org.geysermc.cumulus.response.result.ResultType;
import org.geysermc.cumulus.response.result.ValidFormResponseResult;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.configuration.GeyserConfiguration;
@ -237,26 +236,22 @@ public class LoginEncryptionUtils {
.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_disconnect")
.resultHandler(
(form, result) -> buildAndShowLoginWindow(session),
ResultType.CLOSED, ResultType.INVALID
)
.validResultHandler((form, response) -> {
if (isPasswordAuthEnabled && response.clickedButtonId() == 0) {
.closedOrInvalidResultHandler(() -> buildAndShowLoginWindow(session))
.validResultHandler((response) -> {
if (response.clickedButtonId() == 0) {
session.setMicrosoftAccount(false);
buildAndShowLoginDetailsWindow(session);
return;
}
if (isPasswordAuthEnabled && response.clickedButtonId() == 1) {
session.setMicrosoftAccount(true);
buildAndShowMicrosoftAuthenticationWindow(session);
return;
}
if (response.clickedButtonId() == 0) {
// Just show the OAuth code
session.authenticateWithMicrosoftCode();
if (response.clickedButtonId() == 1) {
if (isPasswordAuthEnabled) {
session.setMicrosoftAccount(true);
buildAndShowMicrosoftAuthenticationWindow(session);
} else {
// Just show the OAuth code
session.authenticateWithMicrosoftCode();
}
return;
}
@ -278,10 +273,7 @@ public class LoginEncryptionUtils {
geyser.auth.login.save_token.proceed""")
.button("%gui.ok")
.button("%gui.decline")
.resultHandler(
authenticateOrKickHandler(session),
ResultType.CLOSED, ResultType.INVALID, ResultType.VALID
)
.resultHandler(authenticateOrKickHandler(session))
);
}
@ -295,10 +287,7 @@ public class LoginEncryptionUtils {
geyser.auth.login.save_token.proceed""")
.button("%gui.ok")
.resultHandler(
authenticateOrKickHandler(session),
ResultType.CLOSED, ResultType.INVALID, ResultType.VALID
)
.resultHandler(authenticateOrKickHandler(session))
);
}
@ -321,11 +310,8 @@ public class LoginEncryptionUtils {
.label("geyser.auth.login.form.details.desc")
.input("geyser.auth.login.form.details.email", "account@geysermc.org", "")
.input("geyser.auth.login.form.details.pass", "123456", "")
.resultHandler(
(form, result) -> buildAndShowLoginDetailsWindow(session),
ResultType.CLOSED, ResultType.INVALID
)
.validResultHandler((form, response) -> session.authenticate(response.next(), response.next())));
.closedOrInvalidResultHandler(() -> buildAndShowLoginDetailsWindow(session))
.validResultHandler((response) -> session.authenticate(response.next(), response.next())));
}
/**
@ -339,11 +325,8 @@ public class LoginEncryptionUtils {
.button("geyser.auth.login.method.browser")
.button("geyser.auth.login.method.password")
.button("geyser.auth.login.form.notice.btn_disconnect")
.resultHandler(
(form, result) -> buildAndShowLoginWindow(session),
ResultType.CLOSED, ResultType.INVALID
)
.validResultHandler((form, response) -> {
.closedOrInvalidResultHandler(() -> buildAndShowLoginWindow(session))
.validResultHandler((response) -> {
if (response.clickedButtonId() == 0) {
session.authenticateWithMicrosoftCode();
} else if (response.clickedButtonId() == 1) {
@ -378,11 +361,8 @@ public class LoginEncryptionUtils {
.content(message.toString())
.button1("%gui.done")
.button2("%menu.disconnect")
.resultHandler(
(form, result) -> buildAndShowMicrosoftAuthenticationWindow(session),
ResultType.CLOSED, ResultType.INVALID
)
.validResultHandler((form, response) -> {
.closedOrInvalidResultHandler(() -> buildAndShowMicrosoftAuthenticationWindow(session))
.validResultHandler((response) -> {
if (response.clickedButtonId() == 1) {
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.disconnect", session.getLocale()));
}

View file

@ -114,7 +114,7 @@ public class SettingsUtils {
}
}
builder.validResultHandler((form, response) -> {
builder.validResultHandler((response) -> {
if (showClientSettings) {
// Client can only see its coordinates if reducedDebugInfo is disabled and coordinates are enabled in geyser config.
if (session.getPreferencesCache().isAllowShowCoordinates()) {

View file

@ -67,7 +67,7 @@ public class StatisticsUtils {
.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_by", FormImage.Type.PATH, "textures/ui/wither_heart_flash")
.validResultHandler((form, response) -> {
.validResultHandler((response) -> {
SimpleForm.Builder builder =
SimpleForm.builder()
.translator(StatisticsUtils::translate, language);
@ -196,7 +196,7 @@ public class StatisticsUtils {
session.sendForm(
builder.content(assembledContent.toString())
.button("gui.back", FormImage.Type.PATH, "textures/gui/newgui/undo")
.validResultHandler((form1, response1) -> buildAndSendStatisticsMenu(session)));
.validResultHandler((response1) -> buildAndSendStatisticsMenu(session)));
}));
}