當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。