package client.command;

public enum Commands {

    Username(new String[]{"/username", "/name", "/u"}, Username.class),
    Team(new String[]{"/team", "/t"}, Team.class),
    Contract(new String[]{"/contract"}, Contract.class),
    Create(new String[]{"/create", "/c"}, Create.class),
    Join(new String[]{"/join", "/j"}, Join.class),
    ListPlayers(new String[]{"/list-players"}, ListPlayers.class),
    ListChannel(new String[]{"/list-channel"}, ListChannel.class),
    Leave(new String[]{"/leave", "/l"}, Leave.class),
    ShowCards(new String[]{"/show-cards"}, ShowCards.class),
    ShowTable(new String[]{"/show-table"}, ShowTable.class),
    PlayCard(new String[]{"/play"}, PlayCard.class),
    ShowContract(new String[]{"/show-contract"}, ShowContract.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;
    }

}

@@ -98,16 +98,22 @@
 e%22, %22/u%22
+, %22/n%22
 %7D, Usern
@@ -203,16 +203,33 @@
 tring%5B%5D%7B
+%22/put-contract%22, 
 %22/contra
@@ -406,16 +406,28 @@
 players%22
+, %22/players%22
 %7D, ListP
@@ -485,16 +485,30 @@
 -channel
+s%22, %22/channels
 %22%7D, List
@@ -619,16 +619,26 @@
 w-cards%22
+, %22/cards%22
 %7D, ShowC
@@ -691,16 +691,26 @@
 w-table%22
+, %22/table%22
 %7D, ShowT
@@ -756,16 +756,22 @@
 %7B%22/play%22
+, %22/p%22
 %7D, PlayC
@@ -1246,29 +1246,36 @@
 xt.s
-tartsWith(alias + ' '
+plit(%22%5C%5Cs+%22)%5B0%5D.equals(alias
 )) %7B

Fix a bug when a command like "/list-players" is miss-spelled and "/leave" is executed cause of its alias "/l". And add some aliases.