Skip to content

Fetch users before giving up on an unknown player in /azlink money - #66

Open
CryLegende wants to merge 1 commit into
Azuriom:masterfrom
CryLegende:fetch-before-money-edit
Open

CryLegende wants to merge 1 commit into
Azuriom:masterfrom
CryLegende:fetch-before-money-edit

Conversation

@CryLegende

Copy link
Copy Markdown

Problem

/azlink money only looks at the user cache, which is filled by the fetch task once per minute. For up to a minute after a player joins, the command fails with Unable to find player '<name>', please try again in few seconds or use '/azlink fetch'.

This hits every plugin that delivers money right after a join, for example rewards queued while the player was offline and run on join. On our server this lost 154 vote rewards in five months, all on the player's first join after a restart. Running /azlink fetch just before does not help: it starts the request but does not wait for the response.

Changes

  • /azlink money: when the player is online but not in the cache yet, fetch the data and retry once the response has been handled. Offline players keep the current error message.
  • FetcherTask.fetch(): when called again within five seconds, return the pending request instead of an already completed future, so callers can actually wait for the response.

Testing

Paper 26.3 with a local Azuriom site: /azlink money add <player> 1 sent from the console one second after the player joined now prints Money has been edited successfully. and updates the balance. Before, it printed Unable to find player. ./gradlew :azlink-common:test passes.

A player who joined after the last data fetch is not in the user cache yet,
so '/azlink money' failed with 'Unable to find player' for up to a minute
after a join. Commands queued for delivery on join (vote rewards...) were
lost this way.

When the target player is online but unknown, fetch the data and retry once
the response is handled. FetcherTask.fetch() now returns the pending request
instead of an already completed future when it is called again within five
seconds, so callers can wait for its response.
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