Need A Little Help

Discussion in 'Plugin Development' started by nmc94, Jun 25, 2011.

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

    nmc94

    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
     
  2. Offline

    Randy Schouten

    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.
     
  3. Offline

    desmin88

    @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)
            }
        }

     
Thread Status:
Not open for further replies.

Share This Page