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,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,