How can I create sign to where players sprightly click it ... It teleports them to certain coords....(and if you can leave how you add text on the sign) sorry I'm a noob at dis
For this specific task, you would only need to know where the sign is, hook into PlayerInteractEvent, and check if a player clicks the block (where the sign is). After that you throw Player.teleport(Location). I assume you want more functionality with this, such as the ability to create dynamic teleportation signs, and edit them from inside the game? Stuff like that is important to know before we start to talk code.
You could use something like this to detect when a player right clicks on a sign. Code:java @EventHandlerpublic void interact(PlayerInteractEvent e) {//Do stuff} As for teleportation: Code:java World world = Bukkit.getServer().getWorld("//World Name");Location locationname = new Location(world, //x, //y, //z coords);player.teleport(locationname);
a small example in psuodo code: Code: @EventHandler public void signPlace(SignChangeEvent e) { if(e.getLine(0).contains("[teleport]")) { e.setLine(0, ChatColor.translateAlternateColors("&", "&[teleport]"); } } @EventHandler public void signInteract(PlayerInteractEvent e) { if(e.getAction() == Action.RIGHT_CLICK_BLOCK) { if(block.getType == Material.SIGN || block.getType == Material.SIGN_POST || block.getType == Material.WALL_SIGN) { Sign sign = (Sign) e.getClickedBlock().getState(); if(sign.getLine(0).contains("[teleport]")) { //let the player do something } } } } edit basicly the most important thing is casting the Sign on getState(); and you can read lines of the sign
basicly yes event at the top code is activated when somebody presses the done button so you could retrieve the lines but also edit the sign lines and add permission checks so not everyone can create that sign because the first line is basicly a tag. with the tag I ment your other event which get triggered when your right click the sign it will search for the line with the name [teleport] and then do something. if you like to change the sign lines when the player clicks on the sign you could easily use sign.setLine(1, "see ya" + e.getPlayer().getName()); and update the block with sign.update(true);