Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.board.list;
- import java.io.File;
- import java.io.IOException;
- import java.util.HashMap;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityDeathEvent;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.scoreboard.DisplaySlot;
- import org.bukkit.scoreboard.Objective;
- import org.bukkit.scoreboard.Score;
- import org.bukkit.scoreboard.Scoreboard;
- import org.bukkit.scoreboard.ScoreboardManager;
- import com.board.api.API;
- import com.board.scoreboard.PexRanks;
- public class playerStat implements Listener {
- public static int dead = 0;
- public static int kill = 0;
- public static YamlConfiguration y = YamlConfiguration
- .loadConfiguration(new File(API.getInstance().getDataFolder(), "database.yml"));
- public static HashMap<String, Integer> playerDeath = new HashMap<>();
- public static void Board(Player p) {
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- Scoreboard board = manager.getNewScoreboard();
- Objective obj = board.registerNewObjective("obj", "dummy");
- obj.setDisplaySlot(DisplaySlot.SIDEBAR);
- obj.setDisplayName(ChatColor.LIGHT_PURPLE + ChatColor.BOLD.toString() + "۞ " + ChatColor.RED
- + ChatColor.BOLD.toString() + "О вас" + ChatColor.LIGHT_PURPLE + ChatColor.BOLD.toString() + " ۞");
- Score line1 = obj.getScore(" ");
- line1.setScore(11);
- Score info = obj.getScore(ChatColor.YELLOW + "Подробная ваша статистика:");
- info.setScore(10);
- Score line2 = obj.getScore(" ");
- line2.setScore(9);
- Score pName = obj.getScore(ChatColor.GRAY + " » Ваш никнейм » " + ChatColor.GREEN + p.getName());
- pName.setScore(8);
- Score line3 = obj.getScore(" ");
- line3.setScore(7);
- Score status = obj.getScore(ChatColor.GRAY + " » Ваш статус » " + PexRanks.Ranks(p));
- status.setScore(6);
- Score line4 = obj.getScore(" ");
- line4.setScore(5);
- Score death = obj.getScore(ChatColor.GRAY + " » Вы умерли » " + ChatColor.GREEN + playerDeath.get(p.getName())
- + ChatColor.GRAY + " раз(а)");
- death.setScore(4);
- Score line5 = obj.getScore(" ");
- line5.setScore(3);
- Score kills = obj
- .getScore(ChatColor.GRAY + " » Вы убили » " + ChatColor.GREEN + kill + ChatColor.GRAY + " моб(а, ов)");
- kills.setScore(2);
- Score line6 = obj.getScore(" ");
- line6.setScore(1);
- Score online = obj
- .getScore(ChatColor.YELLOW + "Текущий онлайн: " + ChatColor.GREEN + Bukkit.getOnlinePlayers().size()
- + ChatColor.YELLOW + " / " + ChatColor.GREEN + Bukkit.getMaxPlayers());
- online.setScore(0);
- p.setScoreboard(board);
- }
- @EventHandler
- public void deathEvent(PlayerDeathEvent e) {
- Player p = (Player) e.getEntity();
- if (p.isDead()) {
- dead += 1;
- playerDeath.put(p.getName(), dead);
- y.set("playerDeath", playerDeath);
- try {
- y.save(new File(API.getInstance().getDataFolder(), "database.yml"));
- } catch (IOException ex) {
- return;
- }
- }
- }
- @EventHandler
- public void killsEvent(EntityDeathEvent e) {
- Entity ent = e.getEntity();
- if (ent.isDead()) {
- kill += 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement