bedrock fix
This commit is contained in:
1 parent
8d3c750ea1
commit
acb7b17eb0
3 files changed
+19
-8
No files matched your search
@@ -77,7 +77,8 @@ public final class Api {
|
|||||||
JsonElement error = json.get("error");
|
JsonElement error = json.get("error");
|
||||||
if (error != null && error.isJsonPrimitive()) message = error.getAsString();
|
if (error != null && error.isJsonPrimitive()) message = error.getAsString();
|
||||||
} catch (RuntimeException ignored) {}
|
} catch (RuntimeException ignored) {}
|
||||||
throw new SignupError(code, "Signup fehlgeschlagen (" + status + "/" + code + "): " + message);
|
throw new SignupError(code, "Signup fehlgeschlagen (" + status + "/" + code + "): " + message
|
||||||
|
+ " [username=" + username + ", uuid=" + uuid + ", edition=" + edition + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HttpResponse<String> call(String method, String path, String body, boolean withAuth) {
|
private static HttpResponse<String> call(String method, String path, String body, boolean withAuth) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public final class Dialog {
|
|||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
DialogAfterAction.NONE,
|
DialogAfterAction.CLOSE,
|
||||||
List.of(plain(Component.text(message), rulesWidth)),
|
List.of(plain(Component.text(message), rulesWidth)),
|
||||||
List.of()
|
List.of()
|
||||||
),
|
),
|
||||||
@@ -105,14 +105,14 @@ public final class Dialog {
|
|||||||
public static boolean handleClick(Player player, DialogState state, Key key, CompoundBinaryTag payload) {
|
public static boolean handleClick(Player player, DialogState state, Key key, CompoundBinaryTag payload) {
|
||||||
state.pendingError = null;
|
state.pendingError = null;
|
||||||
|
|
||||||
|
saveCurrentPage(state, payload);
|
||||||
|
|
||||||
if (key.equals(backKey)) {
|
if (key.equals(backKey)) {
|
||||||
state.previousPage();
|
state.previousPage();
|
||||||
showPage(player, state, null);
|
showPage(player, state, null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCurrentPage(state, payload);
|
|
||||||
|
|
||||||
Component error = validateCurrentPage(player, state);
|
Component error = validateCurrentPage(player, state);
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
showPage(player, state, error);
|
showPage(player, state, error);
|
||||||
@@ -186,10 +186,12 @@ public final class Dialog {
|
|||||||
|
|
||||||
String fullTitle = "Schritt " + state.pageNumber() + "/" + state.pageCount() + " – " + title;
|
String fullTitle = "Schritt " + state.pageNumber() + "/" + state.pageCount() + " – " + title;
|
||||||
|
|
||||||
|
boolean bedrock = PlayerHandler.isBedrockUuid(player.getUuid());
|
||||||
|
|
||||||
List<DialogActionButton> buttons = new ArrayList<>();
|
List<DialogActionButton> buttons = new ArrayList<>();
|
||||||
if (!state.isFirstPage()) buttons.add(button("← Zurück", backKey));
|
|
||||||
if (state.isLastPage()) buttons.add(button("Anmeldung abschließen", finishKey));
|
if (state.isLastPage()) buttons.add(button("Anmeldung abschließen", finishKey));
|
||||||
else buttons.add(button("Weiter →", nextKey, state.isFirstPage() ? cancelWidth : buttonWidth));
|
else buttons.add(button("Weiter →", nextKey, state.isFirstPage() ? cancelWidth : buttonWidth));
|
||||||
|
if (!state.isFirstPage()) buttons.add(bedrock ? 1 : 0, button("← Zurück", backKey));
|
||||||
buttons.add(button("Anmeldung abbrechen", cancelKey, cancelWidth));
|
buttons.add(button("Anmeldung abbrechen", cancelKey, cancelWidth));
|
||||||
|
|
||||||
player.showDialog(new net.minestom.server.dialog.Dialog.MultiAction(
|
player.showDialog(new net.minestom.server.dialog.Dialog.MultiAction(
|
||||||
@@ -198,7 +200,7 @@ public final class Dialog {
|
|||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
state.isLastPage() ? DialogAfterAction.CLOSE : DialogAfterAction.NONE,
|
bedrock || state.isLastPage() ? DialogAfterAction.CLOSE : DialogAfterAction.NONE,
|
||||||
body,
|
body,
|
||||||
inputs
|
inputs
|
||||||
),
|
),
|
||||||
@@ -298,5 +300,4 @@ public final class Dialog {
|
|||||||
private static Component error(String text) {
|
private static Component error(String text) {
|
||||||
return Component.text(text, NamedTextColor.RED);
|
return Component.text(text, NamedTextColor.RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -113,12 +113,14 @@ public final class PlayerHandler {
|
|||||||
private static void cancel(Player player) {
|
private static void cancel(Player player) {
|
||||||
states.remove(player.getUuid());
|
states.remove(player.getUuid());
|
||||||
lastLook.remove(player.getUuid());
|
lastLook.remove(player.getUuid());
|
||||||
|
player.closeDialog();
|
||||||
player.kick("Anmeldung abgebrochen. Du kannst dich jederzeit erneut anmelden.");
|
player.kick("Anmeldung abgebrochen. Du kannst dich jederzeit erneut anmelden.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void disconnect(Player player) {
|
private static void disconnect(Player player) {
|
||||||
states.remove(player.getUuid());
|
states.remove(player.getUuid());
|
||||||
lastLook.remove(player.getUuid());
|
lastLook.remove(player.getUuid());
|
||||||
|
player.closeDialog();
|
||||||
player.kick("Wir freuen uns auf dich!");
|
player.kick("Wir freuen uns auf dich!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ public final class PlayerHandler {
|
|||||||
state.secondName,
|
state.secondName,
|
||||||
birthdayIso,
|
birthdayIso,
|
||||||
state.phoneNumber,
|
state.phoneNumber,
|
||||||
player.getUsername(),
|
signupUsername(player),
|
||||||
player.getUuid(),
|
player.getUuid(),
|
||||||
isBedrockUuid(player.getUuid()) ? "bedrock" : "java"
|
isBedrockUuid(player.getUuid()) ? "bedrock" : "java"
|
||||||
);
|
);
|
||||||
@@ -190,6 +192,13 @@ public final class PlayerHandler {
|
|||||||
states.put(player.getUuid(), done);
|
states.put(player.getUuid(), done);
|
||||||
showDialog(player, done);
|
showDialog(player, done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String signupUsername(Player player) {
|
||||||
|
String username = player.getUsername();
|
||||||
|
if (isBedrockUuid(player.getUuid()) && username.startsWith(".")) return username.substring(1);
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isBedrockUuid(UUID uuid) {
|
public static boolean isBedrockUuid(UUID uuid) {
|
||||||
return uuid.getMostSignificantBits() == 0;
|
return uuid.getMostSignificantBits() == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user