9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-19 14:59:21 +00:00

refactor: place checkin petitions behind experimental setting

This commit is contained in:
William278
2025-06-13 17:51:09 +01:00
parent 554fac89c0
commit 8f2d1c7298
3 changed files with 8 additions and 3 deletions

View File

@@ -150,7 +150,7 @@ public class Settings {
}
}
// 𝓡𝓮𝓭𝓲𝓼 settings
// Redis settings
@Comment("Redis settings")
private RedisSettings redis = new RedisSettings();
@@ -321,6 +321,9 @@ public class Settings {
@Getter(AccessLevel.NONE)
private Map<String, String> eventPriorities = EventListener.ListenerType.getDefaults();
@Comment("Enable checkin petitions for data syncing (experimental)")
private boolean checkinPetitions = false;
public boolean doAutoPin(@NotNull DataSnapshot.SaveCause cause) {
return autoPinnedSaveCauses.contains(cause.name());
}

View File

@@ -177,7 +177,8 @@ public class RedisManager extends JedisPubSub {
).dispatch(plugin, RedisMessage.Type.RETURN_USER_DATA)
);
case CHECK_IN_PETITION -> {
if (!redisMessage.isTargetServer(plugin)) {
if (!redisMessage.isTargetServer(plugin)
|| !plugin.getSettings().getSynchronization().isCheckinPetitions()) {
return;
}
final String payload = new String(redisMessage.getPayload(), StandardCharsets.UTF_8);

View File

@@ -53,7 +53,8 @@ public class LockstepDataSyncer extends DataSyncer {
// If they are checked out, ask the server to check them back in and return false
final Optional<String> server = getRedis().getUserCheckedOut(user);
if (server.isPresent() && !server.get().equals(plugin.getServerName())) {
if (plugin.getSettings().getSynchronization().isCheckinPetitions()
&& server.isPresent() && !server.get().equals(plugin.getServerName())) {
getRedis().petitionServerCheckin(server.get(), user);
return false;
}