C_far icon

[Spigot] c_CowDirt

C_far | PRO | 08/03/16 10:37:00 AM UTC | 0 ⭐ | 440 👁️ | Never ⏰ | []
Java |

1.09 KB

|

None

|

0 👍

/

0 👎

package fr.c_far.cowdirt;
 
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
 
public class Main extends JavaPlugin implements Listener
{
    @Override
    public void onEnable()
    {       
        getServer().getPluginManager().registerEvents(this, this);
        
        System.out.println("[CowDirt] Load.");
        
        return;
    }
    
    @Override
    public void onDisable()
    {
        System.out.println("[CowDirt] Unload.");
        
        return;
    }
    
    @SuppressWarnings("deprecation")
    @EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent e)
    {               
        if(!(e.getEntity() instanceof Cow)) return;
 
                
 
        if(!(e.getDamager() instanceof Player)) return;
        
        if(!((.getItemInHand().getType().equals(Material.DIRT))) return;
        
        Cow c = (Cow) e.getEntity();
        
        c.setHealth(0.0);
        c.getLocation().getBlock().setType(Material.DIRT);
        
        return;
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