Exemplo n.º 1
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;
    }
  }
Exemplo n.º 2
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;
    }
  }