diff --git a/src/main/java/emu/grasscutter/game/managers/SotSManager.java b/src/main/java/emu/grasscutter/game/managers/SotSManager.java index 6427de185..eeafe1a09 100644 --- a/src/main/java/emu/grasscutter/game/managers/SotSManager.java +++ b/src/main/java/emu/grasscutter/game/managers/SotSManager.java @@ -218,11 +218,7 @@ public class SotSManager extends BasePlayerManager { public CityInfoData getCityInfo(int cityId) { if (player.getCityInfoData() == null) player.setCityInfoData(new HashMap<>()); - var cityInfo = player.getCityInfoData().get(cityId); - if (cityInfo == null) { - cityInfo = new CityInfoData(cityId); - player.getCityInfoData().put(cityId, cityInfo); - } + var cityInfo = player.getCityInfoData().computeIfAbsent(cityId, CityInfoData::new); return cityInfo; } diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 83cd2447d..c8c65aded 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -599,9 +599,7 @@ public class Player implements PlayerHook, FieldFetch { GameData.getSceneTagDataMap().values().stream() .filter(SceneTagData::isDefaultValid) .forEach(sceneTag -> { - if (this.getSceneTags().get(sceneTag.getSceneId()) == null) { - this.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>()); - } + this.getSceneTags().computeIfAbsent(sceneTag.getSceneId(), k -> new HashSet<>()); this.getSceneTags().get(sceneTag.getSceneId()).add(sceneTag.getId()); }); }