Skip to content

Commit

Permalink
Fix some logic issue.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BONNe committed Jan 30, 2019
1 parent 8becd9c commit 93a9490
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/main/java/world/bentobox/challenges/panel/TryToComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -764,23 +764,39 @@ private void removeEntities()
*/
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,
Expand Down

0 comments on commit 93a9490

Please sign in to comment.