Implement changing Timeout in the Challenge Edit GUI.

Relates #71
This commit is contained in:
BONNe 2021-09-24 16:16:48 +03:00
parent bb5e861b30
commit 99a3e3f165
3 changed files with 60 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package world.bentobox.challenges.panel.admin;
import java.time.Duration;
import java.util.*;
import java.util.function.Consumer;
@ -272,6 +273,8 @@ public class EditChallengePanel extends CommonPanel
if (this.challenge.isRepeatable())
{
panelBuilder.item(13, this.createRewardButton(RewardButton.COOL_DOWN));
panelBuilder.item(31, this.createRewardButton(RewardButton.REPEAT_COUNT));
panelBuilder.item(15, this.createRewardButton(RewardButton.REPEAT_REWARD_TEXT));
@ -1511,6 +1514,34 @@ public class EditChallengePanel extends CommonPanel
description.add("");
description.add(this.user.getTranslation(Constants.TIPS + "click-to-change"));
}
case COOL_DOWN -> {
description.add(this.user.getTranslation(reference + "value",
"[time]",
Utils.parseDuration(Duration.ofMillis(this.challenge.getTimeout()), this.user)));
icon = new ItemStack(Material.CLOCK);
clickHandler = (panel, user, clickType, i) -> {
Consumer<Number> numberConsumer = number -> {
if (number != null)
{
this.challenge.setTimeout(number.longValue() * 1000);
}
// reopen panel
this.build();
};
ConversationUtils.createNumericInput(numberConsumer,
this.user,
this.user.getTranslation(Constants.CONVERSATIONS + "input-seconds"),
0,
Integer.MAX_VALUE);
return true;
};
glow = false;
description.add("");
description.add(this.user.getTranslation(Constants.TIPS + "click-to-change"));
}
case REPEAT_REWARD_TEXT -> {
icon = new ItemStack(Material.WRITTEN_BOOK);
@ -1815,6 +1846,7 @@ public class EditChallengePanel extends CommonPanel
REPEATABLE,
REPEAT_COUNT,
COOL_DOWN,
REPEAT_REWARD_TEXT,
REPEAT_REWARD_ITEMS,

View File

@ -522,6 +522,15 @@ challenges:
&7 number of repeats
&7 for the challenge.
value: "&7 Current value: &e [number]"
cool_down:
name: "&f&l Cool Down"
description: |-
&7 Allows to change the
&7 cool down seconds that
&7 must be waited between
&7 repeatable challenge
&7 completions.
value: "&7 Current value: &e [time]"
challenges:
name: "&f&l Challenges"
description: |-
@ -852,11 +861,11 @@ challenges:
# Text message that shows challenges wait time if it is larger than 0.
wait-time: "&c&l Available after: &r&c [time]"
# Text message that replaces days if number > 1
in-days: "[number] d, "
in-days: "[number] d "
# Text message that replaces hours if number > 1
in-hours: "[number] h, "
in-hours: "[number] h "
# Text message that replaces minutes if number > 1
in-minutes: "[number] min, "
in-minutes: "[number] min "
# Text message that replaces seconds if number > 1
in-seconds: "[number] s"
# Contains a text generated inside [requirements] lore
@ -1035,6 +1044,8 @@ challenges:
cancelled: "&c Conversation cancelled!"
# Message that appears when admin clicks on number editing button.
input-number: "&e Please enter a number in chat."
# Message that appears when admin clicks on seconds editing button.
input-seconds: "&e Please enter a seconds in chat."
# Error message that is showed if user input a value that is not a number.
numeric-only: "&c The given [value] is not a number!"
# Error message that is showed if user input a number that is smaller or larger that allowed.

View File

@ -511,6 +511,15 @@ challenges:
&7 daudz reižu uzdevumu
&7 varēs izpildīt.
value: "&7 Vērtība: &e [number]"
cool_down:
name: "&f&l Taimouts"
description: |-
&7 Ļauj uzstādīt sekunžu
&7 daudzumu, kas jānogaida
&7 starp sekunžu izpildīšanu
&7 starp atkārtojamajiem
&7 uzdevumiem.
value: "&7 Current value: &e [time]"
challenges:
name: "&f&l Uzdevumi"
description: |-
@ -872,11 +881,11 @@ challenges:
# Text message that shows challenges wait time if it is larger than 0.
wait-time: "&c&l Jānogaida: &r&c [time]"
# Text message that replaces days if number > 1
in-days: "[number] d, "
in-days: "[number] d "
# Text message that replaces hours if number > 1
in-hours: "[number] h, "
in-hours: "[number] h "
# Text message that replaces minutes if number > 1
in-minutes: "[number] min, "
in-minutes: "[number] min "
# Text message that replaces seconds if number > 1
in-seconds: "[number] s"
# Contains a text generated inside [requirements] lore
@ -1058,6 +1067,8 @@ challenges:
cancelled: "&c Saruna pārtraukta!"
# Message that appears when admin clicks on number editing button.
input-number: "&e Lūdzu ieraksti skaitli sarakstē!"
# Message that appears when admin clicks on seconds editing button.
input-seconds: "&e Lūdzu ieraksti sekunžu skaitu sarakstē!"
# Error message that is showed if user input a value that is not a number.
numeric-only: "&c Šis `[value]` nav skaitlis!"
# Error message that is showed if user input a number that is smaller or larger that allowed.