Get relative block from sign?

Discussion in 'Plugin Development' started by Suprem20, Apr 12, 2012.

Thread Status:
Not open for further replies.
  1. Offline



    While developing a new plugin, I encountered a problem when getting lines from a relative sign. Currently, I want to get the third line of the sign (the xp) if the first line is equal to [XpBank] and if the second line is the player's name.

                Block downblock = sign.getBlock().getRelative(BlockFace.DOWN);
                if (downblock.getType().equals(Material.WALL_SIGN) || downblock.getType().equals(Material.SIGN_POST)) {
                    Sign downblocksign = (Sign) block.getState();
                    if (downblocksign.getLine(0).equalsIgnoreCase("[xpbank]") && downblocksign.getLine(1).equalsIgnoreCase(player.getName())
                            && downblocksign.getLine(2).equalsIgnoreCase("Store")) {
                        String str = downblocksign.getLine(3);
                        if (str.equalsIgnoreCase("")) {
                            plugin.tell(player, "No xp stored in bank!");
                        Float f = new Float(str);
                        downblocksign.setLine(3, "");
  2. Offline

    Father Of Time

    You are using the wrong "Sign" class, it has 2; Material and Block. Material.Sign is used to get the "content" of a sign (lines), the Block.Sign is used to understand its global aspects (where it is in the world).

    you need to use:


    You can leave everything as is, but for the part where you need to get the relative make sure to cast your sign as block:

    Block relative = (org.bukkit.block.Sign)OriginalBlockSource;
    relative.getRelative( BlockFace.DOWN );
Thread Status:
Not open for further replies.

Share This Page