fix: death save updating player

feat/data-edit-commands 3.3.3
William278 1 year ago
parent a5d3015c6e
commit 67ef4888da

@ -82,7 +82,7 @@ public abstract class EventListener {
usersInWorld.stream()
.filter(user -> !plugin.isLocked(user.getUuid()) && !user.isNpc())
.forEach(user -> plugin.getDataSyncer().saveData(
user, user.createSnapshot(DataSnapshot.SaveCause.WORLD_SAVE), null
user, user.createSnapshot(DataSnapshot.SaveCause.WORLD_SAVE)
));
}
@ -101,7 +101,7 @@ public abstract class EventListener {
final DataSnapshot.Packed snapshot = user.createSnapshot(DataSnapshot.SaveCause.DEATH);
snapshot.edit(plugin, (data -> data.getInventory().ifPresent(inventory -> inventory.setContents(items))));
plugin.getDataSyncer().saveData(user, snapshot, (u, d) -> plugin.getRedisManager().sendUserDataUpdate(u, d));
plugin.getDataSyncer().saveData(user, snapshot);
}
/**
@ -170,7 +170,6 @@ public abstract class EventListener {
return Map.entry(name().toLowerCase(), defaultPriority.name());
}
@SuppressWarnings("unchecked")
@NotNull
public static Map<String, String> getDefaults() {

@ -119,6 +119,22 @@ public abstract class DataSyncer {
);
}
/**
* Save a {@link DataSnapshot.Packed user's data snapshot} to the database,
* first firing the {@link net.william278.husksync.event.DataSaveEvent}. This will not update data on Redis.
*
* @param user the user to save the data for
* @param data the data to save
* @apiNote Data will not be saved if the {@link net.william278.husksync.event.DataSaveEvent} is cancelled.
* Note that this method can also edit the data before saving it.
* @implNote Note that the {@link net.william278.husksync.event.DataSaveEvent} will <b>not</b> be fired if the
* save cause is {@link DataSnapshot.SaveCause#SERVER_SHUTDOWN}.
* @since 3.3.3
*/
public void saveData(@NotNull User user, @NotNull DataSnapshot.Packed data) {
saveData(user, data, null);
}
// Adds a snapshot to the database and runs the after consumer
@Blocking
private void addSnapshotToDatabase(@NotNull User user, @NotNull DataSnapshot.Packed data,

Loading…
Cancel
Save