Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG committed Dec 29, 2024
2 parents 82e7011 + 37ff39e commit e86c2ea
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/com/iridium/iridiumteams/gui/MissionGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -52,14 +53,23 @@ public void addContent(Inventory inventory) {
super.addContent(inventory);

List<TeamMission> teamMissions = iridiumTeams.getTeamManager().getTeamMissions(team);

// Deals where slot is not null
for (Map.Entry<String, Mission> entry : iridiumTeams.getMissions().missions.entrySet()) {
if (entry.getValue().getMissionType() != missionType) continue;
int level = teamMissions.stream().filter(m -> m.getMissionName().equals(entry.getKey())).map(TeamMission::getMissionLevel).findFirst().orElse(1);
Optional<TeamMission> teamMission = teamMissions.stream().filter(m -> m.getMissionName().equals(entry.getKey())).findFirst();
int level = teamMission.map(TeamMission::getMissionLevel).orElse(1);
if(teamMission.isPresent() && teamMission.get().hasExpired()){
iridiumTeams.getTeamManager().deleteTeamMission(teamMission.get());
iridiumTeams.getTeamManager().deleteTeamMissionData(teamMission.get());
level = 1;
}
MissionData missionData = entry.getValue().getMissionData().get(level);
if (missionData.getItem().slot == null) continue;
inventory.setItem(missionData.getItem().slot, getItem(entry.getKey()));
}

// Deals where slot is null, to randomly pick a few missions
List<String> missions = iridiumTeams.getTeamManager().getTeamMission(team, missionType);
int index = 0;
for (String missionName : missions) {
Expand All @@ -71,6 +81,7 @@ public void addContent(Inventory inventory) {
}

private ItemStack getItem(String missionName) {
// This will create the mission if it doesnt exist
TeamMission teamMission = iridiumTeams.getTeamManager().getTeamMission(team, missionName);
Mission mission = iridiumTeams.getMissions().missions.get(missionName);
MissionData missionData = mission.getMissionData().get(teamMission.getMissionLevel());
Expand Down

0 comments on commit e86c2ea

Please sign in to comment.