Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Converted the new forms
Dieser Commit ist enthalten in:
Ursprung
d4ecd2bd72
Commit
84bcadc687
@ -6,9 +6,9 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ap</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</project>
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>api-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>api-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>base-api</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>api-parent</artifactId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-bungeecord</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Used for better working with internals without reflection -->
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
@ -34,7 +34,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>ap</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-spigot</artifactId>
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-sponge</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-standalone</artifactId>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>bootstrap-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>bootstrap-velocity</artifactId>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc.cumulus</groupId>
|
||||
<artifactId>cumulus</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>core</artifactId>
|
||||
|
||||
@ -21,19 +21,19 @@
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>ap</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-api</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Jackson JSON and YAML serialization -->
|
||||
|
@ -43,29 +43,29 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
@RequiredArgsConstructor
|
||||
public class FormCache {
|
||||
private final FormDefinitions formDefinitions = FormDefinitions.instance();
|
||||
private final AtomicInteger formId = new AtomicInteger(0);
|
||||
private final AtomicInteger formIdCounter = new AtomicInteger(0);
|
||||
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
|
||||
private final GeyserSession session;
|
||||
|
||||
public int addForm(Form form) {
|
||||
int windowId = formId.getAndIncrement();
|
||||
forms.put(windowId, form);
|
||||
return windowId;
|
||||
int formId = formIdCounter.getAndIncrement();
|
||||
forms.put(formId, form);
|
||||
return formId;
|
||||
}
|
||||
|
||||
public void showForm(Form form) {
|
||||
int windowId = addForm(form);
|
||||
int formId = addForm(form);
|
||||
|
||||
if (session.getUpstream().isInitialized()) {
|
||||
sendForm(windowId, form);
|
||||
sendForm(formId, form);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendForm(int windowId, Form form) {
|
||||
private void sendForm(int formId, Form form) {
|
||||
String jsonData = formDefinitions.codecFor(form).jsonData(form);
|
||||
|
||||
ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket();
|
||||
formRequestPacket.setFormId(windowId);
|
||||
formRequestPacket.setFormId(formId);
|
||||
formRequestPacket.setFormData(jsonData);
|
||||
session.sendUpstreamPacket(formRequestPacket);
|
||||
|
||||
@ -74,8 +74,10 @@ public class FormCache {
|
||||
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
||||
latencyPacket.setFromServer(true);
|
||||
latencyPacket.setTimestamp(-System.currentTimeMillis());
|
||||
session.scheduleInEventLoop(() -> session.sendUpstreamPacket(latencyPacket),
|
||||
500, TimeUnit.MILLISECONDS);
|
||||
session.scheduleInEventLoop(
|
||||
() -> session.sendUpstreamPacket(latencyPacket),
|
||||
500, TimeUnit.MILLISECONDS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,10 @@ 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.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;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
@ -59,6 +62,7 @@ import java.security.interfaces.ECPublicKey;
|
||||
import java.security.spec.ECGenParameterSpec;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class LoginEncryptionUtils {
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
@ -264,42 +268,49 @@ public class LoginEncryptionUtils {
|
||||
* Build a window that explains the user's credentials will be saved to the system.
|
||||
*/
|
||||
public static void buildAndShowConsentWindow(GeyserSession session) {
|
||||
String locale = session.getLocale();
|
||||
session.sendForm(
|
||||
SimpleForm.builder()
|
||||
.translator(LoginEncryptionUtils::translate, session.getLocale())
|
||||
.title("%gui.signIn")
|
||||
.content(GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.warning", locale) +
|
||||
"\n\n" +
|
||||
GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.proceed", locale))
|
||||
.content("""
|
||||
geyser.auth.login.save_token.warning
|
||||
|
||||
geyser.auth.login.save_token.proceed""")
|
||||
.button("%gui.ok")
|
||||
.button("%gui.decline")
|
||||
.responseHandler((form, responseData) -> {
|
||||
SimpleFormResponse response = form.parseResponse(responseData);
|
||||
if (response.isCorrect() && response.getClickedButtonId() == 0) {
|
||||
session.authenticateWithMicrosoftCode(true);
|
||||
} else {
|
||||
session.disconnect("%disconnect.quitting");
|
||||
}
|
||||
}));
|
||||
.resultHandler(
|
||||
authenticateOrKickHandler(session),
|
||||
ResultType.CLOSED, ResultType.INVALID, ResultType.VALID
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static void buildAndShowTokenExpiredWindow(GeyserSession session) {
|
||||
String locale = session.getLocale();
|
||||
session.sendForm(
|
||||
SimpleForm.builder()
|
||||
.title(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.expired", locale))
|
||||
.content(GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.expired", locale) +
|
||||
"\n\n" +
|
||||
GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.proceed", locale))
|
||||
.translator(LoginEncryptionUtils::translate, session.getLocale())
|
||||
.title("geyser.auth.login.form.expired")
|
||||
.content("""
|
||||
geyser.auth.login.save_token.expired
|
||||
|
||||
geyser.auth.login.save_token.proceed""")
|
||||
.button("%gui.ok")
|
||||
.responseHandler((form, responseData) -> {
|
||||
SimpleFormResponse response = form.parseResponse(responseData);
|
||||
if (response.isCorrect()) {
|
||||
session.authenticateWithMicrosoftCode(true);
|
||||
} else {
|
||||
session.disconnect("%disconnect.quitting");
|
||||
}
|
||||
}));
|
||||
.resultHandler(
|
||||
authenticateOrKickHandler(session),
|
||||
ResultType.CLOSED, ResultType.INVALID, ResultType.VALID
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static BiConsumer<SimpleForm, FormResponseResult<SimpleFormResponse>> authenticateOrKickHandler(GeyserSession session) {
|
||||
return (form, genericResult) -> {
|
||||
if (genericResult instanceof ValidFormResponseResult<SimpleFormResponse> result &&
|
||||
result.response().clickedButtonId() == 0) {
|
||||
session.authenticateWithMicrosoftCode(true);
|
||||
} else {
|
||||
session.disconnect("%disconnect.quitting");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void buildAndShowLoginDetailsWindow(GeyserSession session) {
|
||||
@ -378,4 +389,30 @@ public class LoginEncryptionUtils {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
This checks per line if there is something to be translated, and it skips Bedrock translation keys (%)
|
||||
*/
|
||||
private static String translate(String key, String locale) {
|
||||
StringBuilder newValue = new StringBuilder();
|
||||
int previousIndex = 0;
|
||||
while (previousIndex < key.length()) {
|
||||
int nextIndex = key.indexOf('\n', previousIndex);
|
||||
int endIndex = nextIndex == -1 ? key.length() : nextIndex;
|
||||
|
||||
// if there is more to this line than just a new line char
|
||||
if (endIndex - previousIndex > 1) {
|
||||
String substring = key.substring(previousIndex, endIndex);
|
||||
if (key.charAt(previousIndex) != '%') {
|
||||
newValue.append(GeyserLocale.getPlayerLocaleString(substring, locale));
|
||||
} else {
|
||||
newValue.append(substring);
|
||||
}
|
||||
}
|
||||
newValue.append('\n');
|
||||
|
||||
previousIndex = endIndex + 1;
|
||||
}
|
||||
return newValue.toString();
|
||||
}
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>geyser-parent</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Geyser</name>
|
||||
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren