Fixed an internal error caused by some unhandled cases.

This commit is contained in:
Stefan923
2020-05-09 15:51:14 +03:00
committed by BrowkS
parent 1d4a1c2a1a
commit 447bfedbb1
2 changed files with 15 additions and 4 deletions

View File

@@ -57,6 +57,11 @@ public class FPromoteCommand extends FCommand {
context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
return;
}
// Don't allow people to promote people with same or higher rank than their.
if (context.fPlayer.getRole().value <= target.getRole().value) {
context.msg(TL.COMMAND_PROMOTE_HIGHER_RANK, target.getName());
return;
}
// Don't allow people to demote people who already have the lowest rank.
if (current.value == 0 && relative <= 0) {
context.msg(TL.COMMAND_PROMOTE_LOWEST_RANK, target.getName());
@@ -69,11 +74,16 @@ public class FPromoteCommand extends FCommand {
}
}
if (promotion == null) {
context.msg(TL.COMMAND_PROMOTE_NOTTHATPLAYER);
// Don't allow people to demote people who already have the lowest rank.
if (current.value == 0 && relative <= 0) {
context.msg(TL.COMMAND_PROMOTE_LOWEST_RANK, target.getName());
return;
}
// Don't allow people to promote people who already have the highest rank.
if (current.value == 4 && relative > 0) {
context.msg(TL.COMMAND_PROMOTE_HIGHEST_RANK, target.getName());
return;
}
// Don't allow people to promote people to their same or higher rnak.
if (context.fPlayer.getRole().value <= promotion.value) {
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);