BlockPlaceEvent and BlockBreakEvent

Discussion in 'Plugin Development' started by Razorcane, Dec 10, 2011.

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

    Razorcane

    I read the javadoc on these two events, and they both say if the event is cancelled, the block will not be placed/broken. I have a command set up, that sets a boolean to true. Whenever a player places a block, or breaks a block, it checks if the boolean is true. If it is, it then checks if the player is a guest or not. If the player is, then the events are cancelled.

    However, this does not work. Even if the boolean is true, the player is a guest, and the event is set to cancelled, the player can still place/break blocks. I'm not sure how or what is causing this, any help would be appreciated.

    Could other plugins be conflicting with this? The only plugins I have that I believe would conflict with this would be Essentials and WorldGuard, however, I am unsure if either of those would override my method.
     
  2. Offline

    DomovoiButler

    then try making a testServer that has no plugins in it and test your plugins on that server
    and also did you register the event?
     
  3. Offline

    Razorcane

    Yes, the events are registered. Whenever the boolean returns true, BlockPlaceEvent is cancelled, but BlockBreakEvent still goes through. I even changed the priority to highest, in case it was conflicting with something else.

    The point is, I use Essentials and WorldGuard, and so this idea has to work with them as well.
     
  4. Offline

    Taco

    Is the player in question an op by chance? If they are try de-opping them to see if that helps.
     
  5. Offline

    Razorcane

    The player isn't an OP, and I don't have it check for OP anyway. I have it check within my custom groups code.
     
  6. Offline

    Taco

    Post your code, I can't help much more without seeing it.
     
  7. Offline

    Razorcane

    Code:
          if(plugin.explorationmode == true){
                if(!plugin.members.contains(p.getName()) || !plugin.litesnipers.contains(p.getName()) || !plugin.snipers.contains(p.getName()) || !plugin.admins.contains(p.getName())){
                    event.setCancelled(true);
                }
            }
    The above code is in the onBlockBreak event in my BlockListener.
     
  8. Offline

    DomovoiButler

    can you post your main class?
     
  9. Offline

    Razorcane

    The entire main class? It's about 950 lines.
     
  10. Offline

    nisovin

    Are you sure that "if" statement is resolving to true? Have you checked?
     
  11. Offline

    Razorcane

    It's the same code in the onBlockPlace event, and that event works, so I assume it is resolving to true(if the boolean == true).
     
Thread Status:
Not open for further replies.

Share This Page