[fixt] [closed]Signtekst Editor by Command

Discussion in 'Plugin Development' started by gamemakertim, Jun 27, 2012.

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

    gamemakertim

    I know the basics,
    how commands works, inport events...

    but now i think i found the problem:
    My sign doesnt change!!
    if i use bukkit.broadcastMessage("Hoi") he send it. but

    Sign.setLine(1, "hoi")

    doesnt work, i tried other numbers, other strings... but he never change the sign text

    Q: How do i change the tekst?

    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void Klik(PlayerInteractEvent e){
            Player pl = e.getPlayer();
            if(e.getAction().equals(Action.LEFT_CLICK_BLOCK) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
                Block bl = e.getClickedBlock();
                if(bl.getType().equals(Material.SIGN) || bl.getType().equals(Material.SIGN_POST) || bl.getType().equals(Material.WALL_SIGN)){
                    Sign s = (Sign)bl.getState();
                    if(e.getAction().equals(Action.LEFT_CLICK_BLOCK) && !pl.isOp()){
                        e.setCancelled(true);
                    }
                    int f = -1;
                    for(int i = 0; 1 < s.getLines().length; i++){
                        if(s.getLine(i).toLowerCase().contains("[score]")){
                            f = i;
                            break;
                        }
                    }
                    if(f!=-1){
                        s.setLine(0, "Hoi Ik ben Tim");
                    }
                }
            }
        }
    why is this not working?
     
  2. Offline

    Njol

    A BlockState is completely independent from the world, i.e. changes to the state won't change the world. You have to call the state's update() method to make the changes affect the world.
     
  3. Offline

    gamemakertim

    i get it
    sign.setline(0, "hoi");
    sign.update();

    TY :D
     
Thread Status:
Not open for further replies.

Share This Page