Skip to content

Commit 8d55143

Browse files
committed
Fix issue when AbandonedListener targeted correct input values.
I did not understand correctly how that listener worked.
1 parent 4ab706b commit 8d55143

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

src/main/java/world/bentobox/challenges/panel/CommonGUI.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,13 @@ public Prompt acceptInput(ConversationContext conversationContext, String answer
10851085
// On cancel conversation will be closed.
10861086
withEscapeSequence("cancel").
10871087
// Use null value in consumer to detect if user has abandoned conversation.
1088-
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
1088+
addConversationAbandonedListener(abandonedEvent ->
1089+
{
1090+
if (!abandonedEvent.gracefulExit())
1091+
{
1092+
consumer.accept(null);
1093+
}
1094+
}).
10891095
withPrefix(context -> user.getTranslation("challenges.gui.questions.prefix")).
10901096
buildConversation(user.getPlayer());
10911097

src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,13 @@ protected Prompt acceptValidatedInput(ConversationContext context, String input)
720720
// On cancel conversation will be closed.
721721
withEscapeSequence("cancel").
722722
// Use null value in consumer to detect if user has abandoned conversation.
723-
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
723+
addConversationAbandonedListener(abandonedEvent ->
724+
{
725+
if (!abandonedEvent.gracefulExit())
726+
{
727+
consumer.accept(null);
728+
}
729+
}).
724730
withLocalEcho(false).
725731
withPrefix(context -> user.getTranslation("challenges.gui.questions.prefix")).
726732
buildConversation(user.getPlayer());

src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,13 @@ public String getPromptText(ConversationContext conversationContext)
480480
// On cancel conversation will be closed.
481481
withEscapeSequence("cancel").
482482
// Use null value in consumer to detect if user has abandoned conversation.
483-
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
483+
addConversationAbandonedListener(abandonedEvent ->
484+
{
485+
if (!abandonedEvent.gracefulExit())
486+
{
487+
consumer.accept(null);
488+
}
489+
}).
484490
withPrefix(context ->
485491
NumberGUI.this.user.getTranslation("challenges.gui.questions.prefix")).
486492
buildConversation(user.getPlayer());

src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,13 @@ public Prompt acceptInput(ConversationContext conversationContext, String answer
305305
// On cancel conversation will be closed.
306306
withEscapeSequence("cancel").
307307
// Use null value in consumer to detect if user has abandoned conversation.
308-
addConversationAbandonedListener(abandonedEvent -> consumer.accept(null)).
308+
addConversationAbandonedListener(abandonedEvent ->
309+
{
310+
if (!abandonedEvent.gracefulExit())
311+
{
312+
consumer.accept(null);
313+
}
314+
}).
309315
withLocalEcho(false).
310316
withPrefix(context -> user.getTranslation("challenges.gui.questions.prefix")).
311317
buildConversation(user.getPlayer());

0 commit comments

Comments
 (0)