Exemplo n.º 1
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    OfflinePlayer modifiedPlayer;
    PlayerProfile profile;
    int levels;
    SkillType skill;
    String usage =
        LocaleLoader.getString(
            "Commands.Usage.3",
            new Object[] {
              "addlevels",
              "[" + LocaleLoader.getString("Commands.Usage.Player") + "]",
              "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">",
              "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"
            });

    if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
      return true;
    }

    switch (args.length) {
      case 2:
        if (sender instanceof Player) {
          if (!Skills.isSkill(args[0])) {
            sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
            return true;
          }

          if (Misc.isInt(args[1])) {
            modifiedPlayer = (Player) sender;
            levels = Integer.valueOf(args[1]);
            skill = Skills.getSkillType(args[0]);
            profile = Users.getProfile(modifiedPlayer);

            if (skill.equals(SkillType.ALL)) {
              sender.sendMessage(
                  LocaleLoader.getString("Commands.addlevels.AwardAll.1", new Object[] {levels}));
            } else {
              sender.sendMessage(
                  LocaleLoader.getString(
                      "Commands.addlevels.AwardSkill.1",
                      new Object[] {levels, Misc.getCapitalized(skill.toString())}));
            }

            profile.addLevels(skill, levels);
          }
        } else {
          sender.sendMessage(usage);
        }

        return true;

      case 3:
        modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
        String playerName = modifiedPlayer.getName();
        profile = Users.getProfile(modifiedPlayer);

        if (profile == null) {
          sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
          return true;
        }

        if (!profile.isLoaded()) {
          sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
          return true;
        }

        if (!Skills.isSkill(args[1])) {
          sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
          return true;
        }

        if (Misc.isInt(args[2])) {
          levels = Integer.valueOf(args[2]);
          skill = Skills.getSkillType(args[1]);

          Users.getProfile(modifiedPlayer).addLevels(skill, levels);

          if (skill.equals(SkillType.ALL)) {
            sender.sendMessage(
                LocaleLoader.getString("Commands.addlevels.AwardAll.2", new Object[] {playerName}));
          } else {
            sender.sendMessage(
                LocaleLoader.getString(
                    "Commands.addlevels.AwardSkill.2",
                    new Object[] {Misc.getCapitalized(skill.toString()), playerName}));
          }

          if (modifiedPlayer.isOnline()) {
            if (skill.equals(SkillType.ALL)) {
              ((Player) modifiedPlayer)
                  .sendMessage(
                      LocaleLoader.getString(
                          "Commands.addlevels.AwardAll.1", new Object[] {levels}));
            } else {
              ((Player) modifiedPlayer)
                  .sendMessage(
                      LocaleLoader.getString(
                          "Commands.addlevels.AwardSkill.1",
                          new Object[] {levels, Misc.getCapitalized(skill.toString())}));
            }
          }
        } else {
          sender.sendMessage(usage);
        }

        return true;

      default:
        sender.sendMessage(usage);
        return true;
    }
  }
Exemplo n.º 2
0
  public boolean load() {
    try {
      // Open the user file
      FileReader file = new FileReader(location);
      BufferedReader in = new BufferedReader(file);
      String line = "";

      while ((line = in.readLine()) != null) {
        // Find if the line contains the player we want.
        String[] character = line.split(":");

        if (!character[0].equals(playerName)) {
          continue;
        }

        if (character.length > 1 && Misc.isInt(character[1]))
          skills.put(SkillType.MINING, Integer.valueOf(character[1]));
        if (character.length > 4 && Misc.isInt(character[4]))
          skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
        if (character.length > 5 && Misc.isInt(character[5]))
          skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
        if (character.length > 6 && Misc.isInt(character[6]))
          skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
        if (character.length > 7 && Misc.isInt(character[7]))
          skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
        if (character.length > 8 && Misc.isInt(character[8]))
          skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
        if (character.length > 9 && Misc.isInt(character[9]))
          skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
        if (character.length > 10 && Misc.isInt(character[10]))
          skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
        if (character.length > 11 && Misc.isInt(character[11]))
          skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
        if (character.length > 12 && Misc.isInt(character[12]))
          skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
        if (character.length > 13 && Misc.isInt(character[13]))
          skills.put(SkillType.AXES, Integer.valueOf(character[13]));
        if (character.length > 14 && Misc.isInt(character[14]))
          skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
        if (character.length > 15 && Misc.isInt(character[15]))
          skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
        if (character.length > 16 && Misc.isInt(character[16]))
          skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
        if (character.length > 17 && Misc.isInt(character[17]))
          skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
        if (character.length > 18 && Misc.isInt(character[18]))
          skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
        if (character.length > 19 && Misc.isInt(character[19]))
          skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
        if (character.length > 20 && Misc.isInt(character[20]))
          skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
        if (character.length > 21 && Misc.isInt(character[21]))
          skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
        if (character.length > 22 && Misc.isInt(character[22]))
          skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
        if (character.length > 24 && Misc.isInt(character[24]))
          skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
        if (character.length > 25 && Misc.isInt(character[25]))
          skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
        if (character.length > 26)
          skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
        if (character.length > 27)
          skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
        if (character.length > 28)
          skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
        if (character.length > 29)
          skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
        if (character.length > 30)
          skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
        if (character.length > 31)
          skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(character[31]));
        if (character.length > 32)
          skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
        if (character.length > 33) {
          for (HudType type : HudType.values()) {
            if (type.toString().equalsIgnoreCase(character[33])) {
              hudType = type;
            }
          }
        }
        if (character.length > 34) skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
        if (character.length > 35) skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
        if (character.length > 36)
          skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));

        loaded = true;

        in.close();
        return true;
      }

      in.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return false;
  }
Exemplo n.º 3
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    String usage1 = LocaleLoader.getString("Commands.xprate.proper.0");
    String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
    String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");

    if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
      return true;
    }

    switch (args.length) {
      case 1:
        if (args[0].equalsIgnoreCase("reset")) {
          if (xpEvent) {
            for (Player x : plugin.getServer().getOnlinePlayers()) {
              x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
            }

            xpEvent = !xpEvent;
            Config.getInstance().xpGainMultiplier = oldRate;
          } else {
            Config.getInstance().xpGainMultiplier = oldRate;
          }
        } else if (Misc.isInt(args[0])) {
          sender.sendMessage(usage3);
        } else {
          sender.sendMessage(usage2);
        }

        return true;

      case 2:
        if (Misc.isInt(args[0])) {
          oldRate = Config.getInstance().xpGainMultiplier;

          if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
            xpEvent = Boolean.valueOf(args[1]);
          } else {
            sender.sendMessage(usage3);
          }

          Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);

          if (xpEvent) {
            for (Player x : plugin.getServer().getOnlinePlayers()) {
              x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
              x.sendMessage(
                  LocaleLoader.getString(
                      "Commands.xprate.started.1",
                      new Object[] {Config.getInstance().xpGainMultiplier}));
            }
          } else {
            sender.sendMessage(
                "The XP RATE was modified to "
                    + Config.getInstance().xpGainMultiplier); // TODO: Locale
          }
        } else {
          sender.sendMessage(usage1);
          sender.sendMessage(usage2);
        }

        return true;

      default:
        sender.sendMessage(usage1);
        sender.sendMessage(usage2);
        return true;
    }
  }