當前位置: 首頁>>代碼示例>>Java>>正文


Java DamageCause.WITHER屬性代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.WITHER屬性的典型用法代碼示例。如果您正苦於以下問題:Java DamageCause.WITHER屬性的具體用法?Java DamageCause.WITHER怎麽用?Java DamageCause.WITHER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.event.entity.EntityDamageEvent.DamageCause的用法示例。


在下文中一共展示了DamageCause.WITHER屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerDeath

@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
	if (event.getEntity().getLastDamageCause() != null) {
		if (event.getEntity().getLastDamageCause().getCause() == DamageCause.WITHER) {
			if (plugin.getValueManager().getValue(FoodType.PROTEIN, event.getEntity()) <= -6) {
				event.setDeathMessage(Broadcast.getMsg(Message.DEATH_PROTEINS_LACK));
				plugin.getValueManager().resetValues(event.getEntity());
				return;
			}
		}
	}
	
	Player player = (Player) event.getEntity();
	String uuid = player.getUniqueId().toString();
	
	if (plugin.getDeathMessages().getDeathMessageBans().contains(uuid)) {
		event.setDeathMessage(null);
		plugin.getDeathMessages().getDeathMessageBans().remove(uuid);
	}
	
	plugin.getValueManager().resetValues(player);
}
 
開發者ID:SugarCaney,項目名稱:FoodBalance,代碼行數:22,代碼來源:DeathListener.java

示例2: onPlayerDeath

@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onPlayerDeath(EntityDamageEvent event) {
	if ((event.getCause() == DamageCause.MAGIC || 
			event.getCause() == DamageCause.WITHER) && 
			event.getEntity() instanceof Player &&
			((Player)event.getEntity()).getHealth() - event.getDamage() <= 0) {
		Player player = (Player) event.getEntity();
		for (AffectedPlayer ap : affected) {
			if (ap.getAffectee() == player && player.hasPotionEffect(ap.getEffect().getType())) {
				event.setCancelled(true);
				player.damage(event.getDamage(), ap.getAffecter());
				affected.remove(player.getName());
			}
		}
	}
}
 
開發者ID:EvilKanoa,項目名稱:RodsTwo,代碼行數:16,代碼來源:Curse.java

示例3: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if (invulnerable || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if (source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if (source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if (damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if (damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if (source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if (source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if (source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if (source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if (source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if (source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if (source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if (source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if (source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if (source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if (cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if (super.damageEntity(source, damage)) {
        if (bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:johnnywoof,項目名稱:NoHack,代碼行數:71,代碼來源:NPCEntity.java

示例4: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if(godmode || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if(source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if(source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if(damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if(damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if(source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if(source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if(source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if(source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if(source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if(source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if(source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if(source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if(source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if(source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if(cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(this, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if(!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if(super.damageEntity(source, damage)) {
        if(bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for(d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:lenis0012,項目名稱:NPCFactory,代碼行數:71,代碼來源:NPCEntity.java

示例5: onSteveHurt

@EventHandler
public void onSteveHurt(EntityDamageEvent e) {
	if(e.getEntity() instanceof Player) {
		Player p = (Player) e.getEntity();
		//p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
		if(e.getCause() == DamageCause.BLOCK_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.DROWNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_ATTACK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALL) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALLING_BLOCK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FIRE_TICK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.LIGHTNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.MELTING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.POISON) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.PROJECTILE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.STARVATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUFFOCATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUICIDE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.THORNS) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.VOID) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.WITHER) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		}
	}
}
 
開發者ID:xize,項目名稱:xEssentials_old_Source,代碼行數:59,代碼來源:steveHurtSound.java


注:本文中的org.bukkit.event.entity.EntityDamageEvent.DamageCause.WITHER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。