refactor: clarify data syncer method names

feat/data-edit-commands
William 4 months ago
parent 4433926ce7
commit ab736829f2
No known key found for this signature in database

@ -53,7 +53,7 @@ public abstract class EventListener {
return; return;
} }
plugin.lockPlayer(user.getUuid()); plugin.lockPlayer(user.getUuid());
plugin.getDataSyncer().setUserData(user); plugin.getDataSyncer().syncApplyUserData(user);
} }
/** /**
@ -66,7 +66,7 @@ public abstract class EventListener {
return; return;
} }
plugin.lockPlayer(user.getUuid()); plugin.lockPlayer(user.getUuid());
plugin.getDataSyncer().saveUserData(user); plugin.getDataSyncer().syncSaveUserData(user);
} }
/** /**

@ -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 * @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 * @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, * Save a {@link DataSnapshot.Packed user's data snapshot} to the database,

@ -35,7 +35,7 @@ public class DelayDataSyncer extends DataSyncer {
} }
@Override @Override
public void setUserData(@NotNull OnlineUser user) { public void syncApplyUserData(@NotNull OnlineUser user) {
plugin.runAsyncDelayed( plugin.runAsyncDelayed(
() -> { () -> {
// Fetch from the database if the user isn't changing servers // Fetch from the database if the user isn't changing servers
@ -58,7 +58,7 @@ public class DelayDataSyncer extends DataSyncer {
} }
@Override @Override
public void saveUserData(@NotNull OnlineUser onlineUser) { public void syncSaveUserData(@NotNull OnlineUser onlineUser) {
plugin.runAsync(() -> { plugin.runAsync(() -> {
getRedis().setUserServerSwitch(onlineUser); getRedis().setUserServerSwitch(onlineUser);
saveData( saveData(

@ -43,7 +43,7 @@ public class LockstepDataSyncer extends DataSyncer {
// Consume their data when they are checked in // Consume their data when they are checked in
@Override @Override
public void setUserData(@NotNull OnlineUser user) { public void syncApplyUserData(@NotNull OnlineUser user) {
this.listenForRedisData(user, () -> { this.listenForRedisData(user, () -> {
if (getRedis().getUserCheckedOut(user).isPresent()) { if (getRedis().getUserCheckedOut(user).isPresent()) {
return false; return false;
@ -58,7 +58,7 @@ public class LockstepDataSyncer extends DataSyncer {
} }
@Override @Override
public void saveUserData(@NotNull OnlineUser onlineUser) { public void syncSaveUserData(@NotNull OnlineUser onlineUser) {
plugin.runAsync(() -> saveData( plugin.runAsync(() -> saveData(
onlineUser, onlineUser.createSnapshot(DataSnapshot.SaveCause.DISCONNECT), onlineUser, onlineUser.createSnapshot(DataSnapshot.SaveCause.DISCONNECT),
(user, data) -> { (user, data) -> {

Loading…
Cancel
Save