当前位置: 首页>>代码示例>>Java>>正文


Java EntityDamageByEntityEvent类代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityDamageByEntityEvent的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageByEntityEvent类的具体用法?Java EntityDamageByEntityEvent怎么用?Java EntityDamageByEntityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntityDamageByEntityEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityDamageByEntityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()))));
					}
				}
			}
		}
	}
}
 
开发者ID:masste,项目名称:McPlayUHC,代码行数:20,代码来源:EntityDamageByEntityListener.java

示例2: call

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof EntityDamageByEntityEvent) {
		final EntityDamageByEntityEvent edbe = (EntityDamageByEntityEvent) event;

		if (edbe.getEntity() instanceof LivingEntity) {
			final LivingEntity le = (LivingEntity) edbe.getEntity();

			final Location eye = profile.getPlayer().getEyeLocation();

			final double yawBetween = Helper.getYawBetween(eye, le.getLocation());
			final double playerYaw = profile.getPlayer().getEyeLocation().getYaw();

			final double angleBetween = Math.abs(180 - Math.abs(Math.abs(yawBetween - playerYaw) - 180));

			callback(angleBetween >= DISALLOWED_ANGLE && previousAngles.size() >= NEEDED_SAMPLES
					&& getAverageAngle() >= DISALLOWED_ANGLE);

			previousAngles.put(angleBetween, System.currentTimeMillis());
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:23,代码来源:KillauraC.java

示例3: resolve

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
            Double projectileDistance = null;

            if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);

            if(projectile.getShooter() instanceof LivingEntity) {
                return new ProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance);
            }
        }
    }
    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:20,代码来源:ProjectileDamageResolver.java

示例4: resolve

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
            Double projectileDistance = null;
            OfflinePlayer dispenserOwner = dispenserTracker.getOwner(projectile);


            if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);

            if(projectile.getShooter() instanceof LivingEntity) {
                return new DispensedProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance, dispenserOwner);
            }
        }
    }
    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:22,代码来源:DispensedProjectileDamageResolver.java

示例5: resolve

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof TNTPrimed) {
            TNTPrimed tnt = (TNTPrimed) event.getDamager();
            Player owner = null;
            if(this.explosiveTracker.hasOwner(tnt)) {
                owner = this.explosiveTracker.getOwner(tnt);
            } else if(this.dispenserTracker.hasOwner(tnt)) {
                // getPlayer() is temporary to keep owner uniform until other services use OfflinePlayer
                owner = this.dispenserTracker.getOwner(tnt).getPlayer();
            }

            return new TNTDamageInfo(tnt, owner);
        }
    }

    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:22,代码来源:TNTDamageResolver.java

示例6: onPvP

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPvP(EntityDamageByEntityEvent evt) {
    if (Parties.isParty(evt.getDamager()))
        return;

    Player attacker = evt.getDamager() instanceof Player ? (Player) evt.getDamager() :
            (evt.getDamager() instanceof Projectile && ((Projectile) evt.getDamager()).getShooter() instanceof Player
            ? (Player) ((Projectile) evt.getDamager()).getShooter() : null); // Yuck, maybe we can make a method for this later.
    if (attacker == null || !(evt.getEntity() instanceof Player))
        return; // One or both of the combatants isn't a player.

    boolean outgoingFail = !getToggle(attacker, Toggle.PVP);
    boolean incomingFail = !getToggle(evt.getEntity(), Toggle.PVP);

    if (outgoingFail || incomingFail) {
        attacker.sendMessage(ChatColor.RED + (outgoingFail ? "You have PvP disabled. (/togglepvp)"
                : evt.getEntity().getName() + " has PvP disabled."));
        evt.setCancelled(true);
        evt.getEntity().setFireTicks(-1); // Disable fire damage.
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:22,代码来源:Toggles.java

示例7: resolve

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent && damageEvent.getCause() == DamageCause.ENTITY_ATTACK) {
        EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) damageEvent;

        if(entityEvent.getDamager() instanceof LivingEntity) {
            LivingEntity attacker = (LivingEntity) entityEvent.getDamager();

            Material weaponMaterial;
            ItemStack held = attacker.getEquipment().getItemInMainHand();
            if(held != null) {
                weaponMaterial = held.getType();
            } else {
                weaponMaterial = Material.AIR;
            }

            return new SimpleMeleeDamageInfo(attacker, weaponMaterial);
        }
    }

    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:23,代码来源:MeleeDamageResolver.java

