/** * Process the Shroom Thumb ability. * * @param blockState The {@link BlockState} to check ability activation for * @return true if the ability was successful, false otherwise */ public boolean processShroomThumb(BlockState blockState) { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); if (!playerInventory.contains(Material.BROWN_MUSHROOM)) { player.sendMessage( LocaleLoader.getString( "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM))); return false; } if (!playerInventory.contains(Material.RED_MUSHROOM)) { player.sendMessage( LocaleLoader.getString( "Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM))); return false; } playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM)); playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM)); player.updateInventory(); if (!SkillUtils.activationSuccessful( SecondaryAbility.SHROOM_THUMB, getPlayer(), getSkillLevel(), activationChance)) { player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail")); return false; } return Herbalism.convertShroomThumb(blockState); }
/* Materials */ public int getXp(SkillType skill, Material material) { return config.getInt( "Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
/* * SKILL SETTINGS */ public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean( "Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
/** * 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); }