예제 #1
0
	async def on_start(self):
		await self.context.setting.register(
			self.setting_voting_enabled, self.setting_voting_ratio, self.setting_remind_interval, self.setting_enabled_replay,
			self.setting_enabled_restart, self.setting_enabled_skip, self.setting_callvoting_disable,
			self.setting_callvoting_timeout, self.setting_enabled_time_extend
		)

		await self.instance.permission_manager.register('cancel', 'Cancel the current vote', app=self, min_level=1)
		await self.instance.permission_manager.register('pass', 'Pass the current vote', app=self, min_level=1)

		await self.instance.command_manager.register(
			Command(command='cancel', target=self.cancel_vote, perms='voting:cancel', admin=True),
			Command(command='pass', target=self.pass_vote, perms='voting:pass', admin=True),
			Command(command='y', aliases=['yes'], target=self.vote_yes),
			Command(command='n', aliases=['no'], target=self.vote_no),
			Command(command='replay', target=self.vote_replay),
			Command(command='restart', aliases=['res'], target=self.vote_restart),
			Command(command='skip', target=self.vote_skip),
			Command(command='extend', target=self.vote_extend),
		)

		self.widget = VoteWidget(self)
		await self.widget.display()

		# Register callback.
		self.context.signals.listen(mp_signals.flow.podium_start, self.podium_start)
		self.context.signals.listen(mp_signals.player.player_connect, self.player_connect)
		self.context.signals.listen(mp_signals.map.map_begin, self.map_start)

		if await self.setting_callvoting_disable.get_value() is True:
			# Disable callvoting
			await self.instance.gbx('SetCallVoteTimeOut', 0)
예제 #2
0
	async def player_connect(self, player, is_spectator, source, signal):
		"""
		Called on a player connecting to the server.
		Will display the voting widget to the player if a vote is currently running.

		:param player: player that is joining the server
		:param is_spectator: whether the joining player is a spectator
		"""

		if self.widget is None:
			self.widget = VoteWidget(self)

		# If there is currently a vote, display the voting widget.
		if self.current_vote is not None:
			await self.widget.display(player=player)
예제 #3
0
파일: __init__.py 프로젝트: suened/PyPlanet
	async def on_start(self):
		"""
		Called on starting the application.
		Will register the voting settings, permissions, signals and commands.
		Also creates the voting widget.

		Disables callvoting (server-based voting).
		"""

		await self.context.setting.register(
			self.setting_voting_enabled, self.setting_voting_ratio, self.setting_voting_timeout,
			self.setting_remind_interval, self.setting_enabled_replay, self.setting_enabled_restart,
			self.setting_enabled_skip, self.setting_callvoting_disable, self.setting_callvoting_timeout,
			self.setting_enabled_time_extend, self.setting_extend_max_amount
		)

		await self.instance.permission_manager.register('cancel', 'Cancel the current vote', app=self, min_level=1)
		await self.instance.permission_manager.register('pass', 'Pass the current vote', app=self, min_level=1)

		await self.instance.command_manager.register(
			Command(command='cancel', target=self.cancel_vote, perms='voting:cancel', admin=True,
					description='Cancels the current chat-based vote.'),
			Command(command='pass', target=self.pass_vote, perms='voting:pass', admin=True,
					description='Passes the current chat-based vote.'),
			Command(command='y', aliases=['yes'], target=self.vote_yes,
					description='Votes yes on the current chat-based vote.'),
			Command(command='n', aliases=['no'], target=self.vote_no,
					description='Votes no on the current chat-based vote.'),
			Command(command='replay', target=self.vote_replay,
					description='Starts a chat-based vote to replay the current map.'),
			Command(command='restart', aliases=['res'], target=self.vote_restart,
					description='Starts a chat-based vote to restart the current map.'),
			Command(command='skip', target=self.vote_skip,
					description='Starts a chat-based vote to skip the current map.'),
			Command(command='extend', target=self.vote_extend,
					description='Starts a chat-based vote to extend the playing time on the current map.'),
		)

		self.widget = VoteWidget(self)

		# Register callback.
		self.context.signals.listen(mp_signals.flow.podium_start, self.podium_start)
		self.context.signals.listen(mp_signals.player.player_connect, self.player_connect)
		self.context.signals.listen(mp_signals.map.map_start, self.map_start)

		if await self.setting_callvoting_disable.get_value() is True:
			# Disable callvoting
			await self.instance.gbx('SetCallVoteTimeOut', 0)
예제 #4
0
	async def player_connect(self, player, is_spectator, source, signal):
		if self.widget is None:
			self.widget = VoteWidget(self)

		await self.widget.display(player=player)