From 87ae8e8125f445f86be19cd2fe6de09db6758287 Mon Sep 17 00:00:00 2001 From: skeletor Date: Wed, 1 Apr 2020 06:06:23 -0400 Subject: [PATCH] fixed nullpointer in traxmanager --- .../habbo/habbohotel/rooms/TraxManager.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java index 334ddc17..3f478feb 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/TraxManager.java @@ -44,24 +44,26 @@ public class TraxManager implements Disposable { try (ResultSet set = statement.executeQuery()) { while (set.next()) { HabboItem musicDisc = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set.getInt("item_id")); + if(musicDisc != null) { + if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) { + try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) { + stmt.setInt(1, this.room.getId()); + stmt.setInt(2, musicDisc.getId()); + stmt.execute(); + } catch (SQLException e) { + Emulator.getLogging().logSQLException(e); + return; + } + } else { + SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId()); - if (!(musicDisc instanceof InteractionMusicDisc) || musicDisc.getRoomId() != -1) { - try (PreparedStatement stmt = connection.prepareStatement("DELETE FROM room_trax_playlist WHERE room_id = ? AND item_id = ? LIMIT 1")) { - stmt.setInt(1, this.room.getId()); - stmt.setInt(2, musicDisc.getId()); - stmt.execute(); - } catch (SQLException e) { - Emulator.getLogging().logSQLException(e); - return; - } - } else { - SoundTrack track = Emulator.getGameEnvironment().getItemManager().getSoundTrack(((InteractionMusicDisc) musicDisc).getSongId()); - - if (track != null) { - this.songs.add((InteractionMusicDisc) musicDisc); - this.totalLength += track.getLength(); + if (track != null) { + this.songs.add((InteractionMusicDisc) musicDisc); + this.totalLength += track.getLength(); + } } } + } } } catch (SQLException e) {