@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;
    }
  }
Exemple #2
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;
    }
  }
Exemple #3
0
  public static boolean handleVampirismEvent(
      Player killer,
      Player victim,
      HashMap<String, Integer> levelChanged,
      HashMap<String, Float> experienceChanged) {
    McMMOPlayerVampirismEvent eventKiller =
        new McMMOPlayerVampirismEvent(killer, false, levelChanged, experienceChanged);
    McMMOPlayerVampirismEvent eventVictim =
        new McMMOPlayerVampirismEvent(victim, true, levelChanged, experienceChanged);
    mcMMO.p.getServer().getPluginManager().callEvent(eventKiller);
    mcMMO.p.getServer().getPluginManager().callEvent(eventVictim);

    boolean isCancelled = eventKiller.isCancelled() || eventVictim.isCancelled();

    if (!isCancelled) {
      HashMap<String, Integer> levelChangedKiller = eventKiller.getLevelChanged();
      HashMap<String, Float> experienceChangedKiller = eventKiller.getExperienceChanged();

      HashMap<String, Integer> levelChangedVictim = eventVictim.getLevelChanged();
      HashMap<String, Float> experienceChangedVictim = eventVictim.getExperienceChanged();

      McMMOPlayer killerPlayer = UserManager.getPlayer(killer);
      PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();

      for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
        String skillName = skillType.toString();
        int victimSkillLevel = victimProfile.getSkillLevel(skillType);

        killerPlayer.addLevels(skillType, levelChangedKiller.get(skillName));
        killerPlayer.beginUnsharedXpGain(
            skillType, experienceChangedKiller.get(skillName), XPGainReason.VAMPIRISM);

        victimProfile.modifySkill(skillType, victimSkillLevel - levelChangedVictim.get(skillName));
        victimProfile.removeXp(skillType, experienceChangedVictim.get(skillName));

        if (victimProfile.getSkillXpLevel(skillType) < 0) {
          victimProfile.setSkillXpLevel(skillType, 0);
        }

        if (victimProfile.getSkillLevel(skillType) < 0) {
          victimProfile.modifySkill(skillType, 0);
        }
      }
    }

    return !isCancelled;
  }
Exemple #4
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;
    }
  }
Exemple #5
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 0:
        if (CommandUtils.noConsoleUsage(sender)) {
          return true;
        }

        if (!hasSelfPermission(sender)) {
          sender.sendMessage(command.getPermissionMessage());
          return true;
        }

        applyCommandAction(UserManager.getPlayer(sender.getName()));
        return true;

      case 1:
        if (!hasOtherPermission(sender)) {
          sender.sendMessage(command.getPermissionMessage());
          return true;
        }

        String playerName = CommandUtils.getMatchedPlayerName(args[0]);
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);

        if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
          return true;
        }

        if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
          return true;
        }

        applyCommandAction(mcMMOPlayer);
        sendSuccessMessage(sender, playerName);
        return true;

      default:
        return false;
    }
  }
Exemple #6
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();
  }