示例8: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.getDamager() instanceof Player) {
        if (event.getEntity() != null && npcs.containsKey(event.getEntity().getUniqueId())) {
            event.setCancelled(true);
            Player p = (Player) (event.getDamager());
            if (plugin.getPD(p) != null) {
                if (lastClick.containsKey(p.getUniqueId())) {
                    if (System.currentTimeMillis() - lastClick.get(p.getUniqueId()) < 333) {
                        return;
                    }
                }
                lastClick.put(p.getUniqueId(), System.currentTimeMillis());
                npcs.get(event.getEntity().getUniqueId()).interact(p, plugin.getPD(p));
            }
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:19,代码来源:NPCManager.java

示例9: onDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onDamageByEntity(EntityDamageByEntityEvent event) {
	if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
		Player player = (Player) event.getEntity();
		Player damager = (Player) event.getDamager();
		Profile playerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(player.getUniqueId());
		Profile damagerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(damager.getUniqueId());
		if (playerProfile.getTeam() == null || damagerProfile.getTeam() == null || playerProfile.getProfileStatus() != ProfileStatus.PLAYING || damagerProfile.getProfileStatus() != ProfileStatus.PLAYING) {
			event.setCancelled(true);
			damager.sendMessage(ChatColor.RED + "You cannot do this in your current state.");
			return;
		}
		if (playerProfile.getTeam() == damagerProfile.getTeam()) {
			event.setCancelled(true);
			damager.sendMessage(ChatColor.YELLOW + "You cannot hurt " + damagerProfile.getTeam().getColor() + player.getName() + ChatColor.YELLOW + ".");
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:19,代码来源:TeamDamageListener.java

示例10: 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()));
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:27,代码来源:Weapons.java

示例11: onEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
	if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
		e.setDamage(e.getDamage() + damage);
		if (effect != null) {

			((LivingEntity) e.getEntity()).addPotionEffect(effect);
		}
	}
	if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
		e.setDamage(e.getDamage() + damage);
	}
	if ((e.getDamager() instanceof Snowball) && (((Snowball) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == name) {
		e.setDamage(e.getDamage() + damage);
	}

}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:18,代码来源:LongRangeWeapon.java

示例12: onEntityByEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityByEntityDamage(EntityDamageByEntityEvent e) {
	/*if ((e.getDamager() instanceof Fireball) && (((Fireball) e.getDamager()).getShooter() instanceof Player)) {
   		e.setDamage(20.0);
   	}

   	if ((e.getDamager() instanceof SmallFireball) && (((SmallFireball) e.getDamager()).getShooter() instanceof Player)) {
   		e.setDamage(100.0);
   	}*/
	/*if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == "S1D") {
   		e.setDamage(e.getDamage() + 4);
   	}
   	if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == "S10D") {
   		e.setDamage(e.getDamage() + 20);
   	}
   	if ((e.getDamager() instanceof Arrow) && (((Arrow) e.getDamager()).getShooter() instanceof Player) && e.getDamager().getCustomName() == "A1D") {
   		e.setDamage(e.getDamage() + 2);
   	}*/


}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:22,代码来源:SuperiorCraft.java

示例13: onEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
void onEvent(EntityDamageEvent event) {
    if(event.getEntity() == player.getBukkit()) {
        // Player took damage
        mutateStamina(options.mutators.injury);

    } else if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK &&
              event instanceof EntityDamageByEntityEvent &&
              ((EntityDamageByEntityEvent) event).getDamager() == player.getBukkit()) {

        // Player is damager and attack is melee
        swinging = false;

        for(StaminaSymptom symptom : getActiveSymptoms()) {
            symptom.onAttack(event);
        }

        mutateStamina(options.mutators.meleeHit);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:PlayerStaminaState.java

示例14: onEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    if(event.getEntity() instanceof Player) {
        Player victim = (Player) event.getEntity();
        Location location = victim.getBoundingBox().center().toLocation(match.getWorld());
        if(event.getDamage() > 0 && location.getY() >= 0 && !victim.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
            EntityUtils.entities(match.getWorld(), Player.class)
                 .filter(player -> settings.getManager(player).getValue(Settings.BLOOD, Boolean.class, false))
                 .forEach(player -> {
                     if(event instanceof EntityDamageByEntityEvent) {
                         player.playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
                     } else {
                         player.playEffect(location, Effect.STEP_SOUND, Material.LAVA);
                     }
                 });
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:BloodMatchModule.java

示例15: 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());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:ProjectileMatchModule.java


注:本文中的org.bukkit.event.entity.EntityDamageByEntityEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。