Example #1
0
  public void onEnable() {
    me = this;
    RegisteredServiceProvider<Permission> permissionProvider =
        getServer()
            .getServicesManager()
            .getRegistration(net.milkbowl.vault.permission.Permission.class);
    if (permissionProvider != null) {
      perms = permissionProvider.getProvider();
    }

    getRanks().options().copyDefaults(true);
    saveRanks();

    for (String s : getRanks().getConfigurationSection("Ranks").getKeys(true)) {
      if (!s.contains(".")) {
        RanksManager.addRank(
            new Rank(
                s,
                getRanks().getString("Ranks." + s + ".Prefix"),
                getRanks().getBoolean("Ranks." + s + ".Default"),
                getRanks().getBoolean("Ranks." + s + ".Max"),
                getRanks().getInt("Ranks." + s + ".Score"),
                InfClassManager.getClass(
                    Team.Human, getRanks().getString("Ranks." + s + ".Class.Human")),
                InfClassManager.getClass(
                    Team.Zombie, getRanks().getString("Ranks." + s + ".Class.Zombie")),
                getRanks().getStringList("Ranks." + s + ".Permissions")));
      }
    }
    RanksManager.getPresets();

    getServer().getPluginManager().registerEvents(this, this);
  }
Example #2
0
  @EventHandler
  public void onInfectedLeave(InfectedCommandEvent e) {
    if (!e.isCancelled() && e.getArgs()[0].toLowerCase().equals("leave")) {
      Player p = e.getP();

      if (RanksManager.canRankUp(p)) RanksManager.setPlayersRank(p, RanksManager.getNextRank(p));

      removePermissions(p);
    }
  }
Example #3
0
  @EventHandler
  public void onInfectedCommand(InfectedCommandEvent event) {
    if (event.getArgs().length >= 1) {
      if (event.getArgs()[0].equalsIgnoreCase("Rank")
          || event.getArgs()[0].equalsIgnoreCase("Ranks") && event.getP() != null) {
        event.setCancelled(true);

        Player p = event.getP();

        if (RanksManager.canRankUp(p)) RanksManager.setPlayersRank(p, RanksManager.getNextRank(p));

        Rank rank = RanksManager.getPlayersRank(p);
        Rank nextRank = RanksManager.getNextRank(p);
        p.sendMessage(Msgs.Format_Header.getString("<title>", "Ranks"));
        if (rank.isMaxRank())
          p.sendMessage("" + ChatColor.RED + ChatColor.BOLD + "                      MAX RANK");
        p.sendMessage(
            ""
                + ChatColor.GREEN
                + ChatColor.BOLD
                + "Your Current Rank: "
                + ChatColor.GRAY
                + rank.getPrefix());
        p.sendMessage(
            ChatColor.GRAY
                + "Your Score: "
                + ChatColor.RED
                + InfPlayerManager.getInfPlayer(p).getScore());
        if (!rank.isMaxRank())
          p.sendMessage(
              ChatColor.GRAY
                  + "Score to next rank: "
                  + ChatColor.RED
                  + (nextRank.getScoreNeeded() - InfPlayerManager.getInfPlayer(p).getScore()));
        if (!rank.isMaxRank())
          p.sendMessage(
              ""
                  + ChatColor.GREEN
                  + ChatColor.BOLD
                  + "Next Rank: "
                  + nextRank.getPrefix()
                  + ChatColor.RED
                  + " - "
                  + ChatColor.GRAY
                  + " Unlocks at "
                  + ChatColor.RED
                  + nextRank.getScoreNeeded());
        if (rank.isMaxRank())
          p.sendMessage("" + ChatColor.RED + ChatColor.BOLD + "                      MAX RANK");
        p.sendMessage(Msgs.Format_Line.getString());
      }
    }
  }
Example #4
0
  @EventHandler
  public void onInfectedJoin(InfectedCommandEvent e) {
    if (!e.isCancelled() && e.getArgs()[0].toLowerCase().equals("join")) {
      Player p = e.getP();

      if (RanksManager.canRankUp(p)) RanksManager.setPlayersRank(p, RanksManager.getNextRank(p));

      InfPlayer ip = InfPlayerManager.getInfPlayer(p);
      ip.setInfClass(Team.Human, RanksManager.getPlayersRank(p).getHumanClass());
      ip.setInfClass(Team.Zombie, RanksManager.getPlayersRank(p).getZombieClass());
      addPermissions(p);
    }
  }
Example #5
0
 public void removePermissions(Player p) {
   for (String s : RanksManager.getPlayersRank(p).getPermissions()) perms.playerRemove(p, s);
 }
Example #6
0
 public void addPermissions(Player p) {
   for (String s : RanksManager.getPlayersRank(p).getPermissions()) perms.playerAdd(p, s);
 }
Example #7
0
 @EventHandler
 public void onInfectedGameEnd(InfectedEndGame event) {
   for (Player u : event.getPlayers())
     if (RanksManager.canRankUp(u)) RanksManager.setPlayersRank(u, RanksManager.getNextRank(u));
 }