當前位置: 首頁>>代碼示例>>Java>>正文


Java DamageCause.PROJECTILE屬性代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.PROJECTILE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DamageCause.PROJECTILE屬性的具體用法?Java DamageCause.PROJECTILE怎麽用?Java DamageCause.PROJECTILE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.event.entity.EntityDamageEvent.DamageCause的用法示例。


在下文中一共展示了DamageCause.PROJECTILE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EntityDamageByEntityListener

@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,代碼行數:19,代碼來源:EntityDamageByEntityListener.java

示例2: onDamageGet

@EventHandler(priority=EventPriority.MONITOR)
public void onDamageGet(EntityDamageEvent e) {
	if (!e.isCancelled()) {
		if (e instanceof EntityDamageByEntityEvent) {
			if (((EntityDamageByEntityEvent) e).getDamager() instanceof Player && SlimefunStartup.chance(100, 45)) {
				if (SlimefunManager.isItemSimiliar(((Player) ((EntityDamageByEntityEvent) e).getDamager()).getInventory().getItemInMainHand(), SlimefunItem.getItem("BLADE_OF_VAMPIRES"), true)) {
					((Player) ((EntityDamageByEntityEvent) e).getDamager()).playSound(((EntityDamageByEntityEvent) e).getDamager().getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F);
					((Player) ((EntityDamageByEntityEvent) e).getDamager()).addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1));
				}
			}
		}
		if (e.getEntity() instanceof Player) {
			if (!e.isCancelled()) {
				if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItem.getByID("LAVA_TALISMAN"));
				if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItem.getByID("WATER_TALISMAN"));
				if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItem.getByID("ANGEL_TALISMAN"));
				if (e.getCause() == DamageCause.FIRE) Talisman.checkFor(e, SlimefunItem.getByID("FIRE_TALISMAN"));
				if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("WARRIOR_TALISMAN"));
				if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("KNIGHT_TALISMAN"));
				if (e.getCause() == DamageCause.PROJECTILE) {
					if (Talisman.checkFor(e, SlimefunItem.getByID("WHIRLWIND_TALISMAN"))) {
						if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
							Vector direction = ((Player) e.getEntity()).getEyeLocation().getDirection().multiply(2.0);
							Projectile projectile = (Projectile) e.getEntity().getWorld().spawnEntity(((LivingEntity) e.getEntity()).getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), ((EntityDamageByEntityEvent) e).getDamager().getType());
							projectile.setVelocity(direction);
							((EntityDamageByEntityEvent) e).getDamager().remove();
						}
					}
				}
			}
		}
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:33,代碼來源:TalismanListener.java

示例3: onDamage

@EventHandler
public void onDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		if (e.getCause() == DamageCause.PROJECTILE) {
			Player p = (Player) e.getEntity();
			e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(PROTECTION, p.getInventory()) * 0.03125));
		}
	}
}
 
開發者ID:crazyhorse961,項目名稱:NationZ,代碼行數:9,代碼來源:EnchantmentZ_Protection.java

示例4: onDamage

@EventHandler
public void onDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		if (e.getCause() == DamageCause.PROJECTILE) {
			Player p = (Player) e.getEntity();
			e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(PROJECTILE_PROTECTION, p.getInventory()) * 0.0625));
		}
	}
}
 
開發者ID:crazyhorse961,項目名稱:NationZ,代碼行數:9,代碼來源:EnchantmentZ_ProjectileProtection.java

示例5: onEntityDamage

