Skip to content

Commit

Permalink
Add requirement-not-met-material and requirement-not-met-entity to di…
Browse files Browse the repository at this point in the history
…splay statistic required item on error.
  • Loading branch information
BONNe committed Feb 2, 2023
1 parent ee8eaf8 commit 431aaf4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/main/java/world/bentobox/challenges/tasks/TryToComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -1461,10 +1461,29 @@ private ChallengeResult checkStatistic(int factor)

if (currentValue < requirements.getAmount())
{
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met",
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
"[value]", String.valueOf(currentValue)));
switch (Objects.requireNonNull(requirements.getStatistic()).getType())
{
case ITEM, BLOCK -> {
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met-material",
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
"[material]", Utils.prettifyObject(requirements.getMaterial(), this.user),
"[value]", String.valueOf(currentValue)));
}
case ENTITY -> {
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met-entity",
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
"[entity]", Utils.prettifyObject(requirements.getEntity(), this.user),
"[value]", String.valueOf(currentValue)));
}
default -> {
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met",
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
"[value]", String.valueOf(currentValue)));
}
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,8 @@ challenges:
not-hooked: "&c Challenges Addon could not find any GameMode."
timeout: "&c This challenge requires to wait [timeout] between completions. You must wait [wait-time] till complete it again."
requirement-not-met: "&c This challenge requires [statistic] to have [number]. You have only [value]. "
requirement-not-met-entity: "&c This challenge requires [statistic] [entity] to have [number]. You have only [value]. "
requirement-not-met-material: "&c This challenge requires [statistic] [material] to have [number]. You have only [value]. "
# # Showcase for manual material translation
# materials:
# # Names should be lowercase.
Expand Down

0 comments on commit 431aaf4

Please sign in to comment.