diff --git a/src/main/java/net/knarcraft/playerpayouts/command/SetGroupPaymentCommand.java b/src/main/java/net/knarcraft/playerpayouts/command/SetGroupPaymentCommand.java index 5ccfbaf..fbb3ea4 100644 --- a/src/main/java/net/knarcraft/playerpayouts/command/SetGroupPaymentCommand.java +++ b/src/main/java/net/knarcraft/playerpayouts/command/SetGroupPaymentCommand.java @@ -11,6 +11,8 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; + /** * A command for overriding payments for specific groups */ @@ -41,6 +43,11 @@ public class SetGroupPaymentCommand implements CommandExecutor { return false; } + if (Arrays.stream(PermissionManager.getPermissionGroups()).noneMatch(item -> item.equals(arguments[0]))) { + stringFormatter.displayErrorMessage(commandSender, Translatable.GROUP_INVALID); + return false; + } + try { String group = arguments[0]; if (StringHelper.isNonValue(arguments[1])) { diff --git a/src/main/java/net/knarcraft/playerpayouts/config/Translatable.java b/src/main/java/net/knarcraft/playerpayouts/config/Translatable.java index 9c89fdb..c2868d8 100644 --- a/src/main/java/net/knarcraft/playerpayouts/config/Translatable.java +++ b/src/main/java/net/knarcraft/playerpayouts/config/Translatable.java @@ -53,6 +53,11 @@ public enum Translatable implements TranslatableMessage { */ PAYOUT_RECEIVED, + /** + * The message displayed when an invalid permission group has been provided + */ + GROUP_INVALID, + ; @Override diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml index b68eef4..abf7f73 100644 --- a/src/main/resources/strings.yml +++ b/src/main/resources/strings.yml @@ -7,4 +7,5 @@ en: PLAYER_PAYOUT_SET: "Player payout for player {player} has been set to {value}" PAYOUT_NUMBER_REQUIRED: "Payout must be a number" PLAYER_ID_REQUIRED: "You must supply a valid name of an online player, or a UUID" - PAYOUT_RECEIVED: "You got a paycheck of {value}" \ No newline at end of file + PAYOUT_RECEIVED: "You got a paycheck of {value}" + GROUP_INVALID: "You have specified an invalid permission group" \ No newline at end of file