/**
   * 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);
  }
  protected void sendAbilityMessages() {
    if (player == null) return;

    player.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));

    if (attacker instanceof Player) {
      ((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
    }
  }
  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);
    }
  }
 @Override
 protected void statsDisplay() {
   if (canGigaDrill) {
     if (endurance)
       player.sendMessage(
           LocaleLoader.getString(
                   "Excavation.Effect.Length", new Object[] {gigaDrillBreakerLength})
               + LocaleLoader.getString(
                   "Perks.activationtime.bonus", new Object[] {gigaDrillBreakerLengthEndurance}));
     else
       player.sendMessage(
           LocaleLoader.getString(
               "Excavation.Effect.Length", new Object[] {gigaDrillBreakerLength}));
   }
 }
Beispiel #5
0
  /**
   * Apply the Gore ability.
   *
   * @param target The LivingEntity to apply Gore on
   * @param damage The initial damage
   */
  public double gore(LivingEntity target, double damage) {
    if (!SkillUtils.activationSuccessful(
        SecondaryAbility.GORE, getPlayer(), getSkillLevel(), activationChance)) {
      return 0;
    }

    BleedTimerTask.add(target, Taming.goreBleedTicks);

    if (target instanceof Player) {
      ((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
    }

    getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));

    damage = (damage * Taming.goreModifier) - damage;
    return damage;
  }
  /**
   * Process the Green Thumb ability for blocks.
   *
   * @param blockState The {@link BlockState} to check ability activation for
   * @return true if the ability was successful, false otherwise
   */
  public boolean processGreenThumbBlocks(BlockState blockState) {
    if (!SkillUtils.activationSuccessful(
        SecondaryAbility.GREEN_THUMB_BLOCK, getPlayer(), getSkillLevel(), activationChance)) {
      getPlayer().sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
      return false;
    }

    return Herbalism.convertGreenTerraBlocks(blockState);
  }
Beispiel #7
0
  /**
   * Handle the Beast Lore ability.
   *
   * @param target The entity to examine
   */
  public void beastLore(LivingEntity target) {
    Player player = getPlayer();
    Tameable beast = (Tameable) target;

    String message = LocaleLoader.getString("Combat.BeastLore") + " ";

    if (beast.isTamed() && beast.getOwner() != null) {
      message =
          message.concat(
              LocaleLoader.getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " ");
    }

    message =
        message.concat(
            LocaleLoader.getString(
                "Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
    player.sendMessage(message);
  }
Beispiel #8
0
  public void processEnvironmentallyAware(Wolf wolf, double damage) {
    if (damage > wolf.getHealth()) {
      return;
    }

    Player owner = getPlayer();

    wolf.teleport(owner);
    owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
  }
Beispiel #9
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (CommandUtils.noConsoleUsage(sender)) {
      return true;
    }

    switch (args.length) {
      case 0:
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
        Player player = mcMMOPlayer.getPlayer();

        if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
          ScoreboardManager.setupPlayerScoreboard(player.getName());
          ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
        } else {
          player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
          player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));

          CommandUtils.printGatheringSkills(player);
          CommandUtils.printCombatSkills(player);
          CommandUtils.printMiscSkills(player);

          int powerLevelCap = Config.getInstance().getPowerLevelCap();

          if (powerLevelCap != Integer.MAX_VALUE) {
            player.sendMessage(
                LocaleLoader.getString(
                    "Commands.PowerLevel.Capped",
                    UserManager.getPlayer(player).getPowerLevel(),
                    powerLevelCap));
          } else {
            player.sendMessage(
                LocaleLoader.getString(
                    "Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
          }
        }

        return true;

      default:
        return false;
    }
  }
Beispiel #10
0
  /**
   * 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);
  }
Beispiel #11
0
  /**
   * Check for arrow deflection.
   *
   * @param defender The defending player
   * @param event The event to modify
   */
  public static void deflectCheck(Player defender, EntityDamageByEntityEvent event) {
    final int MAX_BONUS_LEVEL = 1000;

    int skillLevel = Users.getProfile(defender).getSkillLevel(SkillType.UNARMED);
    int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);

    if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().deflect(defender)) {
      event.setCancelled(true);
      defender.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
    }
  }
