From da61d30f444cbf6bb9d2107908ec40ff97d5cf76 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:50:40 -0300 Subject: [PATCH] refactor: make getGoodsLimit one liner --- src/main/java/emu/grasscutter/game/player/Player.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 1f8c87c03..c6735d82d 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -896,10 +896,8 @@ public class Player implements PlayerHook, FieldFetch { } public ShopLimit getGoodsLimit(int goodsId) { - Optional shopLimit = this.shopLimit.stream().filter(x -> x.getShopGoodId() == goodsId).findFirst(); - if (shopLimit.isEmpty()) - return null; - return shopLimit.get(); + Optional limitOptional = this.shopLimit.stream().filter(x -> x.getShopGoodId() == goodsId).findFirst(); + return limitOptional.orElse(null); } public void addShopLimit(int goodsId, int boughtCount, int nextRefreshTime) {