Advertisement
Guest User

asf

a guest
Feb 6th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. package net.ar.game.character.player;
  2.  
  3. import net.ar.game.World;
  4.  
  5. import java.util.concurrent.TimeUnit;
  6.  
  7. /**
  8. * The enumerated type whose elements represent functionality for the quest tab.
  9. * @author <a href="http://www.rune-server.org/members/stand+up/">Stand Up</a>
  10. */
  11. public enum PlayerPanel {
  12. UPTIME(62154, "@or1@Server Uptime: @yel@" + World.getRunningTime().elapsedTime(TimeUnit.MINUTES) + " minutes"),
  13. PLAYERS_ONLINE(62155, "@or1@Players online: @yel@" + World.getPlayers().size()){
  14. @Override
  15. public void onClick(Player player) {
  16. player.getMessages().sendMessage("There is currently " + World.getPlayers().size() + " players online.");
  17. }
  18. },
  19. EMPTY1(62156, ""),
  20. USERNAME(62157, "@or1@Username: @yel@username"),
  21. PASSWORD(62158, "@or1@Password: @yel@password"),
  22. RANK(62158, "@or1@Rank: @yel@rank"),;
  23.  
  24.  
  25. /**
  26. * The button identification.
  27. */
  28. private final int buttonId;
  29.  
  30. /**
  31. * The text displayed or sent.
  32. */
  33. private String text;
  34.  
  35. /**
  36. * Constructs a new {@link PlayerPanel}.
  37. * @param buttonId {@link #buttonId}.
  38. * @param text {@link #text}.
  39. */
  40. PlayerPanel(int buttonId, String text) {
  41. this.buttonId = buttonId;
  42. this.text = text;
  43. }
  44.  
  45. /**
  46. * Gets the line text.
  47. * @return line text.
  48. */
  49. public String getText() {
  50. return text;
  51. }
  52.  
  53. /**
  54. * Sets the new value for {@link #text}.
  55. * @param text the new value to set.
  56. */
  57. public void setText(String text) {
  58. this.text = text;
  59. }
  60.  
  61. /**
  62. * Gets the button id of the line.
  63. * @return the button id.
  64. */
  65. public int getButtonId() {
  66. return buttonId;
  67. }
  68.  
  69. /**
  70. * Clears the tab on player's login.
  71. * @param player the player logging in.
  72. */
  73. public static void onLogin(Player player) {
  74. for(int i = 16016; i < 16126; i++) {
  75. player.getMessages().sendString("", i);
  76. }
  77. }
  78.  
  79. /**
  80. * Loops the button click interactions.
  81. * @param player the player clicking a button.
  82. * @param buttonId the button id he clicked.
  83. * @return {@code true} of he clicked a tab id, {@code false} otherwise.
  84. */
  85. public static boolean interaction(Player player, int buttonId) {
  86. for(PlayerPanel panel : PlayerPanel.values()) {
  87. if(buttonId == panel.getButtonId()) {
  88. panel.onClick(player);
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94.  
  95. /**
  96. * The action to be done on the click.
  97. * @param player the player doing the click.
  98. */
  99. public void onClick(Player player) {
  100. //Empty
  101. }
  102.  
  103. /**
  104. * Refreshes the specified tab asset for all the players on the world.
  105. * @param update the updated string for that tab.
  106. */
  107. public void refreshAll(String update) {
  108. World.getPlayers().forEach(player -> refresh(player, update));
  109. }
  110.  
  111. /**
  112. * Refreshes the tab asset for a specified player
  113. * @param player the player we're refreshing this {@code enumerator} for.
  114. * @param text the new string to set.
  115. */
  116. public void refresh(Player player, String text) {
  117. player.getMessages().sendString(text, 16026 + ordinal());
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement