Solved BlockPlaceEvent problem

Discussion in 'Plugin Development' started by Major_Derp, Jan 3, 2013.

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

    Major_Derp

    I am trying to listen for a sign being place with [Check in] on the first line. For some reason its not doing what i want it to. here is the code:
    Code:java
    1.  
    2. @EventHandler
    3. public void onBlockPlace(BlockPlaceEvent event){
    4. Block block = event.getBlock();
    5. Player player = event.getPlayer();
    6. if(block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN){
    7. Sign sign = (Sign) block.getState();
    8. String sline1 = sign.getLine(0);
    9. String sline2 = sign.getLine(1);
    10. if(sline1.equalsIgnoreCase("[check in]")){
    11. if(!(sline2.isEmpty())){
    12. if(player.hasPermission("mineprofile.checkin.set")){
    13. player.sendMessage("Checkin point " + ChatColor.RED + sline2 + " Has been set");
    14. }
    15. else{
    16. player.sendMessage(ChatColor.GREEN + "Im sorry you can't create Checkin Signs. Speak to an Admin if This is a problem");
    17. event.setCancelled(true);
    18. }
    19. }
    20. else{
    21. player.sendMessage("Second Line of Checkin Sign must have Text on it.");
    22. }
    23. }
    24. }
    25. }
    26.  

    So if the user doesnt have the perm, they shouldnt be able to place the sign with [Check in] and it should send them the message. But It doesnt. And if the user has the permission, and places the sign, it is supposed to send them a message, but it still does not. here is my plugin.yml file:
    Code:
    name: MineProfile
    main: me.Iqbal.MineProfile.MineProfile
    version: 0.1
    description: MineProfile. A profile System for minecraft. Kind of Like
     
    Facebook for minecraft!
    commands:
      mineprofile:
        description: First Test Command.
      profile:
        description: Create A User Profile
    permissions:
      mineprofile.*:
        description: MineProfile Default basic permission node
        default: false
      mineprofile.checkin.set:
        description: Permission to set checkin signs
        default: false
    And yes, i am sure the event listener is registered. Any help with this would be nice.
     
  2. Offline

    ZeusAllMighty11

    Do SignChangeEvent , where it checks when sign text is updated
     
    Major_Derp likes this.
  3. Offline

    Major_Derp

    At first i tried it and it didnt work, BUT i tried changing the way i got the lines from sign.getLine(); to event.getLine() using the SignChangeEvent, and.... It works! Thanks!
     
Thread Status:
Not open for further replies.

Share This Page