Why can't i get the text on a sign?! Here is code: Code (Text): @EventHandler public void SignClick(PlayerInteractEvent event){ Player player = (Player) event.getPlayer(); Block block = event.getClickedBlock(); Sign sign = (Sign) block.getState(); if(event.getPlayer() instanceof Player){ if(event.getAction() == Action.RIGHT_CLICK_BLOCK){ if(block.getType() == Material.SIGN||block.getType() == Material.WALL_SIGN){ if(sign.getLine()){ } } } } } } It tells me to create a method for: getLine(int) WHY!!??
No, it's probably telling you to USE getLine(int). You have to specify which line you would like to get. Also, you're getting the sign BEFORE you're checking if it's a sign (ClassCastException), checking if a Player is an instanceof Player (And casting a Player to a player), again... before you need to even though it's unnecessary. The method is literally .getPlayer(), and what if the block is null? Again.. before you even checked TL;DR: - You're getting things before checking them. Check first - You're not using the method properly. Sign#getLine(int lineNumber); - You clearly have the slightest clue how to program in Java
Nope :/ It does not even give me stuff to pick.. or how you say it.. idk.. Like. i can pick: equals, clone, and more but not bukkit stuff?...
Assume this is your sign: This is the best sign that has ever been created sign.getLine(0), Returns: "This is the best" sign.getLine(1), Returns: "sign that has" sign.getLine(2), Returns: "ever been" sign.getLine(3), Returns: "created" .getLine(int linNum) returns a String, which would be a Java thing. You may use String methods, such as .equalsIgnoreCase()
@EventHandler public void onPlayerInteract(PlayerInteractEvent e) { if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { Block block = e.getClickedBlock(); 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("...")) {