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


Java EntityDamageByEntityEvent.getDamager方法代码示例

本文整理汇总了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()))));
					}
				}
			}
		}
	}
}
 
开发者ID:masste,项目名称:McPlayUHC,代码行数:20,代码来源:EntityDamageByEntityListener.java

示例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;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:20,代码来源:ProjectileDamageResolver.java

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

示例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);
		}
	}
}
 
开发者ID:OverloadedCore,项目名称:kaosEssentials,代码行数:12,代码来源:Core.java

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

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

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

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

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

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

示例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));
    }
}
 
开发者ID:Project-Coalesce,项目名称:UHC,代码行数:15,代码来源:ArcheryHandler.java

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

示例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);
}
 
开发者ID:cjburkey01,项目名称:ClaimChunk,代码行数:9,代码来源:CancellableChunkEvents.java

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

示例15: ZzzzPlayerAttackEvent

import org.bukkit.event.entity.EntityDamageByEntityEvent; //导入方法依赖的package包/类
public ZzzzPlayerAttackEvent(EntityDamageByEntityEvent event, DamageCause cause) {
    damager = event.getDamager();
    damagee = event.getEntity();
    this.cause = cause;
}
 
开发者ID:IzzelAliz,项目名称:TalentZzzz,代码行数:6,代码来源:ZzzzPlayerAttackEvent.java


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