this question has answer here:
- what nullpointerexception, , how fix it? 12 answers
i'm getting error , have no idea fix it, i've tried can think of.
the code check player's boot slot see if has diamond boots on, , if do, set air banned item.
the error:
too big paste in here here is: http://pastebin.com/zhzc3hut
the code:
@eventhandler public void oninventoryclickboots(inventoryclickevent event) { player player = (player) event.getwhoclicked(); if(player.getinventory().getboots().gettype().equals(material.diamond_boots)){ player.getinventory().setboots(new itemstack(material.air)); } else { } }
i'm getting repeated error helmet, chestplate , leggings slot too.
thanks in advance able me out! explanation of what's going on appreciated!
the problem you're facing getboots itemstack null.
to fix issue, should first check if boots null before checking it's type.
itemstack boots = player.getinventory().getboots(); if (boots != null) { if (boots.gettype().equals(material.diamond_boots) { player.getinventory().setboots(null); } }
@edit
as reminded the_lone_devil:
(...)this because empty slot in inventory null itemstack, if have nothing in boots slot, itemstack returned null.
Comments
Post a Comment