From ab22651425f80288d474cb44ad320eb1973cc7c7 Mon Sep 17 00:00:00 2001 From: BONNe Date: Sat, 26 Jan 2019 13:47:56 +0200 Subject: [PATCH] Fix an issue when users could do challenges in other gamemodes. Fix an issue when users could complete challenges outside their island. --- .../bentobox/challenges/panel/TryToComplete.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/panel/TryToComplete.java b/src/main/java/world/bentobox/challenges/panel/TryToComplete.java index 0a19811..d7d2944 100644 --- a/src/main/java/world/bentobox/challenges/panel/TryToComplete.java +++ b/src/main/java/world/bentobox/challenges/panel/TryToComplete.java @@ -302,11 +302,18 @@ public class TryToComplete ChallengeType type = this.challenge.getChallengeType(); // Check the world - if (!this.challenge.getUniqueId().startsWith(Util.getWorld(this.world).getName())) + if (Util.getWorld(this.world) != Util.getWorld(this.user.getWorld()) || + !this.challenge.getUniqueId().startsWith(Util.getWorld(this.world).getName())) { this.user.sendMessage("general.errors.wrong-world"); result = EMPTY_RESULT; } + // Player is not on island + else if (!this.addon.getIslands().userIsOnIsland(this.user.getWorld(), this.user)) + { + this.user.sendMessage("challenges.error.not-on-island"); + result = EMPTY_RESULT; + } // Check if user has unlocked challenges level. else if (!this.challenge.getLevel().equals(ChallengesManager.FREE) && !this.manager.isLevelUnlocked(this.user, this.world, this.manager.getLevel(this.challenge.getLevel()))) @@ -556,7 +563,7 @@ public class TryToComplete { ChallengeResult result; - if (!this.addon.getIslands().userIsOnIsland(this.world, this.user)) + if (!this.addon.getIslands().userIsOnIsland(this.user.getWorld(), this.user)) { // Player is not on island this.user.sendMessage("challenges.error.not-on-island");