Added player-to-player tempflight payments. - #123
Conversation
| String recipientName = args[0]; | ||
| Player recipientPlayer = Bukkit.getPlayerExact(recipientName); | ||
| UUID recipientUUID = recipientPlayer != null ? recipientPlayer.getUniqueId() : null; |
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
This can be replaced with if (recipientResident.isOnline()) {
and then use resident.getPlayer() inside the if block.
| 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); |
There was a problem hiding this comment.
Not sure why you're using Players here again, you only need to use the resident.isOnline().
There was a problem hiding this comment.
Yeah noted, updated to use the residents' online state rather than the Bukkit lookup.
Summary
Adds an optional command allowing players to transfer their available tempflight time directly to another player.
Usage
Time accepts raw seconds or the existing
s,m,h, anddsuffixes.Configuration
The feature is disabled by default:
Players require the following permission, which defaults to
true:Behaviour
Testing
git diff --checkpasses.mvn clean packagecompletes successfully with Java 21.