@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event)
{
    Entity entity = event.getEntity();
    
    DamageCause cause = event.getCause();
    if(cause == DamageCause.ENTITY_ATTACK || cause == DamageCause.PROJECTILE)
    {
        EntityDamageByEntityEvent event2 = (EntityDamageByEntityEvent)event;
        Entity attacker = event2.getDamager();
        
        if(attacker != null && attacker.getType() == EntityType.PLAYER) return;
        
        if(attacker instanceof Projectile)
        {
            ProjectileSource source = ((Projectile)attacker).getShooter();
            if(source != null && source instanceof Player) return;
        }
    }
    
    if(entity instanceof Animals || entity instanceof WaterMob || entity.getType() == EntityType.VILLAGER || entity.getCustomName() != null)
    {
        Flag flag = this.GetFlagInstanceAtLocation(entity.getLocation(), null);
        if(flag == null) return;
        event.setCancelled(true);
    }
}
 
開發者ID:BigScary,項目名稱:GriefPreventionFlags,代碼行數:27,代碼來源:FlagDef_NoMobDamage.java

示例6: toBukkit

public static DamageCause toBukkit(cn.nukkit.event.entity.EntityDamageEvent.DamageCause nukkit) {
	// TODO Direct mapping via DamageCause.valueOf?
	switch (nukkit) {
		case CONTACT:
			return DamageCause.CONTACT;
		case ENTITY_ATTACK:
			return DamageCause.ENTITY_ATTACK;
		case PROJECTILE:
			return DamageCause.PROJECTILE;
		case SUFFOCATION:
			return DamageCause.SUFFOCATION;
		case FALL:
			return DamageCause.FALL;
		case FIRE:
			return DamageCause.FIRE;
		case FIRE_TICK:
			return DamageCause.FIRE_TICK;
		case LAVA:
			return DamageCause.LAVA;
		case DROWNING:
			return DamageCause.DROWNING;
		case BLOCK_EXPLOSION:
			return DamageCause.BLOCK_EXPLOSION;
		case ENTITY_EXPLOSION:
			return DamageCause.ENTITY_EXPLOSION;
		case VOID:
			return DamageCause.VOID;
		case SUICIDE:
			return DamageCause.SUICIDE;
		case MAGIC:
			return DamageCause.MAGIC;
		case LIGHTNING:
			return DamageCause.LIGHTNING;
		case CUSTOM:
		default:
			return DamageCause.CUSTOM;
	}
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:38,代碼來源:PokkitDamageCause.java

示例7: onEntityDamage

/**
 * On entity damage.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {

    if (conf.isOverrideExplosions()
            && event.getEntity() instanceof Hanging
            && (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION
            || event.getCause() == DamageCause.PROJECTILE)) {
        // Check for ItemFrame
        Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause());
        event.setCancelled(true);
    }
}
 
開發者ID:Tabinol,項目名稱:Factoid,代碼行數:17,代碼來源:WorldListener.java

示例8: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {
        if (event.getCause() == DamageCause.ENTITY_ATTACK || event.getCause() == DamageCause.PROJECTILE) {
            if (((Player) event.getEntity()).isBlocking()) {
                event.setCancelled(true);
            } else {
                CharacterPlugin characterPlugin = plugin.getServer().getServicesManager().getRegistration(CharacterPlugin.class).getProvider();
                characterPlugin.getActiveCharacter((Player) event.getEntity()).setHealth(((Player) event.getEntity()).getHealth());
            }
        }
    }
}
 
開發者ID:WaywardRealms,項目名稱:Wayward,代碼行數:13,代碼來源:EntityDamageListener.java

示例9: onEntityDamageEvent

@EventHandler(priority = EventPriority.HIGHEST)
   public void onEntityDamageEvent(final EntityDamageEvent event) {
       if (!(event.getEntity() instanceof Player)) {
           return;
       }
       Player player = (Player) event.getEntity();
       if (event.getCause() == DamageCause.FALL) {
       	//Check if player actually performed /leap
       	if (sccp.canLeap.contains(player)) {
       		event.setCancelled(true);
       	}
       	if (sccp.swActionDamage.contains(player)) {
           	sccp.swPlayers.remove(player);
           	sccp.swActionDamage.remove(player);
           }
       }
       if (event.getCause() == DamageCause.PROJECTILE) {
       	if (sccp.swActionProjectile.contains(player)) {
           	sccp.swPlayers.remove(player);
           	sccp.swActionProjectile.remove(player);
           }
       }
       if (sccp.swActionDamage.contains(player)) {
       	sccp.swPlayers.remove(player);
       	sccp.swActionDamage.remove(player);
       }
}
 
開發者ID:SugarCaney,項目名稱:SugCubeCommandPack,代碼行數:27,代碼來源:PlayerListener.java

示例10: IsPvEKill

private boolean IsPvEKill(DamageCause damageCause)
{
	boolean pve = this.model.getConfig().getZombieSpawnCondition().getPvE();

	if(pve)
	{
		if(damageCause == DamageCause.ENTITY_ATTACK || damageCause == DamageCause.ENTITY_EXPLOSION || damageCause == DamageCause.PROJECTILE)
		{
			return true;
		}
	}

	return false;
}
 
開發者ID:DreanorBukkit,項目名稱:ZombieResurrection,代碼行數:14,代碼來源:EntityDeathListener.java

示例11: handleEntityDamageEvent

public static EntityDamageEvent handleEntityDamageEvent(net.minecraft.entity.Entity entity, net.minecraft.util.DamageSource source, int damage) {
    net.minecraft.entity.Entity damager = source.func_76346_g();
    DamageCause cause = DamageCause.ENTITY_ATTACK;

    if (source instanceof net.minecraft.util.EntityDamageSourceIndirect) {
        damager = ((net.minecraft.util.EntityDamageSourceIndirect) source).getProximateDamageSource();
        if (damager.getBukkitEntity() instanceof ThrownPotion) {
            cause = DamageCause.MAGIC;
        } else if (damager.getBukkitEntity() instanceof Projectile) {
            cause = DamageCause.PROJECTILE;
        }
    }

    return callEntityDamageEvent(damager, entity, cause, damage);
}
 
開發者ID:agaricusb,項目名稱:MCPBukkit,代碼行數:15,代碼來源:CraftEventFactory.java

示例12: revealOnArrow

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void revealOnArrow(final EntityDamageByEntityEvent event) {
    if(event.getCause() == DamageCause.PROJECTILE && event.getDamager() instanceof Arrow && event.getEntity() instanceof Player) {
        this.reveal((Player) event.getEntity(), GhostSquadron.ARROW_REVEAL_DURATION);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:6,代碼來源:GhostSquadronMatchModule.java

示例13: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if (invulnerable || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if (source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if (source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if (damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if (damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if (source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if (source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if (source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if (source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if (source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if (source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if (source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if (source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if (source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if (source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if (cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if (super.damageEntity(source, damage)) {
        if (bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:johnnywoof,項目名稱:NoHack,代碼行數:71,代碼來源:NPCEntity.java

示例14: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if(godmode || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if(source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if(source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if(damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if(damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if(source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if(source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if(source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if(source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if(source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if(source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if(source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if(source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if(source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if(source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if(cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(this, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if(!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if(super.damageEntity(source, damage)) {
        if(bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for(d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:lenis0012,項目名稱:NPCFactory,代碼行數:71,代碼來源:NPCEntity.java

示例15: onSteveHurt

@EventHandler
public void onSteveHurt(EntityDamageEvent e) {
	if(e.getEntity() instanceof Player) {
		Player p = (Player) e.getEntity();
		//p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
		if(e.getCause() == DamageCause.BLOCK_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.DROWNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_ATTACK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALL) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALLING_BLOCK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FIRE_TICK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.LIGHTNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.MELTING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.POISON) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.PROJECTILE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.STARVATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUFFOCATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUICIDE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.THORNS) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.VOID) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.WITHER) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		}
	}
}
 
開發者ID:xize,項目名稱:xEssentials_old_Source,代碼行數:59,代碼來源:steveHurtSound.java


注:本文中的org.bukkit.event.entity.EntityDamageEvent.DamageCause.PROJECTILE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。