BlockPlacevent don't return sign text

Discussion in 'Plugin Development' started by Benni1000, Jul 4, 2012.

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

    Benni1000

    Hello,
    i am having an issue with the BlockPlaceEvent.
    I try reading the text on the Block when its a sign, but the sign returns nothing,
    when i try sign.getLine(0);

    Code:
    @EventHandler (priority = EventPriority.HIGHEST)
        public void onBlockPlaceEvent(BlockPlaceEvent ev) {
            if(ev.getBlock().getType() == Material.SIGN_POST || ev.getBlock().getType() == Material.WALL_SIGN) {
                Sign sign = (Sign) ev.getBlock().getState();
                log.info(sign.getLine(1));
                if(sign.getLine(0).equalsIgnoreCase("[Reward]")) {
                    if(!ev.getPlayer().hasPermission("simplereward.create")) {
                        ev.getPlayer().sendMessage("§4You don't have Permissions to create a Reward Sign!");
                        ev.setCancelled(true);
                    }
                    else {
                        ev.getPlayer().sendMessage("§2You created an RewardSign!");
                    }
                }
            }
        }
     
  2. Offline

    MucTweezer

    I'm thinking that when you place the block (the sign), it won't have anything written on it yet. Therefore, it won't return anything.

    You might consider checking out SignChangeEvent to see if that can do what you're looking for.
     
  3. Offline

    Benni1000

    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page