Skip to content

Use local player cache for pay commands#283

Open
Javavailable wants to merge 3 commits into
FancyInnovations:mainfrom
Javavailable:pay-uuid-clean
Open

Use local player cache for pay commands#283
Javavailable wants to merge 3 commits into
FancyInnovations:mainfrom
Javavailable:pay-uuid-clean

Conversation

@Javavailable

@Javavailable Javavailable commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📋 Description

This fixes a lag issue we noticed on our live server when players repeatedly used pay commands with unknown player names.

Before this change, the pay flow tried to resolve offline player names synchronously through Minecraft Services when the target was not online. With random or invalid names, this could make a normal command wait on an external request and cause visible server lag.

The pay command now only uses local player data. Online players can still be paid normally, known/cached economy players still work, and unknown offline names fail fast with the existing player-not-found message.

✅ Checklist

  • My code follows the project's coding style and guidelines
  • I have tested my changes locally and they work as expected
  • I have added necessary documentation (if applicable)
  • I have linked related issues using Fixes #issue_number or Closes #issue_number
  • I have rebased/merged with the latest main branch

🔍 Changes

  • Added a local cached-player lookup helper to CurrencyPlayerManager
  • Added a getPlayer(UUID, String) overload to avoid unnecessary name lookups when the player name is already known
  • Updated /pay to avoid synchronous UUID lookups for unknown offline names
  • Updated currency-specific pay commands to use the same local lookup behavior
  • Kept online player payments and known/cached offline player payments working as before

🧪 How to Test

  1. Start a server with FancyEconomy installed.
  2. Join with two players and give one of them some balance.
  3. Run /pay <onlinePlayer> <amount> and confirm the payment still works.
  4. Have the target player leave, then run /pay <knownPlayerName> <amount> and confirm known cached players can still be paid.
  5. Run /pay <randomUnknownName> <amount> and confirm it immediately returns the existing player-not-found message instead of waiting on an external lookup.
  6. Repeat the same checks with a currency-specific command, for example /<currency> pay <player> <amount>.

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