From 783a68a757eeb722dc9c6336fa5dead8c53e1ee5 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Wed, 13 May 2020 16:17:06 +0200 Subject: [PATCH] Call the TeamSetownerEvent before making the change in AdminTeamSetownerCommand Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1349 Also call one of the two "RankChange" event before the change (not doing the latter was a bug, actually). --- .../commands/admin/team/AdminTeamSetownerCommand.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamSetownerCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamSetownerCommand.java index 1967f68b4..77945a9ba 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamSetownerCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamSetownerCommand.java @@ -55,11 +55,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand { // Get the User corresponding to the current owner User previousOwner = User.getInstance(previousOwnerUUID); - - // Make new owner User target = User.getInstance(targetUUID); - getIslands().setOwner(getWorld(), user, targetUUID); - user.sendMessage("commands.admin.team.setowner.success", TextVariables.NAME, args.get(0)); // Fire event so add-ons know Island island = getIslands().getIsland(getWorld(), targetUUID); @@ -72,6 +68,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand { .build(); // Call the rank change event for the new island owner + // We need to call it BEFORE the actual change, in order to retain the player's previous rank. IslandEvent.builder() .island(island) .involvedPlayer(targetUUID) @@ -80,7 +77,12 @@ public class AdminTeamSetownerCommand extends CompositeCommand { .rankChange(island.getRank(target), RanksManager.OWNER_RANK) .build(); + // Make new owner + getIslands().setOwner(getWorld(), user, targetUUID); + user.sendMessage("commands.admin.team.setowner.success", TextVariables.NAME, args.get(0)); + // Call the rank change event for the old island owner + // We need to call it AFTER the actual change. IslandEvent.builder() .island(island) .involvedPlayer(previousOwnerUUID) @@ -88,6 +90,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand { .reason(IslandEvent.Reason.RANK_CHANGE) .rankChange(RanksManager.OWNER_RANK, island.getRank(previousOwner)) .build(); + return true; } }