Possible to return multiple ENUM constants?

Discussion in 'Plugin Development' started by PandazNWafflez, May 14, 2012.

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

    PandazNWafflez

    How do you return multiple enum constants, if you can. I thought maybe this:

    Code:
    return EnumName.CONSTANT.CONSTANT2;
    
    But not sure.
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    It is not possible like that.

    If you need to return a list (or an array) of results, return a list of results.

    EDIT: EnumSet is the right way to go, but same idea.
     
  3. Offline

    PandazNWafflez

    kumpelblase2
    Sagacious_Zed

    I tried the one on stackoverflow.com, it now looks like this:

    Code:
    return EnumSet<AbilityList>.of(AbilityList.BURNING_ARROW, AbilityList.POISON_ARROW, AbilityList.POWER_ARROW, AbilityList.GUARD, AbilityList.REGULAR_ATTACK, AbilityList.REGULAR_DEFEND);
    
    But Eclipse says that EnumSet and AbilityList in:

    Code:
    EnumSet<AbilityList>
    
    Cannot be resolved to a variable. I have imported them both. Looking at the stackoverflow answer in more detail it looks like:

    Code:
    EnumSet<AbilityList<E>>
    
    But I'm not sure what to put in place of the E :/

    But actually, is the list thing actually wrong? Or just worse? Cause I think it would be better for me to do that, because I need to reference this relatively fast and a lot, so:

    Code:
    if (ablilityList.contains(AbilityList.BURNING_ARROW))
    
    Would be much better.
     
  4. Code:
    return EnumSet.of(AbilityList.BURNING_ARROW, AbilityList.POISON_ARROW, AbilityList.POWER_ARROW, AbilityList.GUARD, AbilityList.REGULAR_ATTACK, AbilityList.REGULAR_DEFEND);
    that should work so without the <AbilityList>.
     
  5. Offline

    PandazNWafflez

    Thanks
     
  6. I would say yes.
     
Thread Status:
Not open for further replies.

Share This Page