Hi everyone! I want to edit the text of a sign. Basicly I have the coords and the world of a sign in a HashMap. So now I want to check if the block at that coords is a sign and then write something on it. Can I also check whether the row is at an end? Please Help!
First get the block and it's state Code: Block block = world.getBlockAt(x, y, z); BlockState state = block.gteState(); Then to see if it's a sign Code: if (state instanceof Sign){ Sign sign = (Sign) state; } You then have sign.getLines() which will get all 4 lines and sign.getLine(int) which will get a specific lines, there are also corresponding set*() methods
So another problem occures. I thought my code is correct so I tested it. But When I use the command to set the Line of a sign it didnt work! There was nothing to see onto the sign but there is also no error in the console or something like that. Here the code: Code: public boolean ExecuteCmd(Player p, String cmd, String[] args) { if (cmd.equalsIgnoreCase("set")){ StringBuilder news = new StringBuilder(); for(int i = 1; i < args.length; i++) { if(i > 1) news.append(" "); news.append(args[i]); } String newschecked = news.toString(); if (newschecked == null) { p.sendMessage("Aufschrift kann nicht leer sein!"); p.sendMessage("Korrekte Verwendung: /signnews set [Aufschrift]"); } else if (newschecked != null) { String SignName = "Sign"; int length = 4; for (int i = 0; length < plugin.signs.get(SignName).length; i++) { SignName = "Sign" + i; } String[] SignArguments = {plugin.signs.get(SignName)[0], plugin.signs.get(SignName)[1], plugin.signs.get(SignName)[2], plugin.signs.get(SignName)[3], newschecked}; plugin.signs.put(SignName, SignArguments); //Koordinaten aus der Hashmap int x = new Double(SignArguments[0]).intValue(); int y = new Double(SignArguments[1]).intValue(); int z = new Double(SignArguments[2]).intValue(); //Weltname aus der Hashmap in eine Welt umwanden World world = Bukkit.getServer().getWorld(plugin.signs.get(SignName)[3]); //Auf Sign überprüfen Block b = world.getBlockAt(x, y, z); BlockState state = b.getState(); if (state instanceof Sign) { Sign sign = (Sign) state; sign.setLine(2, newschecked); p.sendMessage("Schild erfolgreich beschriftet!"); } else { p.sendMessage("Der Block ist kein Schild!"); } } return true; } return false; } I dont know what to do. Please Help!