Guest User

Ladder-IBR3

a guest
May 21st, 2019
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.infogroup.infoboard.scoreboard;
  2.  
  3. import com.infogroup.infoboard.InfoBoardReborn;
  4. import com.infogroup.infoboard.utils.SortByPriority;
  5. import org.bukkit.Bukkit;
  6.  
  7. import java.util.ArrayList;
  8. import java.util.Collections;
  9. import java.util.List;
  10.  
  11. public class Ladder {
  12.  
  13. private InfoBoardReborn plugin;
  14.  
  15. private ArrayList<InfoBoard> boards;
  16. private int position;
  17. private String name;
  18. private int shownTime;
  19.  
  20. public Ladder(InfoBoardReborn plugin, String name, List<String> list) {
  21. this.plugin = plugin;
  22. this.name = name;
  23.  
  24. boards = new ArrayList<>();
  25. for (String s : list) {
  26. Bukkit.getConsoleSender().sendMessage("boards: " + s);
  27. this.boards.add(
  28. this.plugin.getIBM()
  29. .getInfoBoard(s)); //ERROR NULL
  30. }
  31. this.position = 0;
  32. }
  33.  
  34. /**
  35. * Get the next Board in line.
  36. *
  37. * @return InfoBoard
  38. */
  39. public InfoBoard getNext() {
  40. this.resetShownTime();
  41. if (boards.size() > position) {
  42. this.position++;
  43. return this.boards.get(position);
  44. } else {
  45. this.position = 0;
  46. return this.boards.get(position);
  47. }
  48. }
  49.  
  50. /**
  51. * Get the current InfoBoard
  52. *
  53. * @return InfoBoard
  54. */
  55. public InfoBoard getCurrent() {
  56. return this.boards.get(position);
  57. }
  58.  
  59. /**
  60. * Get the current position
  61. *
  62. * @return Integer
  63. */
  64. public Integer getPosition() {
  65. return this.position;
  66. }
  67.  
  68. /**
  69. * Get the name of the ladder
  70. * @return String
  71. */
  72. public String getName(){
  73. return this.name;
  74. }
  75.  
  76. /**
  77. * Sort the Boards list by their priorities
  78. */
  79. public void sortListByPriorities() {
  80. Collections.sort(this.boards, new SortByPriority());
  81. }
  82.  
  83. /**
  84. * Get the time the current board has been shown
  85. *
  86. * @return Integer
  87. */
  88. public Integer getShownTime() {
  89. return this.shownTime;
  90. }
  91.  
  92. /**
  93. * Add 1 to the shownTime counter
  94. */
  95. public void addShownTime() {
  96. this.shownTime++;
  97. }
  98.  
  99. /**
  100. * Reset the shownTime counter
  101. */
  102. public void resetShownTime() {
  103. this.shownTime = 0;
  104. }
  105.  
  106. /**
  107. * Get the amount of boards in the ladder
  108. *
  109. * @return Integer
  110. */
  111. public Integer size() {
  112. return this.boards.size();
  113. }
  114. }
RAW Paste Data