package me.illuminatiproductions.youtubeplugin.commands;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CreateSign implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player){
Player player = (Player) sender;
if (args.length != 2){
player.sendMessage("You need to specify a line and word");
player.sendMessage("Like this: /sign 3 bacon");
}else if(args.length == 2){
//Put a sign at a players location
player.getWorld().getBlockAt(player.getLocation()).setType(Material.WALL_SIGN);
//Get an instance of the sign so you can edit it
Sign sign = (Sign) player.getWorld().getBlockAt(player.getLocation()).getState();
int line = Integer.parseInt(args[0]) - 1; //The line the player specified
String word = args[1]; //Word the player specified
sign.setLine(line, word); //Edit the sign
//Update the state of the sign
sign.update();
}
//Can be used to place a sign
//player.getWorld().getBlockAt(player.getLocation()).setType(Material.SIGN);
//Get the sign/block
//Sign sign1 = (Sign) player.getWorld().getBlockAt(player.getLocation()).getState();
//sign1.setLine(1, "Booty"); //Edit the signs second line
// sign1.update(); //Updates the state of the sign
}
return true;
}
}