From c589c2dc6f22b56f8c512d94a39b155bf015d2ce Mon Sep 17 00:00:00 2001 From: B1n_ry Date: Sun, 29 Sep 2024 16:28:30 +0200 Subject: [PATCH] If dying for the first time in a world with an empty inventory, players will no longer be disconnected --- CHANGELOG.md | 4 ++++ .../java/com/b1n_ry/yigd/components/RespawnComponent.java | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2ef0a6..f61b90cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # You're in Grave Danger 2.4.10 +### Fixes +* If dying for the first time in a world with an empty inventory, players will +no longer be disconnected. + --- # You're in Grave Danger 2.4.9 diff --git a/src/main/java/com/b1n_ry/yigd/components/RespawnComponent.java b/src/main/java/com/b1n_ry/yigd/components/RespawnComponent.java index 96fdcaf4..6d22ac27 100644 --- a/src/main/java/com/b1n_ry/yigd/components/RespawnComponent.java +++ b/src/main/java/com/b1n_ry/yigd/components/RespawnComponent.java @@ -98,9 +98,11 @@ public void apply(ServerPlayerEntity player) { } if (extraFeaturesConfig.graveCompass.receiveOnRespawn) { List playerGraves = DeathInfoManager.INSTANCE.getBackupData(new ProfileComponent(player.getGameProfile())); - GraveComponent latestGrave = playerGraves.getLast(); + if (!playerGraves.isEmpty()) { + GraveComponent latestGrave = playerGraves.getLast(); - GraveCompassHelper.giveCompass(player, latestGrave.getGraveId(), latestGrave.getPos(), latestGrave.getWorldRegistryKey()); + GraveCompassHelper.giveCompass(player, latestGrave.getGraveId(), latestGrave.getPos(), latestGrave.getWorldRegistryKey()); + } } for (YigdConfig.RespawnConfig.ExtraItemDrop extraItemDrop : config.respawnConfig.extraItemDrops) {