From 8d5514325c42fc54734e3986dab58f57a91625c7 Mon Sep 17 00:00:00 2001 From: BONNe Date: Wed, 29 Apr 2020 23:15:24 +0300 Subject: [PATCH] Fix issue when AbandonedListener targeted correct input values. I did not understand correctly how that listener worked. --- .../java/world/bentobox/challenges/panel/CommonGUI.java | 8 +++++++- .../world/bentobox/challenges/panel/admin/AdminGUI.java | 8 +++++++- .../world/bentobox/challenges/panel/util/NumberGUI.java | 8 +++++++- .../bentobox/challenges/panel/util/StringListGUI.java | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/panel/CommonGUI.java b/src/main/java/world/bentobox/challenges/panel/CommonGUI.java index 39897d6..b50b360 100644 --- a/src/main/java/world/bentobox/challenges/panel/CommonGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/CommonGUI.java @@ -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()); diff --git a/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java b/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java index a0efdd7..216d6f1 100644 --- a/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/admin/AdminGUI.java @@ -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()); diff --git a/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java b/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java index 4f00cbc..e58a153 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/NumberGUI.java @@ -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()); diff --git a/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java b/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java index 0e7ea8f..07f30a3 100644 --- a/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java +++ b/src/main/java/world/bentobox/challenges/panel/util/StringListGUI.java @@ -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());