fixed bugs
This commit is contained in:
1 parent
edd67a4fc5
commit
bbd41432c3
6 files changed
+221
-51
No files matched your search
@@ -22,11 +22,15 @@ public final class Dialog {
|
||||
private static final Key nextKey = Key.key(namespace, "next");
|
||||
private static final Key backKey = Key.key(namespace, "back");
|
||||
private static final Key finishKey = Key.key(namespace, "finish");
|
||||
private static final Key cancelKey = Key.key(namespace, "cancel");
|
||||
private static final Key disconnectKey = Key.key(namespace, "disconnect");
|
||||
|
||||
private static final String privacyUrl = "https://mhsl.eu/id.html";
|
||||
private static final String rulesUrl = "https://mhsl.eu/craftattack/rules";
|
||||
|
||||
private static final int rulesWidth = 300;
|
||||
private static final int buttonWidth = 150;
|
||||
private static final int cancelWidth = 2 * buttonWidth + 4;
|
||||
|
||||
private static final String rulesPreamble = "Alle Teilnehmer müssen die Regeln lesen. Sie sorgen für einen reibungslosen, geordneten Ablauf von CraftAttack 9 und sind wörtlich zu nehmen. Sie gehen bewusst nicht tief ins Detail und umreißen manche Themen nur grob. Auf Wunsch der Spieler entscheiden die Administratoren und orientieren sich dabei an den Regeln. Für Vollständigkeit, Richtigkeit und Aktualität aller Angaben wird keine Gewähr übernommen. Ob und wie Regeln durchgesetzt werden, entscheiden die Administratoren, nachdem sie sich mit dem Geschädigten abgesprochen und eine zur Situation passende Maßnahme gewählt haben.";
|
||||
|
||||
@@ -49,11 +53,58 @@ public final class Dialog {
|
||||
return key.namespace().equals(namespace);
|
||||
}
|
||||
|
||||
public static boolean isCancelKey(Key key) {
|
||||
return key.equals(cancelKey);
|
||||
}
|
||||
|
||||
public static boolean isDisconnectKey(Key key) {
|
||||
return key.equals(disconnectKey);
|
||||
}
|
||||
|
||||
public static void open(Player player, DialogState state) {
|
||||
showPage(player, state, null);
|
||||
if (state.isDone()) showDone(player, state.doneMessage());
|
||||
else if (state.submitting) showSubmitting(player);
|
||||
else showPage(player, state, state.pendingError);
|
||||
}
|
||||
|
||||
public static void showError(Player player, DialogState state, String message) {
|
||||
state.pendingError = error(message);
|
||||
showPage(player, state, state.pendingError);
|
||||
}
|
||||
|
||||
private static void showSubmitting(Player player) {
|
||||
player.showDialog(new net.minestom.server.dialog.Dialog.Notice(
|
||||
new DialogMetadata(
|
||||
Component.text("Anmeldung wird gesendet …"),
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
DialogAfterAction.NONE,
|
||||
List.of(plain(Component.text("Einen Moment bitte, deine Anmeldung wird übermittelt."), rulesWidth)),
|
||||
List.of()
|
||||
),
|
||||
new DialogActionButton(Component.text("Bitte warten …"), null, cancelWidth, null)
|
||||
));
|
||||
}
|
||||
|
||||
private static void showDone(Player player, String message) {
|
||||
player.showDialog(new net.minestom.server.dialog.Dialog.Notice(
|
||||
new DialogMetadata(
|
||||
Component.text("Anmeldung abgeschlossen"),
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
DialogAfterAction.NONE,
|
||||
List.of(plain(Component.text(message), rulesWidth)),
|
||||
List.of()
|
||||
),
|
||||
button("Verbindung trennen", disconnectKey, cancelWidth)
|
||||
));
|
||||
}
|
||||
|
||||
public static boolean handleClick(Player player, DialogState state, Key key, CompoundBinaryTag payload) {
|
||||
state.pendingError = null;
|
||||
|
||||
if (key.equals(backKey)) {
|
||||
state.previousPage();
|
||||
showPage(player, state, null);
|
||||
@@ -86,9 +137,9 @@ public final class Dialog {
|
||||
case data -> {
|
||||
title = "Profildaten";
|
||||
body.add(plain("Bitte fülle deine Profildaten aus."));
|
||||
inputs.add(text("name", "Vorname", state.firstName, 50));
|
||||
inputs.add(text("secondName", "Nachname", state.secondName, 50));
|
||||
inputs.add(text("birthday", "Geburtstag (TT.MM.JJJJ)", state.birthday, 10));
|
||||
inputs.add(text("name", "Vorname (*)", state.firstName, 50));
|
||||
inputs.add(text("secondName", "Nachname (*)", state.secondName, 50));
|
||||
inputs.add(text("birthday", "Geburtstag (TT.MM.JJJJ) (*)", state.birthday, 10));
|
||||
inputs.add(text("phoneNumber", "Telefonnummer (optional)", state.phoneNumber, 30));
|
||||
}
|
||||
case consent -> {
|
||||
@@ -109,7 +160,7 @@ public final class Dialog {
|
||||
body.add(plain(Component.text(
|
||||
"Ich bin mit der Speicherung meiner in der Anmeldung angegebenen, persönlichen Daten einverstanden.",
|
||||
NamedTextColor.GRAY), rulesWidth));
|
||||
inputs.add(checkbox("privacy", "Ich stimme zu *", state.privacyAccepted));
|
||||
inputs.add(checkbox("privacy", "Datenspeicherung zustimmen (*)", state.privacyAccepted));
|
||||
}
|
||||
case logs -> {
|
||||
title = "Einverständnis (2/3)";
|
||||
@@ -119,14 +170,14 @@ public final class Dialog {
|
||||
"Die Log-Speicherung betrifft jede Interaktion im Spiel und zugehörige Daten, " +
|
||||
"z.B. Chatnachrichten, welche vom Minecraft-Client an den Server übermittelt werden.",
|
||||
NamedTextColor.GRAY), rulesWidth));
|
||||
inputs.add(checkbox("logs", "Ich stimme zu *", state.logsAccepted));
|
||||
inputs.add(checkbox("logs", "Log-Speicherung zustimmen (*)", state.logsAccepted));
|
||||
}
|
||||
case rules -> {
|
||||
title = "Einverständnis (3/3)";
|
||||
body.add(plain(Component.text(
|
||||
"Ich bin mit den Regeln einverstanden und achte sie.",
|
||||
NamedTextColor.GRAY), rulesWidth));
|
||||
inputs.add(checkbox("rules", "Ich stimme zu *", state.rulesAccepted));
|
||||
inputs.add(checkbox("rules", "Regeln zustimmen (*)", state.rulesAccepted));
|
||||
}
|
||||
default -> throw new IllegalStateException();
|
||||
}
|
||||
@@ -138,7 +189,8 @@ public final class Dialog {
|
||||
List<DialogActionButton> buttons = new ArrayList<>();
|
||||
if (!state.isFirstPage()) buttons.add(button("← Zurück", backKey));
|
||||
if (state.isLastPage()) buttons.add(button("Anmeldung abschließen", finishKey));
|
||||
else buttons.add(button("Weiter →", nextKey));
|
||||
else buttons.add(button("Weiter →", nextKey, state.isFirstPage() ? cancelWidth : buttonWidth));
|
||||
buttons.add(button("Anmeldung abbrechen", cancelKey, cancelWidth));
|
||||
|
||||
player.showDialog(new net.minestom.server.dialog.Dialog.MultiAction(
|
||||
new DialogMetadata(
|
||||
@@ -152,7 +204,7 @@ public final class Dialog {
|
||||
),
|
||||
buttons,
|
||||
null,
|
||||
2
|
||||
state.isFirstPage() ? 1 : 2
|
||||
));
|
||||
}
|
||||
|
||||
@@ -206,10 +258,14 @@ public final class Dialog {
|
||||
}
|
||||
|
||||
private static DialogActionButton button(String label, Key key) {
|
||||
return button(label, key, buttonWidth);
|
||||
}
|
||||
|
||||
private static DialogActionButton button(String label, Key key, int width) {
|
||||
return new DialogActionButton(
|
||||
Component.text(label),
|
||||
null,
|
||||
150,
|
||||
width,
|
||||
new DialogAction.DynamicCustom(key, CompoundBinaryTag.builder().build())
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user