diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java index d590bb0e..cddf2f2f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AddYoutubePlaylistCommand.java @@ -27,7 +27,7 @@ public class AddYoutubePlaylistCommand extends Command { int itemId; try { - itemId = Integer.valueOf(params[1]); + itemId = Integer.parseInt(params[1]); } catch (NumberFormatException e) { gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_add_youtube_playlist.no_base_item")); return true; @@ -45,7 +45,7 @@ public class AddYoutubePlaylistCommand extends Command { return true; } - Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.valueOf(params[1]), playlist); + Emulator.getGameEnvironment().getItemManager().getYoutubeManager().addPlaylistToItem(Integer.parseInt(params[1]), playlist); try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `youtube_playlists` (`item_id`, `playlist_id`) VALUES (?, ?)")) { statement.setInt(1, itemId); diff --git a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java index 3672c6fd..1352f763 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/YoutubeManager.java @@ -98,20 +98,19 @@ public class YoutubeManager { final String playlistId = set.getString("playlist_id"); youtubeDataLoaderPool.submit(() -> { - ArrayList playlists = this.playlists.getOrDefault(itemId, new ArrayList<>()); YoutubePlaylist playlist; try { playlist = this.getPlaylistDataById(playlistId); + if (playlist != null) { - playlists.add(playlist); + this.addPlaylistToItem(itemId, playlist); } } catch (IOException e) { LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e); } - this.playlists.put(itemId, playlists); }); } }