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);

View File

@ -713,6 +713,8 @@ public enum TL {
COMMAND_PROMOTE_PROMOTED("promoted"),
COMMAND_PROMOTE_DEMOTED("demoted"),
COMMAND_PROMOTE_LOWEST_RANK("&c&l[!]&7 &c%1$s&7 already has the lowest rank in the faction."),
COMMAND_PROMOTE_HIGHEST_RANK("&c&l[!]&7 &c%1$s&7 already has the highest rank in the faction."),
COMMAND_PROMOTE_HIGHER_RANK("&c&l[!]&7 &c%1$s&7 has a higher rank than yours. You &4can not modify&7 his rank."),
COMMAND_PROMOTE_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"),
COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"),
@ -724,7 +726,6 @@ public enum TL {
COMMAND_PROMOTE_DESCRIPTION("/f promote <name>"),
COMMAND_PROMOTE_WRONGFACTION("&c&l[!]&7 &c%1$s&7 is &cnot&7 part of your faction."),
COMMAND_NOACCESS("&c&l[!]&7 You don't have access to that."),
COMMAND_PROMOTE_NOTTHATPLAYER("&c&l[!]&7 That player &ccannot&7 be promoted."),
COMMAND_PROMOTE_NOT_ALLOWED("&c&l[!]&7 You cannot promote to the same rank as yourself!"),
COMMAND_PROMOTE_NOTSELF("&c&l[!]&7 You cannot manage your own rank."),
COMMAND_PROMOTE_NOT_SAME("&c&l[!]&7 You cannot promote to the same rank as yourself!"),