forked from SteamWar/SteamWar
Fix GameModeConfig
This commit is contained in:
@@ -30,6 +30,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
public final class GameModeConfig<M, W> {
|
public final class GameModeConfig<M, W> {
|
||||||
@@ -710,13 +711,26 @@ public final class GameModeConfig<M, W> {
|
|||||||
Map<Set<M>, Integer> Limited = new HashMap<>();
|
Map<Set<M>, Integer> Limited = new HashMap<>();
|
||||||
for (Map<?, ?> entry : loader.getMapList("Limited")) {
|
for (Map<?, ?> entry : loader.getMapList("Limited")) {
|
||||||
int amount = (Integer) entry.get("Amount");
|
int amount = (Integer) entry.get("Amount");
|
||||||
Set<String> materials = new HashSet<>((List<String>) entry.get("Materials"));
|
Set<M> materials = Stream.of((List<String>) entry.get("Materials"))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.map(String::toUpperCase)
|
||||||
|
.map(material -> {
|
||||||
|
try {
|
||||||
|
return loader.materialMapper.apply(material);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (amount == 0) {
|
if (amount == 0) {
|
||||||
materials.forEach(material -> {
|
materials.forEach(material -> {
|
||||||
Limited.put(Collections.singleton(loader.materialMapper.apply(material.toUpperCase())), 0);
|
Limited.put(Collections.singleton(material), 0);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Limited.put(Collections.unmodifiableSet(materials.stream().map(String::toUpperCase).map(loader.materialMapper).collect(Collectors.toSet())), amount);
|
Limited.put(materials, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SQLWrapper.impl.getMaterialWithGreaterBlastResistance(MaxBlastResistance).forEach(material -> {
|
SQLWrapper.impl.getMaterialWithGreaterBlastResistance(MaxBlastResistance).forEach(material -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user