From ecc133fbda0f3bee5209ec190607f0e7f17266d7 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Fri, 12 Jan 2018 10:15:49 +0100 Subject: [PATCH] Ignoring multi space in command --- .../java/net/Broken/Outils/CommandParser.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/Broken/Outils/CommandParser.java b/src/main/java/net/Broken/Outils/CommandParser.java index b4e7dfa..00fd97c 100644 --- a/src/main/java/net/Broken/Outils/CommandParser.java +++ b/src/main/java/net/Broken/Outils/CommandParser.java @@ -12,29 +12,31 @@ import java.util.Arrays; */ public class CommandParser { - Logger logger = LogManager.getLogger(); + private Logger logger = LogManager.getLogger(); public CommandContainer parse(String brt, MessageReceivedEvent e) { ArrayList split =new ArrayList(); String brut =brt; - String sansTete = brut.replaceFirst("//",""); // on retire l'entete - String[] splitSansTete = sansTete.split(" "); // on prend l'espace comme separateur cmd/arg - for(String s : splitSansTete){ //= pourchaque - split.add(s); // on fait un truc que je comprend pas trop x) + String sansTete = brut.replaceFirst("//",""); + String[] splitSansTete = sansTete.split(" "); + + for(String s : splitSansTete){ + if(s.length()>0) + split.add(s); } - String commande = split.get(0); // on recuperre la 1er partie qui correspond a la cmd + + String commande = split.get(0); String[] args = new String[split.size()-1]; split.subList(1,split.size()).toArray(args); + for(int i=0;i