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


Java EntityDamageByEntityEvent类代码示例

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

EntityDamageByEntityEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityDamageByEntityEvent类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    Entity damager = event.getDamager();
    if (entity instanceof Player && damager instanceof Player) {
        Player attacker = (Player) damager;
        if (plugin.getPvpClassManager().getEquippedClass(attacker) == this) {
            ItemStack stack = attacker.getItemInHand();
            if (stack != null && stack.getType() == Material.GOLD_SWORD && stack.getEnchantments().isEmpty()) {
                Player player = (Player) entity;
                player.sendMessage(SettingsYML.ENEMY_COLOUR + attacker.getName() + ChatColor.YELLOW + " has backstabbed you.");
                player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                attacker.sendMessage(ChatColor.YELLOW + "You have backstabbed " + SettingsYML.ENEMY_COLOUR + player.getName() + ChatColor.YELLOW + '.');
                attacker.setItemInHand(new ItemStack(Material.AIR, 1));
                player.setHealth(12);
                attacker.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);

                event.setDamage(3.0);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:24,代码来源:RogueClass.java


示例17: onPlayerKillsPlayer

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerKillsPlayer(EntityDamageByEntityEvent e) {
	if (!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player))
		return;

	Player killer = (Player) e.getDamager();
	Player target = (Player) e.getEntity();

	// Check if the target is dead
	if (target.getHealth() - e.getDamage() <= 0) {
		PlayerObject killerObject = main.getPlayerManager().getMortuusPlayer(killer.getUniqueId());

		// Sets the time in SECONDS.
		killerObject.setLastPlayerKillTime(System.currentTimeMillis() / 1000);
		killerObject.addPlayerKills(1);

		for (PKStates state : PKStates.values()) {
			if (killerObject.getPlayerKills() == state.getRequiredKills()) {
				killerObject.setPkState(state);
				main.getScoreboards().switchTeam(killer, state.name());
				break;
			}
		}
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:26,代码来源:PlayerListener.java


示例18: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player) {
        Player attacker = BukkitUtils.getFinalAttacker(event, true);
        if (attacker == null)
            return;

        long remaining;
        Player player = (Player) entity;
        if ((remaining = getRemaining(player)) > 0L) {
            event.setCancelled(true);
            attacker.sendMessage(ChatColor.RED + player.getName() + " has their " + getDisplayName() + ChatColor.RED + " timer for another " + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + '.');

            return;
        }

        if ((remaining = getRemaining(attacker)) > 0L) {
            event.setCancelled(true);
            attacker.sendMessage(ChatColor.RED + "You cannot attack players whilst your " + getDisplayName() + ChatColor.RED + " timer is active [" + ChatColor.BOLD
                    + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + " remaining]. Use '" + ChatColor.GOLD + PVP_COMMAND + ChatColor.RED + "' to allow pvp.");
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:26,代码来源:InvincibilityTimer.java


示例19: 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);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:22,代码来源:ObsidianMaceWeakness.java


示例20: 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);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:21,代码来源:StarBattleaxeWither.java


示例21: damage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public void damage(double amount, Entity source)
{
	Map<DamageModifier, Double> modifiers = new EnumMap<>(DamageModifier.class);
	modifiers.put(DamageModifier.BASE, 1.0);
	Map<DamageModifier, Function<Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
	modifierFunctions.put(DamageModifier.BASE, damage -> damage);
	
	EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(source, this, DamageCause.ENTITY_ATTACK, modifiers, modifierFunctions);
	event.setDamage(amount);
	Bukkit.getPluginManager().callEvent(event);
	if (!event.isCancelled())
	{
		setHealth(health - amount);
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:17,代码来源:PlayerMock.java


示例22: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	if ((event.getDamager() instanceof Player)) {
		Player p = (Player)event.getDamager();

		if (Kit.getKit(p).getName().equalsIgnoreCase("woodcutter") && (p.getItemInHand().getType().name().contains("_AXE"))) {
			Random r = new Random();

			double multiplier = 1.0D + 1.0D * r.nextDouble() - r.nextDouble() + 0.5D;

			if (multiplier < 1.0D)
				multiplier = 1.0D;
			if (multiplier >= 2.0D) {
				multiplier = 2.0D;
			}
			event.setDamage((int)(event.getDamage() * multiplier));
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:20,代码来源:KitEvents.java


示例23: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	if (event.getDamager() instanceof Player == false)
		return;
	
	PetInstance pet = PetInstance.get(event.getEntity());
	
	if (pet == null)
		return;
	
	event.setCancelled(true);
	
	if (pet.getOwner().equalsIgnoreCase(((Player) event.getDamager()).getName())) {
		Chat.player((Player) event.getDamager(), "&2[Pets] &aYou have removed your pet. Spawn it with &b/pet spawn");
		pet.despawn();
		pet.setToSpawn(false);
	}
	else {
		Chat.player((Player) event.getDamager(), "&2[Pets] &cBuy pets at www.mczone.co/shop");
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:22,代码来源:PetEvents.java


示例24: onDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onDamage(EntityDamageByEntityEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!(e.getDamager() instanceof Player)) {
        return;
    }
    Player p = (Player) e.getDamager();
    long left = CooldownManager.getInstance().getLeft(p, 3000);
    if (left == 0) {
        CooldownManager.getInstance().add(p);
        return;
    }
    e.setCancelled(true);
    p.sendMessage(Messages.prefix + Messages.Cooldown.replace("%time%", String.valueOf(left)));
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:18,代码来源:PlayerListener.java


示例25: onEntityDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
	if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Enable")) {
		if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Options.Entity.Enable")) {
      if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.Options.Entity.EntityDamageByEntity")) {
      	if (!ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Damage.World.All_World")) {
      		if (WorldUtils.getWD().contains(e.getEntity().getWorld().getName())) {
      			e.setCancelled(true);
      			if (e.getEntity() instanceof ItemFrame) {
      			      e.setCancelled(true);
      			}
      		}
      	} else {
      		e.setCancelled(true);
      		if (e.getEntity() instanceof ItemFrame) {
     			      e.setCancelled(true);
     			}
      	}
      }
		}
	}
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:23,代码来源:BasicFeatures.java


示例26: onPlayerDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true) // Prevent players from being damaged in the party world unless in a game.
public void onPlayerDamage(EntityDamageEvent evt) {
    if (!isParty(evt.getEntity()))
        return;

    if (!(evt.getEntity() instanceof LivingEntity))
        evt.setCancelled(true); // Default to no damage, if the entity isn't alive.

    if (!(evt.getEntity() instanceof Player))
        return; // If the damaged isn't a player, ignore this next bit that may uncancel it.
    Player p = (Player) evt.getEntity();
    evt.setCancelled(!checkParty(p, PartyGame::allowDamage));
    if (evt instanceof EntityDamageByEntityEvent) { // Handle combat differently.
        EntityDamageByEntityEvent dmg = (EntityDamageByEntityEvent) evt;
        boolean isMob = evt.getEntity() instanceof Creature;
        boolean isPlayer = dmg.getEntity() instanceof Player && dmg.getDamager() instanceof Player;
        evt.setCancelled((!checkParty(p, PartyGame::allowMobCombat) && isMob) || (!checkParty(p, PartyGame::allowPlayerCombat) && isPlayer));
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:20,代码来源:Parties.java


示例27: 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));
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:13,代码来源:KillauraB.java


示例28: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
	if(!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player))
		return;
	
	Player player = (Player) event.getDamager();
	Player victim = (Player) event.getEntity();
	
	if(!Utility.canAttack(player, victim))
		return;
	
	ItemStack item = player.getInventory().getItemInMainHand();
	if(item == null)
		return;
	if(!plugin.getAbilityManager().hasAbility(item))
		return;
	
	Ability ability = plugin.getAbilityManager().getAbility(item);
	
	switch(ability.getName()) {
		case "Poison":
			handlePoison(player, victim);
			return;
		case "Flame":
			handleFlame(player, victim);
			return;
		default:
			return;
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:31,代码来源:AbilityListener.java


示例29: onPlayerHitDungeonDisplay

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerHitDungeonDisplay(EntityDamageByEntityEvent event) {
    if (event.getEntityType() == EntityType.ENDER_CRYSTAL) {
        if (event.getDamager() instanceof Player)
            handleBossSpawn(event.getDamager(), event.getEntity());
        event.setCancelled(true);
    } else if (event.getEntityType() == EntityType.ARMOR_STAND) {
        if (event.getDamager() instanceof Player)
            handleRewards(event.getDamager(), event.getEntity());
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:12,代码来源:DungeonManager.java


示例30: onPlayerHitBuffEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public static void onPlayerHitBuffEvent(EntityDamageByEntityEvent event) {
    if (event.getEntityType() == EntityType.ENDER_CRYSTAL) {
        if (event.getDamager() instanceof Player)
            handleBuff(event.getDamager(), event.getEntity());
        else if (event.getDamager() instanceof Projectile) {
            if (((Projectile) event.getDamager()).getShooter() instanceof Player)
                handleBuff(((Player) ((Projectile) event.getDamager()).getShooter()), event.getEntity());
        }
        event.setCancelled(true);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:13,代码来源:BuffManager.java


示例31: 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);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:11,代码来源:CoreListener.java


示例32: onDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onDamageByEntity(EntityDamageByEntityEvent event) {
	if (event.isCancelled()) {
		return;
	}
	if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
		Game game = Chambers.getInstance().getGameManager().getGame();
		if (game.getInvincibilityTime() > 0) {
			Player damager = (Player) event.getDamager();
			damager.sendMessage(ChatColor.RED + "The invincibility timer is still on.");
			event.setCancelled(true);
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:15,代码来源:GameDamageListener.java


示例33: offenseEffect

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public void offenseEffect(LivingEntity user, LivingEntity target, EntityDamageByEntityEvent event){

    int randomNum = ThreadLocalRandom.current().nextInt(1, 6 + 1);
    switch (randomNum){
        case 4:
            target.getLocation().getWorld().strikeLightning(target.getLocation());
            break;
    }
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:11,代码来源:ThunderingStrike.java


示例34: offenseEffect

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@Override
public void offenseEffect(LivingEntity user, LivingEntity target, EntityDamageByEntityEvent event){
    double health = user.getHealth();
    if (health == 3.0 || health == 2.5) {
        event.setDamage(event.getDamage() + 0.5);
    } else if (health == 2.0 || health == 1.5) {
        event.setDamage(event.getDamage() + 1.0);
    } else if (health == 1.0){
        event.setDamage(event.getDamage() + 1.5);
    } else if (health == 0.5){
        event.setDamage(event.getDamage() + 2.0);
    }

}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:15,代码来源:LastHope.java


示例35: onDamage

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
	// Cancelling team damage
	if(event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
		Player victim = (Player) event.getEntity();
		Player damager = (Player) event.getDamager();
		if(!Utility.canAttack(victim, damager)){
			event.setCancelled(true);
		}
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:12,代码来源:PlayerListener.java


示例36: onEntityDamageByEntity

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.getDamager() instanceof Player) {
        Player player = (Player) event.getDamager();
        if (isClaimingWand(player.getItemInHand())) {
            player.setItemInHand(new ItemStack(Material.AIR, 1));
            plugin.getClaimHandler().clearClaimSelection(player);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:11,代码来源:ClaimWandListener.java


示例37: ArmorStandDestroy

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void ArmorStandDestroy(EntityDamageByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + "IslandGuard New " + e.getEventName());
    }
    if (!(e.getEntity() instanceof LivingEntity)) {
        return;
    }
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    final LivingEntity livingEntity = (LivingEntity) e.getEntity();
    if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) {
        return;
    }
    if (e.getDamager() instanceof Player) {
        Player p = (Player) e.getDamager();
        if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        // Check if on island
        if (plugin.getIslands().playerIsOnIsland(p)) {
            return;
        }
        // Check island
        Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        if (island != null && island.getFlag(SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:37,代码来源:IslandGuard1_8.java


示例38: 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);
	}
}
 
开发者ID:SamaGames,项目名称:Absorption,代码行数:14,代码来源:PlayerListener.java


示例39: weakDamageDirectWithGun

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入依赖的package包/类
/**
 * Doesn't seem to work right now but basically, if you smack someone over the head
 * with the gun instead of shoot it, do less damage.
 * 
 * @param event The hit event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void weakDamageDirectWithGun(EntityDamageByEntityEvent event) {
	if (event.getDamager() instanceof LivingEntity) {
		LivingEntity damager = (LivingEntity) event.getDamager();
		EntityEquipment equips = damager.getEquipment();
		StandardGun gun = findGun(equips.getItemInMainHand());
		if (gun != null) {
			// modify damage!
			event.setDamage(gun.getBluntDamage());
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:19,代码来源:Guns.java



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