What's the diffrence?

Discussion in 'Plugin Development' started by Giorgio, Dec 10, 2012.

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

    Giorgio

    I was always wondering what the difference from:

    Code:
    return false;
    and

    Code:
    return true;
     
  2. Offline

    Barinade

    One is false, the other is true
     
    brord and JazzaG like this.
  3. Offline

    gomeow

    Return false if the user made an error (or at the end of the onCommand)
    return true otherwise

    false indicates bukkit needs to show the usage message
     
  4. Offline

    Barinade

    Assuming he's using it with onCommand
     
  5. Offline

    ZeusAllMighty11 Retired Staff

    When using with a boolean, this is what returns.


    So for example:
    Code:
    public List<String>myFriends = new ArrayList<String>();
     
    public boolean isFriend(String friend){
        if(myFriends.contains(friend)){
            return true;
        }
    }
     
  6. Offline

    Barinade

    ^ what she said.

    If you are using it with onCommand it basically means if the command executed properly or had proper arguments.
    I don't use these because I handle every possibility in my commands like a wizard.
     
  7. Offline

    ZeusAllMighty11 Retired Staff


    I am male :D
     
  8. Offline

    Barinade

    Yes ma'am.

    OT:
    You could do something like this:

    public String areYouBarinade(String playerName) {
    if (playerName.equals("Barinade") {
    return "Omg, you're Barinade!";
    } else {
    return "You imposter piece of ****!";
    }
    }

    Then in an event or something, do
    player.sendMessage(areYouBarinade(player.getName()));
     
  9. Offline

    gomeow

    Are you able to return nothing? (Say that if was false)
     
  10. Offline

    ZeusAllMighty11 Retired Staff


    If you want to return nothing, return false anyway, because returning true progresses the code (if possible), and returning false will just be like 'ah, don't move on '



    Maybe @Fireblast907 knows

    I don't know the damn username
     
  11. Offline

    gomeow

    Doesn't returning false show the usage message? (I usually put the usage messages in the code so I don't know what happens)

    And his name is fireblast709
     
  12. Offline

    Barinade

    What he means
    Code:
    public List<String>myFriends = new ArrayList<String>();
     
    public boolean isFriend(String friend){
        if(myFriends.contains(friend)){
            return true;
        }
        return false;
    }
     
  13. Offline

    ZeusAllMighty11 Retired Staff



    I never set a usage message.
     
  14. Offline

    gomeow

    Say you did in the plugin.yml
     
  15. Offline

    Barinade

    Say you didn't and you handle all your shit yourself because the plugin.yml usage field is crap and you should feel crappy for using it! :p
     
    ZeusAllMighty11 likes this.
  16. Offline

    gomeow

    I do do it myself, but it doesn't sate my curiosity....
     
  17. Offline

    Giorgio

    Ohhhhh k, thank you all for your comments some weren't really needed :p. Thank you im getting to understand this now.
     
Thread Status:
Not open for further replies.

Share This Page