Compare commits
No commits in common. "2c7ee30ad2f46e6ccfcec9197ab05739ce6c442b" and "1646488316c99ac7be68cb4d24d516dafdc31878" have entirely different histories.
2c7ee30ad2
...
1646488316
1 changed files with 19 additions and 42 deletions
|
@ -8,6 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.ineanto.nicko.Nicko;
|
import xyz.ineanto.nicko.Nicko;
|
||||||
import xyz.ineanto.nicko.gui.prompt.Prompt;
|
import xyz.ineanto.nicko.gui.prompt.Prompt;
|
||||||
|
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -18,6 +19,7 @@ public class ConversationPrompt extends Prompt {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
private String skin;
|
||||||
|
|
||||||
public ConversationPrompt(Player player) {
|
public ConversationPrompt(Player player) {
|
||||||
super(player);
|
super(player);
|
||||||
|
@ -28,26 +30,15 @@ public class ConversationPrompt extends Prompt {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayNameThenSkinPrompt() {
|
public void displayNameThenSkinPrompt() {
|
||||||
conversationFactory
|
|
||||||
.thatExcludesNonPlayersWithMessage("Player only")
|
|
||||||
.withTimeout(30)
|
|
||||||
.withModality(false)
|
|
||||||
.withFirstPrompt(new ChangeNameConversation())
|
|
||||||
.withEscapeSequence("EXIT")
|
|
||||||
.withInitialSessionData(Map.of(identifier, true, identifier + "-both", true))
|
|
||||||
.withLocalEcho(false)
|
|
||||||
.buildConversation(player)
|
|
||||||
.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displaySkinPrompt() {
|
public void displaySkinPrompt() {
|
||||||
conversationFactory
|
conversationFactory
|
||||||
.thatExcludesNonPlayersWithMessage("Player only")
|
.thatExcludesNonPlayersWithMessage("Player only")
|
||||||
.withModality(false)
|
|
||||||
.withTimeout(30)
|
.withTimeout(30)
|
||||||
.withFirstPrompt(new ChangeSkinConversation())
|
.withFirstPrompt(new NickoConversation(player, playerLanguage))
|
||||||
.withEscapeSequence("EXIT")
|
.withInitialSessionData(Map.of(identifier, true, identifier + "-skin", true))
|
||||||
.withLocalEcho(false)
|
.withLocalEcho(false)
|
||||||
.buildConversation(player)
|
.buildConversation(player)
|
||||||
.begin();
|
.begin();
|
||||||
|
@ -55,45 +46,31 @@ public class ConversationPrompt extends Prompt {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayNamePrompt() {
|
public void displayNamePrompt() {
|
||||||
conversationFactory
|
|
||||||
.thatExcludesNonPlayersWithMessage("Player only")
|
|
||||||
.withModality(false)
|
|
||||||
.withTimeout(30)
|
|
||||||
.withFirstPrompt(new ChangeNameConversation())
|
|
||||||
.withEscapeSequence("EXIT")
|
|
||||||
.withLocalEcho(false)
|
|
||||||
.buildConversation(player)
|
|
||||||
.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChangeNameConversation extends StringPrompt {
|
private class NickoConversation extends StringPrompt {
|
||||||
|
private final Player player;
|
||||||
|
private final PlayerLanguage playerLanguage;
|
||||||
|
|
||||||
|
public NickoConversation(Player player, PlayerLanguage playerLanguage) {
|
||||||
|
this.player = player;
|
||||||
|
this.playerLanguage = playerLanguage;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
||||||
return "Enter your new name";
|
return "Enter your skin";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable org.bukkit.conversations.Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
public @Nullable org.bukkit.conversations.Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
||||||
if (Objects.equals(context.getSessionData(identifier + "-both"), true)) {
|
if (Objects.equals(context.getSessionData(identifier + "-skin"), true)) {
|
||||||
name = input;
|
skin = input;
|
||||||
return new ChangeSkinConversation();
|
update(null, skin, true);
|
||||||
|
return END_OF_CONVERSATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
update(input, null, false);
|
|
||||||
return END_OF_CONVERSATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ChangeSkinConversation extends StringPrompt {
|
|
||||||
@Override
|
|
||||||
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
|
||||||
return "Enter your new skin";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable org.bukkit.conversations.Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
|
||||||
update(name != null ? name : null, input, true);
|
|
||||||
name = null;
|
|
||||||
return END_OF_CONVERSATION;
|
return END_OF_CONVERSATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue