99import net .theevilreaper .bounce .jump .PlayerJumpTask ;
1010import net .theevilreaper .bounce .util .GameMessages ;
1111import org .jetbrains .annotations .NotNull ;
12+ import org .jetbrains .annotations .Nullable ;
1213
1314import java .util .Objects ;
1415
16+ /**
17+ * The {@link BounceProfile} class represents a player's profile during the game period.
18+ * It stores the player's score, kills, deaths, and manages the player's jump task.
19+ *
20+ * @author theEvilReaper
21+ * @version 1.0.0
22+ * @since 0.1.0
23+ */
1524public final class BounceProfile implements Comparable <BounceProfile > {
1625
1726 private final Player player ;
@@ -22,23 +31,45 @@ public final class BounceProfile implements Comparable<BounceProfile> {
2231 private PlayerJumpTask jumpRunnable ;
2332 private long firstReachTimestamp ;
2433
34+ /**
35+ * Constructs a new BounceProfile for the specified player.
36+ *
37+ * @param player the player associated with this profile
38+ */
2539 public BounceProfile (@ NotNull Player player ) {
2640 this .player = player ;
2741 this .points = 0 ;
2842 }
2943
44+ /**
45+ * Registers a jump runnable for the player's profile.
46+ * This runnable will be executed when the player jumps.
47+ *
48+ * @param pushData the push data containing information about the jump
49+ */
3050 public void registerJumpRunnable (@ NotNull PushData pushData ) {
3151 this .jumpRunnable = new PlayerJumpTask (player , pushData );
3252 }
3353
34- public void setLastDamager (Player paramPlayer ) {
54+ /**
55+ * Sets the last player who damaged this profile's player.
56+ *
57+ * @param paramPlayer the player who last damaged this profile's player
58+ */
59+ public void setLastDamager (@ NotNull Player paramPlayer ) {
3560 this .lastDamager = paramPlayer ;
3661 }
3762
63+ /**
64+ * Increments the kill count for this profile.
65+ */
3866 public void addKill () {
3967 ++kills ;
4068 }
4169
70+ /**
71+ * Increments the death count for this profile.
72+ */
4273 public void addDeath () {
4374 ++deaths ;
4475 }
@@ -54,6 +85,11 @@ public int hashCode() {
5485 return Objects .hashCode (player );
5586 }
5687
88+ /**
89+ * Adds points to the profile's score and updates the scoreboard.
90+ *
91+ * @param paramPoints the number of points to add
92+ */
5793 public void addPoints (int paramPoints ) {
5894 points += paramPoints ;
5995 firstReachTimestamp = System .nanoTime ();
@@ -62,6 +98,11 @@ public void addPoints(int paramPoints) {
6298 player .sendActionBar (GameMessages .getCoinComponent (paramPoints , true ));
6399 }
64100
101+ /**
102+ * Removes points from the profile's score.
103+ *
104+ * @param paramPoints the number of points to remove
105+ */
65106 public void removePoints (int paramPoints ) {
66107 addDeath ();
67108 if (points > 0 ) {
@@ -71,53 +112,80 @@ public void removePoints(int paramPoints) {
71112 }
72113 }
73114
115+ /**
116+ * Sends the round statistics to the player.
117+ *
118+ * @param winner true if the player won the round, false otherwise
119+ */
74120 public void sendStats (boolean winner ) {
75121 Component message = GameMessages .STATS_LINE
76122 .append (Component .newline ())
77123 .append (Component .text ("Round statistics" , NamedTextColor .YELLOW ))
78124 .append (Component .newline ())
79- .append (Component .text ("Win: " , NamedTextColor .GRAY ))
80- .append (Component .text (winner ? "✔" : "✘" , winner ? NamedTextColor .GREEN : NamedTextColor .RED ))
125+ .append (Component .text ("Win: " , NamedTextColor .GRAY )
126+ .append (Component .text (winner ? "✔" : "✘" , winner ? NamedTextColor .GREEN : NamedTextColor .RED ) ))
81127 .append (Component .newline ())
82128 .append (Component .text ("Points: " , NamedTextColor .GRAY )
83129 .append (Component .text (points , NamedTextColor .RED )))
84130 .append (Component .newline ())
85131 .append (Component .text ("Kills: " , NamedTextColor .GRAY )
86132 .append (Component .text (kills , NamedTextColor .RED )))
87133 .append (Component .newline ())
88- .append (Component .text ("Tode : " , NamedTextColor .GRAY )
134+ .append (Component .text ("Deaths : " , NamedTextColor .GRAY )
89135 .append (Component .text (deaths , NamedTextColor .RED )))
90136 .append (Component .newline ())
91137 .append (GameMessages .STATS_LINE );
92138
93- this .player .sendActionBar (message );
139+ this .player .sendMessage (message );
94140 }
95141
96142 @ Override
97143 public int compareTo (@ NotNull BounceProfile other ) {
98- int pointComparison = Integer .compare (other .points , this .points ); // Descending by points
144+ System .out .println ("" + this .points + " vs " + other .points );
145+ int pointComparison = Integer .compare (this .points , other .points ); // Descending by points
99146 if (pointComparison != 0 ) return pointComparison ;
100147
101148 return Long .compare (this .firstReachTimestamp , other .firstReachTimestamp ); // Ascending by timestamp
102149 }
103150
151+ /**
152+ * Updates the scoreboard for this profile's player.
153+ */
104154 private void updateScoreboard () {
105155 EventDispatcher .call (new ScoreUpdateEvent (player , points ));
106156 }
107157
158+ /**
159+ * Resets the last damager of this profile.
160+ */
108161 public void resetDamager () {
109162 this .lastDamager = null ;
110163 }
111164
165+ /**
166+ * Returns the player associated with this profile.
167+ *
168+ * @return the player
169+ */
112170 public Player getPlayer () {
113171 return player ;
114172 }
115173
174+ /**
175+ * Returns the jump runnable associated with this profile's player.
176+ *
177+ * @return the jump runnable, or null if it has not been registered
178+ */
116179 public PlayerJumpTask getJumpRunnable () {
117180 return jumpRunnable ;
118181 }
119182
120- public Player getLastDamager () {
183+ /**
184+ * Returns the last player who damaged this profile's player.
185+ *
186+ * @return the last damager, or null if no player has damaged this profile's player
187+ */
188+ public @ Nullable Player getLastDamager () {
121189 return lastDamager ;
122190 }
123191}
0 commit comments