/** * Check to see if an ability can be activated. * * @param skill The skill the ability is based on */ public void checkAbilityActivation(SkillType skill) { ToolType tool = skill.getTool(); AbilityType ability = skill.getAbility(); setToolPreparationMode(tool, false); if (getAbilityMode(ability)) { return; } int timeRemaining = calculateTimeRemaining(ability); if (timeRemaining > 0) { /* * Axes and Woodcutting are odd because they share the same tool. * We show them the too tired message when they take action. */ if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) { player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); } return; } if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) { return; } int ticks = PerksUtils.handleActivationPerks( player, 2 + (getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength()); // Notify people that ability has been activated ParticleEffectUtils.playAbilityEnabledEffect(player); if (useChatNotifications()) { player.sendMessage(ability.getAbilityOn()); } SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); // Enable the ability profile.setAbilityDATS( ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); setAbilityMode(ability, true); if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { SkillUtils.handleAbilitySpeedIncrease(player); } new AbilityDisableTask(this, ability) .runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR); }
public void pummel(LivingEntity target, Wolf wolf) { double chance = 10 / activationChance; SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent( getPlayer(), SecondaryAbility.PUMMEL, chance); mcMMO.p.getServer().getPluginManager().callEvent(event); if ((event.getChance() * activationChance) <= Misc.getRandom().nextInt(activationChance)) { return; } ParticleEffectUtils.playGreaterImpactEffect(target); target.setVelocity(wolf.getLocation().getDirection().normalize().multiply(1.5D)); if (target instanceof Player) { Player defender = (Player) target; if (UserManager.getPlayer(defender).useChatNotifications()) { defender.sendMessage("Wolf pummeled at you"); } } }
public void celebrateLevelUp(Player player) { ParticleEffectUtils.fireworkParticleShower(player, runescapeColor); }
/** * Handle the Call of the Wild ability. * * @param type The type of entity to summon. * @param summonAmount The amount of material needed to summon the entity */ private void callOfTheWild(EntityType type, int summonAmount) { Player player = getPlayer(); ItemStack heldItem = player.getInventory().getItemInMainHand(); int heldItemAmount = heldItem.getAmount(); Location location = player.getLocation(); if (heldItemAmount < summonAmount) { player.sendMessage( LocaleLoader.getString( "Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType()))); return; } if (!rangeCheck(type)) { return; } int amount = Config.getInstance().getTamingCOTWAmount(type); int tamingCOTWLength = Config.getInstance().getTamingCOTWLength(type); for (int i = 0; i < amount; i++) { if (!summonAmountCheck(type)) { return; } location = Misc.getLocationOffset(location, 1); LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, type); FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player); mcMMO.p.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { continue; } entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); ((Tameable) entity).setOwner(player); entity.setRemoveWhenFarAway(false); addToTracker(entity); switch (type) { case OCELOT: ((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]); break; case WOLF: entity.setMaxHealth(20.0); entity.setHealth(entity.getMaxHealth()); break; case HORSE: Horse horse = (Horse) entity; entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15)); entity.setHealth(entity.getMaxHealth()); horse.setColor( Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]); horse.setStyle( Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]); horse.setJumpStrength( Math.max( AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min( Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength()))); // TODO: setSpeed, once available break; default: break; } if (Permissions.renamePets(player)) { entity.setCustomName( LocaleLoader.getString( "Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type))); } ParticleEffectUtils.playCallOfTheWildEffect(entity); } player .getInventory() .setItemInMainHand( heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount)); String lifeSpan = ""; if (tamingCOTWLength > 0) { lifeSpan = LocaleLoader.getString("Taming.Summon.Lifespan", tamingCOTWLength); } player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan); player.playSound(location, SoundAdapter.FIREWORK_BLAST_FAR, 1F, 0.5F); }