From c67b527d5570445ff07463c17c29e7b36999c6f5 Mon Sep 17 00:00:00 2001 From: B1n_ry Date: Sun, 29 Sep 2024 19:19:48 +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 f68e47f..364d27d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # You're in Grave Danger 2.0.6 +### 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.0.5 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 e824412..5009a3f 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(ServerPlayer player) { } if (extraFeaturesConfig.graveCompass.receiveOnRespawn) { List playerGraves = DeathInfoManager.INSTANCE.getBackupData(new ResolvableProfile(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) {