diff --git a/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryPlayerRevivalData.java b/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryPlayerRevivalData.java index f1cda00..b748578 100644 --- a/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryPlayerRevivalData.java +++ b/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryPlayerRevivalData.java @@ -1,6 +1,7 @@ package net.blay09.mods.hardcorerevival; import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.Nullable; class InMemoryPlayerRevivalData { private boolean knockedOut; @@ -68,11 +69,12 @@ public void setRescueTime(int rescueTime) { this.rescueTime = rescueTime; } + @Nullable public Player getRescueTarget() { return rescueTarget; } - public void setRescueTarget(Player rescueTarget) { + public void setRescueTarget(@Nullable Player rescueTarget) { this.rescueTarget = rescueTarget; } } diff --git a/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryRevivalDataProvider.java b/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryRevivalDataProvider.java index 0ec62cc..545bf2c 100644 --- a/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryRevivalDataProvider.java +++ b/common/src/main/java/net/blay09/mods/hardcorerevival/InMemoryRevivalDataProvider.java @@ -1,6 +1,7 @@ package net.blay09.mods.hardcorerevival; import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.Map; @@ -85,7 +86,7 @@ public int getRescueTime(Player player) { } @Override - public void setRescueTarget(Player player, Player rescueTarget) { + public void setRescueTarget(Player player, @Nullable Player rescueTarget) { getPlayerData(player).setRescueTarget(rescueTarget); } diff --git a/common/src/main/java/net/blay09/mods/hardcorerevival/PersistentRevivalDataProvider.java b/common/src/main/java/net/blay09/mods/hardcorerevival/PersistentRevivalDataProvider.java index 3ea63b7..779bf0d 100644 --- a/common/src/main/java/net/blay09/mods/hardcorerevival/PersistentRevivalDataProvider.java +++ b/common/src/main/java/net/blay09/mods/hardcorerevival/PersistentRevivalDataProvider.java @@ -3,6 +3,7 @@ import net.blay09.mods.balm.api.Balm; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.Nullable; public class PersistentRevivalDataProvider implements RevivalDataProvider { @@ -93,8 +94,12 @@ public int getRescueTime(Player player) { } @Override - public void setRescueTarget(Player player, Player rescueTarget) { - getRevivalData(player).putUUID(RESCUE_TARGET, rescueTarget.getGameProfile().getId()); + public void setRescueTarget(Player player, @Nullable Player rescueTarget) { + if (rescueTarget != null) { + getRevivalData(player).putUUID(RESCUE_TARGET, rescueTarget.getGameProfile().getId()); + } else { + getRevivalData(player).remove(RESCUE_TARGET); + } } @Override diff --git a/common/src/main/java/net/blay09/mods/hardcorerevival/PlayerHardcoreRevivalManager.java b/common/src/main/java/net/blay09/mods/hardcorerevival/PlayerHardcoreRevivalManager.java index ea7c574..3a9086c 100644 --- a/common/src/main/java/net/blay09/mods/hardcorerevival/PlayerHardcoreRevivalManager.java +++ b/common/src/main/java/net/blay09/mods/hardcorerevival/PlayerHardcoreRevivalManager.java @@ -69,10 +69,11 @@ public static int getRescueTime(Player player) { return getRevivalDataProvider(player.level()).getRescueTime(player); } - public static void setRescueTarget(Player player, Player rescueTarget) { + public static void setRescueTarget(Player player, @Nullable Player rescueTarget) { getRevivalDataProvider(player.level()).setRescueTarget(player, rescueTarget); } + @Nullable public static Player getRescueTarget(Player player) { return getRevivalDataProvider(player.level()).getRescueTarget(player); }