Skip to content

Commit 2f89af4

Browse files
committed
Print song information on exception during playback
1 parent 7c22d8f commit 2f89af4

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/main/java/com/xxmicloxx/NoteBlockAPI/songplayer/EntitySongPlayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ public void playTick(Player player, int tick) {
7878
channelMode.play(player, entity.getLocation(), song, layer, note, soundCategory, volume, !enable10Octave);
7979

8080
if (isInRange(player)) {
81-
if (!this.playerList.get(player.getUniqueId())) {
81+
if (!playerList.get(player.getUniqueId())) {
8282
playerList.put(player.getUniqueId(), true);
8383
Bukkit.getPluginManager().callEvent(new PlayerRangeStateChangeEvent(this, player, true));
8484
}
8585
} else {
86-
if (this.playerList.get(player.getUniqueId())) {
86+
if (playerList.get(player.getUniqueId())) {
8787
playerList.put(player.getUniqueId(), false);
8888
Bukkit.getPluginManager().callEvent(new PlayerRangeStateChangeEvent(this, player, false));
8989
}

src/main/java/com/xxmicloxx/NoteBlockAPI/songplayer/PositionSongPlayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ public void playTick(Player player, int tick) {
9090
channelMode.play(player, targetLocation, song, layer, note, soundCategory, volume, !enable10Octave);
9191

9292
if (isInRange(player)) {
93-
if (!this.playerList.get(player.getUniqueId())) {
93+
if (!playerList.get(player.getUniqueId())) {
9494
playerList.put(player.getUniqueId(), true);
9595
Bukkit.getPluginManager().callEvent(new PlayerRangeStateChangeEvent(this, player, true));
9696
}
9797
} else {
98-
if (this.playerList.get(player.getUniqueId())) {
98+
if (playerList.get(player.getUniqueId())) {
9999
playerList.put(player.getUniqueId(), false);
100100
Bukkit.getPluginManager().callEvent(new PlayerRangeStateChangeEvent(this, player, false));
101101
}

src/main/java/com/xxmicloxx/NoteBlockAPI/songplayer/SongPlayer.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,17 +432,29 @@ private void start() {
432432
CallUpdate("tick", tick);
433433

434434
plugin.doSync(() -> {
435-
for (UUID uuid : playerList.keySet()) {
436-
Player player = Bukkit.getPlayer(uuid);
437-
if (player == null) {
438-
// offline...
439-
continue;
435+
try {
436+
for (UUID uuid : playerList.keySet()) {
437+
Player player = Bukkit.getPlayer(uuid);
438+
if (player == null) {
439+
// offline...
440+
continue;
441+
}
442+
playTick(player, tick);
440443
}
441-
playTick(player, tick);
444+
} catch (Exception e){
445+
Bukkit.getLogger().severe("An error occurred during the playback of song "
446+
+ (song != null ?
447+
song.getPath() + " (" + song.getAuthor() + " - " + song.getTitle() + ")"
448+
: "null"));
449+
e.printStackTrace();
442450
}
443451
});
444452
}
445453
} catch (Exception e) {
454+
Bukkit.getLogger().severe("An error occurred during the playback of song "
455+
+ (song != null ?
456+
song.getPath() + " (" + song.getAuthor() + " - " + song.getTitle() + ")"
457+
: "null"));
446458
e.printStackTrace();
447459
} finally {
448460
lock.unlock();

0 commit comments

Comments
 (0)