Guest User

Untitled

a guest
Feb 17th, 2020
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package de.itsmomoyt.scoreboard;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.scoreboard.DisplaySlot;
  6. import org.bukkit.scoreboard.Objective;
  7. import org.bukkit.scoreboard.Scoreboard;
  8.  
  9. import de.itsmomoyt.mian.Main;
  10.  
  11.  
  12. public class ScoreboardHandler {
  13.  
  14. private static Integer animationCount;
  15.  
  16. private String[] animation = new String[] {
  17. "§9Sky§eDealer§7.§ede", "§7§lWillkommen", "§aSkyPvP", "§9Sky§eDealer§7.§ede", "§7§lWelcome", "§aSkyPvP"
  18. };
  19.  
  20. public void setScoreboard(final Player player) {
  21. final Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
  22. final Objective obj = scoreboard.registerNewObjective("main-content", "dummy");
  23.  
  24. obj.setDisplaySlot(DisplaySlot.SIDEBAR);
  25. obj.setDisplayName(animation[animationCount]);
  26.  
  27. obj.getScore("§a").setScore(9);
  28. obj.getScore("§7Account§8:").setScore(8);
  29. obj.getScore("§8» §4"+player.getName()).setScore(7);
  30. obj.getScore("§b ").setScore(6);
  31. obj.getScore("§7Coins§8:").setScore(5);
  32. obj.getScore("§8» §e0").setScore(4);
  33. obj.getScore("§b ").setScore(3);
  34. obj.getScore("§7TeamSpeak§8:").setScore(2);
  35. obj.getScore("§8» §9Sky§eDealer§7.§ede").setScore(1);
  36. obj.getScore("§b ").setScore(0);
  37.  
  38.  
  39. player.setScoreboard(scoreboard);
  40. }
  41. public void startAnimation() {
  42. animationCount = 0;
  43. Bukkit.getScheduler().runTaskTimer(Main.getPlugin(Main.class), new Runnable() {
  44.  
  45. @Override
  46. public void run() {
  47. Bukkit.getOnlinePlayers().forEach(current -> {
  48.  
  49. if(current.getScoreboard() == null)
  50. setScoreboard(current);
  51.  
  52. current.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(animation[animationCount]);
  53. });
  54.  
  55. animationCount++;
  56.  
  57. if(animationCount == animation.length)
  58. animationCount = 0;
  59.  
  60.  
  61. }
  62. }, 10, 100);
  63. }
  64. }
RAW Paste Data