本文整理汇总了Java中org.bukkit.event.entity.EntityDamageByEntityEvent.getDamager方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageByEntityEvent.getDamager方法的具体用法?Java EntityDamageByEntityEvent.getDamager怎么用?Java EntityDamageByEntityEvent.getDamager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDamageByEntityEvent
的用法示例。
在下文中一共展示了EntityDamageByEntityEvent.getDamager方法的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: 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;
}
示例3: onDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageByEntityEvent event) {
// 处理实体受伤是实体所为事件
Entity entity = event.getEntity();
Entity damager = event.getDamager();
if(damager instanceof Snowball) {
Snowball snowball = (Snowball) damager;
if(snowball.getShooter() instanceof Player) {
event.setDamage(10d);
}
}
}
示例4: onHit
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST)
public void onHit(EntityDamageByEntityEvent e) {
if(e.isCancelled())return;
if (e.getEntity() instanceof Player && e.getDamager() instanceof Player) {
// Player to = (Player) e.getEntity();
Player by = (Player) e.getDamager();
if (!e.isCancelled()) {
by.giveExp(5);
}
}
}
示例5: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@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 item = player.getItemInHand();
if(item.getType() == Material.WOOD_SPADE)
{
item.setDurability((short)(item.getDurability() - 2));
}
}
}
示例6: entityDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void entityDamage(final EntityDamageEvent event) {
if(!(event instanceof EntityDamageByEntityEvent)) return;
EntityDamageByEntityEvent realEvent = (EntityDamageByEntityEvent) event;
if(!(realEvent.getDamager() instanceof Player) || !(realEvent.getEntity() instanceof Player)) return;
final Player damager = (Player) realEvent.getDamager();
final Player victim = (Player) realEvent.getEntity();
if(victim.hasPermission(GizmoConfig.EXEMPT_PERMISSION)) return;
if(!(Gizmos.gizmoMap.get(damager) instanceof PopperGizmo)) return;
if(damager.getItemInHand().getType() != this.getIcon()) return;
if(!damager.canSee(victim)) return;
damager.hidePlayer(victim);
damager.playSound(damager.getLocation(), Sound.BLOCK_LAVA_POP, 1f, 2f);
Integer count = poppedCount.get(damager);
if(count == null) count = 0;
count++;
poppedCount.put(damager, count);
if(count % 10 == 0) {
RaindropUtil.giveRaindrops(
Users.playerId(damager), 1, null,
new TranslatableComponent("gizmo.popper.raindropsResult", new Component(String.valueOf(count), net.md_5.bungee.api.ChatColor.GOLD))
);
}
event.setCancelled(true);
}
示例7: 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);
}
}
示例8: onAttack
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onAttack(EntityDamageByEntityEvent e) {
if(!(e.getDamager() instanceof Player) || !(e.getEntity() instanceof Player)) {
return;
}
Player p = (Player) e.getEntity();
Player attacker = (Player) e.getDamager();
for(PotionEffect effect : attacker.getActivePotionEffects()) {
if(effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
e.setDamage(e.getDamage() - (3 * effect.getAmplifier()));
}
}
}
示例9: onPlayerDamage
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDamage(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
if ((damager instanceof Player && ItemUtils.isWeapon(((Player) damager).getItemInHand())) ||
(damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Player)) {
event.setDamage(DAMAGE);
}
}
示例10: 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());
}
}
}
示例11: playerShotEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void playerShotEvent(final EntityDamageByEntityEvent event) {
if (GameState.current() == GameState.LOBBY || GameState.current() == GameState.ENDED) {
return;
}
if (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE && event.getDamager() instanceof Arrow &&
((Arrow) event.getDamager()).getShooter() instanceof Player && event.getEntity() instanceof Player) {
Player shot = (Player) event.getEntity();
Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
shooter.sendMessage(ChatColor.GRAY + "➵ " + ChatColor.AQUA + shot.getName() + " " + ChatColor.RED +
new BigDecimal(shot.getHealth() / 2).setScale(1, BigDecimal.ROUND_HALF_UP));
}
}
示例12: onPlayerHitNPC
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerHitNPC(EntityDamageByEntityEvent event)
{
if (Reflection.getHandle(event.getEntity()) instanceof CustomNPC && event.getDamager() instanceof Player)
{
CustomNPC npc = (CustomNPC) Reflection.getHandle(event.getEntity());
npc.onInteract(false, (Player) event.getDamager());
}
}
示例13: 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);
}
示例14: 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 (isSubclaimWand(player.getItemInHand())) {
player.setItemInHand(new ItemStack(Material.AIR, 1));
plugin.getClaimHandler().clearClaimSelection(player);
}
}
}
示例15: ZzzzPlayerAttackEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
public ZzzzPlayerAttackEvent(EntityDamageByEntityEvent event, DamageCause cause) {
damager = event.getDamager();
damagee = event.getEntity();
this.cause = cause;
}