public void spawnMonster(Player player) { Monster monster = TenJavaPlugin.getMonsterManager().getMonster(player); LinkedHashMap configurationSection = TenJavaPlugin.getConfigManager().getExact(monster.evolution); String entity = (String) configurationSection.get("entity"); if(entity.equals("Chicken")) { final Entity chicken = player.getWorld().spawnEntity(player.getLocation().add(new Vector(0,1,0)), EntityType.CHICKEN); monster.entityId = chicken.getEntityId(); playerEntityHashMap.put(player, chicken); Bukkit.getScheduler().runTaskLater(TenJavaPlugin.getInstance(), new Runnable() { @Override public void run() { chicken.playEffect(EntityEffect.WOLF_HEARTS); } }, 5*20); } }
@EventHandler public void onHit(EntityDamageByEntityEvent event) { Entity damager = event.getDamager(); final Entity entity = event.getEntity(); if (damager instanceof Player && toggleData.containsKey(((Player) damager).getName().toLowerCase()) && toggleData.get(((Player) damager).getName().toLowerCase())) { entity.getWorld().playSound(entity.getLocation(), Sound.CHICKEN_EGG_POP, 5F, 1F); entity.playEffect(EntityEffect.WOLF_SMOKE); Location location = entity.getLocation(); entity.getWorld().spigot().playEffect(location, Effect.HEART, 1, 1, 0.35F, 1.5F, 0.35F, 0.5F, 15, 5); entity.getWorld().spigot().playEffect(location, Effect.FLAME, 1, 1, 0.5F, 2F, 0.5F, 0.5F, 15, 5); entity.getWorld().spigot().playEffect(location, Effect.CLOUD, 1, 1, 1F, 2F, 1F, 0.5F, 30, 5); entity.getWorld().spigot().playEffect(location, Effect.MAGIC_CRIT, 1, 1, 0.5F, 1F, 0.5F, 0.5F, 20, 5); entity.getWorld().spigot().playEffect(location, Effect.PARTICLE_SMOKE, 1, 1, 0.5F, 1F, 0.5F, 0.5F, 40, 5); event.setCancelled(true); } }
/** * Checks whether the exiled player is inside any bastion fields they don't have * permission on and deals them damage if they are. * @param player The player to check */ private void checkBastion(Player player) { if (pearlApi.isPlayerInUnpermittedBastion(player) && player.getHealth() > 0) { player.setHealth(Math.max(0, player.getHealth() - bastionDamage)); player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_HURT, 1.0F, 1.0F); player.playEffect(EntityEffect.HURT); msg(player, "<b>You aren't allowed in this bastion field when exiled."); } }
@SuppressWarnings("unchecked") @Override public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) { entity = (Expression<Entity>) e[0]; effect = (Expression<EntityEffect>) e[1]; return true; }
/** * Play heart particles at the given location. * <p> * <i>Implementation note:</i> This method accomplishes the desired behavior by spawning a wolf, playing the {@linkplain EntityEffect#WOLF_HEARTS wolf heart} effect, and removing the wolf. * Event handlers at the highest priority level are registered that will uncancel the spawn of this wolf. * </p> * @param location The location at which to play the heart effect. */ public static void playHeartEffect(@Nonnull Location location){ Validate.notNull(location, "The location of the effect must not be null."); Validate.notNull(location.getWorld(), "The location must not have a null world."); _eventListener.getWolfSpawnLocSet().add(location); Wolf o = location.getWorld().spawn(location, Wolf.class); o.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, (int) Constants.TICKS_PER_MINUTE, 0)); o.playEffect(EntityEffect.WOLF_HEARTS); o.remove(); }
/** * Play effects triggered by an eating horse. * * @param horse The horse * @param happy Show hearts? */ private void playFeedEffects(Horse horse, boolean happy) { horse.getWorld().playSound(horse.getLocation(), Sound.EAT, 1.0f, 0.75f); if (happy) { horse.playEffect(EntityEffect.WOLF_HEARTS); } }
@Override public void playEffect(EntityEffect type) { // TODO Auto-generated method stub throw new UnimplementedOperationException(); }
@Override public void damage(double amount, Entity source, DamageCause cause) { // fire resistance if (cause != null && hasPotionEffect(PotionEffectType.FIRE_RESISTANCE)) { switch (cause) { case PROJECTILE: if (!(source instanceof Fireball)) { break; } case FIRE: case FIRE_TICK: case LAVA: return; } } // armor damage protection // formula source: // http://minecraft.gamepedia.com/Armor#Damage_Protection double defensePoints = getAttributeManager().getPropertyValue(Key.KEY_ARMOR); double toughness = getAttributeManager().getPropertyValue(Key.KEY_ARMOR_TOUGHNESS); amount = amount * (1 - Math.min(20.0, Math.max(defensePoints / 5.0, defensePoints - amount / (2.0 + toughness / 4.0))) / 25); // fire event NPCDamageEvent event; if (source == null) { event = new NPCDamageEvent(this, cause, amount); } else { event = new NPCDamageByEntityEvent(this, cause, amount, source); } if (!event.callEvent()) { return; } // apply damage amount = event.getFinalDamage(); setLastDamage(amount); setHealth(health - amount); playEffect(EntityEffect.HURT); // play sounds, handle death if (health > 0) { Sound hurtSound = getHurtSound(); if (hurtSound != null && !isSilent()) { world.playSound(location, hurtSound, getSoundVolume(), getSoundPitch()); } } setLastDamager(source); }
private Type(final EntityEffect effect) { this.effect = effect; }
public boolean isEntityEffect() { return type.effect instanceof EntityEffect; }
public void playEffect(EntityEffect type) { this.getHandle().worldObj.setEntityState(getHandle(), type.getData()); }
@Override public void playEffect(EntityEffect type) { throw Pokkit.unsupported(); }
@Override public void playEffect(EntityEffect type) { // Not supported yet. As effects are usually unimportant, it's not worth // to crash a plugin over this, so let this method fail silently }
public void playEffect(EntityEffect type) { throw new NotImplementedException("playEffect(EntityEffect)"); }
public void playEffect(EntityEffect type) { this.getHandle().world.broadcastEntityEffect(getHandle(), type.getData()); }
@Override public void playEffect(EntityEffect entityEffect) { entity.worldObj.setEntityState(entity, entityEffect.getData()); }
@Override public void playEffect(EntityEffect type) { throw new UnsupportedOperationException(); }
public void setEntityEffect(EntityEffect entityEffect) { this.entityEffect = entityEffect; }
public static double processThickFur(Wolf wolf, double damage) { wolf.playEffect(EntityEffect.WOLF_SHAKE); return damage / thickFurModifier; }
public static void processThickFurFire(Wolf wolf) { wolf.playEffect(EntityEffect.WOLF_SMOKE); wolf.setFireTicks(0); }
public static double processShockProof(Wolf wolf, double damage) { wolf.playEffect(EntityEffect.WOLF_SHAKE); return damage / shockProofModifier; }
public static void processHolyHound(Wolf wolf, double damage) { double modifiedHealth = Math.min(wolf.getHealth() + damage, wolf.getMaxHealth()); wolf.setHealth(modifiedHealth); wolf.playEffect(EntityEffect.WOLF_HEARTS); }
@Override public void playEffect(EntityEffect type) { throw new NotImplementedException("TODO"); }
@Override public void playEffect(EntityEffect arg0) { }
@Override public void playEffect(EntityEffect arg0) { // TODO Auto-generated method stub }
public void playEffect(EntityEffect type) { this.getHandle().field_70170_p.func_72960_a(getHandle(), type.getData()); }
@Override public void playEffect(EntityEffect type) { // TODO Auto-generated method stub }
public void hurt(int amount){ double hp = player.getHealth(); double resultant = Math.max(0, hp - amount); player.playEffect(EntityEffect.HURT); player.setHealth(resultant); }