Beispiel #12
0
  private void checkForUpdates() {
    if (!Config.getInstance().getUpdateCheckEnabled()) {
      return;
    }

    Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);

    if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
      this.updateAvailable = false;
      return;
    }

    if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
      this.updateAvailable = false;
      return;
    }

    this.updateAvailable = true;
    getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
    getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
  }
Beispiel #13
0
  public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);

    McMMOPartyTeleportEvent event =
        new McMMOPartyTeleportEvent(
            teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
    mcMMO.p.getServer().getPluginManager().callEvent(event);

    if (event.isCancelled()) {
      return;
    }

    teleportingPlayer.teleport(targetPlayer);

    teleportingPlayer.sendMessage(
        LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
    targetPlayer.sendMessage(
        LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));

    mcMMOPlayer.getPartyTeleportRecord().actualizeLastUse();
  }
Beispiel #14
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 2:
        String targetName = CommandUtils.getMatchedPlayerName(args[1]);
        McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);

        if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
          return false;
        }

        Player target = mcMMOTarget.getPlayer();
        Player player = (Player) sender;
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
        String playerName = player.getName();

        if (player.equals(target)) {
          sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
          return true;
        }

        if (PartyManager.inSameParty(player, target)) {
          sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
          return true;
        }

        if (!PartyManager.canInvite(mcMMOPlayer)) {
          player.sendMessage(LocaleLoader.getString("Party.Locked"));
          return true;
        }

        Party playerParty = mcMMOPlayer.getParty();
        mcMMOTarget.setPartyInvite(playerParty);

        sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
        target.sendMessage(
            LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName));
        target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
        return true;

      default:
        sender.sendMessage(
            LocaleLoader.getString(
                "Commands.Usage.2",
                "party",
                "invite",
                "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
        return true;
    }
  }
  @Override
  protected void statsDisplay() {
    if (canBonusDamage) {
      player.sendMessage(
          LocaleLoader.getString(
              "Ability.Generic.Template",
              new Object[] {
                LocaleLoader.getString("Unarmed.Ability.Bonus.0"),
                LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus})
              }));
    }

    if (canDeflect) {
      player.sendMessage(
          LocaleLoader.getString(
              "Unarmed.Ability.Chance.ArrowDeflect", new Object[] {deflectChance}));
    }

    if (canDisarm) {
      player.sendMessage(
          LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] {disarmChance}));
    }

    if (canBerserk) {
      player.sendMessage(
          LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] {berserkLength}));
    }
  }
  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);
    }
  }
  @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"));
  }
