package client.command;

public enum Commands {

    Username(new String[]{"/username", "/name", "/u"}, Username.class),
    Team(new String[]{"/team", "/t"}, Team.class),
    Create(new String[]{"/create", "/c"}, Create.class),
    Join(new String[]{"/join", "/j"}, Join.class),
    ListChannel(new String[]{"/list-channel"}, ListChannel.class),
    Leave(new String[]{"/leave", "/l"}, Leave.class),
    ShowCards(new String[]{"/show-cards"}, ShowCards.class),
    ListPLayers(new String[]{"list-players"}, ListPlayers.class);

    private String[] aliases;
    private Class command;


    Commands(String[] aliases, Class command) {
        this.aliases = aliases;
        this.command = command;
    }

    public static Class from(String text) throws Exception {
        for (Commands command : Commands.values()) {
            for (String alias : command.getAliases()) {
                if (text.startsWith(alias)) {
                    return command.getCommand();
                }
            }
        }
        throw new Exception();
    }

    public String[] getAliases() {
        return this.aliases;
    }

    public Class getCommand() {
        return this.command;
    }

}

@@ -273,32 +273,100 @@
 , Join.class),%0D%0A
+    ListPlayers(new String%5B%5D%7B%22/list-players%22%7D, ListPlayers.class),%0D%0A
     ListChannel(
@@ -535,75 +535,8 @@
 ass)
-,%0D%0A    ListPLayers(new String%5B%5D%7B%22list-players%22%7D, ListPlayers.class)
 ;%0D%0A%0D

update Commands Enum