Backported some minor fixes from ms4, credits to brenoepic.

This commit is contained in:
Harmonic 2023-01-04 18:45:55 -08:00
parent 4340261506
commit f051d1d155
2 changed files with 3 additions and 8 deletions

View File

@ -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);

View File

@ -95,20 +95,15 @@ public class YoutubeManager {
final String playlistId = set.getString("playlist_id");
youtubeDataLoaderPool.submit(() -> {
ArrayList<YoutubePlaylist> 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);
});
}
}