Skip to content

Commit aac1771

Browse files
authored
Allow for more customizable song finish behavior in SongPlayer (#32)
* Refactored onFinished to onSongFinished * Added newline
1 parent 447419e commit aac1771

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/main/java/net/raphimc/noteblocklib/player/SongPlayer.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public Song getSong() {
117117

118118
/**
119119
* Sets the song that should be played.<br>
120-
* Can be called in {@link #onFinished()}.
120+
* Can be called in {@link #onSongFinished()}.
121121
*
122122
* @param song The song to play.
123123
*/
@@ -226,8 +226,7 @@ protected void tick() {
226226

227227
this.tick++;
228228
if (this.tick >= this.song.getNotes().getLengthInTicks()) {
229-
this.stop();
230-
this.onFinished();
229+
this.onSongFinished();
231230
return;
232231
}
233232
if (this.ticksPerSecond != this.song.getTempoEvents().getEffectiveTempo(this.tick)) {
@@ -262,7 +261,9 @@ protected boolean shouldTick() {
262261
/**
263262
* Called when the song has finished playing.
264263
*/
265-
protected void onFinished() {
264+
protected void onSongFinished() {
265+
this.stop();
266+
this.onFinished();
266267
}
267268

268269
/**
@@ -293,4 +294,13 @@ protected boolean preTick() {
293294
return true;
294295
}
295296

297+
/**
298+
* Called when the song has finished playing.
299+
*
300+
* @see #onSongFinished()
301+
*/
302+
@Deprecated
303+
protected void onFinished() {
304+
}
305+
296306
}

0 commit comments

Comments
 (0)