Compare commits

..

No commits in common. "2c7ee30ad2f46e6ccfcec9197ab05739ce6c442b" and "1646488316c99ac7be68cb4d24d516dafdc31878" have entirely different histories.

View file

@ -8,6 +8,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.ineanto.nicko.Nicko;
import xyz.ineanto.nicko.gui.prompt.Prompt;
import xyz.ineanto.nicko.language.PlayerLanguage;
import java.util.Map;
import java.util.Objects;
@ -18,6 +19,7 @@ public class ConversationPrompt extends Prompt {
private final Player player;
private String name;
private String skin;
public ConversationPrompt(Player player) {
super(player);
@ -28,26 +30,15 @@ public class ConversationPrompt extends Prompt {
@Override
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
public void displaySkinPrompt() {
conversationFactory
.thatExcludesNonPlayersWithMessage("Player only")
.withModality(false)
.withTimeout(30)
.withFirstPrompt(new ChangeSkinConversation())
.withEscapeSequence("EXIT")
.withFirstPrompt(new NickoConversation(player, playerLanguage))
.withInitialSessionData(Map.of(identifier, true, identifier + "-skin", true))
.withLocalEcho(false)
.buildConversation(player)
.begin();
@ -55,45 +46,31 @@ public class ConversationPrompt extends Prompt {
@Override
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
public @NotNull String getPromptText(@NotNull ConversationContext context) {
return "Enter your new name";
return "Enter your skin";
}
@Override
public @Nullable org.bukkit.conversations.Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
if (Objects.equals(context.getSessionData(identifier + "-both"), true)) {
name = input;
return new ChangeSkinConversation();
if (Objects.equals(context.getSessionData(identifier + "-skin"), true)) {
skin = input;
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;
}
}