Use a LinkedHashMap to store challenges.
This commit is contained in:
parent
875d770742
commit
b773e7f0f3
|
|
@ -3,16 +3,15 @@ package com.alttd.cometskyblock.challenges;
|
|||
import com.alttd.cometskyblock.CometSkyBlockPlugin;
|
||||
import com.alttd.cometskyblock.api.challenges.ChallengeDifficulty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class ChallengeHandler {
|
||||
|
||||
private final Map<String, Challenge> easyChallenges = new HashMap<>();
|
||||
private final Map<String, Challenge> mediumChallenges = new HashMap<>();
|
||||
private final Map<String, Challenge> hardChallenges = new HashMap<>();
|
||||
private final Map<String, Challenge> impossibleChallenges = new HashMap<>();
|
||||
private final Map<String, Challenge> exoticChallenges = new HashMap<>();
|
||||
private final Map<String, Challenge> easyChallenges = new LinkedHashMap<>();
|
||||
private final Map<String, Challenge> mediumChallenges = new LinkedHashMap<>();
|
||||
private final Map<String, Challenge> hardChallenges = new LinkedHashMap<>();
|
||||
private final Map<String, Challenge> impossibleChallenges = new LinkedHashMap<>();
|
||||
private final Map<String, Challenge> exoticChallenges = new LinkedHashMap<>();
|
||||
|
||||
private final CometSkyBlockPlugin plugin;
|
||||
|
||||
|
|
@ -56,4 +55,40 @@ public class ChallengeHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Challenge> getChallengesList(ChallengeDifficulty challengeDifficulty) {
|
||||
List<Challenge> challenges = new ArrayList<>();
|
||||
switch (challengeDifficulty) {
|
||||
case MEDIUM -> {
|
||||
for (Map.Entry<String, Challenge> challengeEntry : mediumChallenges.entrySet()) {
|
||||
challenges.add(challengeEntry.getValue());
|
||||
}
|
||||
return challenges;
|
||||
}
|
||||
case HARD -> {
|
||||
for (Map.Entry<String, Challenge> challengeEntry : hardChallenges.entrySet()) {
|
||||
challenges.add(challengeEntry.getValue());
|
||||
}
|
||||
return challenges;
|
||||
}
|
||||
case LEGENDARY -> {
|
||||
for (Map.Entry<String, Challenge> challengeEntry : impossibleChallenges.entrySet()) {
|
||||
challenges.add(challengeEntry.getValue());
|
||||
}
|
||||
return challenges;
|
||||
}
|
||||
case EXOTIC -> {
|
||||
for (Map.Entry<String, Challenge> challengeEntry : exoticChallenges.entrySet()) {
|
||||
challenges.add(challengeEntry.getValue());
|
||||
}
|
||||
return challenges;
|
||||
}
|
||||
default -> {
|
||||
for (Map.Entry<String, Challenge> challengeEntry : easyChallenges.entrySet()) {
|
||||
challenges.add(challengeEntry.getValue());
|
||||
}
|
||||
return challenges;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ public class ChallengesGUI extends GUIInventory {
|
|||
|
||||
currentSlot = 0;
|
||||
int startIndex = pageIndex * (getInventory().getSize() - 9);
|
||||
List<Challenge> challenges = CometSkyBlockPlugin.instance().challengeHandler().getChallenges(challengeDifficulty).values().stream().toList();
|
||||
List<Challenge> challenges = CometSkyBlockPlugin.instance().challengeHandler().getChallengesList(challengeDifficulty);
|
||||
for (int i = startIndex; i < challenges.size(); i++) {
|
||||
Challenge challenge = challenges.get(i);
|
||||
int challengeCount = island.challengeCount(challenge.key());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user