@EventHandler public void onInteract(PlayerInteractEvent e) { Player player = e.getPlayer(); if(e.getPlayer().getItemInHand().getType() == Material.AIR){ if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 4)); } } } not really sure whats wrong with this code, someone help please.
Well, we don't know either, since you haven't told us your issue... My guesses: - Nothing happens > the event is not registered - NullPointerException > getItemInHand is null (but if I remember correctly it's not the case here) - Your method may fire twice > PlayerInteractEvent: "potentially fired once for each hand" Also, please use code tags...
You must check if getItemInHand() is null BEFORE you check its type. If you invoke getType() or any other method on a null object you will get a Null Pointer Exception. Sent from my iPhone using Tapatalk