Fix #4
All checks were successful
KnarCraft/PlayerPayouts/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2024-01-25 13:06:40 +01:00
parent f4a5811156
commit 7a817595c1
3 changed files with 14 additions and 1 deletions

View File

@ -11,6 +11,8 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
/** /**
* A command for overriding payments for specific groups * A command for overriding payments for specific groups
*/ */
@ -41,6 +43,11 @@ public class SetGroupPaymentCommand implements CommandExecutor {
return false; return false;
} }
if (Arrays.stream(PermissionManager.getPermissionGroups()).noneMatch(item -> item.equals(arguments[0]))) {
stringFormatter.displayErrorMessage(commandSender, Translatable.GROUP_INVALID);
return false;
}
try { try {
String group = arguments[0]; String group = arguments[0];
if (StringHelper.isNonValue(arguments[1])) { if (StringHelper.isNonValue(arguments[1])) {

View File

@ -53,6 +53,11 @@ public enum Translatable implements TranslatableMessage {
*/ */
PAYOUT_RECEIVED, PAYOUT_RECEIVED,
/**
* The message displayed when an invalid permission group has been provided
*/
GROUP_INVALID,
; ;
@Override @Override

View File

@ -8,3 +8,4 @@ en:
PAYOUT_NUMBER_REQUIRED: "Payout must be a number" PAYOUT_NUMBER_REQUIRED: "Payout must be a number"
PLAYER_ID_REQUIRED: "You must supply a valid name of an online player, or a UUID" PLAYER_ID_REQUIRED: "You must supply a valid name of an online player, or a UUID"
PAYOUT_RECEIVED: "You got a paycheck of {value}" PAYOUT_RECEIVED: "You got a paycheck of {value}"
GROUP_INVALID: "You have specified an invalid permission group"