Skip to content

Commit

Permalink
Fast bug fix when users could not write a valid input via chat message.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed May 1, 2020
2 parents 8383c93 + 8d55143 commit 4caeee6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>0.8.1</build.version>
<build.version>0.8.2</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/world/bentobox/challenges/panel/CommonGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,13 @@ public Prompt acceptInput(ConversationContext conversationContext, String answer
// On cancel conversation will be closed.
withEscapeSequence("cancel").
// Use null value in consumer to detect if user has abandoned conversation.
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
addConversationAbandonedListener(abandonedEvent ->
{
if (!abandonedEvent.gracefulExit())
{
consumer.accept(null);
}
}).
withPrefix(context -> user.getTranslation("challenges.gui.questions.prefix")).
buildConversation(user.getPlayer());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,13 @@ protected Prompt acceptValidatedInput(ConversationContext context, String input)
// On cancel conversation will be closed.
withEscapeSequence("cancel").
// Use null value in consumer to detect if user has abandoned conversation.
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
addConversationAbandonedListener(abandonedEvent ->
{
if (!abandonedEvent.gracefulExit())
{
consumer.accept(null);
}
}).
withLocalEcho(false).
withPrefix(context -> user.getTranslation("challenges.gui.questions.prefix")).
buildConversation(user.getPlayer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,13 @@ public String getPromptText(ConversationContext conversationContext)
// On cancel conversation will be closed.
withEscapeSequence("cancel").
// Use null value in consumer to detect if user has abandoned conversation.
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
addConversationAbandonedListener(abandonedEvent ->
{
if (!abandonedEvent.gracefulExit())
{
consumer.accept(null);
}
}).
withPrefix(context ->
NumberGUI.this.user.getTranslation("challenges.gui.questions.prefix")).
buildConversation(user.getPlayer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,13 @@ public Prompt acceptInput(ConversationContext conversationContext, String answer
// On cancel conversation will be closed.
withEscapeSequence("cancel").
// Use null value in consumer to detect if user has abandoned conversation.
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
addConversationAbandonedListener(abandonedEvent ->
{
if (!abandonedEvent.gracefulExit())
{
consumer.accept(null);
}
}).
withLocalEcho(false).
withPrefix(context -> user.getTranslation("challenges.gui.questions.prefix")).
buildConversation(user.getPlayer());
Expand Down

0 comments on commit 4caeee6

Please sign in to comment.