Beispiel #18
0
  /**
   * Monitor PlayerChangedWorld events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    PlayerProfile profile = Users.getProfile(player);

    if (profile == null) {
      return;
    }

    if (profile.getGodMode()) {
      if (!Permissions.getInstance().mcgod(player)) {
        profile.toggleGodMode();
        player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
      }
    }

    if (profile.inParty()) {
      if (!Permissions.getInstance().party(player)) {
        profile.removeParty();
        player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
      }
    }
  }
Beispiel #19
0
public enum ChatMode {
  ADMIN(
      LocaleLoader.getString("Commands.AdminChat.On"),
      LocaleLoader.getString("Commands.AdminChat.Off")),
  PARTY(
      LocaleLoader.getString("Commands.Party.Chat.On"),
      LocaleLoader.getString("Commands.Party.Chat.Off"));

  private String enabledMessage;
  private String disabledMessage;

  private ChatMode(String enabledMessage, String disabledMessage) {
    this.enabledMessage = enabledMessage;
    this.disabledMessage = disabledMessage;
  }

  public String getEnabledMessage() {
    return enabledMessage;
  }

  public String getDisabledMessage() {
    return disabledMessage;
  }
}
  @Override
  protected void statsDisplay() {
    // TODO: Remove? Basically duplicates the above.
    if (canLeafBlow) {
      if (skillValue < leafBlowUnlock) {
        player.sendMessage(
            LocaleLoader.getString(
                "Ability.Generic.Template.Lock",
                new Object[] {
                  LocaleLoader.getString(
                      "Woodcutting.Ability.Locked.0", new Object[] {leafBlowUnlock})
                }));
      } else {
        player.sendMessage(
            LocaleLoader.getString(
                "Ability.Generic.Template",
                new Object[] {
                  LocaleLoader.getString("Woodcutting.Ability.0"),
                  LocaleLoader.getString("Woodcutting.Ability.1")
                }));
      }
    }

    if (canDoubleDrop && !doubleDropsDisabled) {
      if (player.hasPermission("mcmmo.perks.lucky.woodcutting"))
        player.sendMessage(
            LocaleLoader.getString(
                    "Woodcutting.Ability.Chance.DDrop", new Object[] {doubleDropChance})
                + LocaleLoader.getString(
                    "Perks.lucky.bonus", new Object[] {doubleDropChanceLucky}));
      else
        player.sendMessage(
            LocaleLoader.getString(
                "Woodcutting.Ability.Chance.DDrop", new Object[] {doubleDropChance}));
    }

    if (canTreeFell) {
      player.sendMessage(
          LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] {treeFellerLength}));
    }
  }
  @Override
  protected void effectsDisplay() {
    if (lucky) {
      String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
      player.sendMessage(
          perkPrefix
              + LocaleLoader.getString(
                  "Effects.Template",
                  new Object[] {
                    LocaleLoader.getString("Perks.lucky.name"),
                    LocaleLoader.getString(
                        "Perks.lucky.desc",
                        new Object[] {Skills.localizeSkillName(SkillType.EXCAVATION)})
                  }));
    }

    if (canGigaDrill) {
      player.sendMessage(
          LocaleLoader.getString(
              "Effects.Template",
              new Object[] {
                LocaleLoader.getString("Excavation.Effect.0"),
                LocaleLoader.getString("Excavation.Effect.1")
              }));
    }

    if (canTreasureHunt) {
      player.sendMessage(
          LocaleLoader.getString(
              "Effects.Template",
              new Object[] {
                LocaleLoader.getString("Excavation.Effect.2"),
                LocaleLoader.getString("Excavation.Effect.3")
              }));
    }
  }
Beispiel #22
0
  public void processAbilityActivation(SkillType skill) {
    if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
      return;
    }

    ItemStack inHand = player.getItemInHand();

    if (mcMMO.getModManager().isCustomTool(inHand)
        && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
      return;
    }

    if (!getAbilityUse()) {
      return;
    }

    for (AbilityType abilityType : AbilityType.values()) {
      if (getAbilityMode(abilityType)) {
        return;
      }
    }

    AbilityType ability = skill.getAbility();
    ToolType tool = skill.getTool();

    /*
     * Woodcutting & Axes need to be treated differently.
     * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
     */
    if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
      if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
        int timeRemaining = calculateTimeRemaining(ability);

        if (!getAbilityMode(ability) && timeRemaining > 0) {
          player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
          return;
        }
      }

      if (Config.getInstance().getAbilityMessagesEnabled()) {
        player.sendMessage(tool.getRaiseTool());
      }

      setToolPreparationMode(tool, true);
      new ToolLowerTask(this, tool)
          .runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
    }
  }
  /**
   * Process the Hylian Luck ability.
   *
   * @param blockState The {@link BlockState} to check ability activation for
   * @return true if the ability was successful, false otherwise
   */
  public boolean processHylianLuck(BlockState blockState) {
    if (!SkillUtils.activationSuccessful(
        SecondaryAbility.HYLIAN_LUCK, getPlayer(), getSkillLevel(), activationChance)) {
      return false;
    }

    List<HylianTreasure> treasures;

    switch (blockState.getType()) {
      case DEAD_BUSH:
      case LONG_GRASS:
      case SAPLING:
        treasures = TreasureConfig.getInstance().hylianFromBushes;
        break;

      case RED_ROSE:
      case YELLOW_FLOWER:
        if (mcMMO.getPlaceStore().isTrue(blockState)) {
          mcMMO.getPlaceStore().setFalse(blockState);
          return false;
        }

        treasures = TreasureConfig.getInstance().hylianFromFlowers;
        break;

      case FLOWER_POT:
        treasures = TreasureConfig.getInstance().hylianFromPots;
        break;

      default:
        return false;
    }

    Player player = getPlayer();

    if (treasures.isEmpty()
        || !EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
      return false;
    }

    blockState.setType(Material.AIR);

    Misc.dropItem(
        blockState.getLocation(),
        treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
    player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
    return true;
  }
Beispiel #24
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 0:
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);

        sender.sendMessage(
            LocaleLoader.getString(
                "Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
        mcMMOPlayer.toggleChatNotifications();
        return true;

      default:
        return false;
    }
  }
