Scope
Allow the admin bypass toggle to persist across server restarts and player logout/login. Currently, bypass state is stored in-memory only and is lost whenever the server restarts or (by design) never cleared on logout — meaning bypass survives logout but not restart, which is inconsistent.
- Persist admin bypass state to player data storage (JSON)
- Restore bypass state on player login
- Restore bypass state on server restart (when admin next connects)
- Maintain current GUI toggle behavior on Admin Dashboard
Implementation Details
Current bypass storage (HyperFactions.java:128-129):
// Admin bypass state (per-player toggle for protection bypass)privatefinalMap<UUID, Boolean> adminBypassEnabled = newConcurrentHashMap<>();
Current toggle (HyperFactions.java:1089-1091):
publicbooleantoggleAdminBypass(@NotNullUUIDplayerUuid) {
returnadminBypassEnabled.compute(playerUuid, (k, v) -> v == null || !v);
}GUI trigger:AdminDashboardPage.java (lines 119-179) — "Toggle Bypass" button on Admin Dashboard
Needed changes:
Add field to PlayerData.java: private boolean adminBypassEnabled = false;
- Serialize/deserialize alongside existing fields (power, kills, deaths, etc.)
- PlayerData already persists to
data/players/{uuid}.json via JsonPlayerStorage
Load bypass state on player connect (PlayerConnectionHandler.java):
- After
loadPlayerData(uuid), check playerData.isAdminBypassEnabled() - If true AND player has
hyperfactions.admin.use permission, restore to in-memory map - If player no longer has admin permission, clear the persisted flag
Save bypass state on toggle (HyperFactions.toggleAdminBypass()):
- After toggling in-memory map, also update
PlayerData.adminBypassEnabled and trigger save - Can use existing async save pattern:
playerStorage.savePlayerData(data)
Include in auto-save cycle: Already covered — PeriodicTaskManager saves all player data periodically, and PlayerData fields are included automatically
Existing persistence pattern to follow (PlayerData.java):
- Fields like
powerLossDisabled (boolean) and claimDecayExempt (boolean) already follow this exact pattern - JSON serialization handled by
JsonPlayerStorage which reads/writes all PlayerData fields
Protection check unchanged (ProtectionChecker.java:145-155):
- Still reads from in-memory
adminBypassEnabled map — no changes needed - The map is populated from persisted data on login, cleared on explicit toggle-off
Risks and Alternatives
- Risk: Admin who is demoted (loses
hyperfactions.admin.use permission) could have a stale bypass flag persisted — mitigate by checking permission on login before restoring bypass - Risk: If player data fails to load, bypass should default to OFF (fail-safe)
- Alternative: Separate
bypass-players.json file instead of extending PlayerData — simpler but adds another file to manage - Alternative: Config-based approach where bypass is listed in config.json — would survive restarts but is less elegant than per-player data
References and Media
Follows the existing PlayerData persistence pattern used for powerLossDisabled and claimDecayExempt flags. The auto-save system (PeriodicTaskManager) already handles periodic flushing of player data to disk.
Scope
Allow the admin bypass toggle to persist across server restarts and player logout/login. Currently, bypass state is stored in-memory only and is lost whenever the server restarts or (by design) never cleared on logout — meaning bypass survives logout but not restart, which is inconsistent.
Implementation Details
Current bypass storage (
HyperFactions.java:128-129):Current toggle (
HyperFactions.java:1089-1091):GUI trigger:
AdminDashboardPage.java(lines 119-179) — "Toggle Bypass" button on Admin DashboardNeeded changes:
Add field to
PlayerData.java:private boolean adminBypassEnabled = false;data/players/{uuid}.jsonviaJsonPlayerStorageLoad bypass state on player connect (
PlayerConnectionHandler.java):loadPlayerData(uuid), checkplayerData.isAdminBypassEnabled()hyperfactions.admin.usepermission, restore to in-memory mapSave bypass state on toggle (
HyperFactions.toggleAdminBypass()):PlayerData.adminBypassEnabledand trigger saveplayerStorage.savePlayerData(data)Include in auto-save cycle: Already covered —
PeriodicTaskManagersaves all player data periodically, andPlayerDatafields are included automaticallyExisting persistence pattern to follow (
PlayerData.java):powerLossDisabled(boolean) andclaimDecayExempt(boolean) already follow this exact patternJsonPlayerStoragewhich reads/writes allPlayerDatafieldsProtection check unchanged (
ProtectionChecker.java:145-155):adminBypassEnabledmap — no changes neededRisks and Alternatives
hyperfactions.admin.usepermission) could have a stale bypass flag persisted — mitigate by checking permission on login before restoring bypassbypass-players.jsonfile instead of extendingPlayerData— simpler but adds another file to manageReferences and Media
Follows the existing
PlayerDatapersistence pattern used forpowerLossDisabledandclaimDecayExemptflags. The auto-save system (PeriodicTaskManager) already handles periodic flushing of player data to disk.