Fix LevelListRequestHandler.

This handler did not return list of strings but list of challenge levels, that is incorrect.
Not it should work correctly.
This commit is contained in:
BONNe 2019-11-13 16:16:59 +02:00 committed by BONNe1704
parent e75d13666e
commit 4cae1ed267
2 changed files with 29 additions and 11 deletions

View File

@ -1725,6 +1725,23 @@ public class ChallengesManager
}
/**
* This method returns list of challenge levels in given gameMode.
* @param world for which levels must be searched.
* @return List with challengeLevel uniqueIds in given world.
*/
public List<String> getLevelNames(@NonNull World world)
{
return this.islandWorldManager.getAddon(world).map(gameMode ->
this.levelCacheData.values().stream().
sorted(ChallengeLevel::compareTo).
filter(level -> level.matchGameMode(gameMode.getDescription().getName())).
map(ChallengeLevel::getUniqueId).
collect(Collectors.toList())).
orElse(Collections.emptyList());
}
/**
* Get challenge level by its challenge.
*

View File

@ -52,7 +52,8 @@ public class LevelListRequestHandler extends AddonRequestHandler
return Collections.emptyList();
}
return this.addon.getChallengesManager().getLevels(Bukkit.getWorld((String) metaData.get("world-name")));
return this.addon.getChallengesManager().getLevelNames(
Bukkit.getWorld((String) metaData.get("world-name")));
}