Guest User

Untitled

a guest
Jul 3rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. package pl.kopara.kguild.tablist;
  2.  
  3.  
  4. import com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
  5. import pl.kopara.kguild.utils.Util;
  6.  
  7. public class TabCell
  8. {
  9. private final Tab tab;
  10. private String prefix;
  11. private final String name;
  12. private String suffix;
  13. private int ping;
  14. protected boolean sent;
  15. protected boolean teamExists;
  16. protected boolean toRemove;
  17.  
  18. public TabCell(final Tab tab, final String prefix, final String name, final String suffix, final int ping) {
  19. super();
  20. this.tab = tab;
  21. this.prefix = Util.fixColor(prefix.substring(0, Math.min(prefix.length(), 16)));
  22. this.name = Util.fixColor(name.substring(0, Math.min(name.length(), 16)));
  23. this.suffix = Util.fixColor(suffix.substring(0, Math.min(suffix.length(), 16)));
  24. this.ping = ping;
  25. this.teamExists = true;
  26. this.sent = false;
  27. }
  28.  
  29. public TabCell(final Tab tab, final String name) {
  30. super();
  31. this.tab = tab;
  32. this.name = Util.fixColor(name.substring(0, Math.min(name.length(), 16)));
  33. this.teamExists = false;
  34. this.sent = false;
  35. }
  36.  
  37. public void createPrefixAndSuffix(final String prefix, final String suffix) {
  38. if (this.toRemove || this.teamExists) {
  39. return;
  40. }
  41. this.teamExists = true;
  42. this.prefix = Util.fixColor(prefix.substring(0, Math.min(prefix.length(), 16)));
  43. this.suffix = Util.fixColor(suffix.substring(0, Math.min(suffix.length(), 16)));
  44. final WrapperPlayServerScoreboardTeam w = new WrapperPlayServerScoreboardTeam();
  45. w.setTeamName(this.name);
  46. w.setTeamDisplayName(this.name);
  47. w.setTeamPrefix(this.prefix);
  48. w.setTeamSuffix(this.suffix);
  49. w.setPacketMode((byte)0);
  50. w.sendPacket(this.tab.getPlayer());
  51. }
  52.  
  53. public void updatePrefixAndSuffix(final String prefix, final String suffix) {
  54. if (this.toRemove || !this.teamExists) {
  55. return;
  56. }
  57. this.prefix = Util.fixColor(prefix.substring(0, Math.min(prefix.length(), 16)));
  58. this.suffix = Util.fixColor(suffix.substring(0, Math.min(suffix.length(), 16)));
  59. final WrapperPlayServerScoreboardTeam w = new WrapperPlayServerScoreboardTeam();
  60. w.setTeamName(this.name);
  61. w.setTeamDisplayName(this.name);
  62. w.setTeamPrefix(this.prefix);
  63. w.setTeamSuffix(this.suffix);
  64. w.setPacketMode((byte)2);
  65. w.sendPacket(this.tab.getPlayer());
  66. }
  67.  
  68. public void removePrefixAndSuffix() {
  69. if (this.toRemove || !this.teamExists) {
  70. return;
  71. }
  72. this.teamExists = false;
  73. final WrapperPlayServerScoreboardTeam w = new WrapperPlayServerScoreboardTeam();
  74. w.setTeamName(this.name);
  75. w.setPacketMode((byte)1);
  76. w.sendPacket(this.tab.getPlayer());
  77. }
  78.  
  79. public Tab getTab() {
  80. return this.tab;
  81. }
  82.  
  83. public String getPrefix() {
  84. return this.prefix;
  85. }
  86.  
  87. public String getName() {
  88. return this.name;
  89. }
  90.  
  91. public String getSuffix() {
  92. return this.suffix;
  93. }
  94.  
  95. public int getPing() {
  96. return this.ping;
  97. }
  98.  
  99. public boolean isSent() {
  100. return this.sent;
  101. }
  102.  
  103. public boolean isTeamExists() {
  104. return this.teamExists;
  105. }
  106.  
  107. public boolean isToRemove() {
  108. return this.toRemove;
  109. }
  110.  
  111. public void setPrefix(final String prefix) {
  112. this.prefix = prefix;
  113. }
  114.  
  115. public void setSuffix(final String suffix) {
  116. this.suffix = suffix;
  117. }
  118.  
  119. public void setPing(final int ping) {
  120. this.ping = ping;
  121. }
  122.  
  123. public void setSent(final boolean sent) {
  124. this.sent = sent;
  125. }
  126.  
  127. public void setTeamExists(final boolean teamExists) {
  128. this.teamExists = teamExists;
  129. }
  130.  
  131. public void setToRemove(final boolean toRemove) {
  132. this.toRemove = toRemove;
  133. }
  134. }
Add Comment
Please, Sign In to add comment