Skip to content

Commit

Permalink
Update the region immediately after a transfer has occurred. Addition…
Browse files Browse the repository at this point in the history
…ally, remove the previous owner from the friend feature
  • Loading branch information
md5sha256 committed Jan 29, 2024
1 parent c3bc945 commit e13a5f2
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,32 @@ private void handlePlayer(Player player, String[] args) {
}
if (region.isLandlord(player.getUniqueId())) {
// Transfer ownership if same as landlord
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
region.setOwner(targetPlayer.getUniqueId());
region.setLandlord(targetPlayer.getUniqueId(), targetPlayerName);
this.messageBridge.message(player, "transfer-transferred-owner", targetPlayerName, region);
if (targetPlayer.isOnline()) {
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-owner", targetPlayerName, region);
}
region.update();
region.saveRequired();
return;
}
if (!region.isOwner(player.getUniqueId())) {
// Cannot transfer tenant if we aren't the current tenant
this.messageBridge.message(player, "transfer-notCurrentTenant");
return;
}
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
// Swap the owner/occupant (renter or buyer)
region.setOwner(targetPlayer.getUniqueId());

this.messageBridge.message(player, "transfer-transferred-tenant", targetPlayerName, region);
if (targetPlayer.isOnline()) {
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-tenant", targetPlayerName, region);
}
region.update();
region.saveRequired();
}

@Override
Expand Down

0 comments on commit e13a5f2

Please sign in to comment.