From ab736829f216454cc3be4875cdbb3611160d9b79 Mon Sep 17 00:00:00 2001 From: William Date: Sun, 21 Jul 2024 01:04:14 +0100 Subject: [PATCH] refactor: clarify data syncer method names --- .../net/william278/husksync/listener/EventListener.java | 4 ++-- .../java/net/william278/husksync/sync/DataSyncer.java | 8 ++++---- .../net/william278/husksync/sync/DelayDataSyncer.java | 4 ++-- .../net/william278/husksync/sync/LockstepDataSyncer.java | 4 ++-- 4 files changed, 10 insertions(+), 10 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 c1cfbcf1..857ae896 100644 --- a/common/src/main/java/net/william278/husksync/listener/EventListener.java +++ b/common/src/main/java/net/william278/husksync/listener/EventListener.java @@ -53,7 +53,7 @@ public abstract class EventListener { return; } plugin.lockPlayer(user.getUuid()); - plugin.getDataSyncer().setUserData(user); + plugin.getDataSyncer().syncApplyUserData(user); } /** @@ -66,7 +66,7 @@ public abstract class EventListener { return; } plugin.lockPlayer(user.getUuid()); - plugin.getDataSyncer().saveUserData(user); + plugin.getDataSyncer().syncSaveUserData(user); } /** diff --git a/common/src/main/java/net/william278/husksync/sync/DataSyncer.java b/common/src/main/java/net/william278/husksync/sync/DataSyncer.java index 7be66a6b..09df185c 100644 --- a/common/src/main/java/net/william278/husksync/sync/DataSyncer.java +++ b/common/src/main/java/net/william278/husksync/sync/DataSyncer.java @@ -81,18 +81,18 @@ public abstract class DataSyncer { } /** - * Called when a user's data should be fetched and applied to them + * Called when a user's data should be fetched and applied to them as part of a synchronization process * * @param user the user to fetch data for */ - public abstract void setUserData(@NotNull OnlineUser user); + public abstract void syncApplyUserData(@NotNull OnlineUser user); /** - * Called when a user's data should be serialized and saved + * Called when a user's data should be serialized and saved as part of a synchronization process * * @param user the user to save */ - public abstract void saveUserData(@NotNull OnlineUser user); + public abstract void syncSaveUserData(@NotNull OnlineUser user); /** * Save a {@link DataSnapshot.Packed user's data snapshot} to the database, diff --git a/common/src/main/java/net/william278/husksync/sync/DelayDataSyncer.java b/common/src/main/java/net/william278/husksync/sync/DelayDataSyncer.java index a1a90fdb..3751b3c7 100644 --- a/common/src/main/java/net/william278/husksync/sync/DelayDataSyncer.java +++ b/common/src/main/java/net/william278/husksync/sync/DelayDataSyncer.java @@ -35,7 +35,7 @@ public class DelayDataSyncer extends DataSyncer { } @Override - public void setUserData(@NotNull OnlineUser user) { + public void syncApplyUserData(@NotNull OnlineUser user) { plugin.runAsyncDelayed( () -> { // Fetch from the database if the user isn't changing servers @@ -58,7 +58,7 @@ public class DelayDataSyncer extends DataSyncer { } @Override - public void saveUserData(@NotNull OnlineUser onlineUser) { + public void syncSaveUserData(@NotNull OnlineUser onlineUser) { plugin.runAsync(() -> { getRedis().setUserServerSwitch(onlineUser); saveData( diff --git a/common/src/main/java/net/william278/husksync/sync/LockstepDataSyncer.java b/common/src/main/java/net/william278/husksync/sync/LockstepDataSyncer.java index dbafcdae..ad2329c8 100644 --- a/common/src/main/java/net/william278/husksync/sync/LockstepDataSyncer.java +++ b/common/src/main/java/net/william278/husksync/sync/LockstepDataSyncer.java @@ -43,7 +43,7 @@ public class LockstepDataSyncer extends DataSyncer { // Consume their data when they are checked in @Override - public void setUserData(@NotNull OnlineUser user) { + public void syncApplyUserData(@NotNull OnlineUser user) { this.listenForRedisData(user, () -> { if (getRedis().getUserCheckedOut(user).isPresent()) { return false; @@ -58,7 +58,7 @@ public class LockstepDataSyncer extends DataSyncer { } @Override - public void saveUserData(@NotNull OnlineUser onlineUser) { + public void syncSaveUserData(@NotNull OnlineUser onlineUser) { plugin.runAsync(() -> saveData( onlineUser, onlineUser.createSnapshot(DataSnapshot.SaveCause.DISCONNECT), (user, data) -> {