Fix issue when AbandonedListener targeted correct input values.

I did not understand correctly how that listener worked.
This commit is contained in:
BONNe 2020-04-29 23:15:24 +03:00
parent 4ab706b207
commit 8d5514325c
4 changed files with 28 additions and 4 deletions

View File

@ -1085,7 +1085,13 @@ public abstract class CommonGUI
// 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());

View File

@ -720,7 +720,13 @@ public class AdminGUI extends CommonGUI
// 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());

View File

@ -480,7 +480,13 @@ public class NumberGUI
// 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());

View File

@ -305,7 +305,13 @@ public class StringListGUI
// 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());