Skip to content

Fix AuthMe login window: pause time tracking pre-auth and recalc on a…#10

Open
Becerritoo wants to merge 1 commit into
Ajneb97:mainfrom
Becerritoo:main
Open

Fix AuthMe login window: pause time tracking pre-auth and recalc on a…#10
Becerritoo wants to merge 1 commit into
Ajneb97:mainfrom
Becerritoo:main

Conversation

@Becerritoo
Copy link
Copy Markdown

Summary

This PR fixes a timing/permission window where PlayerTimeLimit could incorrectly fall back to default before players authenticate with AuthMe (join -> /login).

It also removes an unsafe async permission check path and makes limit recalculation/auth synchronization deterministic.

Problem

On AuthMe servers, players are online before being authenticated.
During that pre-auth window:

  • limit recalculation could run with incomplete/default permission state
  • time_limit could be set to default
  • remaining time UI and behavior became inconsistent until later updates

Additionally, PlayerUpdateLimitTask was running asynchronously while calling player.hasPermission(...), which is not a safe pattern for Bukkit player state access.

Changes

1) Main-thread limit recalculation

  • Changed PlayerUpdateLimitTask from:
    • runTaskTimerAsynchronously(...)
    • to runTaskTimer(...)

2) Auth-aware readiness guard

  • Added isReadyForTimeTracking(Player) in PlayerDataManager.
  • Behavior:
    • If AuthMe is not installed: returns true
    • If AuthMe is installed: returns true only when:
      • player is authenticated, or
      • player is not registered

3) Pause pre-auth mutations

  • PlayerTimeTask.execute() now skips players not ready for tracking.
  • PlayerUpdateLimitTask.execute() now skips limit recalculation for players not ready.
  • manageJoin(...) no longer forces updateTimeLimit(...) before auth readiness.

4) Immediate recalc on auth events

  • Added new integration class: AuthMeSupport
  • Registers optional listeners (via reflection) for:
    • fr.xephi.authme.events.LoginEvent
    • fr.xephi.authme.events.RestoreSessionEvent
    • fr.xephi.authme.events.RegisterEvent
  • On these events:
    • recalculates limit immediately
    • refreshes info bars

5) Plugin metadata

  • Added AuthMe to softdepend in plugin.yml

Files changed

  • src/main/java/ptl/ajneb97/PlayerTimeLimit.java
  • src/main/java/ptl/ajneb97/managers/PlayerDataManager.java
  • src/main/java/ptl/ajneb97/tasks/PlayerTimeTask.java
  • src/main/java/ptl/ajneb97/tasks/PlayerUpdateLimitTask.java
  • src/main/java/ptl/ajneb97/integrations/AuthMeSupport.java (new)
  • src/main/resources/plugin.yml

Compatibility

  • No config format changes
  • No command changes
  • No DB schema changes
  • Behavior is unchanged on servers without AuthMe (except safer main-thread limit task)

Expected behavior after merge

  • No more default limit overwrite during pre-login/auth window
  • No time consumption before AuthMe authentication
  • Correct role limit is applied immediately after /login or session restore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant