BlockBreakEvent signs help

Discussion in 'Plugin Development' started by shadow5353, Sep 17, 2013.

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

    shadow5353

    Hello all bukkit Developer

    I am having some problem with the BlockBreakEvent because i am trying to make a event that if a sign is having on the top line [Something] it will not be breaked if the player don't have the permission. So if someone can guide me to how i can do this it could be awesome
     
  2. Offline

    chasechocolate

    Check if block.getState() instanceof Sign, then cast, and check if sign.getLine(0).equalsIgnoreCase("[Something]").
     
  3. Offline

    shadow5353


    Thanks :) Im gonna try to see if i can get it to work


    Now i have tried but i still cant get it to work. Here is my code

    Code:java
    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent e){
    3. if(e.getBlock().getState() instanceof Sign){
    4. Sign s = (Sign) e.getBlock().getState();
    5. if(s.getLine(0).equalsIgnoreCase("[§6CG]")){
    6. if(!(e.getPlayer().hasPermission("customgravity.sign.remove"))){
    7. e.setCancelled(false);
    8. e.getPlayer().sendMessage(ChatColor.GOLD + "[" + ChatColor.DARK_RED + "CG" + ChatColor.GOLD + "]" + ChatColor.RED + " You don't have permission!");
    9. }
    10. else if(e.getPlayer().hasPermission("customgravity.sign.remove")){
    11. e.setCancelled(true);
    12. }
    13. }
    14. }
    15. }


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

    Bammerbom

    shadow5353
    Don't use §6 in this line. Use ChatColor.
    if(s.getLine(0).equalsIgnoreCase("[§6CG]")){
     
    shadow5353 likes this.
  5. Offline

    shadow5353

    Jhtzb
    Thanks for the help. It is now working
     
    Jhtzb likes this.
  6. Offline

    JPG2000

  7. Offline

    chasechocolate

Thread Status:
Not open for further replies.

Share This Page