コード例 #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);
  }
コード例 #2
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 /* Materials  */
 public int getXp(SkillType skill, Material material) {
   return config.getInt(
       "Experience."
           + StringUtils.getCapitalized(skill.toString())
           + "."
           + StringUtils.getPrettyItemString(material).replace(" ", "_"));
 }
コード例 #3
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 /*
  * SKILL SETTINGS
  */
 public boolean getDoubleDropsEnabled(SkillType skill, Material material) {
   return config.getBoolean(
       "Double_Drops."
           + StringUtils.getCapitalized(skill.toString())
           + "."
           + StringUtils.getPrettyItemString(material).replace(" ", "_"));
 }
コード例 #4
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"));
 }
コード例 #5
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public int getPartyFeatureUnlockLevel(PartyFeature partyFeature) {
   return config.getInt(
       "Party.Leveling."
           + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "")
           + "_UnlockLevel",
       0);
 }
コード例 #6
0
ファイル: ChildConfig.java プロジェクト: 95001588/mcMMO
  @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();
  }
コード例 #7
0
  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);
    }
  }
コード例 #8
0
  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);
    }
  }
コード例 #9
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
  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;
  }
コード例 #10
0
ファイル: AbilityType.java プロジェクト: Toxic-Waste/mcMMO
  @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;
  }
コード例 #11
0
ファイル: SkillType.java プロジェクト: nwich/mcMMO
  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;
  }
コード例 #12
0
  @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"));
  }
コード例 #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)));
  }
コード例 #14
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 public double getExponent(FormulaType type) {
   return config.getDouble(
       "Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent");
 }
コード例 #15
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 public int getBase(FormulaType type) {
   return config.getInt(
       "Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base");
 }
コード例 #16
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 /* Curve values */
 public double getMultiplier(FormulaType type) {
   return config.getDouble(
       "Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier");
 }
コード例 #17
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public int getMySQLMaxPoolSize(PoolIdentifier identifier) {
   return config.getInt(
       "MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()), 10);
 }
コード例 #18
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public int getLevelCap(SkillType skill) {
   int cap =
       config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
   return (cap <= 0) ? Integer.MAX_VALUE : cap;
 }
コード例 #19
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 /* Woodcutting */
 public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) {
   return config.getBoolean(
       "Double_Drops.Woodcutting."
           + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_"));
 }
コード例 #20
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public int getMySQLMaxConnections(PoolIdentifier identifier) {
   return config.getInt(
       "MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()), 30);
 }
コード例 #21
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 /* Skill modifiers */
 public double getFormulaSkillModifier(SkillType skill) {
   return config.getDouble(
       "Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()));
 }
コード例 #22
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 /* Hardcore Mode */
 public boolean getHardcoreStatLossEnabled(SkillType skillType) {
   return config.getBoolean(
       "Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()),
       false);
 }
コード例 #23
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public boolean getPVEEnabled(SkillType skill) {
   return config.getBoolean(
       "Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true);
 }
コード例 #24
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) {
   config.set(
       "Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled);
 }
コード例 #25
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public boolean getHardcoreVampirismEnabled(SkillType skillType) {
   return config.getBoolean(
       "Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false);
 }
コード例 #26
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
 public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) {
   config.set(
       "Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()),
       enabled);
 }
コード例 #27
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 /* Combat XP Multipliers */
 public double getCombatXP(EntityType entity) {
   return config.getDouble(
       "Experience.Combat.Multiplier."
           + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
 }
コード例 #28
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");
 }
コード例 #29
0
ファイル: ExperienceConfig.java プロジェクト: riking/mcMMO
 public double getRepairXP(RepairMaterialType repairMaterialType) {
   return config.getDouble(
       "Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString()));
 }
コード例 #30
0
ファイル: Config.java プロジェクト: jjm223/mcMMO
  @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);
  }