本文整理汇总了Java中org.bukkit.event.entity.EntityDamageByEntityEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageByEntityEvent.getEntity方法的具体用法?Java EntityDamageByEntityEvent.getEntity怎么用?Java EntityDamageByEntityEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDamageByEntityEvent
的用法示例。
在下文中一共展示了EntityDamageByEntityEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDamageEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamageEntity(EntityDamageByEntityEvent e){
Player p;
if (e.getDamager() instanceof Player && e.getEntity() instanceof Zombie){
p = (Player)e.getDamager();
Weapon weapon;
if (p.getInventory().getItemInMainHand() == null || !Weapon.isWeapon(p.getInventory().getItemInMainHand())) return;
if (Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand()) == null) {
e.setDamage(0);
return;
}
weapon = Weapon.getWeaponByItemStack(p.getInventory().getItemInMainHand());
if (weapon.getId() != 0) return;
e.setDamage(((Zombie) e.getEntity()).getMaxHealth());
}
if (e.getDamager() instanceof Zombie && e.getEntity() instanceof Player) {
p = (Player) e.getEntity();
if (this.plugin.getBlooding().contains(new TWDPlayer(p.getUniqueId()))) return;
this.plugin.getBlooding().add(new TWDPlayer(p.getUniqueId()));
}
}
示例2: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Player attacker = getDamageSource(event.getDamager());
Entity eDefender = event.getEntity();
if (!(eDefender instanceof Player)) {
forbidIfInProtectedTerritory(attacker, eDefender, event, ATTACK);
return;
}
Player defender = (Player) eDefender;
Faction aFaction = plugin.getFactionCache().getByMember(attacker);
Faction dFaction = plugin.getFactionCache().getByMember(defender);
Faction rFaction = plugin.getFactionCache().getByLocation(defender.getLocation());
if (aFaction.getRelation(dFaction).isProtected()) {
ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_PLAYER.getMessage(), dFaction);
event.setCancelled(true);
} else if (rFaction != null && rFaction.getRelation(dFaction).isProtected()) {
if (plugin.getFConfig().isTerritoryProtectionEnabled() && (!plugin.getFConfig().isCapitalProtectionEnabled()
|| rFaction.getCapital().equals(plugin.getBoard().getByLocation(eDefender.getLocation())))) {
ParsingUtil.sendMessage(attacker, FMessage.PROTECTION_CANNOT_ATTACK_FACTION.getMessage(), rFaction);
event.setCancelled(true);
} else if (plugin.getFConfig().getTerritoryShield() != 0) {
event.setDamage(event.getDamage() * plugin.getFConfig().getTerritoryShield());
}
}
}
示例3: onProjectileHurtEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHurtEvent(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof LivingEntity)) return;
final LivingEntity damagedEntity = (LivingEntity) event.getEntity();
final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(event.getDamager());
if(projectileDefinition == null) return;
if(!projectileDefinition.potion().isEmpty()) {
damagedEntity.addPotionEffects(projectileDefinition.potion());
}
if(projectileDefinition.damage() != null) {
event.setDamage(projectileDefinition.damage());
}
}
示例4: onTag
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onTag(EntityDamageByEntityEvent e)
{
if ((!(e.getEntity() instanceof Player)) || (!(e.getDamager() instanceof Player))) {
return;
}
Player staff = (Player)e.getDamager();
if (modMode.contains(staff.getName())) {
e.setCancelled(true);
}
}
示例5: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof EnderCrystal) || event.getEntity().getWorld().getEnvironment() != Environment.THE_END
|| !entity.isInvulnerable()) return;
event.setCancelled(true);
}
示例6: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
/**
* Removes the hit cooldown upon a player attack and reduces the amount of damage dealt according to a modifier.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player
&& event.getDamager() instanceof Player
&& event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)) {
event.setDamage(event.getDamage() * damageReduction);
Bukkit.getScheduler().runTask(OpenUHC.getInstance(), () -> ((Player) entity).setNoDamageTicks(0));
}
}
示例7: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Player attacker = BukkitUtils.getFinalAttacker(event, true);
Entity entity;
if (attacker != null && (entity = event.getEntity()) instanceof Player) {
Player attacked = (Player) entity;
setCooldown(attacker, attacker.getUniqueId(), defaultCooldown, false);
setCooldown(attacked, attacked.getUniqueId(), defaultCooldown, false);
}
}
示例8: onEntityDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
e.setCancelled(true);
if(e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
GamePlayer damager = Absorption.getPlayer((Player) e.getDamager());
GamePlayer player = Absorption.getPlayer((Player) e.getEntity());
if(damager == null || player == null) return;
player.hitByPlayer(damager);
}
}
示例9: onEntityDamageByEntityEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player && !(e.getEntity() instanceof ArmorStand)) {
((Player) e.getDamager()).sendMessage(ChatColor.GRAY + "You did " + Math.round(e.getDamage()) + ChatColor.RED + " \u2764 " + ChatColor.GRAY + "to " + e.getEntity().getName());
}
if (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof Player) {
((Player) (((Projectile) e.getDamager()).getShooter())).sendMessage(ChatColor.GRAY + "You did " + Math.round(e.getDamage()) + ChatColor.RED + " \u2764 " + ChatColor.GRAY + "to " + e.getEntity().getName());
}
}
示例10: checkItemFrameItemRemove
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameItemRemove(EntityDamageByEntityEvent event) {
// This event is fired when popping an item out of an item frame, without breaking the frame itself
if(event.getEntity() instanceof ItemFrame && ((ItemFrame) event.getEntity()).getItem() != null) {
this.handleHangingBreak(event, (Hanging) event.getEntity(), event.getDamager());
}
}
示例11: onEntityDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
/**
* Set NoDamageTicks to 0 on player -> player damage
*
* @param event Event
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByEntityEvent event)
{
if (!(event.getEntity() instanceof Player) || (!(event.getDamager() instanceof Player)) && !(event.getDamager() instanceof Projectile))
return;
((Player) event.getEntity()).setNoDamageTicks(0);
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> ((Player)event.getEntity()).setNoDamageTicks(0), 1);
}
示例12: onPlayerDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDamage(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player && BukkitUtils.getFinalAttacker(event, false) != null) {
Player player = (Player) entity;
if (plugin.getPvpClassManager().hasClassEquipped(player, this)) {
removeInvisibilitySafely(player);
}
}
}
示例13: onHangingDamageByEntity
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onHangingDamageByEntity(final EntityDamageByEntityEvent event) {
final Entity entity = event.getEntity();
if (entity instanceof Hanging) {
final Player attacker = BukkitUtils.getFinalAttacker((EntityDamageEvent)event, false);
if (!attemptBuild((Entity)attacker, entity.getLocation(), ChatColor.GRAY + "You may not build in the territory of %1$s" + ChatColor.GRAY + '.')) {
event.setCancelled(true);
}
}
}
示例14: onEntityDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler()
public void onEntityDamage(EntityDamageByEntityEvent e) {
if (!ClaimChunk.getInstance().getChunkHandler().isClaimed(e.getEntity().getLocation().getChunk())) {
return;
}
if (e.getDamager() instanceof Player && e.getEntity() instanceof Animals)
ChunkHelper.cancelAnimalDamage((Player) e.getDamager(), e.getDamager().getLocation().getChunk(), e);
}
示例15: onDamaged
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamaged(EntityDamageByEntityEvent event)
{
if(event.isCancelled()) return;
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
healing.getScore(player).setScore(0);
}
}