示例#1
0
文件: Config.java 项目: jjm223/mcMMO
 /* Taming */
 public Material getTamingCOTWMaterial(EntityType type) {
   return Material.matchMaterial(
       config.getString(
           "Skills.Taming.Call_Of_The_Wild."
               + StringUtils.getPrettyEntityTypeString(type)
               + ".Item_Material"));
 }
示例#2
0
 /* Combat XP Multipliers */
 public double getCombatXP(EntityType entity) {
   return config.getDouble(
       "Experience.Combat.Multiplier."
           + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
 }
示例#3
0
文件: Config.java 项目: jjm223/mcMMO
 public int getTamingCOTWMaxAmount(EntityType type) {
   return config.getInt(
       "Skills.Taming.Call_Of_The_Wild."
           + StringUtils.getPrettyEntityTypeString(type)
           + ".Summon_Max_Amount");
 }
示例#4
0
  /**
   * 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);
  }