Пример #1
0
  public void loadPlayer(Player player) {

    StatistikPlayer statistikPlayer = new StatistikPlayer(playerTable, player.getName());

    players.add(statistikPlayer);

    statistikPlayer.setAviableRanks(plugin.getRankManager().getRanks(player));
  }
Пример #2
0
  public void savePlayers() {

    if (players.size() > 0) {

      for (StatistikPlayer player : players) {
        calculatePoints(player);
        player.save();
      }
    }
  }
Пример #3
0
  public StatistikPlayer getPlayer(Player player) {

    for (StatistikPlayer player2 : players) {

      if (player2.getName().equalsIgnoreCase(player.getName())) {

        return player2;
      }
    }

    return null;
  }
Пример #4
0
  public void removePlayer(Player player) {

    for (StatistikPlayer player2 : players) {

      if (player2.getName().equalsIgnoreCase(player.getName())) {

        // Spieler Stats speichern und entfernen
        player2.save();
        players.remove(player2);
        return;
      }
    }
  }
Пример #5
0
  public void checkNewRanks() {

    if (players.size() > 0) {

      for (StatistikPlayer player : players) {

        Player spieler = plugin.getServer().getPlayer(player.getName());

        ArrayList<Rank> ranks =
            Statistik.getInstance()
                .getRankManager()
                .getRanks(plugin.getServer().getPlayer(player.getName()));
        ArrayList<Rank> newRanks =
            Statistik.getInstance()
                .getRankManager()
                .getRanks(plugin.getServer().getPlayer(player.getName()));
        ArrayList<Rank> oldRanks = player.getAviableRanks();

        if (oldRanks != null) {

          if (ranks != null) {

            if (ranks.size() > 0) {

              for (Rank rank : ranks) {

                for (Rank rank2 : oldRanks) {

                  if (rank.equals(rank2)) {
                    newRanks.remove(rank);
                  }
                }
              }
            }

            if (ranks.size() > 0) {

              for (Rank rank : newRanks) {
                spieler.sendMessage(
                    ChatColor.GOLD
                        + "Du hast soeben den Titel "
                        + rank.getName()
                        + ChatColor.WHITE
                        + " freigeschaltet, nutze nun "
                        + ChatColor.GREEN
                        + "/rank set "
                        + rank.getTag()
                        + ChatColor.GOLD
                        + " um den Titel festzulegen.");
              }
            }
          }

        } else {

          if (ranks != null) {

            for (Rank rank : ranks) {
              spieler.sendMessage(
                  ChatColor.GOLD
                      + "Du hast soeben den Titel "
                      + rank.getName()
                      + ChatColor.WHITE
                      + " freigeschaltet, nutze nun "
                      + ChatColor.GREEN
                      + "/rank set "
                      + rank.getTag()
                      + ChatColor.GOLD
                      + " um den Titel festzulegen.");
            }
          }
        }

        player.setAviableRanks(ranks);
      }
    }
  }
Пример #6
0
  public void calculatePoints(StatistikPlayer player) {

    Integer points = 0;

    points =
        points
            + ((player.getPlayTime() / settingsManager.getPlayTimeFor())
                * settingsManager.getPlayTimePoints());

    points =
        points
            + ((player.getBlockBreak() / settingsManager.getBlockBreakFor())
                * settingsManager.getBlockBreakPoints());
    points =
        points
            + ((player.getBlockPlace() / settingsManager.getBlockPlaceFor())
                * settingsManager.getBlockPlacePoints());

    points =
        points
            + ((player.getPlayerKill() / settingsManager.getPlayerKillFor())
                * settingsManager.getPlayerKillPoints());
    points =
        points
            + ((player.getPlayerDeath() / settingsManager.getPlayerDeathFor())
                * settingsManager.getPlayerDeathPoints());

    points =
        points
            + ((player.getMonsterKill() / settingsManager.getMonsterKillFor())
                * settingsManager.getMonsterKillPoints());
    points =
        points
            + ((player.getMonsterDeath() / settingsManager.getMonsterDeathFor())
                * settingsManager.getMonsterDeathPoints());

    points =
        points
            + ((player.getOtherDeath() / settingsManager.getOtherDeathFor())
                * settingsManager.getOtherDeathPoints());
    points =
        points
            + ((player.getFishing() / settingsManager.getFishingFor())
                * settingsManager.getFishingPoints());

    points =
        points
            + ((player.getBlockMove() / settingsManager.getBlockMoveFor())
                * settingsManager.getBlockMovePoints());
    points =
        points
            + ((player.getBlockFall() / settingsManager.getBlockFallFor())
                * settingsManager.getBlockFallPoints());

    player.setPoints(points);
  }