Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. package com.minexd.praxi.scoreboard;
  2.  
  3. import com.bizarrealex.aether.scoreboard.Board;
  4. import com.bizarrealex.aether.scoreboard.BoardAdapter;
  5. import com.bizarrealex.aether.scoreboard.cooldown.BoardCooldown;
  6. import com.minexd.praxi.event.game.EventGame;
  7. import com.minexd.praxi.profile.Profile;
  8. import com.minexd.praxi.profile.ProfileState;
  9. import com.minexd.praxi.queue.QueueProfile;
  10. import com.minexd.zoot.util.CC;
  11. import com.minexd.zoot.util.TimeUtil;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import com.minexd.praxi.Praxi;
  15. import com.minexd.praxi.party.Party;
  16. import java.util.Set;
  17. import org.bukkit.Bukkit;
  18. import org.bukkit.entity.Player;
  19. import org.bukkit.scheduler.BukkitRunnable;
  20.  
  21. public class ScoreboardAdapter implements BoardAdapter {
  22.  
  23. private int inQueues;
  24. private int inFights;
  25.  
  26. public ScoreboardAdapter() {
  27. new BukkitRunnable() {
  28. @Override
  29. public void run() {
  30. int inQueues = 0;
  31. int inFights = 0;
  32.  
  33. for (Player player : Bukkit.getOnlinePlayers()) {
  34. Profile profile = Profile.getByUuid(player.getUniqueId());
  35.  
  36. if (profile != null) {
  37. if (profile.getState() == ProfileState.QUEUEING) {
  38. inQueues++;
  39. } else if (profile.getState() == ProfileState.FIGHTING || profile.getState() == ProfileState.EVENT) {
  40. inFights++;
  41. }
  42. }
  43. }
  44.  
  45. ScoreboardAdapter.this.inQueues = inQueues;
  46. ScoreboardAdapter.this.inFights = inFights;
  47. }
  48. }.runTaskTimerAsynchronously(Praxi.get(), 2L, 2L);
  49. }
  50.  
  51. @Override
  52. public String getTitle(Player player) {
  53. return Praxi.get().getMainConfig().getString("SCOREBOARD.TITLE");
  54. }
  55.  
  56. @Override
  57. public List<String> getScoreboard(Player player, Board board, Set<BoardCooldown> cooldowns) {
  58. Profile profile = Profile.getByUuid(player.getUniqueId());
  59.  
  60. if (!profile.getOptions().showScoreboard()) {
  61. return null;
  62. }
  63.  
  64. List<String> lines = new ArrayList<>();
  65.  
  66. if (profile.getState() == ProfileState.LOBBY || profile.getState() == ProfileState.QUEUEING) {
  67. lines.add("&bOnline: &7" + Bukkit.getOnlinePlayers().size());
  68. lines.add("&bIn Fights: &7" + inFights);
  69. lines.add("&bIn Queues: &7" + inQueues);
  70.  
  71. if (EventGame.getActiveGame() == null && !EventGame.getCooldown().hasExpired()) {
  72. lines.add("&bEvent Cooldown: &7" + TimeUtil.millisToTimer(EventGame.getCooldown().getRemaining()));
  73. }
  74. }
  75.  
  76. if (profile.getState() == ProfileState.LOBBY) {
  77. if (profile.getParty() != null) {
  78. lines.add("&bYour Party");
  79.  
  80. int added = 0;
  81. Party party = profile.getParty();
  82.  
  83. for (Player otherPlayer : party.getListOfPlayers()) {
  84. added++;
  85.  
  86. lines.add(" &7" + (party.getLeader().equals(otherPlayer) ? "*" : "-") + " &r" +
  87. otherPlayer.getName());
  88.  
  89. if (added >= 4) {
  90. break;
  91. }
  92. }
  93. }
  94. } else if (profile.getState() == ProfileState.QUEUEING) {
  95. QueueProfile queueProfile = profile.getQueueProfile();
  96.  
  97. lines.add(CC.SB_BAR);
  98. lines.add("&a&oSearching for a match...");
  99. lines.add(" ");
  100. lines.add("&b" + queueProfile.getQueue().getQueueName());
  101. lines.add("&bElapsed: &7" + TimeUtil.millisToTimer(queueProfile.getPassed()));
  102.  
  103. if (queueProfile.getQueue().isRanked()) {
  104. lines.add("&bELO Range: &7" + queueProfile.getMinRange() + " -> " + queueProfile.getMaxRange());
  105. }
  106. } else if (profile.getState() == ProfileState.FIGHTING || profile.getState() == ProfileState.SPECTATING) {
  107. lines.addAll(profile.getMatch().getScoreboardLines(player));
  108. } else if (profile.getState() == ProfileState.EVENT) {
  109. lines.addAll(EventGame.getActiveGame().getGameLogic().getScoreboardEntries());
  110. }
  111.  
  112.  
  113.  
  114. lines.add(0, CC.SB_BAR);
  115. lines.add(" ");
  116. lines.add("&7&ozahir.cc");
  117. lines.add(CC.SB_BAR);
  118.  
  119. return lines;
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement