Added support for the jukebox to use the shownames of its users.
This commit is contained in:
		
							parent
							
								
									86bcb3d295
								
							
						
					
					
						commit
						956c3b50d6
					
				@ -492,7 +492,13 @@ class AOProtocol(asyncio.Protocol):
 | 
			
		||||
                name, length = self.server.get_song_data(args[0])
 | 
			
		||||
 | 
			
		||||
                if self.client.area.jukebox:
 | 
			
		||||
                    self.client.area.add_jukebox_vote(self.client, name, length)
 | 
			
		||||
                    showname = ''
 | 
			
		||||
                    if len(args) > 2:
 | 
			
		||||
                        if len(args[2]) > 0 and not self.client.area.showname_changes_allowed:
 | 
			
		||||
                            self.client.send_host_message("Showname changes are forbidden in this area!")
 | 
			
		||||
                            return
 | 
			
		||||
                        showname = args[2]
 | 
			
		||||
                    self.client.area.add_jukebox_vote(self.client, name, length, showname)
 | 
			
		||||
                    logger.log_server('[{}][{}]Added a jukebox vote for {}.'.format(self.client.area.id, self.client.get_char_name(), name), self.client)
 | 
			
		||||
                else:
 | 
			
		||||
                    if len(args) > 2:
 | 
			
		||||
 | 
			
		||||
@ -114,12 +114,12 @@ class AreaManager:
 | 
			
		||||
                    return False
 | 
			
		||||
            return True
 | 
			
		||||
 | 
			
		||||
        def add_jukebox_vote(self, client, music_name, length=-1):
 | 
			
		||||
        def add_jukebox_vote(self, client, music_name, length=-1, showname=''):
 | 
			
		||||
            if length <= 0:
 | 
			
		||||
                self.remove_jukebox_vote(client, False)
 | 
			
		||||
            else:
 | 
			
		||||
                self.remove_jukebox_vote(client, True)
 | 
			
		||||
                self.jukebox_votes.append(self.JukeboxVote(client, music_name, length))
 | 
			
		||||
                self.jukebox_votes.append(self.JukeboxVote(client, music_name, length, showname))
 | 
			
		||||
                client.send_host_message('Your song was added to the jukebox.')
 | 
			
		||||
                if len(self.jukebox_votes) == 1:
 | 
			
		||||
                    self.start_jukebox()
 | 
			
		||||
@ -160,7 +160,10 @@ class AreaManager:
 | 
			
		||||
                self.current_music = ''
 | 
			
		||||
                return
 | 
			
		||||
 | 
			
		||||
            if vote_picked.showname == '':
 | 
			
		||||
                self.send_command('MC', vote_picked.name, vote_picked.client.char_id)
 | 
			
		||||
            else:
 | 
			
		||||
                self.send_command('MC', vote_picked.name, vote_picked.client.char_id, vote_picked.showname)
 | 
			
		||||
 | 
			
		||||
            self.current_music_player = 'The Jukebox'
 | 
			
		||||
            self.current_music_player_ipid = 'has no IPID'
 | 
			
		||||
@ -257,11 +260,12 @@ class AreaManager:
 | 
			
		||||
                client.send_command('LE', *self.get_evidence_list(client))
 | 
			
		||||
        
 | 
			
		||||
        class JukeboxVote:
 | 
			
		||||
            def __init__(self, client, name, length):
 | 
			
		||||
            def __init__(self, client, name, length, showname):
 | 
			
		||||
                self.client = client
 | 
			
		||||
                self.name = name
 | 
			
		||||
                self.length = length
 | 
			
		||||
                self.chance = 1
 | 
			
		||||
                self.showname = showname
 | 
			
		||||
 | 
			
		||||
    def __init__(self, server):
 | 
			
		||||
        self.server = server
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user