Minor adjustments to code

This commit is contained in:
tastybento 2018-08-31 10:57:03 +09:00
parent 4e3ebc4af8
commit 649006e1ef
2 changed files with 4 additions and 5 deletions

View File

@ -225,7 +225,7 @@ public class ChallengesManager {
int total = challengeMap.values().size();
int waiverAmount = en.getKey().getWaiveramount();
int challengesDone = (int) en.getValue().stream().filter(ch -> pd.isChallengeDone(world, ch.getUniqueId())).count();
int challsToDo = Math.max(0,total-challengesDone-waiverAmount);
int challsToDo = Math.max(0,total - challengesDone - waiverAmount);
boolean complete = challsToDo > 0 ? false : true;
// Create result class with the data
result.add(new LevelStatus(en.getKey(), previousLevel, challsToDo, complete, isUnlocked));

View File

@ -3,7 +3,6 @@ package bentobox.addon.challenges.panel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.World;
@ -47,6 +46,7 @@ public class ChallengesPanels2 {
return;
}
if (level.isEmpty()) {
// TODO: open the furthest challenge panel
level = manager.getChallengeList().keySet().iterator().next().getUniqueId();
}
this.level = level;
@ -67,9 +67,8 @@ public class ChallengesPanels2 {
}
private void addChallengeItems(PanelBuilder panelBuilder) {
Set<Challenges> levelChallenges = manager.getChallenges(level, world);
// Only show a control panel for the level requested.
for (Challenges challenge : levelChallenges) {
for (Challenges challenge : manager.getChallenges(level, world)) {
createItem(panelBuilder, challenge);
}
}
@ -127,7 +126,7 @@ public class ChallengesPanels2 {
private void addNavigation(PanelBuilder panelBuilder) {
// Add navigation to other levels
for (LevelStatus status: manager.getChallengeLevelStatus(user, world)) {
if (status.getLevel().getUniqueId().equals(level)) {
if (status.getLevel().getUniqueId().equalsIgnoreCase(level)) {
// Skip if this is the current level
continue;
}