Example #1
0
  /**
   * 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);
  }
Example #2
0
 /* Materials  */
 public int getXp(SkillType skill, Material material) {
   return config.getInt(
       "Experience."
           + StringUtils.getCapitalized(skill.toString())
           + "."
           + StringUtils.getPrettyItemString(material).replace(" ", "_"));
 }
Example #3
0
 /*
  * SKILL SETTINGS
  */
 public boolean getDoubleDropsEnabled(SkillType skill, Material material) {
   return config.getBoolean(
       "Double_Drops."
           + StringUtils.getCapitalized(skill.toString())
           + "."
           + StringUtils.getPrettyItemString(material).replace(" ", "_"));
 }
Example #4
0
 /* Taming */
 public Material getTamingCOTWMaterial(EntityType type) {
   return Material.matchMaterial(
       config.getString(
           "Skills.Taming.Call_Of_The_Wild."
               + StringUtils.getPrettyEntityTypeString(type)
               + ".Item_Material"));
 }
Example #5
0
 public int getPartyFeatureUnlockLevel(PartyFeature partyFeature) {
   return config.getInt(
       "Party.Leveling."
           + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "")
           + "_UnlockLevel",
       0);
 }
Example #6
0
  @Override
  protected void loadKeys() {
    config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));

    FamilyTree.clearRegistrations(); // when reloading, need to clear statics

    for (SkillType skill : SkillType.CHILD_SKILLS) {
      plugin.debug("Finding parents of " + skill.name());

      EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
      boolean useDefaults = false; // If we had an error we back out and use defaults

      for (String name : config.getStringList(StringUtils.getCapitalized(skill.name()))) {
        try {
          SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
          FamilyTree.enforceNotChildSkill(parentSkill);
          parentSkills.add(parentSkill);
        } catch (IllegalArgumentException ex) {
          plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
          useDefaults = true;
          break;
        }
      }

      if (useDefaults) {
        parentSkills.clear();
        for (String name :
            config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
          /* We do less checks in here because it's from inside our jar.
           * If they're dedicated enough to have modified it, they can have the errors it may produce.
           * Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
           */
          parentSkills.add(SkillType.valueOf(name.toUpperCase()));
        }
      }

      // Register them
      for (SkillType parentSkill : parentSkills) {
        plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
        FamilyTree.registerParent(skill, parentSkill);
      }
    }

    FamilyTree.closeRegistration();
  }
  private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
    party.setSharingDrops(type, toggle);

    String toggleMessage =
        LocaleLoader.getString(
            "Commands.Party.ToggleShareCategory",
            StringUtils.getCapitalized(type.toString()),
            toggle ? "enabled" : "disabled");

    for (Player member : party.getOnlineMembers()) {
      member.sendMessage(toggleMessage);
    }
  }
  private void handleChangingShareMode(Party party, ShareMode mode) {
    party.setItemShareMode(mode);

    String changeModeMessage =
        LocaleLoader.getString(
            "Commands.Party.SetSharing",
            LocaleLoader.getString("Party.ShareType.Item"),
            LocaleLoader.getString(
                "Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));

    for (Player member : party.getOnlineMembers()) {
      member.sendMessage(changeModeMessage);
    }
  }
Example #9
0
  public boolean getDoubleDropsDisabled(SkillType skill) {
    String skillName = StringUtils.getCapitalized(skill.toString());
    ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
    if (section == null) return false;
    Set<String> keys = section.getKeys(false);
    boolean disabled = true;

    for (String key : keys) {
      if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
        disabled = false;
        break;
      }
    }

    return disabled;
  }
Example #10
0
  @Override
  public String toString() {
    String baseString = name();
    String[] substrings = baseString.split("_");
    String formattedString = "";

    int size = 1;

    for (String string : substrings) {
      formattedString = formattedString.concat(StringUtils.getCapitalized(string));

      if (size < substrings.length) {
        formattedString = formattedString.concat("_");
      }

      size++;
    }

    return formattedString;
  }
Example #11
0
  public static SkillType getSkill(String skillName) {
    if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
      for (SkillType type : values()) {
        if (skillName.equalsIgnoreCase(
            LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) {
          return type;
        }
      }
    }

    for (SkillType type : values()) {
      if (type.name().equalsIgnoreCase(skillName)) {
        return type;
      }
    }

    if (!skillName.equalsIgnoreCase("all")) {
      mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); // TODO: Localize
    }

    return null;
  }
  @Override
  public void run() {
    if (query.equalsIgnoreCase(
        "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
      sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
    } else {
      sender.sendMessage(
          LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
    }

    int place = (page * 10) - 9;

    for (ArrayList<String> stat : userStats) {
      String digit = (place < 10) ? "0" : "" + String.valueOf(place);

      // Format: 1. Playername - skill value
      sender.sendMessage(
          digit + ". " + ChatColor.GREEN + stat.get(1) + " - " + ChatColor.WHITE + stat.get(0));
      place++;
    }

    sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
  }
Example #13
0
  /**
   * Check the XP of a skill.
   *
   * @param skillType The skill to check
   */
  private void checkXp(SkillType skillType, XPGainReason xpGainReason) {
    if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
      return;
    }

    int levelsGained = 0;
    float xpRemoved = 0;

    while (getSkillXpLevelRaw(skillType) >= getXpToLevel(skillType)) {
      if (hasReachedLevelCap(skillType)) {
        setSkillXpLevel(skillType, 0);
        break;
      }

      xpRemoved += profile.levelUp(skillType);
      levelsGained++;
    }

    if (!EventUtils.handleLevelChangeEvent(
        player, skillType, levelsGained, xpRemoved, true, xpGainReason)) {
      return;
    }

    if (Config.getInstance().getLevelUpSoundsEnabled()) {
      player.playSound(
          player.getLocation(),
          Sound.ENTITY_EXPERIENCE_ORB_PICKUP,
          Misc.LEVELUP_VOLUME,
          Misc.LEVELUP_PITCH);
    }

    player.sendMessage(
        LocaleLoader.getString(
            StringUtils.getCapitalized(skillType.toString()) + ".Skillup",
            levelsGained,
            getSkillLevel(skillType)));
  }
Example #14
0
 public double getExponent(FormulaType type) {
   return config.getDouble(
       "Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent");
 }
Example #15
0
 public int getBase(FormulaType type) {
   return config.getInt(
       "Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base");
 }
Example #16
0
 /* Curve values */
 public double getMultiplier(FormulaType type) {
   return config.getDouble(
       "Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier");
 }
Example #17
0
 public int getMySQLMaxPoolSize(PoolIdentifier identifier) {
   return config.getInt(
       "MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()), 10);
 }
Example #18
0
 public int getLevelCap(SkillType skill) {
   int cap =
       config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
   return (cap <= 0) ? Integer.MAX_VALUE : cap;
 }
Example #19
0
 /* Woodcutting */
 public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) {
   return config.getBoolean(
       "Double_Drops.Woodcutting."
           + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_"));
 }
Example #20
0
 public int getMySQLMaxConnections(PoolIdentifier identifier) {
   return config.getInt(
       "MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()), 30);
 }
Example #21
0
 /* Skill modifiers */
 public double getFormulaSkillModifier(SkillType skill) {
   return config.getDouble(
       "Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()));
 }
Example #22
0
 /* Hardcore Mode */
 public boolean getHardcoreStatLossEnabled(SkillType skillType) {
   return config.getBoolean(
       "Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()),
       false);
 }
Example #23
0
 public boolean getPVEEnabled(SkillType skill) {
   return config.getBoolean(
       "Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true);
 }
Example #24
0
 public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) {
   config.set(
       "Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled);
 }
Example #25
0
 public boolean getHardcoreVampirismEnabled(SkillType skillType) {
   return config.getBoolean(
       "Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false);
 }
Example #26
0
 public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) {
   config.set(
       "Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()),
       enabled);
 }
Example #27
0
 /* Combat XP Multipliers */
 public double getCombatXP(EntityType entity) {
   return config.getDouble(
       "Experience.Combat.Multiplier."
           + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
 }
Example #28
0
 public int getTamingCOTWMaxAmount(EntityType type) {
   return config.getInt(
       "Skills.Taming.Call_Of_The_Wild."
           + StringUtils.getPrettyEntityTypeString(type)
           + ".Summon_Max_Amount");
 }
Example #29
0
 public double getRepairXP(RepairMaterialType repairMaterialType) {
   return config.getDouble(
       "Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString()));
 }
Example #30
0
  @Override
  protected boolean validateKeys() {
    // Validate all the settings!
    List<String> reason = new ArrayList<String>();

    /* General Settings */
    if (getSaveInterval() <= 0) {
      reason.add("General.Save_Interval should be greater than 0!");
    }

    /* MySQL Settings */
    for (PoolIdentifier identifier : PoolIdentifier.values()) {
      if (getMySQLMaxConnections(identifier) <= 0) {
        reason.add(
            "MySQL.Database.MaxConnections."
                + StringUtils.getCapitalized(identifier.toString())
                + " should be greater than 0!");
      }
      if (getMySQLMaxPoolSize(identifier) <= 0) {
        reason.add(
            "MySQL.Database.MaxPoolSize."
                + StringUtils.getCapitalized(identifier.toString())
                + " should be greater than 0!");
      }
    }

    /* Mob Healthbar */
    if (getMobHealthbarTime() == 0) {
      reason.add(
          "Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
    }

    /* Scoreboards */
    if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
      reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
    }

    if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
      reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
    }

    if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
      reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
    }

    if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
      reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
    }

    if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
      reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
    }

    if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
      reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
    }

    if (!(getRankUseChat() || getRankUseBoard())) {
      reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
    }

    if (!(getTopUseChat() || getTopUseBoard())) {
      reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
    }

    if (!(getStatsUseChat() || getStatsUseBoard())) {
      reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
    }

    if (!(getInspectUseChat() || getInspectUseBoard())) {
      reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
    }

    /* Database Purging */
    if (getPurgeInterval() < -1) {
      reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
    }

    if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
      reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
    }

    /* Hardcore Mode */
    if (getHardcoreDeathStatPenaltyPercentage() < 0.01
        || getHardcoreDeathStatPenaltyPercentage() > 100) {
      reason.add(
          "Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
    }

    if (getHardcoreVampirismStatLeechPercentage() < 0.01
        || getHardcoreVampirismStatLeechPercentage() > 100) {
      reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
    }

    /* Items */
    if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
      reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
    }

    if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
      reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 9!");
    }

    if (getChimaeraItem() == null) {
      reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
    }

    /* Particles */
    if (getLevelUpEffectsTier() < 1) {
      reason.add("Particles.LevelUp_Tier should be at least 1!");
    }

    /* PARTY SETTINGS */
    if (getAutoPartyKickInterval() < -1) {
      reason.add("Party.AutoKick_Interval should be at least -1!");
    }

    if (getAutoPartyKickTime() < 0) {
      reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
    }

    if (getPartyShareBonusBase() <= 0) {
      reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
    }

    if (getPartyShareBonusIncrease() < 0) {
      reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
    }

    if (getPartyShareBonusCap() <= 0) {
      reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
    }

    if (getPartyShareRange() <= 0) {
      reason.add("Party.Sharing.Range should be greater than 0!");
    }

    if (getPartyXpCurveMultiplier() < 1) {
      reason.add("Party.Leveling.Xp_Curve_Modifier should be at least 1!");
    }

    for (PartyFeature partyFeature : PartyFeature.values()) {
      if (getPartyFeatureUnlockLevel(partyFeature) < 0) {
        reason.add(
            "Party.Leveling."
                + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "")
                + "_UnlockLevel should be at least 0!");
      }
    }

    /* Inspect command distance */
    if (getInspectDistance() <= 0) {
      reason.add("Commands.inspect.Max_Distance should be greater than 0!");
    }

    if (getTreeFellerThreshold() <= 0) {
      reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
    }

    if (getDetonatorItem() == null) {
      reason.add("Skills.Mining.Detonator_Item is invalid!");
    }

    if (getRepairAnvilMaterial() == null) {
      reason.add("Skills.Repair.Anvil_Type is invalid!!");
    }

    if (getSalvageAnvilMaterial() == null) {
      reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
    }

    if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
      reason.add("Cannot use the same item for Repair and Salvage anvils!");
    }

    if (getTamingCOTWMaterial(EntityType.WOLF) == null) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Material is invalid!!");
    }

    if (getTamingCOTWMaterial(EntityType.OCELOT) == null) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Material is invalid!!");
    }

    if (getTamingCOTWMaterial(EntityType.HORSE) == null) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Material is invalid!!");
    }

    if (getTamingCOTWCost(EntityType.WOLF) <= 0) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Amount should be greater than 0!");
    }

    if (getTamingCOTWCost(EntityType.OCELOT) <= 0) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Amount should be greater than 0!");
    }

    if (getTamingCOTWCost(EntityType.HORSE) <= 0) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Amount should be greater than 0!");
    }

    if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Summon_Amount should be greater than 0!");
    }

    if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Summon_Amount should be greater than 0!");
    }

    if (getTamingCOTWAmount(EntityType.HORSE) <= 0) {
      reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Summon_Amount should be greater than 0!");
    }

    return noErrorsInConfig(reason);
  }