Multiple conditions in an IF statement

Discussion in 'Plugin Development' started by AndyMcB1, Jun 5, 2013.

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


      if (event.getBlock().getType() != Material.LONG_GRASS) {
                if (event.getBlock().getType() != Material.LEAVES) {
    I know this doesn't work..

    How would i do
    if (event.getBlock().getType() != Material.LONG_GRASS OR Material.LEAVES) {
  2. Offline


    if(!(event.getBlock().getType() == Material.LONG_GRASS || event.getBlock().getType() == Material.LEAVES)){
  3. Offline




    if(!(event.getBlock().getType() == Material.LONG_GRASS || event.getBlock().getType() == Material.LEAVES)){
    the ! used for?
  4. Offline


    AndyMcB1 That is the operator for the logical inverse... basically, if you convert the if statement to speech ("if the type of block of the event is long grass or the type is leaves"), then put "not" in front of it, then you get the result of that if statement... so...
    !true = false
    !false = true
  5. Offline


    so why can't you do

    if((event.getBlock().getType() != Material.LONG_GRASS || event.getBlock().getType() != Material.LEAVES)){

    or can you? Still new to all of this
  6. Offline

    inventorman101 Retired Staff

    You can do that != is just saying "not equal"
  7. Offline


  8. Offline


    Learn Java, then you won't have silly questions like this.
  9. Offline


    I'm starting a cert 4 in programming in a few weeks.

    More efficient in what way?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 1, 2016
  10. Offline


    That seemed a bit harsh it's not like he came on asking people to an entire plugin for him because he didn't know java(which many do), he was just asking a simple question. AndyMcB1 I recommend researching all the logical operators(just google for it) and how they work.
  11. Offline


    I will elaborate on what Garris0n said and recommend looking up the difference between bitwise and logical AND-operators and OR-operators as well as the bitwise exclusive OR
  12. Offline


    I understand a bit of it :)

    I was trying
    if (event.getBlock().getType() != Material.LONG_GRASS) || Material.LEAVES {

    Thanks for sticking up for me, you have to start somewhere! :)
  13. Offline


    A bit harsh? He came asking for help on constructing an if statement. I say this a lot, but this is for Plugin Development not Java help.
  14. Offline


    Understandable, I won't post here again regarding Java issues.
  15. Offline


    I don't think there's an issue with you posting java problems in here but i did do a few tutorials on the basics of java before i started plugin development and i think if you did the same it would help you out. :)

    P.S. If you have anymore java related issues then simply google the problem because 9/10 times you usually find the answer, youtube is also available and if all else fails then feel free to PM me. :D
Thread Status:
Not open for further replies.

Share This Page