Advertisement
Lisenochek

Untitled

Oct 19th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. package com.board.list;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.HashMap;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10. import org.bukkit.entity.Entity;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.entity.EntityDeathEvent;
  15. import org.bukkit.event.entity.PlayerDeathEvent;
  16. import org.bukkit.scoreboard.DisplaySlot;
  17. import org.bukkit.scoreboard.Objective;
  18. import org.bukkit.scoreboard.Score;
  19. import org.bukkit.scoreboard.Scoreboard;
  20. import org.bukkit.scoreboard.ScoreboardManager;
  21.  
  22. import com.board.api.API;
  23. import com.board.scoreboard.PexRanks;
  24.  
  25. public class playerStat implements Listener {
  26.  
  27. public static int dead = 0;
  28. public static int kill = 0;
  29.  
  30. public static YamlConfiguration y = YamlConfiguration
  31. .loadConfiguration(new File(API.getInstance().getDataFolder(), "database.yml"));
  32. public static HashMap<String, Integer> playerDeath = new HashMap<>();
  33.  
  34. public static void Board(Player p) {
  35.  
  36. ScoreboardManager manager = Bukkit.getScoreboardManager();
  37. Scoreboard board = manager.getNewScoreboard();
  38. Objective obj = board.registerNewObjective("obj", "dummy");
  39.  
  40. obj.setDisplaySlot(DisplaySlot.SIDEBAR);
  41. obj.setDisplayName(ChatColor.LIGHT_PURPLE + ChatColor.BOLD.toString() + "۞ " + ChatColor.RED
  42. + ChatColor.BOLD.toString() + "О вас" + ChatColor.LIGHT_PURPLE + ChatColor.BOLD.toString() + " ۞");
  43.  
  44. Score line1 = obj.getScore(" ");
  45. line1.setScore(11);
  46.  
  47. Score info = obj.getScore(ChatColor.YELLOW + "Подробная ваша статистика:");
  48. info.setScore(10);
  49.  
  50. Score line2 = obj.getScore(" ");
  51. line2.setScore(9);
  52.  
  53. Score pName = obj.getScore(ChatColor.GRAY + " » Ваш никнейм » " + ChatColor.GREEN + p.getName());
  54. pName.setScore(8);
  55.  
  56. Score line3 = obj.getScore(" ");
  57. line3.setScore(7);
  58.  
  59. Score status = obj.getScore(ChatColor.GRAY + " » Ваш статус » " + PexRanks.Ranks(p));
  60. status.setScore(6);
  61.  
  62. Score line4 = obj.getScore(" ");
  63. line4.setScore(5);
  64.  
  65. Score death = obj.getScore(ChatColor.GRAY + " » Вы умерли » " + ChatColor.GREEN + playerDeath.get(p.getName())
  66. + ChatColor.GRAY + " раз(а)");
  67. death.setScore(4);
  68.  
  69. Score line5 = obj.getScore(" ");
  70. line5.setScore(3);
  71.  
  72. Score kills = obj
  73. .getScore(ChatColor.GRAY + " » Вы убили » " + ChatColor.GREEN + kill + ChatColor.GRAY + " моб(а, ов)");
  74. kills.setScore(2);
  75.  
  76. Score line6 = obj.getScore(" ");
  77. line6.setScore(1);
  78.  
  79. Score online = obj
  80. .getScore(ChatColor.YELLOW + "Текущий онлайн: " + ChatColor.GREEN + Bukkit.getOnlinePlayers().size()
  81. + ChatColor.YELLOW + " / " + ChatColor.GREEN + Bukkit.getMaxPlayers());
  82. online.setScore(0);
  83.  
  84. p.setScoreboard(board);
  85. }
  86.  
  87. @EventHandler
  88. public void deathEvent(PlayerDeathEvent e) {
  89.  
  90. Player p = (Player) e.getEntity();
  91.  
  92. if (p.isDead()) {
  93.  
  94. dead += 1;
  95.  
  96. playerDeath.put(p.getName(), dead);
  97. y.set("playerDeath", playerDeath);
  98.  
  99. try {
  100. y.save(new File(API.getInstance().getDataFolder(), "database.yml"));
  101. } catch (IOException ex) {
  102. return;
  103. }
  104. }
  105. }
  106.  
  107. @EventHandler
  108. public void killsEvent(EntityDeathEvent e) {
  109.  
  110. Entity ent = e.getEntity();
  111.  
  112. if (ent.isDead()) {
  113.  
  114. kill += 1;
  115. }
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement