Skip to content

Commit

Permalink
Remove two cases of == equality check for residents (#7084)
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr authored Nov 14, 2023
1 parent 61268ae commit 5605251
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3027,7 +3027,7 @@ public static void townKickResidents(CommandSender sender, Resident resident, To
continue;
}

if (resident == member) {
if (member.equals(resident)) {
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_you_cannot_kick_yourself"));
kicking.remove(member);
continue;
Expand Down Expand Up @@ -4463,10 +4463,15 @@ private void parseTownBuyTownCommand(CommandSender sender, String[] args) throws
}

Resident currentMayor = town.getMayor();
if (currentMayor == resident) {
if (resident.equals(currentMayor)) {
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_town_buytown_already_mayor", resident.getTownOrNull().getName()));
return;
}

if (resident.isMayor()) {
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_mayor_abandon"));
return;
}

if (!resident.getAccount().withdraw(town.getForSalePrice(), "Town purchase cost.")) {
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_err_you_need_x_to_pay", town.getForSalePrice()));
Expand Down

0 comments on commit 5605251

Please sign in to comment.