mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 05:25:21 +01:00
Add 2 new methods that detects if exist any challenge or level for given world.
This commit is contained in:
parent
13faf478ee
commit
f5cf5f5867
@ -1396,4 +1396,36 @@ public class ChallengesManager
|
|||||||
this.levelDatabase.deleteObject(challengeLevel);
|
this.levelDatabase.deleteObject(challengeLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns if in given world has any stored challenge or level.
|
||||||
|
* @param world World that needs to be checked
|
||||||
|
* @return <code>true</code> if world has any challenge or level, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean hasAnyChallengeData(@NonNull World world)
|
||||||
|
{
|
||||||
|
world = Util.getWorld(world);
|
||||||
|
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.hasAnyChallengeData(world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns if in given world has any stored challenge or level.
|
||||||
|
* @param worldName World name that needs to be checked
|
||||||
|
* @return <code>true</code> if world has any challenge or level, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean hasAnyChallengeData(@NonNull String worldName)
|
||||||
|
{
|
||||||
|
return this.challengeDatabase.loadObjects().stream().anyMatch(
|
||||||
|
challenge -> challenge.getUniqueId().startsWith(worldName)) ||
|
||||||
|
this.levelDatabase.loadObjects().stream().anyMatch(
|
||||||
|
level -> level.getUniqueId().startsWith(worldName));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user