sign.setLine not working?

Discussion in 'Plugin Development' started by artish1, Jan 31, 2013.

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


    So im creating my own arena, the fact is that everything works except when i left click the sign which is what i want, it would put in my name on w/e line is open, i'm not technically done with it but im having problems with the fact that its not putting "Anything" on the sign,
    I have put myself some messages to send myself in order to find out where the problem is. but all the Messages came back to me perfectly fine, if one did not come back then i know that the problem is somewhere before the message pops up. All messages though came back perfectly fine... here is what i have so far:
        public void onSigninteract(PlayerInteractEvent e){
            Player player = e.getPlayer();
            if(e.getAction() == Action.LEFT_CLICK_BLOCK){
                player.sendMessage("left clicked block");
                if(e.getClickedBlock().getType().getId() == 63 || e.getClickedBlock().getType().getId() == 68 || e.getClickedBlock().getType().getId() == 323){
                    player.sendMessage("if its a sign");
                Sign sign = (Sign) e.getClickedBlock().getState();
                player.sendMessage("obtained the Sign Object");
                Boolean contains = false;
                for (String line : sign.getLines())
                if (line.contains("--ZetaxArena--"))
                contains = true;
                    if(contains == true){
                            String name = player.getName();
                            sign.setLine(1, name);
                            player.sendMessage(ChatColor.GREEN + "You have Joined the Tournament!");
    Even the last message, "You have joined the tournament" also came up, but still the sign refuses to put anything on it.
  2. Offline


    I don't see anything wrong with your code, but I would recommend checking if the BlockState is an instanceof a Sign, rather than checking the item IDs. I'll keep looking for a solution to your original problem, though...

    //EDIT: Try debugging the player name. In other words, echo out the name, and try setting the line to a static - let me rephrase - constant string.
  3. Offline


    You can try sign.update();

    Or maybe try doing if(sign.getLine(1) == null || sign.getLine(1).equalsIgnoreCase("")){ // stuff }
    artish1 likes this.
  4. Offline


    Be careful which Bukkit class you import. I had the same error 1 hour ago.
    Make sure you import org.bukkit.block.Sign which is an interface, and not org,bukkit.material.Sign which is a normal class... If you use an IDE like eclipse, it should tell you that a method such as sign.getLine(int) doesnt exist if you use the material. But you cant expect people to have an IDE so I wonder whether this might be a solution for you.
  5. Offline


    Oh the sign.update() worked perfectly fine :) ty thats all i need
Thread Status:
Not open for further replies.

Share This Page