mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-04 23:53:20 +08:00
refactor: replace lambda with method reference
This commit is contained in:
parent
870085fc91
commit
3119e0fffc
@ -630,15 +630,15 @@ public final class GameData {
|
||||
|
||||
// Non-nullable value getters
|
||||
public static int getAvatarLevelExpRequired(int level) {
|
||||
return Optional.ofNullable(avatarLevelDataMap.get(level)).map(d -> d.getExp()).orElse(0);
|
||||
return Optional.ofNullable(avatarLevelDataMap.get(level)).map(AvatarLevelData::getExp).orElse(0);
|
||||
}
|
||||
|
||||
public static int getAvatarFetterLevelExpRequired(int level) {
|
||||
return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(d -> d.getExp()).orElse(0);
|
||||
return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(AvatarFetterLevelData::getExp).orElse(0);
|
||||
}
|
||||
|
||||
public static int getRelicExpRequired(int rankLevel, int level) {
|
||||
return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(d -> d.getExp()).orElse(0);
|
||||
return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(ReliquaryLevelData::getExp).orElse(0);
|
||||
}
|
||||
|
||||
// Generic getter
|
||||
|
@ -67,7 +67,7 @@ public class AvatarSkillDepotData extends GameResource {
|
||||
Optional.ofNullable(this.talents)
|
||||
.map(talents -> talents.get(0))
|
||||
.map(i -> GameData.getAvatarTalentDataMap().get((int) i))
|
||||
.map(talentData -> talentData.getMainCostItemId())
|
||||
.map(AvatarTalentData::getMainCostItemId)
|
||||
.ifPresent(itemId -> this.talentCostItemId = itemId);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class TrialAvatarActivityChallengeTrigger extends ActivityWatcher {
|
||||
if (paramList.isEmpty()) return false;
|
||||
|
||||
val paramCond = Stream.of(paramList.get(0).split(",")).toList();
|
||||
return Stream.of(param).allMatch(x -> paramCond.contains(x));
|
||||
return Stream.of(param).allMatch(paramCond::contains);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +103,7 @@ public class BattlePassManager extends BasePlayerDataManager {
|
||||
|
||||
// Will return a new empty mission if the mission id is not found
|
||||
public BattlePassMission loadMissionById(int id) {
|
||||
return getMissions().computeIfAbsent(id, i -> new BattlePassMission(i));
|
||||
return getMissions().computeIfAbsent(id, BattlePassMission::new);
|
||||
}
|
||||
|
||||
public boolean hasMission(int id) {
|
||||
|
@ -8,6 +8,7 @@ import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.avatar.*;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.player.*;
|
||||
import emu.grasscutter.game.props.*;
|
||||
import emu.grasscutter.game.props.ItemUseAction.UseItemParams;
|
||||
@ -370,7 +371,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
switch (itemId) {
|
||||
case 101 -> // Character exp
|
||||
this.player.getTeamManager().getActiveTeam().stream()
|
||||
.map(e -> e.getAvatar())
|
||||
.map(EntityAvatar::getAvatar)
|
||||
.forEach(
|
||||
avatar ->
|
||||
this.player
|
||||
@ -381,7 +382,7 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
this.player.addExpDirectly(count);
|
||||
case 105 -> // Companionship exp
|
||||
this.player.getTeamManager().getActiveTeam().stream()
|
||||
.map(e -> e.getAvatar())
|
||||
.map(EntityAvatar::getAvatar)
|
||||
.forEach(
|
||||
avatar ->
|
||||
this.player
|
||||
|
@ -11,7 +11,7 @@ public enum BlossomType {
|
||||
|
||||
private static final Int2ObjectMap<BlossomType> map =
|
||||
new Int2ObjectOpenHashMap<>(
|
||||
Stream.of(values()).collect(Collectors.toMap(x -> x.getGadgetId(), x -> x)));
|
||||
Stream.of(values()).collect(Collectors.toMap(BlossomType::getGadgetId, x -> x)));
|
||||
@Getter private final int gadgetId;
|
||||
@Getter private final int circleCampId;
|
||||
@Getter private final int blossomChestId;
|
||||
|
@ -4,6 +4,7 @@ import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.*;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.PlayerLevelData;
|
||||
import emu.grasscutter.data.excels.scene.SceneTagData;
|
||||
import emu.grasscutter.data.excels.world.WeatherData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.*;
|
||||
@ -596,7 +597,7 @@ public class Player implements PlayerHook, FieldFetch {
|
||||
*/
|
||||
private void applyStartingSceneTags() {
|
||||
GameData.getSceneTagDataMap().values().stream()
|
||||
.filter(sceneTag -> sceneTag.isDefaultValid())
|
||||
.filter(SceneTagData::isDefaultValid)
|
||||
.forEach(sceneTag -> {
|
||||
if (this.getSceneTags().get(sceneTag.getSceneId()) == null) {
|
||||
this.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>());
|
||||
@ -1551,7 +1552,7 @@ public class Player implements PlayerHook, FieldFetch {
|
||||
}
|
||||
|
||||
public void unfreezeUnlockedScenePoints() {
|
||||
unlockedScenePoints.keySet().forEach(sceneId -> unfreezeUnlockedScenePoints(sceneId));
|
||||
unlockedScenePoints.keySet().forEach(this::unfreezeUnlockedScenePoints);
|
||||
}
|
||||
|
||||
public int getLegendaryKey() {
|
||||
|
@ -257,7 +257,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
}
|
||||
|
||||
// Convert avatars into a collection of avatar IDs, then add
|
||||
team.getAvatars().addAll(avatars.stream().map(a -> a.getAvatarId()).toList());
|
||||
team.getAvatars().addAll(avatars.stream().map(Avatar::getAvatarId).toList());
|
||||
|
||||
// Update team
|
||||
if (this.getPlayer().isInMultiplayer()) {
|
||||
@ -332,7 +332,7 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
// Dual element resonances
|
||||
elementCounts.object2IntEntrySet().stream()
|
||||
.filter(e -> e.getIntValue() >= 2)
|
||||
.map(e -> e.getKey())
|
||||
.map(Map.Entry::getKey)
|
||||
.filter(elementType -> elementType.getTeamResonanceId() != 0)
|
||||
.forEach(
|
||||
elementType -> {
|
||||
|
@ -71,7 +71,7 @@ public class ShopInfo {
|
||||
}
|
||||
|
||||
public void removeVirtualCosts() {
|
||||
if (this.costItemList != null) this.costItemList.removeIf(item -> evaluateVirtualCost(item));
|
||||
if (this.costItemList != null) this.costItemList.removeIf(this::evaluateVirtualCost);
|
||||
}
|
||||
|
||||
public enum ShopRefreshType {
|
||||
|
@ -22,7 +22,7 @@ public class PacketAvatarExpeditionAllDataRsp extends BasePacket {
|
||||
.setExpeditionCountLimit(expeditionCountLimit)
|
||||
.putAllExpeditionInfoMap(
|
||||
expeditionInfo.entrySet().stream()
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().toProto())))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toProto())))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class PacketAvatarExpeditionDataNotify extends BasePacket {
|
||||
AvatarExpeditionDataNotify.newBuilder()
|
||||
.putAllExpeditionInfoMap(
|
||||
expeditionInfo.entrySet().stream()
|
||||
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().toProto())))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toProto())))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public final class Tools {
|
||||
GameData.getMainQuestDataMap().int2ObjectEntrySet().stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
e -> e.getIntKey(), e -> (int) e.getValue().getTitleTextMapHash())));
|
||||
Int2ObjectMap.Entry::getIntKey, e -> (int) e.getValue().getTitleTextMapHash())));
|
||||
// val questDescs = new
|
||||
// Int2IntRBTreeMap(GameData.getQuestDataMap().int2ObjectEntrySet().stream().collect(Collectors.toMap(e -> (int) e.getIntKey(), e -> (int) e.getValue().getDescTextMapHash())));
|
||||
|
||||
@ -99,7 +99,7 @@ public final class Tools {
|
||||
newTranslatedLine(
|
||||
template,
|
||||
LongStream.of(hashes)
|
||||
.mapToObj(hash -> getTextMapKey(hash))
|
||||
.mapToObj(Language::getTextMapKey)
|
||||
.toArray(TextStrings[]::new));
|
||||
}
|
||||
};
|
||||
|
@ -253,11 +253,11 @@ public final class Language {
|
||||
TextStrings.LIST_LANGUAGES.parallelStream()
|
||||
.collect(
|
||||
Collectors.toConcurrentMap(
|
||||
s -> TextStrings.MAP_LANGUAGES.getInt(s),
|
||||
TextStrings.MAP_LANGUAGES::getInt,
|
||||
s -> loadTextMapFile(s, nameHashes)));
|
||||
List<Int2ObjectMap<String>> languageMaps =
|
||||
IntStream.range(0, TextStrings.NUM_LANGUAGES)
|
||||
.mapToObj(i -> mapLanguageMaps.get(i))
|
||||
.mapToObj(mapLanguageMaps::get)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Map<TextStrings, TextStrings> canonicalTextStrings = new HashMap<>();
|
||||
|
Loading…
Reference in New Issue
Block a user