예제 #1
0
        public bool AddDisc(Item item)
        {
            if (item.GetBaseItem().InteractionType != InteractionType.MUSIC_DISC)
            {
                return(false);
            }

            int musicId;

            if (!int.TryParse(item.ExtraData, out musicId))
            {
                return(false);
            }

            var music = TraxSoundManager.GetMusic(musicId);

            if (music == null)
            {
                return(false);
            }

            if (Playlist.Contains(item))
            {
                return(false);
            }

            if (IsPlaying)
            {
                return(false);
            }

            using (var adap = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("INSERT INTO room_jukebox_songs (room_id, item_id) VALUES (@room, @item)");
                adap.AddParameter("room", Room.Id);
                adap.AddParameter("item", item.Id);
                adap.RunQuery();
            }

            Playlist.Add(item);
            Room.SendMessage(new SetJukeboxPlayListComposer(Room));
            Room.SendMessage(new LoadJukeboxUserMusicItemsComposer(Room));
            return(true);
        }
예제 #2
0
 public TraxMusicData GetMusicByItem(Item item)
 {
     return(item != null?TraxSoundManager.GetMusic(item.ExtradataInt) : null);
 }