refactor: replace lambda with method reference

This commit is contained in:
Breno A. 2024-06-09 09:10:48 -03:00
parent 8c35c89bf5
commit 870085fc91
3 changed files with 4 additions and 3 deletions

View File

@ -25,7 +25,7 @@ public class RewardPreviewData extends GameResource {
Arrays.stream(this.previewItems)
.filter(d -> d.getId() > 0 && d.getCount() != null && !d.getCount().isEmpty())
.map(ItemParamStringData::toItemParamData)
.toArray(size -> new ItemParamData[size]);
.toArray(ItemParamData[]::new);
} else {
this.previewItemsArray = new ItemParamData[0];
}

View File

@ -1,5 +1,6 @@
package emu.grasscutter.game.props.ItemUseAction;
import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.props.ItemUseOp;
import emu.grasscutter.game.systems.InventorySystem;
@ -43,7 +44,7 @@ public class ItemUseGainAvatar extends ItemUseInt {
int itemId =
Optional.ofNullable(params.player.getAvatars().getAvatarById(this.i))
.map(Avatar::getSkillDepot)
.map(depot -> depot.getTalentCostItemId())
.map(AvatarSkillDepotData::getTalentCostItemId)
.orElse((this.i % 1000) + 100);
return params.player.getInventory().addItem(itemId);
}

View File

@ -58,7 +58,7 @@ public class InventorySystem extends BaseGameSystem {
} else {
avatarId =
Optional.ofNullable(GameData.getItemDataMap().get(id))
.map(itemData -> itemData.getItemUseActions())
.map(ItemData::getItemUseActions)
.flatMap(
actions ->
actions.stream()