From 469fe0922eaf9c86f7ba1662936c7c8bee9df03d Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Mon, 15 Apr 2019 14:57:11 -0700 Subject: [PATCH] =Added array input to AllowedGuildRole Users can now enter in multiple roles by separating them with a comma in the command --- locStrings.config | 2 +- src/commands/CommandAllowedGuildRole.java | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/locStrings.config b/locStrings.config index d64a2a4..cc2fd23 100644 --- a/locStrings.config +++ b/locStrings.config @@ -172,7 +172,7 @@ WolframInfo=Will query wolframalpha with your question and give a full image out WolframNoArgs=You need to provide some arguments! [CommandAddGuildRole] -AddGuildRoleInfo= +AddGuildRoleInfo=Add a role to yourself! AddGuildRoleNotAllowed=You are not allowed to add %s! AddGuildRoleSuccess=Added %s to %s AddGuildRoleFailure=Failed to add %s to %s diff --git a/src/commands/CommandAllowedGuildRole.java b/src/commands/CommandAllowedGuildRole.java index e752e26..f71697e 100644 --- a/src/commands/CommandAllowedGuildRole.java +++ b/src/commands/CommandAllowedGuildRole.java @@ -20,15 +20,20 @@ public class CommandAllowedGuildRole extends Command @Override public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { - String role = input.args.split(" ")[0]; - if(guild.allowedRole.contains(role)) + String [] roles = input.args.split(","); + String role; + for(int i = 0; i < roles.length; i++) { - res.Call(LocStrings.Stub("AllowedGuildRoleDuplicate")); - } - else - { - guild.allowedRole.add(role); - res.Call(String.format(LocStrings.Stub("AllowedGuildRoleSuccess"), role)); + role = roles[i].trim(); + if(guild.allowedRole.contains(role)) + { + res.Call(LocStrings.Stub("AllowedGuildRoleDuplicate")); + } + else + { + guild.allowedRole.add(role); + res.Call(String.format(LocStrings.Stub("AllowedGuildRoleSuccess"), role)); + } } } } \ No newline at end of file