[Help] Sign Updates

Discussion in 'Plugin Development' started by TechGuard, Mar 14, 2011.

Thread Status:
Not open for further replies.
  1. How can I update signs correctly?
    Code:
    Sign sign = (Sign)block.getState();
    sign.setLine(0, "line 1");
    sign.update();
    That won't work.
     
  2. Offline

    CypherX

    Code:
    sign.update(true);
    That should work.
     
  3. Isn't working :(
     
  4. Offline

    CypherX

    Weird, it worked when I tested it. I'll play around with it some more and and respond if I figure something out.

    EDIT: Yeah, I have no idea why it won't work for you. Just using sign.update() is working fine for me. Using CraftBukkit build 527 and Bukkit build 451.
     
  5. Offline

    needspeed10

    The code should work. I am using something similar to this and it works.
    So just check if the rest of your plugin is correct?
     
  6. Code:
    Sign sign = (Sign)world.getBlockAt(x, y, z).getState();
     
  7. Offline

    needspeed10

    Try
    Code:
    Block target = world.getBlockAt(x, y, z);
    if(target.getTypeId()==63 || target.getTypeId()==68) sign = (Sign)target.getState();
    else getServer().broadcastMessage("fail");
     
  8. No, I get the signs. it changes the line. But it won't update.
     
  9. Offline

    Crash

    Try this :
    Code:
    Sign sign = (Sign)block.getState();
    sign.setLine(0, "line 1");
    System.out.println(sign.getLine(0));
     
  10. Offline

    Edward Hand

    Hackish solutions to the rescue:
    Code:
    CraftWorld cWorld = (CraftWorld)theWorld;
    TileEntitySign teSign = (TileEntitySign)cWorld.getHandle().f(theSign.getX(),theSign,getY(),theSign.getZ())
    for(Player p : theServer.getOnlinePlayers())
    {
        CraftPlayer cPlayer = (CraftPlayer)p;
        cPlayer.getHandle().a(teSign);
    
    }
     
  11. getHandle().f(); represents a boolean.

    Should getHandle().getTileEntity() work?

    EDIT: am I doing something wrong?
    Code:
    private void update(World w, Location l){
            CraftWorld cWorld = (CraftWorld)w;
            TileEntitySign teSign = (TileEntitySign)cWorld.getHandle().getTileEntity((int)l.getX(), (int)l.getY(), (int)l.getZ());
            for(Player p : plugin.getServer().getOnlinePlayers()){
                CraftPlayer cPlayer = (CraftPlayer)p;
                cPlayer.getHandle().a(teSign);
            }
        }
    bump

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

    eisental

Thread Status:
Not open for further replies.

Share This Page