#Weird null

1 messages · Page 1 of 1 (latest)

ocean holly
#

Hi. When im using this:

public class ButtonEvent implements Listener
{
    @EventHandler
    public void onButton(PlayerInteractEvent e)
    {
        if (e.getClickedBlock().getType() == Material.STONE_BUTTON)
        {
            Button button = ((Button) e.getClickedBlock().getState().getData());
            Block block = e.getClickedBlock().getRelative(button.getAttachedFace());

            if (block.getType().equals(Material.SPONGE))
            {
                RandomTeleportUtil.randomTeleport(e.getPlayer());
            }
        }
    }
}

It works with no problem, but, it gives a null error: https://www.toptal.com/developers/hastebin/erijojekaq.rb
It shows line 16, the first if, but event when i remove it, error doesn't goes away, and shows same line, 16

glossy reef
surreal sky
#

not nullchecking block?

#

damn got sniped

glossy reef
#

you need to check first

ocean holly
#

yes, but it appears when i click the button

#

but okay, ill try

#

Oh. Wait, what?

#

Its working

#

XD

glossy reef
#

lol

ocean holly
#

thanks xD

glossy reef
#

np