Solved How would I shrink this boolean statement

Discussion in 'Plugin Development' started by messageofdeath, Jun 18, 2014.

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


    I'm trying to shrink this boolean statement so I can make my code look better.
    I'm trying to get it to one line somewhat like this.

    1. (groupx.hasPermission() && cmd.getSender().hasPermission(groupx.getPermission()) ? "&aYes" : "&cNo")

    Im trying to shrink this one
    1. if(groupx.hasPermission()) {
    2. if(cmd.getSender().hasPermission(groupx.getPermission())) {
    3. //Go through
    4. }else{
    5. //Don't
    6. }
    7. }else{
    8. //Go through
    9. }

    after posting this i looked at it and solved it.

    End result
    1. if(!groupx.hasPermission() || groupx.hasPermission() && cmd.getSender().hasPermission(groupx.getPermission())) {
    3. }

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page