List<Loadout> loadouts = playerTeam.getInventories().resolveNewLoadouts();
List<String> sortedNames = LoadoutYmlMapper.sortNames(Loadout.toLegacyFormat(loadouts));
sortedNames.remove("first");
for (Iterator<String> it = sortedNames.iterator(); it.hasNext();) {
String loadoutName = it.next();
Loadout ldt = Loadout.getLoadout(loadouts, loadoutName);
if (ldt.requiresPermission() && !player.hasPermission(ldt.getPermission())) {
it.remove();
}
}
if (sortedNames.isEmpty()) {
// Fix for zones that mistakenly only specify a `first' loadout, but do not add any others.
this.resetInventory(playerTeam, player, Collections.<Integer, ItemStack>emptyMap());
War.war.msg(player, "404 No loadouts found");
return;
}
int currentIndex = selection.getSelectedIndex();
Loadout firstLoadout = Loadout.getLoadout(loadouts, "first");
int i = 0;
Iterator<String> it = sortedNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
if (i == currentIndex) {
if (playerTeam.getTeamConfig().resolveBoolean(TeamConfig.PLAYERLOADOUTASDEFAULT) && name.equals("default")) {
// Use player's own inventory as loadout
this.resetInventory(playerTeam, player, this.getPlayerInventoryFromSavedState(player));
} else if (isFirstRespawn && firstLoadout != null && name.equals("default")
&& (firstLoadout.requiresPermission() ? player.hasPermission(firstLoadout.getPermission()) : true)) {
// Get the loadout for the first spawn
this.resetInventory(playerTeam, player, Loadout.getLoadout(loadouts, "first").getContents());
} else {
// Use the loadout from the list in the settings
this.resetInventory(playerTeam, player, Loadout.getLoadout(loadouts, name).getContents());