1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

return false vs true

Discussion in 'Development' started by Levi, Jul 20, 2020.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    so i have a command

    it has if (!$this->testPermission($sender) return false

    will this stop right there and not execute further code compared to if i return true?
     
    Primus likes this.
  2. alvin0319

    alvin0319 Creeper

    Messages:
    5
    GitHub:
    alvin0319
    'return false' will send usage to player, 'return true' will nothing happen.
     
  3. anirudh246

    anirudh246 Spider Jockey

    Messages:
    29
    It’s ok to ask questions, but if they are like this, you should simply https://tryitands.ee

    -Ani
     
  4. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25

    Hi,
    return false 》 return false;
     
    Last edited: Jul 21, 2020
  5. anirudh246

    anirudh246 Spider Jockey

    Messages:
    29
    Assuming you mean to use the hasPermission() method, it depends whether or not they have the permission to return true or not.

    If they do not have the permission, it will return false.
    We do not have any else statement or an else if statement to say what the other output would be, so it would probably just be null, if I’m not wrong.
     
  6. Primus

    Primus Zombie Pigman

    Messages:
    749
    The value you return in the scope of onCommand will determine if command's usage will be sent or not.

    You should learn what 'return' does
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.