Hey, I am currently trying to add a feature to my plugin but cant get it to work. It should be simple, but it just isn't working right. I need to make it so when a player has a glass block on their head it allows them to stay underwater indefinitely. If anyone is interested in helping me with this, send me a message. Here is the plugin I am trying to add the feature to: http://tinyurl.com/blockhat Thanks
Code: public void onEntityDamage(EntityDamageEvent event){ if(event.getCause().toString().equals("DROWNING"){ if(player.getInventory().getHelmet().equals(Material.GLASS)){ event.setCancelled(true); } } Pretty sure this doesn't work exactly like this, but something like that should work.
@nmc94 Code: public void onEntityDamage(EntityDamageEvent event) { if(event.getEntity() instanceof Player && event.getCause() == DROWNING) { Player p = (Player) event.getEntity(); if(p.getInventory().getHelmet().getTypeId() == 20) { event.setCancelled(true) } }