Fixes owner being allowed to demote himself (#834)

* Fixes owner demoting himself to subowner

This occurred whilst owner demoted himself to a subowner that led to non existence of the true owner

* Adds error on demote-yourself message
This commit is contained in:
wellnesscookie 2019-07-11 16:52:57 +02:00 committed by tastybento
parent 1c1996ba4c
commit dd0396161e
2 changed files with 7 additions and 0 deletions

View File

@ -52,6 +52,11 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
return true;
}
// Check if the user is not trying to promote/ demote himself
if (target == user) {
user.sendMessage("demote.errors.cant-demote-yourself");
return true;
}
if (!inTeam(getWorld(), target) || !getOwner(getWorld(), user).equals(getOwner(getWorld(), target))) {
user.sendMessage("general.errors.not-in-team");
return true;

View File

@ -507,6 +507,8 @@ commands:
demote:
description: "demote a player on your island down a rank"
parameters: "<player>"
errors:
cant-demote-yourself: "&cYou can't demote yourself!"
failure: "&cPlayer cannot be demoted any further!"
success: "&aDemoted [name] to [rank]"
promote: