mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 21:46:50 +01:00
Fixes #263
Thanks to @sgdc3 who found my mistake with checking if challenges exists when opening GUI.
This commit is contained in:
parent
b4e62f1e89
commit
93f07b95ed
@ -2088,7 +2088,7 @@ public class ChallengesManager
|
|||||||
/**
|
/**
|
||||||
* This method returns if in given world has any stored challenge or level.
|
* This method returns if in given world has any stored challenge or level.
|
||||||
* @param world World that needs to be checked
|
* @param world World that needs to be checked
|
||||||
* @return <code>true</code> if world has any challenge or level, otherwise <code>false</code>
|
* @return {@code true} if world has any challenge or level, otherwise {@code false}
|
||||||
*/
|
*/
|
||||||
public boolean hasAnyChallengeData(@NonNull World world)
|
public boolean hasAnyChallengeData(@NonNull World world)
|
||||||
{
|
{
|
||||||
@ -2100,14 +2100,14 @@ public class ChallengesManager
|
|||||||
/**
|
/**
|
||||||
* This method returns if in given gameMode has any stored challenge or level.
|
* This method returns if in given gameMode has any stored challenge or level.
|
||||||
* @param gameMode GameMode addon name that needs to be checked
|
* @param gameMode GameMode addon name that needs to be checked
|
||||||
* @return <code>true</code> if gameMode has any challenge or level, otherwise <code>false</code>
|
* @return {@code true} if gameMode has any challenge or level, otherwise {@code false}
|
||||||
*/
|
*/
|
||||||
public boolean hasAnyChallengeData(@NonNull String gameMode)
|
public boolean hasAnyChallengeData(@NonNull String gameMode)
|
||||||
{
|
{
|
||||||
return this.challengeDatabase.loadObjects().stream().anyMatch(
|
return this.challengeCacheData.values().stream().anyMatch(challenge -> challenge.matchGameMode(gameMode)) ||
|
||||||
challenge -> challenge.matchGameMode(gameMode)) ||
|
this.levelCacheData.values().stream().anyMatch(level -> level.matchGameMode(gameMode)) ||
|
||||||
this.levelDatabase.loadObjects().stream().anyMatch(
|
this.challengeDatabase.loadObjects().stream().anyMatch(challenge -> challenge.matchGameMode(gameMode)) ||
|
||||||
level -> level.matchGameMode(gameMode));
|
this.levelDatabase.loadObjects().stream().anyMatch(level -> level.matchGameMode(gameMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ public class ChallengesGUI extends CommonGUI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.containsChallenges = this.challengesManager.hasAnyChallengeData(this.world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
@ -76,7 +78,7 @@ public class ChallengesGUI extends CommonGUI
|
|||||||
public void build()
|
public void build()
|
||||||
{
|
{
|
||||||
// Do not open gui if there is no challenges.
|
// Do not open gui if there is no challenges.
|
||||||
if (!this.challengesManager.hasAnyChallengeData(this.world))
|
if (!this.containsChallenges)
|
||||||
{
|
{
|
||||||
this.addon.logError("There are no challenges set up!");
|
this.addon.logError("There are no challenges set up!");
|
||||||
this.user.sendMessage("challenges.errors.no-challenges");
|
this.user.sendMessage("challenges.errors.no-challenges");
|
||||||
@ -518,4 +520,9 @@ public class ChallengesGUI extends CommonGUI
|
|||||||
* Challenge Manager object.
|
* Challenge Manager object.
|
||||||
*/
|
*/
|
||||||
private ChallengesManager challengesManager;
|
private ChallengesManager challengesManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This boolean indicates if in the world there exist challenges for displaying in GUI.
|
||||||
|
*/
|
||||||
|
private final boolean containsChallenges;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user