From 101e0c11d76b48c6354ab3edad4d3b96da01d7da Mon Sep 17 00:00:00 2001 From: William Date: Tue, 27 Dec 2022 19:31:14 +0000 Subject: [PATCH] Fix unsynced players having data saved on world save / death --- .../net/william278/husksync/listener/EventListener.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/net/william278/husksync/listener/EventListener.java b/common/src/main/java/net/william278/husksync/listener/EventListener.java index 19d58292..2123034c 100644 --- a/common/src/main/java/net/william278/husksync/listener/EventListener.java +++ b/common/src/main/java/net/william278/husksync/listener/EventListener.java @@ -180,8 +180,11 @@ public abstract class EventListener { if (disabling || !plugin.getSettings().saveOnWorldSave) { return; } - usersInWorld.forEach(user -> user.getUserData(plugin.getLoggingAdapter(), plugin.getSettings()).join().ifPresent( - userData -> plugin.getDatabase().setUserData(user, userData, DataSaveCause.WORLD_SAVE).join())); + usersInWorld.stream() + .filter(user -> !lockedPlayers.contains(user.uuid)) + .forEach(user -> user.getUserData(plugin.getLoggingAdapter(), plugin.getSettings()) + .thenAccept(data -> data.ifPresent(userData -> plugin.getDatabase() + .setUserData(user, userData, DataSaveCause.WORLD_SAVE)))); } /** @@ -191,7 +194,7 @@ public abstract class EventListener { * @param drops The items that this user would have dropped */ protected void saveOnPlayerDeath(@NotNull OnlineUser user, @NotNull ItemData drops) { - if (disabling || !plugin.getSettings().saveOnDeath) { + if (disabling || !plugin.getSettings().saveOnDeath || lockedPlayers.contains(user.uuid)) { return; }