Beispiel #25
0
  /**
   * Check for disarm.
   *
   * @param PPa Profile of the attacking player
   * @param defender The defending player
   */
  public static void disarmProcCheck(Player attacker, Player defender) {
    final int MAX_BONUS_LEVEL = 1000;

    PlayerProfile PPa = Users.getProfile(attacker);
    int skillLevel = PPa.getSkillLevel(SkillType.UNARMED);
    int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);

    ItemStack inHand = defender.getItemInHand();

    if (!inHand.getType().equals(Material.AIR)) {
      if (random.nextInt(3000) <= skillCheck && !ironGrip(defender, attacker)) {
        defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));

        Misc.mcDropItem(defender.getLocation(), inHand);
        defender.setItemInHand(new ItemStack(Material.AIR));
      }
    }
  }
Beispiel #26
0
  @Override
  protected void statsDisplay() {
    if (canMasterAngler) {
      player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
    }

    if (canTreasureHunt) {
      player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
    }

    if (canMagicHunt) {
      player.sendMessage(
          LocaleLoader.getString("Fishing.Enchant.Chance", magicChance)
              + chanceRaining
              + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
    }

    if (canShake) {
      int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();

      if (skillValue < unlockLevel) {
        player.sendMessage(
            LocaleLoader.getString(
                "Ability.Generic.Template.Lock",
                LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
      } else {
        player.sendMessage(
            LocaleLoader.getString("Fishing.Ability.Shake", shakeChance)
                + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : ""));
      }
    }

    if (canFishermansDiet) {
      player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
    }
  }
Beispiel #27
0
  private boolean summonAmountCheck(EntityType entityType) {
    Player player = getPlayer();

    int maxAmountSummons = Config.getInstance().getTamingCOTWMaxAmount(entityType);

    if (maxAmountSummons <= 0) {
      return true;
    }

    List<TrackedTamingEntity> trackedEntities = getTrackedEntities(entityType);
    int summonAmount = trackedEntities == null ? 0 : trackedEntities.size();

    if (summonAmount >= maxAmountSummons) {
      player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.TooMany", maxAmountSummons));
      return false;
    }

    return true;
  }
  /**
   * Process the Green Terra ability.
   *
   * @param blockState The {@link BlockState} to check ability activation for
   * @return true if the ability was successful, false otherwise
   */
  public boolean processGreenTerra(BlockState blockState) {
    Player player = getPlayer();

    if (!Permissions.greenThumbBlock(player, blockState.getType())) {
      return false;
    }

    PlayerInventory playerInventory = player.getInventory();
    ItemStack seed = new ItemStack(Material.SEEDS);

    if (!playerInventory.containsAtLeast(seed, 1)) {
      player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
      return false;
    }

    playerInventory.removeItem(seed);
    player.updateInventory(); // Needed until replacement available

    return Herbalism.convertGreenTerraBlocks(blockState);
  }
Beispiel #29
0
  @Override
  protected void dataCalculations() {
    boolean isStorming = player.getWorld().hasStorm();

    // TREASURE HUNTER
    if (canTreasureHunt) {
      lootTier = mcMMOPlayer.getFishingManager().getLootTier();
      double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();

      if (isStorming) {
        chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
        enchantChance *= 1.1D;
      }

      String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
      magicChance = treasureHunterStrings[0];
      magicChanceLucky = treasureHunterStrings[1];
    }

    // SHAKE
    if (canShake) {
      String[] shakeStrings =
          calculateAbilityDisplayValues(
              UserManager.getPlayer(player).getFishingManager().getShakeProbability());
      shakeChance = shakeStrings[0];
      shakeChanceLucky = shakeStrings[1];
    }

    // FISHERMAN'S DIET
    if (canFishermansDiet) {
      fishermansDietRank =
          calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
    }

    // MASTER ANGLER
    if (canMasterAngler) {
      biteChance =
          calculateAbilityDisplayValues(
              ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500)) * 100.0)[0];
    }
  }
Beispiel #30
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;
  }