From 31b8f0be250f82725c4ac92b90fd0094825db035 Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Sat, 9 May 2020 14:53:02 +0300 Subject: [PATCH] Fixed internal error caused by trying to demote a player who already has the lowest rank --- .../com/massivecraft/factions/cmd/roles/FPromoteCommand.java | 5 +++++ src/main/java/com/massivecraft/factions/zcore/util/TL.java | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java b/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java index 7d82d9e6..3a38bded 100644 --- a/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/roles/FPromoteCommand.java @@ -57,6 +57,11 @@ public class FPromoteCommand extends FCommand { context.msg(TL.COMMAND_PROMOTE_NOT_SAME); 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. if (context.fPlayer.getRole().value <= promotion.value) { context.msg(TL.COMMAND_PROMOTE_NOT_ALLOWED); diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index cec8857e..5bc2a12c 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -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_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_COLEADER_ADMIN("&c&l[!]&7 &cColeaders cant promote players to Admin!"), 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_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_PENALTY(" (penalty: "), COMMAND_POWER_DESCRIPTION("&a&l» &7Show player &apower &7info"),