9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-26 18:19:10 +00:00

Ensure players have their inventory contents saved on death

This commit is contained in:
William
2022-10-12 01:45:46 +01:00
parent 2351be31e3
commit 2b91154ca2
3 changed files with 20 additions and 6 deletions

View File

@@ -181,13 +181,16 @@ public abstract class EventListener {
*
* @param user The user who died
*/
protected void handlePlayerDeath(@NotNull OnlineUser user) {
protected void handlePlayerDeath(@NotNull OnlineUser user, @NotNull ItemData drops) {
if (disabling || !plugin.getSettings().saveOnDeath) {
return;
}
user.getUserData(plugin.getLoggingAdapter(), plugin.getSettings())
.thenAccept(data -> data.ifPresent(userData -> plugin.getDatabase()
.setUserData(user, userData, DataSaveCause.DEATH)));
.thenAccept(data -> data.ifPresent(userData -> {
userData.getInventory().orElse(ItemData.empty()).serializedItems = drops.serializedItems;
plugin.getDatabase().setUserData(user, userData, DataSaveCause.DEATH);
}));
}
/**