Signs - trying to set sign texts

Discussion in 'Plugin Development' started by Unprofessional, Jan 2, 2016.

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

    Unprofessional

    im trying to replace a block with a sign and set the sign to have text

    Code:
                  k4.setType(Material.WALL_SIGN);
                   
                    Sign sign = (Sign)k4;
                   
                    sign.setLine(0,"This");
                   sign.setLine(1,"is a sign");
                    sign.update(); 
    
    
     
  2. Offline

    Gorbit99

    What is happening instead?
    Are there errors? (If yes, post your whole stacktrace)
    Have you tried debugging?
    Can you post your whole class/method this is happening in?
     
  3. Offline

    HenrySartori

    Hey guy! I Make the code for you, look:

    IF you want a code that for example, the player writes:

    /Sign add (FirstLine)

    Contact me at skype: <REDACTED>

    Code:
    package soulKits.Comandos;
    
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.entity.Player;
    
    public class blabla implements CommandExecutor {
     
        public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("sign add")) { //When the player write /sign add
                Player p = (Player)sender;//Instancing Player to p
                Location loc = p.getLocation(); //This will create a sign in the Location of the Player
                Block k4 = loc.getBlock();//Setting k4 to the block of the location of player
                k4.setType(Material.SIGN);//Setting k4 as a Sign
                Sign sign = (Sign)k4; //Saying that sign = k4 Sign
                sign.setLine(0, "This is your"); //Write your text here
                sign.setLine(1, "first");//Write your text here
                sign.setLine(2, "Sign!");//Write your text here
            }
            return false;
        }
    }
    
     
    Last edited by a moderator: Jan 2, 2016
  4. Offline

    Zombie_Striker

  5. Offline

    mcdorli

    DON'T SPOONFEED. Especially if it doesn't work.
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page