Java issue — if says nothing, code does nothing

Discussion in 'Plugin Development' started by Fifteen, Jan 26, 2011.

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

    Fifteen

    Hey, I have a little problem here. As the title says, when I call the second if in this snippet:

    Code:
    if (b.getTypeId() == 54 && i == si && ap == false)
    {
         //When debugging, I found out that any code here gets called, but nothing that's placed after it.
         if (Locked.oo == true && !p.isOp() && !Locked.ano.contains(p.getName()))
         {
              return;
         }
         else if (!PChest.getPlacer(b).equalsIgnoreCase(p.getName()) && !p.isOp())
         {
              p.sendMessage(Locked.r + "This chest doesn't belong to you.");
              return;
         }
        Chest.select(p.getName(), b);
        p.sendMessage(Locked.r + "The chest has been selected.");
         if (ls)
             plugin.log.info(p.getName() + " has selected a chest.");
    }
    ...nothing happens. As I'm an op, it should proceed to the final piece of code, but it doesn't. It just skips everything after the second if. How do I solve this?

    Full source: https://github.com/Fifteen/Locked/

    EDIT: This code is surrounded by try and catch doesn't print the error (intentional). I'll add ex.printStackTrace() and see what's wrong :p

    EDIT 2: Turns out I forgot that it performs a check that throws an exception because BlockPlaceEvent hasn't been implemented [​IMG]
     
  2. Offline

    crowebird

    Have you checked p.isOp() as an output just to make sure it is seeing you as an op?
    Try an output p.sendMessage("Is Op" + (p.isOp() ? "true" : "false")) before you do any of the if statements just to make sure. (Note I was note sure if java allows a conditional to be output hence the ternary output instead)
     
  3. Offline

    Fifteen

    if (p.isOp()) works in all other cases, so that probably isn't the problem.
     
Thread Status:
Not open for further replies.

Share This Page