本文整理汇总了Java中org.bukkit.event.entity.EntityDamageByEntityEvent.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageByEntityEvent.getCause方法的具体用法?Java EntityDamageByEntityEvent.getCause怎么用?Java EntityDamageByEntityEvent.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDamageByEntityEvent
的用法示例。
在下文中一共展示了EntityDamageByEntityEvent.getCause方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EntityDamageByEntityListener
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void EntityDamageByEntityListener(EntityDamageByEntityEvent e) {
if (!GameManager.getGameSituation()) {
e.setCancelled(true);
}
if (e.getDamager() instanceof Player) {
if (e.getEntity() instanceof Player) {
Player damager = (Player) e.getDamager();
Player victim = (Player) e.getEntity();
if (SettingsManager.shotinfo) {
if (e.getCause() == DamageCause.PROJECTILE) {
if(victim.getLocation().distance(damager.getLocation()) < 20) {
Bukkit.broadcastMessage(SettingsManager.niceshot.replace("%s", victim.getName()).replace("%s", damager.getName()).replace("%d", String.valueOf(victim.getLocation().distance(damager.getLocation()))));
}
}
}
}
}
}
示例2: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack mainItem = player.getInventory().getItemInMainHand();
LivingEntity enemy = (LivingEntity)event.getEntity();
if(mainItem.getType() == Material.GOLD_SPADE)
{
enemy.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 100, 0, false));
enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 48, 2, true));
Location particleLoc = player.getLocation();
particleLoc.setY(particleLoc.getY() + 2);
ParticleEffect.HEART.display(0.5f, 0, 0.5f, 1, 2, particleLoc, 64);
}
}
}
示例3: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack mainItem = player.getInventory().getItemInMainHand();
LivingEntity enemy = (LivingEntity)event.getEntity();
Random rand = new Random();
if(mainItem.getType() == Material.GOLD_AXE)
{
enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
}
}
}
示例4: call
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@Override
public void call(Event event) {
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent edbe = (EntityDamageByEntityEvent) event;
if (edbe.getCause() != DamageCause.ENTITY_ATTACK) {
return;
}
callback(!isInLineOfSight(edbe.getEntity(), 2.0));
}
}
示例5: onMelee
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMelee(EntityDamageByEntityEvent event) {
if(knockback.isPresent() &&
victim.equals(event.getEntity()) &&
event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK &&
event.getDamager() instanceof LivingEntity &&
victim.getNoDamageTicks() <= 0) {
applyImpulses((LivingEntity) event.getDamager());
}
}
示例6: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack item = player.getItemInHand();
if(item.getType() == Material.WOOD_SPADE)
{
item.setDurability((short)(item.getDurability() - 2));
}
}
}
示例7: playerShotEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void playerShotEvent(final EntityDamageByEntityEvent event) {
if (GameState.current() == GameState.LOBBY || GameState.current() == GameState.ENDED) {
return;
}
if (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE && event.getDamager() instanceof Arrow &&
((Arrow) event.getDamager()).getShooter() instanceof Player && event.getEntity() instanceof Player) {
Player shot = (Player) event.getEntity();
Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
shooter.sendMessage(ChatColor.GRAY + "➵ " + ChatColor.AQUA + shot.getName() + " " + ChatColor.RED +
new BigDecimal(shot.getHealth() / 2).setScale(1, BigDecimal.ROUND_HALF_UP));
}
}
示例8: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player)event.getDamager();
ItemStack mainItem = player.getInventory().getItemInMainHand();
ItemStack offItem = player.getInventory().getItemInOffHand();
LivingEntity enemy = (LivingEntity)event.getEntity();
Random rand = new Random();
if(mainItem.getType() == Material.WOOD_HOE)
{
enemy.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, 0, false));
if(mainItem.getDurability() >= 59)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInMainHand(null);
}
}
if(offItem.getType() == Material.WOOD_HOE)
{
int chance_poison = rand.nextInt(4) + 1;
switch(chance_poison)
{
case 1:
case 2:
enemy.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, 0, false));
break;
default:
}
offItem.setDurability((short)(offItem.getDurability() + 1));
if(offItem.getDurability() >= 59)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInOffHand(null);
}
}
}
}
示例9: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
ItemStack offItem = player.getInventory().getItemInOffHand();
if(dualWield.getScore(player).getScore() == 1)
{
event.setCancelled(true);
return;
}
Random rand = new Random();
if(offItem.getType() == Material.GOLD_HOE)
{
if(event.getDamager() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
{
LivingEntity enemy = (LivingEntity)event.getDamager();
enemy.damage(event.getDamage() * 40 / 100, player);
}
int chance_reduceDur = rand.nextInt(10) + 1;
switch(chance_reduceDur)
{
case 1:
offItem.setDurability((short)(offItem.getDurability() + 1));
break;
default:
}
if(offItem.getDurability() >= 32)
{
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getInventory().setItemInOffHand(null);
}
}
}
}