From 56052512c77de7f6a1b865680d2daa7d73864891 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Tue, 14 Nov 2023 01:34:02 +0100 Subject: [PATCH] Remove two cases of == equality check for residents (#7084) --- .../palmergames/bukkit/towny/command/TownCommand.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java b/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java index 6836d9b5fc..ae242640fd 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/command/TownCommand.java @@ -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; @@ -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()));