Skip to content

Added player-to-player tempflight payments. - #123

Open
Triumvir-Civ wants to merge 2 commits into
TownyAdvanced:masterfrom
Triumvir-Civ:feature/tempflight-payments
Open

Added player-to-player tempflight payments.#123
Triumvir-Civ wants to merge 2 commits into
TownyAdvanced:masterfrom
Triumvir-Civ:feature/tempflight-payments

Conversation

@Triumvir-Civ

@Triumvir-Civ Triumvir-Civ commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an optional command allowing players to transfer their available tempflight time directly to another player.

Usage

/tfly pay <player> <time>

Time accepts raw seconds or the existing s, m, h, and d suffixes.

Configuration

The feature is disabled by default:

options:
  allow_tempflight_payments: false

Players require the following permission, which defaults to true:

townyflight.command.tfly.pay

Behaviour

  • Supports online and offline Towny residents.
  • Prevents payments to yourself.
  • Rejects invalid amounts and insufficient balances.
  • Protects against recipient balance overflow.
  • Updates both players’ persistent tempflight metadata immediately.
  • Updates active in-memory balances for online players.
  • Notifies online recipients when they receive time.
  • Uses the existing auto-enable flight behaviour for eligible online recipients.
  • Adds configurable messages, help output and tab completion.
  • Does not require recipient confirmation.

Testing

  • git diff --check passes.
  • mvn clean package completes successfully with Java 21.
  • Builds jar.
  • Tested functionality in-game on our pre-production server.

Comment on lines +196 to +198
String recipientName = args[0];
Player recipientPlayer = Bukkit.getPlayerExact(recipientName);
UUID recipientUUID = recipientPlayer != null ? recipientPlayer.getUniqueId() : null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff feels really messy, instead of using a recipient player throughout the early parts of this method I'd use the resident instead.

String recipientName = args[0];
Resident recipientRes = TownyAPI.getInstance().getResident(recipientName);
if (recipientRes == null) {
Message.of("Player " + recipientName + " not found. Could not transfer tempflight.").to(sender);
return;
}

UUID recipientUUID = recipientRes.getUUID();
if (player.getUniqueID().equals(recipientUUID)) {
Message.of(Message.getLangString("tempFlightPaymentSelf")).to(sender);
return;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really valid critique - I've made that change to use resident throughout, but I've kept in the backup UUID check for the not found message, just as a failsafe.

recipientName
)).to(sender);

if (recipientPlayer != null && recipientPlayer.isOnline()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be replaced with if (recipientResident.isOnline()) {

and then use resident.getPlayer() inside the if block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

Comment on lines +130 to +136
Player senderPlayer = Bukkit.getPlayer(senderUUID);
Player recipientPlayer = Bukkit.getPlayer(recipientUUID);

if (senderPlayer != null && senderPlayer.isOnline())
playerUUIDSecondsMap.put(senderUUID, senderRemainingSeconds);
if (recipientPlayer != null && recipientPlayer.isOnline())
playerUUIDSecondsMap.put(recipientUUID, recipientTotalSeconds);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why you're using Players here again, you only need to use the resident.isOnline().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah noted, updated to use the residents' online state rather than the Bukkit lookup.

@Triumvir-Civ
Triumvir-Civ requested a review from LlmDl July 27, 2026 05:38
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.

2 participants