From a3fd10c3be1f2270ad60e1c9c4251ae4e9ef41a7 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 30 Sep 2023 18:09:40 -0400 Subject: [PATCH] Fix NullPointerException when refilling an avatar with no skill depot --- .../game/managers/energy/EnergyManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java index 5b4e6eb64..72f178a40 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java @@ -1,7 +1,5 @@ package emu.grasscutter.game.managers.energy; -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; - import com.google.protobuf.InvalidProtocolBufferException; import emu.grasscutter.Grasscutter; import emu.grasscutter.data.*; @@ -23,9 +21,12 @@ import emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason; import emu.grasscutter.server.game.GameSession; import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.objects.*; +import lombok.Getter; + import java.util.*; import java.util.concurrent.ThreadLocalRandom; -import lombok.Getter; + +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; public class EnergyManager extends BasePlayerManager { private static final Int2ObjectMap> energyDropData = @@ -394,10 +395,12 @@ public class EnergyManager extends BasePlayerManager { public void refillTeamEnergy(PropChangeReason changeReason, boolean isFlat) { for (var entityAvatar : this.player.getTeamManager().getActiveTeam()) { // giving the exact amount read off the AvatarSkillData.json - entityAvatar.addEnergy( - entityAvatar.getAvatar().getSkillDepot().getEnergySkillData().getCostElemVal(), - changeReason, - isFlat); + var skillDepot = entityAvatar.getAvatar().getSkillDepot(); + if (skillDepot != null) { + entityAvatar.addEnergy( + skillDepot.getEnergySkillData().getCostElemVal(), + changeReason, isFlat); + } } }