From 93a9490cad9b3b4bf91b97e92cf5a97947ab008f Mon Sep 17 00:00:00 2001 From: BONNe Date: Wed, 30 Jan 2019 19:11:27 +0200 Subject: [PATCH 1/2] Fix some logic issue. Add proper logic check for invalid Other Type challenges. - If VaultHook is enabled required money should be more then 0, otherwise challenge is not valid. - If LevelAddon is exists required level should be more then 0, otherwise challenge is not valid. - If required experience is less then 0, challenge is not valid. - If Level addon is missing, nut it requires some level, then challenge is not valid. - If VaultHook is missing, nut it requires some money, then challenge is not valid. --- .../challenges/panel/TryToComplete.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/panel/TryToComplete.java b/src/main/java/world/bentobox/challenges/panel/TryToComplete.java index ceffdba..3107f84 100644 --- a/src/main/java/world/bentobox/challenges/panel/TryToComplete.java +++ b/src/main/java/world/bentobox/challenges/panel/TryToComplete.java @@ -764,23 +764,39 @@ public class TryToComplete */ private ChallengeResult checkOthers() { - if (!this.addon.isEconomyProvided() || - this.challenge.getRequiredMoney() <= 0 || - !this.addon.getEconomyProvider().has(this.user, this.challenge.getRequiredMoney())) + if (!this.addon.isLevelProvided() && + this.challenge.getRequiredIslandLevel() != 0) + { + this.user.sendMessage("challenges.missing-addon"); + } + else if (!this.addon.isEconomyProvided() && + this.challenge.getRequiredMoney() != 0) + { + this.user.sendMessage("challenges.missing-addon"); + } + else if (this.addon.isEconomyProvided() && this.challenge.getRequiredMoney() < 0) + { + this.user.sendMessage("challenges.incorrect"); + } + else if (this.addon.isEconomyProvided() && + !this.addon.getEconomyProvider().has(this.user, this.challenge.getRequiredMoney())) { this.user.sendMessage("challenges.not-enough-money", "[money]", Integer.toString(this.challenge.getRequiredMoney())); } - else if (this.challenge.getRequiredExperience() <= 0 || - this.user.getPlayer().getTotalExperience() < this.challenge.getRequiredExperience()) + else if (this.challenge.getRequiredExperience() < 0) + { + this.user.sendMessage("challenges.incorrect"); + } + else if (this.user.getPlayer().getTotalExperience() < this.challenge.getRequiredExperience()) { this.user.sendMessage("challenges.not-enough-exp", "[xp]", Integer.toString(this.challenge.getRequiredExperience())); } - else if (!this.addon.isLevelProvided() || - this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < this.challenge.getRequiredIslandLevel()) + else if (this.addon.isLevelProvided() && + this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < this.challenge.getRequiredIslandLevel()) { this.user.sendMessage("challenges.error.island-level", TextVariables.NUMBER, From f14f23c76634fec7340d78ec32b4b8c022ebd800 Mon Sep 17 00:00:00 2001 From: BONNe Date: Wed, 30 Jan 2019 19:12:41 +0200 Subject: [PATCH 2/2] Add 2 new messages Add message for missing-addon and incorrect challenge. --- src/main/resources/locales/en-US.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 245f3c2..6339716 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -218,3 +218,5 @@ challenges: you-completed: You completed the [challenge] challenge! you-completed-level: Congratulations, you complete [level]! you-repeated: You repeated the [challenge] challenge! + missing-addon: It is not possible to complete challenge. Plugin or addon is missing. + incorrect: Current challenge is corupted.