mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Converted the new forms
This commit is contained in:
parent
d4ecd2bd72
commit
84bcadc687
15 changed files with 99 additions and 60 deletions
|
@ -6,9 +6,9 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>ap</artifactId>
|
<artifactId>ap</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</project>
|
</project>
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>api-parent</artifactId>
|
<artifactId>api-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>api-parent</artifactId>
|
<artifactId>api-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>base-api</artifactId>
|
<artifactId>base-api</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>api-parent</artifactId>
|
<artifactId>api-parent</artifactId>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>bootstrap-parent</artifactId>
|
<artifactId>bootstrap-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bootstrap-bungeecord</artifactId>
|
<artifactId>bootstrap-bungeecord</artifactId>
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Used for better working with internals without reflection -->
|
<!-- Used for better working with internals without reflection -->
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bootstrap-parent</artifactId>
|
<artifactId>bootstrap-parent</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>ap</artifactId>
|
<artifactId>ap</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>bootstrap-parent</artifactId>
|
<artifactId>bootstrap-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bootstrap-spigot</artifactId>
|
<artifactId>bootstrap-spigot</artifactId>
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>bootstrap-parent</artifactId>
|
<artifactId>bootstrap-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bootstrap-sponge</artifactId>
|
<artifactId>bootstrap-sponge</artifactId>
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>bootstrap-parent</artifactId>
|
<artifactId>bootstrap-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bootstrap-standalone</artifactId>
|
<artifactId>bootstrap-standalone</artifactId>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>bootstrap-parent</artifactId>
|
<artifactId>bootstrap-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>bootstrap-velocity</artifactId>
|
<artifactId>bootstrap-velocity</artifactId>
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
|
|
||||||
|
@ -21,19 +21,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>ap</artifactId>
|
<artifactId>ap</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-api</artifactId>
|
<artifactId>geyser-api</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Jackson JSON and YAML serialization -->
|
<!-- Jackson JSON and YAML serialization -->
|
||||||
|
|
|
@ -43,29 +43,29 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class FormCache {
|
public class FormCache {
|
||||||
private final FormDefinitions formDefinitions = FormDefinitions.instance();
|
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 Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
|
||||||
private final GeyserSession session;
|
private final GeyserSession session;
|
||||||
|
|
||||||
public int addForm(Form form) {
|
public int addForm(Form form) {
|
||||||
int windowId = formId.getAndIncrement();
|
int formId = formIdCounter.getAndIncrement();
|
||||||
forms.put(windowId, form);
|
forms.put(formId, form);
|
||||||
return windowId;
|
return formId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showForm(Form form) {
|
public void showForm(Form form) {
|
||||||
int windowId = addForm(form);
|
int formId = addForm(form);
|
||||||
|
|
||||||
if (session.getUpstream().isInitialized()) {
|
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);
|
String jsonData = formDefinitions.codecFor(form).jsonData(form);
|
||||||
|
|
||||||
ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket();
|
ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket();
|
||||||
formRequestPacket.setFormId(windowId);
|
formRequestPacket.setFormId(formId);
|
||||||
formRequestPacket.setFormData(jsonData);
|
formRequestPacket.setFormData(jsonData);
|
||||||
session.sendUpstreamPacket(formRequestPacket);
|
session.sendUpstreamPacket(formRequestPacket);
|
||||||
|
|
||||||
|
@ -74,8 +74,10 @@ public class FormCache {
|
||||||
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
||||||
latencyPacket.setFromServer(true);
|
latencyPacket.setFromServer(true);
|
||||||
latencyPacket.setTimestamp(-System.currentTimeMillis());
|
latencyPacket.setTimestamp(-System.currentTimeMillis());
|
||||||
session.scheduleInEventLoop(() -> session.sendUpstreamPacket(latencyPacket),
|
session.scheduleInEventLoop(
|
||||||
500, TimeUnit.MILLISECONDS);
|
() -> 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.CustomForm;
|
||||||
import org.geysermc.cumulus.form.ModalForm;
|
import org.geysermc.cumulus.form.ModalForm;
|
||||||
import org.geysermc.cumulus.form.SimpleForm;
|
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.ResultType;
|
||||||
|
import org.geysermc.cumulus.response.result.ValidFormResponseResult;
|
||||||
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;
|
||||||
|
@ -59,6 +62,7 @@ import java.security.interfaces.ECPublicKey;
|
||||||
import java.security.spec.ECGenParameterSpec;
|
import java.security.spec.ECGenParameterSpec;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class LoginEncryptionUtils {
|
public class LoginEncryptionUtils {
|
||||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
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.
|
* Build a window that explains the user's credentials will be saved to the system.
|
||||||
*/
|
*/
|
||||||
public static void buildAndShowConsentWindow(GeyserSession session) {
|
public static void buildAndShowConsentWindow(GeyserSession session) {
|
||||||
String locale = session.getLocale();
|
|
||||||
session.sendForm(
|
session.sendForm(
|
||||||
SimpleForm.builder()
|
SimpleForm.builder()
|
||||||
|
.translator(LoginEncryptionUtils::translate, session.getLocale())
|
||||||
.title("%gui.signIn")
|
.title("%gui.signIn")
|
||||||
.content(GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.warning", locale) +
|
.content("""
|
||||||
"\n\n" +
|
geyser.auth.login.save_token.warning
|
||||||
GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.proceed", locale))
|
|
||||||
|
geyser.auth.login.save_token.proceed""")
|
||||||
.button("%gui.ok")
|
.button("%gui.ok")
|
||||||
.button("%gui.decline")
|
.button("%gui.decline")
|
||||||
.responseHandler((form, responseData) -> {
|
.resultHandler(
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
authenticateOrKickHandler(session),
|
||||||
if (response.isCorrect() && response.getClickedButtonId() == 0) {
|
ResultType.CLOSED, ResultType.INVALID, ResultType.VALID
|
||||||
session.authenticateWithMicrosoftCode(true);
|
)
|
||||||
} else {
|
);
|
||||||
session.disconnect("%disconnect.quitting");
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void buildAndShowTokenExpiredWindow(GeyserSession session) {
|
public static void buildAndShowTokenExpiredWindow(GeyserSession session) {
|
||||||
String locale = session.getLocale();
|
|
||||||
session.sendForm(
|
session.sendForm(
|
||||||
SimpleForm.builder()
|
SimpleForm.builder()
|
||||||
.title(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.expired", locale))
|
.translator(LoginEncryptionUtils::translate, session.getLocale())
|
||||||
.content(GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.expired", locale) +
|
.title("geyser.auth.login.form.expired")
|
||||||
"\n\n" +
|
.content("""
|
||||||
GeyserLocale.getPlayerLocaleString("geyser.auth.login.save_token.proceed", locale))
|
geyser.auth.login.save_token.expired
|
||||||
|
|
||||||
|
geyser.auth.login.save_token.proceed""")
|
||||||
.button("%gui.ok")
|
.button("%gui.ok")
|
||||||
.responseHandler((form, responseData) -> {
|
.resultHandler(
|
||||||
SimpleFormResponse response = form.parseResponse(responseData);
|
authenticateOrKickHandler(session),
|
||||||
if (response.isCorrect()) {
|
ResultType.CLOSED, ResultType.INVALID, ResultType.VALID
|
||||||
session.authenticateWithMicrosoftCode(true);
|
)
|
||||||
} else {
|
);
|
||||||
session.disconnect("%disconnect.quitting");
|
}
|
||||||
}
|
|
||||||
}));
|
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) {
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>geyser-parent</artifactId>
|
<artifactId>geyser-parent</artifactId>
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-cumulus-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Geyser</name>
|
<name>Geyser</name>
|
||||||
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
<description>Allows for players from Minecraft Bedrock Edition to join Minecraft Java Edition servers.</description>
|
||||||
|
|
Loading…
Reference in a new issue