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.
This commit is contained in:
BONNe 2019-01-30 19:11:27 +02:00 committed by GitHub
parent 8becd9c08b
commit 93a9490cad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -764,22 +764,38 @@ public class TryToComplete
*/ */
private ChallengeResult checkOthers() private ChallengeResult checkOthers()
{ {
if (!this.addon.isEconomyProvided() || if (!this.addon.isLevelProvided() &&
this.challenge.getRequiredMoney() <= 0 || 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.addon.getEconomyProvider().has(this.user, this.challenge.getRequiredMoney()))
{ {
this.user.sendMessage("challenges.not-enough-money", this.user.sendMessage("challenges.not-enough-money",
"[money]", "[money]",
Integer.toString(this.challenge.getRequiredMoney())); Integer.toString(this.challenge.getRequiredMoney()));
} }
else if (this.challenge.getRequiredExperience() <= 0 || else if (this.challenge.getRequiredExperience() < 0)
this.user.getPlayer().getTotalExperience() < this.challenge.getRequiredExperience()) {
this.user.sendMessage("challenges.incorrect");
}
else if (this.user.getPlayer().getTotalExperience() < this.challenge.getRequiredExperience())
{ {
this.user.sendMessage("challenges.not-enough-exp", this.user.sendMessage("challenges.not-enough-exp",
"[xp]", "[xp]",
Integer.toString(this.challenge.getRequiredExperience())); Integer.toString(this.challenge.getRequiredExperience()));
} }
else if (!this.addon.isLevelProvided() || else if (this.addon.isLevelProvided() &&
this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < this.challenge.getRequiredIslandLevel()) this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < this.challenge.getRequiredIslandLevel())
{ {
this.user.sendMessage("challenges.error.island-level", this.user.sendMessage("challenges.error.island-level",