String contained in set help

Discussion in 'Plugin Development' started by LRFLEW, Feb 28, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    LRFLEW

    I am trying to see if a command is one of the strings specified elsewhere. Currently, I use an Enum as follows:
    Code:
    public enum CraftCommands {
    
        kick ("kick"),
        ban ("ban"),
        banIp ("ban-ip"),
        pardon ("pardon"),
        pardonIp ("pardon-ip"),
        list ("list"),
        tp ("tp"),
        give ("give"),
        say ("say"),
        tell ("tell"),
        help ("help"),
        qMark ("?"),
        time ("time"),
        stop ("stop"),
        op ("op"),
        deop ("deop"),
        saveAll ("save-all"),
        saveOff ("save-off"),
        saveOn ("save-on"),
        version ("version"),
        plugins ("plugins");
    
        private final char[] call;
        CraftCommands (String com) {
            this.call = com.toCharArray();
        }
    
        public String command () {
            return new String(call);
        }
    
        public static boolean contains (String com) {
            for ( CraftCommands c : CraftCommands.values() ) {
                if (c.command().equals(com)) {
                    return true;
                }
            }
            return false;
        }
    
    }
    But a friend of mine suggested using a Set. I have tried messing with it, but since a Set is an interface, there are a ton of way to do that. What do you recommend?
    --- merged: Feb 28, 2011 9:20 PM ---
    Really?!? No help ?
     
  2. Offline

    Plague

    Since I am a C programmer, I recommend googling.
     
  3. Offline

    LRFLEW

    No other help? Wow y'all are helpful :p.
     
  4. Offline

    Plague

    God heps those who help themselves ;)
     
Thread Status:
Not open for further replies.

Share This Page