Skip to content

Commit

Permalink
Refactor transfer to transfer both buyers and renters. Update lang fi…
Browse files Browse the repository at this point in the history
…les and fix data keys in GeneralRegion
  • Loading branch information
md5sha256 committed Nov 24, 2023
1 parent ff1ea3a commit 7e1d716
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,16 @@ private void handlePlayer(Player player, String[] args) {
}
return;
}
if (region instanceof RentRegion rentRegion) {
if (!rentRegion.isRenter(player.getUniqueId())) {
// Cannot transfer tenant if we aren't the current tenant
this.messageBridge.message(player, "transfer-notCurrentTenant");
return;
}
// Don't restart the rent, just swap the renter
rentRegion.setRenter(targetPlayer.getUniqueId());
this.messageBridge.message(player, "transfer-transferred-tenant", targetPlayerName, region);
if (targetPlayer.isOnline()) {
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-tenant", targetPlayerName, region);
}
if (!region.isOwner(player.getUniqueId())) {
// Cannot transfer tenant if we aren't the current tenant
this.messageBridge.message(player, "transfer-notCurrentTenant");
return;
}
// 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1594,15 +1594,15 @@ public long getVolume() {
* @return Returns true if region transfers are enabled, false otherwise
*/
public boolean isTransferEnabled() {
return getBooleanSetting("transferMode");
return getBooleanSetting("general.transferMode");
}

/**
* Se whether region transfers are enabled
* @param enabled Whether region transfers should be enabled, false otherwise
*/
public void setTransferEnabled(boolean enabled) {
setSetting("transferMode", enabled);
setSetting("general.transferMode", enabled);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions AreaShop/src/main/resources/lang/EN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ transfer-help: "/as transfer <player> [region], the region you stand in will be
transfer-noPermission: "You don't have permission to transfer a region."
transfer-disabled: "Transferring has been disabled for this region."
transfer-transferred-owner: "%lang:region% has been transferred and is now owned by %0%."
transfer-transferred-tenant: "%lang:region% has been transferred and is now rented by %0%."
transfer-transferred-tenant: "%lang:region% has been transferred and is now occupied by %0%."
transfer-noPlayer: "Unknown player: %0%"
transfer-notCurrentTenant: "You are not the current tenant/renter of this region."
transfer-notCurrentTenant: "You are not the current tenant of this region."
transfer-transferSelf: "You cannot transfer a region to yourself."

reload-reloading: "Reloaded all configuration and region files."
Expand Down

0 comments on commit 7e1d716

Please sign in to comment.