mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-10-31 15:59:48 +01:00
Call a RankChange event for the old island owner in Setowner commands
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1342
This commit is contained in:
parent
937052d378
commit
de124ab182
@ -46,22 +46,32 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.not-in-team");
|
||||
return false;
|
||||
}
|
||||
if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
|
||||
|
||||
UUID previousOwnerUUID = getIslands().getOwner(getWorld(), targetUUID);
|
||||
if (targetUUID.equals(previousOwnerUUID)) {
|
||||
user.sendMessage("commands.admin.team.setowner.already-owner", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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);
|
||||
// Call the setowner event
|
||||
TeamEvent.builder()
|
||||
.island(island)
|
||||
.reason(TeamEvent.Reason.SETOWNER)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.build();
|
||||
|
||||
// Call the rank change event for the new island owner
|
||||
IslandEvent.builder()
|
||||
.island(island)
|
||||
.involvedPlayer(targetUUID)
|
||||
@ -69,6 +79,15 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(island.getRank(target), RanksManager.OWNER_RANK)
|
||||
.build();
|
||||
|
||||
// Call the rank change event for the old island owner
|
||||
IslandEvent.builder()
|
||||
.island(island)
|
||||
.involvedPlayer(previousOwnerUUID)
|
||||
.admin(true)
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(RanksManager.OWNER_RANK, island.getRank(previousOwner))
|
||||
.build();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
getIslands().setOwner(getWorld(), user, targetUUID);
|
||||
// Call the event for the new owner
|
||||
IslandEvent.builder()
|
||||
.island(island)
|
||||
.involvedPlayer(targetUUID)
|
||||
@ -80,11 +81,18 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(island.getRank(User.getInstance(targetUUID)), RanksManager.OWNER_RANK)
|
||||
.build();
|
||||
// Call the event for the previous owner
|
||||
IslandEvent.builder()
|
||||
.island(island)
|
||||
.involvedPlayer(playerUUID)
|
||||
.admin(false)
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(RanksManager.OWNER_RANK, island.getRank(user))
|
||||
.build();
|
||||
getIslands().save(island);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
List<String> options = new ArrayList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user