本文整理汇总了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()))));
}
}
}
}
}
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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.
}
}
示例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;
}
示例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));
}
}
}
}
示例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 + ".");
}
}
}
示例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()));
}
}
示例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);
}
}
示例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);
}*/
}
示例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);
}
}
示例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);
}
});
}
}
}
示例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());
}
}