Exemple #7
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    switch (args.length) {
      case 1:
        if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
          ScoreboardManager.setupPlayerScoreboard(sender.getName());
        }

        String playerName = Misc.getMatchedPlayerName(args[0]);
        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);

        // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in
        // the database. If it's not, abort the process.
        if (mcMMOPlayer == null) {
          PlayerProfile profile =
              mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile

          if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
            return true;
          }

          if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
            ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
            return true;
          }

          sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));

          sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
          for (SkillType skill : SkillType.GATHERING_SKILLS) {
            sender.sendMessage(CommandUtils.displaySkill(profile, skill));
          }

          sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
          for (SkillType skill : SkillType.COMBAT_SKILLS) {
            sender.sendMessage(CommandUtils.displaySkill(profile, skill));
          }

          sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
          for (SkillType skill : SkillType.MISC_SKILLS) {
            sender.sendMessage(CommandUtils.displaySkill(profile, skill));
          }

        } else {
          Player target = mcMMOPlayer.getPlayer();

          if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
            if (!Permissions.inspectOffline(sender)) {
              sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
              return true;
            }
          } else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
            return true;
          }

          if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
            ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
            return true;
          }

          sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
          CommandUtils.printGatheringSkills(target, sender);
          CommandUtils.printCombatSkills(target, sender);
          CommandUtils.printMiscSkills(target, sender);
          sender.sendMessage(
              LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
        }

        return true;

      default:
        return false;
    }
  }
  // TODO: Add Alchemy
  public static String replaceVariables(String string, Player player) {
    String newString = string;

    McMMOPlayer mp = UserManager.getPlayer(player.getName());
    if (newString.contains("<mcmmopowerlevel>"))
      newString = newString.replaceAll("<mcmmopowerlevel>", String.valueOf(mp.getPowerLevel()));
    if (newString.contains("<mcmmoacrobatics>"))
      newString =
          newString.replaceAll(
              "<mcmmoacrobatics>", String.valueOf(mp.getAcrobaticsManager().getSkillLevel()));
    if (newString.contains("<mcmmoalchemy>"))
      newString =
          newString.replaceAll(
              "<mcmmoalchemy>", String.valueOf(mp.getAlchemyManager().getSkillLevel()));
    if (newString.contains("<mcmmoarchery>"))
      newString =
          newString.replaceAll(
              "<mcmmoarchery>", String.valueOf(mp.getArcheryManager().getSkillLevel()));
    if (newString.contains("<mcmmoaxes>"))
      newString =
          newString.replaceAll("<mcmmoaxes>", String.valueOf(mp.getAxesManager().getSkillLevel()));
    if (newString.contains("<mcmmoexcavation>"))
      newString =
          newString.replaceAll(
              "<mcmmoexcavation>", String.valueOf(mp.getExcavationManager().getSkillLevel()));
    if (newString.contains("<mcmmofishing>"))
      newString =
          newString.replaceAll(
              "<mcmmofishing>", String.valueOf(mp.getFishingManager().getSkillLevel()));
    if (newString.contains("<mcmmoherbalism>"))
      newString =
          newString.replaceAll(
              "<mcmmoherbalism>", String.valueOf(mp.getHerbalismManager().getSkillLevel()));
    if (newString.contains("<mcmmomining>"))
      newString =
          newString.replaceAll(
              "<mcmmomining>", String.valueOf(mp.getMiningManager().getSkillLevel()));
    if (newString.contains("<mcmmorepair>"))
      newString =
          newString.replaceAll(
              "<mcmmorepair>", String.valueOf(mp.getRepairManager().getSkillLevel()));
    if (newString.contains("<mcmmosmelting>"))
      newString =
          newString.replaceAll(
              "<mcmmosmelting>", String.valueOf(mp.getSmeltingManager().getSkillLevel()));
    if (newString.contains("<mcmmoswords>"))
      newString =
          newString.replaceAll(
              "<mcmmoswords>", String.valueOf(mp.getSwordsManager().getSkillLevel()));
    if (newString.contains("<mcmmotaming>"))
      newString =
          newString.replaceAll(
              "<mcmmotaming>", String.valueOf(mp.getTamingManager().getSkillLevel()));
    if (newString.contains("<mcmmounarmed>"))
      newString =
          newString.replaceAll(
              "<mcmmounarmed>", String.valueOf(mp.getUnarmedManager().getSkillLevel()));
    if (newString.contains("<mcmmowoodcutting>"))
      newString =
          newString.replaceAll(
              "<mcmmowoodcutting>", String.valueOf(mp.getWoodcuttingManager().getSkillLevel()));

    if (newString.contains("<mcmmomaxpowerlevel>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxpowerlevel>", String.valueOf(ExperienceAPI.getPowerLevelCap()));
    if (newString.contains("<mcmmomaxacrobatics>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxacrobatics>", String.valueOf(ExperienceAPI.getLevelCap("ACROBATICS")));
    if (newString.contains("<mcmmomaxalchemy>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxalchemy>", String.valueOf(ExperienceAPI.getLevelCap("ALCHEMY")));
    if (newString.contains("<mcmmomaxarchery>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxarchery>", String.valueOf(ExperienceAPI.getLevelCap("ARCHERY")));
    if (newString.contains("<mcmmomaxaxes>"))
      newString =
          newString.replaceAll("<mcmmomaxaxes>", String.valueOf(ExperienceAPI.getLevelCap("AXES")));
    if (newString.contains("<mcmmomaxexcavation>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxexcavation>", String.valueOf(ExperienceAPI.getLevelCap("EXCAVATION")));
    if (newString.contains("<mcmmomaxfishing>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxfishing>", String.valueOf(ExperienceAPI.getLevelCap("FISHING")));
    if (newString.contains("<mcmmomaxherbalism>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxherbalism>", String.valueOf(ExperienceAPI.getLevelCap("HERBALISM")));
    if (newString.contains("<mcmmomaxmining>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxmining>", String.valueOf(ExperienceAPI.getLevelCap("MINING")));
    if (newString.contains("<mcmmomaxrepair>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxrepair>", String.valueOf(ExperienceAPI.getLevelCap("REPAIR")));
    if (newString.contains("<mcmmomaxsmelting>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxsmelting>", String.valueOf(ExperienceAPI.getLevelCap("SMELTING")));
    if (newString.contains("<mcmmomaxswords>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxswords>", String.valueOf(ExperienceAPI.getLevelCap("SWORDS")));
    if (newString.contains("<mcmmomaxtaming>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxtaming>", String.valueOf(ExperienceAPI.getLevelCap("TAMING")));
    if (newString.contains("<mcmmomaxunarmed>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxunarmed>", String.valueOf(ExperienceAPI.getLevelCap("UNARMED")));
    if (newString.contains("<mcmmomaxwoodcutting>"))
      newString =
          newString.replaceAll(
              "<mcmmomaxwoodcutting>", String.valueOf(ExperienceAPI.getLevelCap("WOODCUTTING")));

    if (newString.contains("<mcmmonextacrobatics>"))
      newString =
          newString.replaceAll(
              "<mcmmonextacrobatics>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "ACROBATICS")));
    if (newString.contains("<mcmmonextalchemy>"))
      newString =
          newString.replaceAll(
              "<mcmmonextalchemy>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "ALCHEMY")));
    if (newString.contains("<mcmmonextarchery>"))
      newString =
          newString.replaceAll(
              "<mcmmonextarchery>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "ARCHERY")));
    if (newString.contains("<mcmmonextaxes>"))
      newString =
          newString.replaceAll(
              "<mcmmonextaxes>", String.valueOf(ExperienceAPI.getXPToNextLevel(player, "AXES")));
    if (newString.contains("<mcmmonextexcavation>"))
      newString =
          newString.replaceAll(
              "<mcmmonextexcavation>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "EXCAVATION")));
    if (newString.contains("<mcmmonextfishing>"))
      newString =
          newString.replaceAll(
              "<mcmmonextfishing>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "FISHING")));
    if (newString.contains("<mcmmonextherbalism>"))
      newString =
          newString.replaceAll(
              "<mcmmonextherbalism>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "HERBALISM")));
    if (newString.contains("<mcmmonextmining>"))
      newString =
          newString.replaceAll(
              "<mcmmonextmining>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "MINING")));
    if (newString.contains("<mcmmonextrepair>"))
      newString =
          newString.replaceAll(
              "<mcmmonextrepair>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "REPAIR")));
    if (newString.contains("<mcmmonextsmelting>"))
      newString =
          newString.replaceAll(
              "<mcmmonextsmelting>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "SMELTING")));
    if (newString.contains("<mcmmonextswords>"))
      newString =
          newString.replaceAll(
              "<mcmmonextswords>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "SWORDS")));
    if (newString.contains("<mcmmonexttaming>"))
      newString =
          newString.replaceAll(
              "<mcmmonexttaming>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "TAMING")));
    if (newString.contains("<mcmmonextunarmed>"))
      newString =
          newString.replaceAll(
              "<mcmmonextunarmed>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "UNARMED")));
    if (newString.contains("<mcmmonextwoodcutting>"))
      newString =
          newString.replaceAll(
              "<mcmmonextwoodcutting>",
              String.valueOf(ExperienceAPI.getXPToNextLevel(player, "WOODCUTTING")));

    if (newString.contains("<mcmmoparty>"))
      newString =
          newString.replaceAll(
              "<mcmmoparty>",
              String.valueOf(
                  ""
                      + (PartyManager.getParty(player.getName()) != null
                          ? PartyManager.getParty(player.getName()).getName()
                          : "Unknown")));
    if (newString.contains("<mcmmopartyleader>"))
      newString =
          newString.replaceAll(
              "<mcmmopartyleader>",
              String.valueOf(
                  ""
                      + (PartyManager.getParty(player.getName()).getLeader() != null
                          ? PartyManager.getParty(player.getName()).getLeader()
                          : "Unknown")));
    if (newString.contains("<mcmmopartyexpshare>"))
      newString =
          newString.replaceAll(
              "<mcmmopartyexpshare>",
              String.valueOf(
                  ""
                      + (PartyManager.getParty(player.getName()) != null
                          ? PartyManager.getParty(player.getName()).getXpShareMode().toString()
                          : "Unknown")));
    if (newString.contains("<mcmmopartymembers>"))
      newString =
          newString.replaceAll(
              "<mcmmopartymembers>",
              String.valueOf(
                  ""
                      + (PartyManager.getParty(player.getName()) != null
                          ? PartyManager.getParty(player.getName()).getMembers().size()
                          : "0")));
    if (newString.contains("<mcmmopartymemberson>"))
      newString =
          newString.replaceAll(
              "<mcmmopartymemberson>",
              String.valueOf(
                  ""
                      + (PartyManager.getParty(player.getName()) != null
                          ? PartyManager.getParty(player.getName()).getOnlineMembers().size()
                          : "0")));

    if (newString.contains("<mcmmogodmode>"))
      newString =
          newString.replaceAll(
              "<mcmmogodmode>",
              String.valueOf(UserManager.getPlayer(player.getName()).getGodMode()));

    return newString;
  }
  /**
   * Handle EntityDamage events that involve modifying the event.
   *
   * @param event The event to modify
   */
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onEntityDamage(EntityDamageEvent event) {
    if (event instanceof FakeEntityDamageEvent) {
      return;
    }

    double damage = event.getDamage();

    if (damage <= 0) {
      return;
    }

    Entity entity = event.getEntity();

    if (entity.hasMetadata(mcMMO.customDamageKey)) {
      entity.removeMetadata(mcMMO.customDamageKey, plugin);
      return;
    }

    if (Misc.isNPCEntity(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) {
      return;
    }

    LivingEntity livingEntity = (LivingEntity) entity;

    if (CombatUtils.isInvincible(livingEntity, damage)) {
      return;
    }

    DamageCause cause = event.getCause();

    if (livingEntity instanceof Player) {
      Player player = (Player) entity;
      McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);

      /* Check for invincibility */
      if (mcMMOPlayer.getGodMode()) {
        event.setCancelled(true);
        return;
      }

      switch (cause) {
        case FALL:
          if (Config.getInstance().getPreventXPAfterTeleport()
              && SkillUtils.calculateTimeLeft(
                      (long) mcMMOPlayer.getTeleportATS() * Misc.TIME_CONVERSION_FACTOR, 5, player)
                  > 0) {
            return;
          }

          AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();

          if (acrobaticsManager.canRoll()) {
            event.setDamage(acrobaticsManager.rollCheck(event.getDamage()));

            if (event.getDamage() == 0) {
              event.setCancelled(true);
              return;
            }
          }
          break;

        case BLOCK_EXPLOSION:
          MiningManager miningManager = mcMMOPlayer.getMiningManager();

          if (miningManager.canUseDemolitionsExpertise()) {
            event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));

            if (event.getDamage() == 0) {
              event.setCancelled(true);
              return;
            }
          }
          break;

        default:
          break;
      }

      if (event.getDamage() >= 1) {
        mcMMOPlayer.actualizeRecentlyHurt();
      }
    } else if (livingEntity instanceof Tameable) {
      Tameable pet = (Tameable) livingEntity;
      AnimalTamer owner = pet.getOwner();

      if (Taming.canPreventDamage(pet, owner)) {
        Player player = (Player) owner;
        Wolf wolf = (Wolf) pet;

        TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager();

        switch (cause) {
          case CONTACT:
          case FIRE:
          case LAVA:
            if (tamingManager.canUseEnvironmentallyAware()) {
              tamingManager.processEnvironmentallyAware(wolf, event.getDamage());
            }
            return;

          case FALL:
            if (tamingManager.canUseEnvironmentallyAware()) {
              event.setCancelled(true);
            }
            return;

          case ENTITY_ATTACK:
          case PROJECTILE:
            if (tamingManager.canUseThickFur()) {
              event.setDamage(Taming.processThickFur(wolf, event.getDamage()));

              if (event.getDamage() == 0) {
                event.setCancelled(true);
              }
            }
            return;

          case FIRE_TICK:
            if (tamingManager.canUseThickFur()) {
              Taming.processThickFurFire(wolf);
            }
            return;

          case MAGIC:
          case POISON:
          case WITHER:
            if (tamingManager.canUseHolyHound()) {
              Taming.processHolyHound(wolf, event.getDamage());
            }
            return;

          case BLOCK_EXPLOSION:
          case ENTITY_EXPLOSION:
          case LIGHTNING:
            if (tamingManager.canUseShockProof()) {
              event.setDamage(Taming.processShockProof(wolf, event.getDamage()));

              if (event.getDamage() == 0) {
                event.setCancelled(true);
              }
            }
            return;

          default:
            return;
        }
      }
    }
  }
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (CommandUtils.noConsoleUsage(sender)) {
      return true;
    }

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

        boolean isLucky = Permissions.lucky(player, skill);
        boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
        float skillValue = mcMMOPlayer.getSkillLevel(skill);

        permissionsCheck(player);
        dataCalculations(player, skillValue, isLucky);

        if (Config.getInstance().getSkillUseBoard()) {
          ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
        }

        if (!skill.isChildSkill()) {
          player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
          player.sendMessage(
              LocaleLoader.getString(
                  "Commands.XPGain",
                  LocaleLoader.getString(
                      "Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
          player.sendMessage(
              LocaleLoader.getString(
                  "Effects.Level",
                  (int) skillValue,
                  mcMMOPlayer.getSkillXpLevel(skill),
                  mcMMOPlayer.getXpToLevel(skill)));
        } else {
          player.sendMessage(
              LocaleLoader.getString(
                  "Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
          player.sendMessage(
              LocaleLoader.getString(
                  "Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
          player.sendMessage(LocaleLoader.getString("Effects.Child", (int) skillValue));

          player.sendMessage(
              LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents")));
          Set<SkillType> parents = FamilyTree.getParents(skill);

          for (SkillType parent : parents) {
            player.sendMessage(
                parent.getName()
                    + " - "
                    + LocaleLoader.getString(
                        "Effects.Level",
                        mcMMOPlayer.getSkillLevel(parent),
                        mcMMOPlayer.getSkillXpLevel(parent),
                        mcMMOPlayer.getXpToLevel(parent)));
          }
        }

        List<String> effectMessages = effectsDisplay();

        if (!effectMessages.isEmpty()) {
          player.sendMessage(
              LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));

          if (isLucky) {
            String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
            player.sendMessage(
                perkPrefix
                    + LocaleLoader.getString(
                        "Effects.Template",
                        LocaleLoader.getString("Perks.Lucky.Name"),
                        LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
          }

          for (String message : effectMessages) {
            player.sendMessage(message);
          }
        }

        List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);

        if (!statsMessages.isEmpty()) {
          player.sendMessage(
              LocaleLoader.getString(
                  "Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));

          for (String message : statsMessages) {
            player.sendMessage(message);
          }
        }

        player.sendMessage(
            LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase()));
        return true;

      default:
        return skillGuideCommand.onCommand(sender, command, label, args);
    }
  }
Exemple #11
0
 public void applyXpGain(int xp) {
   mcMMOPlayer.beginXpGain(skill, xp);
 }
Exemple #12
0
 public int getSkillLevel() {
   return mcMMOPlayer.getProfile().getSkillLevel(skill);
 }
Exemple #13
0
 public PlayerProfile getProfile() {
   return mcMMOPlayer.getProfile();
 }
Exemple #14
0
 public Player getPlayer() {
   return mcMMOPlayer.getPlayer();
 }
Exemple #15
0
 public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
   this.mcMMOPlayer = mcMMOPlayer;
   this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
   this.skill = skill;
 }