Fixed internal error caused by trying to demote a player who already has the lowest rank

This commit is contained in:
Stefan923 2020-05-09 14:53:02 +03:00 committed by BrowkS
parent 842eb097c6
commit 31b8f0be25
2 changed files with 7 additions and 1 deletions

View File

@ -57,6 +57,11 @@ public class FPromoteCommand extends FCommand {
context.msg(TL.COMMAND_PROMOTE_NOT_SAME); context.msg(TL.COMMAND_PROMOTE_NOT_SAME);
return; 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());
return;
}
// Don't allow people to promote people to their same or higher rank. // Don't allow people to promote people to their same or higher rank.
if (context.fPlayer.getRole().value <= promotion.value) { if (context.fPlayer.getRole().value <= promotion.value) {
context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED);

View File

@ -712,6 +712,7 @@ public enum TL {
COMMAND_PROMOTE_SUCCESS("&c&l[!]&7 You successfully&c %1$s %2$s &cto&7 %3$s"), COMMAND_PROMOTE_SUCCESS("&c&l[!]&7 You successfully&c %1$s %2$s &cto&7 %3$s"),
COMMAND_PROMOTE_PROMOTED("promoted"), COMMAND_PROMOTE_PROMOTED("promoted"),
COMMAND_PROMOTE_DEMOTED("demoted"), 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_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"), COMMAND_PROMOTE_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"),
COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"), COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle permanent faction power option"),
@ -731,7 +732,7 @@ public enum TL {
COMMAND_POWER_TOSHOW("to show player power info"), COMMAND_POWER_TOSHOW("to show player power info"),
COMMAND_POWER_FORSHOW("for showing player power info"), COMMAND_POWER_FORSHOW("for showing player power info"),
COMMAND_POWER_POWER("&c&l[!]&7 &c%1$s » &cPower &7/ &cMaxpower&a » &c%2$d &7/&c%3$d %4$s"), COMMAND_POWER_POWER("&c&l[!]&7 &c%1$s » &cPower &7/ &cMaxpower&a » &c%2$d &7/ &c%3$d %4$s"),
COMMAND_POWER_BONUS(" (bonus: "), COMMAND_POWER_BONUS(" (bonus: "),
COMMAND_POWER_PENALTY(" (penalty: "), COMMAND_POWER_PENALTY(" (penalty: "),
COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"), COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"),