Solved Sign Under Block

Discussion in 'Spigot Plugin Development' started by Accessory, Jun 19, 2016.

Thread Status:
Not open for further replies.
  1. Hey so I'm trying to get what a sign says under a block the player is standing on. It gets the material "Sign Post" but when I check if the block is instance of a Sign it doesn't return true.

    This is my code:
    Code (Text):
                    if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.DIAMOND_BLOCK) {
                        System.out.println("[!] Block under Diamond: " + player.getLocation().subtract(0, 2, 0).getBlock().getType().toString());
                        if(player.getLocation().subtract(0, 2, 0).getBlock() instanceof Sign) {
                            System.out.println("[!] Block under Diamond is instanceof a Sign!");
                            Sign sign = (Sign) player.getLocation().subtract(0, 2, 0).getBlock();
                            if (sign.getLine(0).equalsIgnoreCase("[Potion]")) {
                                System.out.println("[!] Has [Potion]!");
                                if (!CommandManager.isInt(sign.getLine(1)) || !CommandManager.isInt(sign.getLine(2)) || !CommandManager.isInt(sign.getLine(3))) {
                                    System.out.println("[!] Being returned...");

                                System.out.println("[!] Potion " + sign.getLine(1) + " " + sign.getLine(3) + " for " + sign.getLine(2) + " second(s).");

                                player.playEffect(player.getLocation(), Effect.SPLASH, 1);
                                player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(sign.getLine(1)), Integer.parseInt(sign.getLine(2)), Integer.parseInt(sign.getLine(3))));
                                System.out.println("[!] Potion given!");
    This is as far as it goes in debug messages:
    [19:52:55 INFO]: [!] Block under Diamond: SIGN_POST

    None of the other debug messages ever run. I find this strange since its a sign so it shouldn't get stuck there. Please help asap. Thank you.
  2. A Block cannot be an instance of Sign. Its BlockState can, however.
    • Agree Agree x 1
  3. @WinX64 Smh, thank you! Can't believe I forgot that.
Thread Status:
Not open for further replies.