def __init__(self, app): """ :param app: App instance. :type app: pyplanet.apps.contrib.admin.app.Admin """ self.app = app self.instance = app.instance self.setting_juke_after_adding = Setting( 'juke_after_adding', 'Juke map after adding to the server', Setting.CAT_BEHAVIOUR, type=bool, description= 'Add the map just added from file or MX to the jukebox.', default=True)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.manialinks = None self.msg_view = MessagesView(self) self.msg_loop_task = None self.chat_messages = [] self.msg_interval_setting = Setting( 'messages_interval', 'Messages interval', Setting.CAT_BEHAVIOUR, type=int, description='The time between the chat messages in seconds', default=60 * 5, change_target=self.interval_changed) self.loop = None self.lock = asyncio.Lock(loop=self.loop) self.msg_index = 0
async def test_saving(self): instance = Controller.prepare(name='default').instance await instance.db.connect() await instance.apps.discover() test_1 = Setting('test1', 'Test 1', Setting.CAT_GENERAL, type=str) await instance.setting_manager.register( test_1 ) expected = 'test1' await test_1.set_value('test1') cached = await test_1.get_value(refresh=False) real = await test_1.get_value(refresh=True) assert cached == expected assert real == expected
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.current_votes = [] self.current_karma = 0 self.current_positive_votes = 0 self.current_negative_votes = 0 self.widget = None self.setting_finishes_before_voting = Setting( 'finishes_before_voting', 'Finishes before voting', Setting.CAT_BEHAVIOUR, type=int, description= 'Amount of times a player should finish before being allowed to vote.', default=0)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.sector_widget = SectorTimesWidget(self) self.cp_widget = CheckpointDiffWidget(self) self.gear_view = GearIndicatorView(self) self.setting_enable_gear_indicator = Setting( 'gear_indicator', 'Enable Gear Indicator', Setting.CAT_FEATURES, type=bool, default=True, description= 'Enable the Gear Indicator View in Stadium based titles', change_target=self.reload_settings) self.gear_view_possible = False
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.api = MXApi() self.namespace = 'mx' self.site_name = 'ManiaExchange' self.site_short_name = 'MX' self.setting_mx_key = Setting( 'mx_key', 'ManiaExchange/TrackmaniaExchange Key', Setting.CAT_KEYS, type=str, default=None, description= 'Is only required when you want to download from a private group/section!' )
def __init__(self, *args, **kwargs): """ Initializes the plugin. """ super().__init__(*args, **kwargs) self.context.signals.listen(mp_signals.flow.podium_start, self.podium_start) self.mod_url = "http://www.maniapark.com/download/mods/TMT_stadium.zip" self.setting_mod_url = Setting( 'mod_url', 'Mod Url', Setting.CAT_KEYS, type=str, description= 'The mod link to be forced (Skip the map to apply the mod change).', )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.enabled = False self.current_limit = None self.next_limit = None self.setting_enable_dynamic_points = Setting( 'dynamic_points', 'Enable dynamic points limit', Setting.CAT_FEATURES, type=bool, description='Enable the dynamic points limit for Shootmania Royal.', default=True, change_target=self.enable_changed ) self.setting_min_points = Setting( 'min_points', 'Minimum number of points', Setting.CAT_GENERAL, type=int, description='The points limit will never go bellow this number of points.', default=10, change_target=self.on_changes ) self.setting_max_points = Setting( 'max_points', 'Maximum number of points', Setting.CAT_GENERAL, type=int, description='The points limit will never go above this number of points. Leave at 0 to disable.', default=0, change_target=self.on_changes ) self.setting_points_per_player = Setting( 'per_player_points', 'Points per player', Setting.CAT_GENERAL, type=int, description='The points every player should increase the total points limit of the map.', default=10, change_target=self.on_changes ) self.setting_change_during_map = Setting( 'change_during_map', 'Change during map gameplay', Setting.CAT_FEATURES, type=bool, description='Enable this to change points during a map gameplay.', default=True, change_target=self.on_changes ) self.setting_announce_points_change = Setting( 'announce_change', 'Announce points change at map start/end', Setting.CAT_FEATURES, type=bool, description='The points every player should increase the total points limit of the map.', default=True, change_target=self.on_changes )
def __init__(self, app): """ :param app: App instance. :type app: pyplanet.apps.contrib.admin.app.Admin """ self.app = app self.instance = app.instance self.view = ToolbarView(self.app) self.setting_enable_toolbar = Setting( 'enable_toolbar', 'Enable the admin toolbar', Setting.CAT_DESIGN, type=bool, description= 'Enable and show the admin toolbar for admins (all players with level above player level).', default=True)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.lock = asyncio.Lock() self.context.signals.listen(mp_signals.map.map_end, self.map_end) self.server = None self.current_song_index = 0 self.current_song = None self.songs = [] self.list_view = None self.playlist = [] self.playlist_view = None self.setting_override_map_music = Setting( 'override_map_music', 'Override map music', Setting.CAT_BEHAVIOUR, type=bool, description='Whether to override the map music.', default=True)
def __init__(self, app): """ Initiate toolbar component. :param app: App config instance :type app: pyplanet.apps.core.pyplanet.app.PyPlanetConfig """ self.app = app self.setting_display_toolbar = Setting( 'display_player_toolbar', 'Display player toolbar', Setting.CAT_DESIGN, type=bool, default=True, description= 'Display the toolbar to all the players, the toolbar contains some useful buttons', change_target=self.reload_settings) self.widget = ToolbarView(self.app)
async def on_start(self): # Settings await self.context.setting.register( Setting('normal_map_list', 'Map list to return to after tournament', Setting.CAT_OTHER, type=str, default='maplist.txt', description='Map list to return to after tournament'), Setting( 'schedule_start_behavior', 'Schedule start behavior', Setting.CAT_BEHAVIOUR, type=int, default='0', description= "0: Don't change timelimit, start after maps finish. 1: Extend timelimit " "of the map before starting tournament (Starts exactly at the right time). " "2: End the map at the specified time."), ) # Perms await self.instance.permission_manager.register('tournament', 'Manage tournaments', app=self, min_level=2) # Commands await self.instance.command_manager.register( Command(command='starttournament', target=self.command_start_tournament, perms='tournamentschedule:tournament', admin=True, description='Starts tournament with default settings'), Command(command='endtournament', target=self.command_end_tournament, perms='tournamentschedule:tournament', admin=True, description='Ends tournament'), Command(command='scheduletournament', aliases=['st'], target=self.command_schedule_tournament, perms='tournamentschedule:tournament', admin=True, description='Schedule new tournament'), Command(command='tournamentschedulelist', aliases=['tsl'], target=self.command_tournament_schedule_list, perms='tournamentschedule:tournament', admin=True, description='View and edit scheduled tournaments.'), Command(command='checkschedule', aliases=['cs'], target=self.command_check_schedule, perms='tournamentschedule:tournament', admin=True, description='Queue tournament if ready.'), ) # Signals self.context.signals.listen(mp_signals.map.map_begin, self.signal_map_begin) self.context.signals.listen(tm_signals.scores, self.signal_scores) await self.refresh_schedule()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setting_dynatime_active = Setting( 'dynatime_active', 'Dynatime active', Setting.CAT_BEHAVIOUR, type=bool, description='Activate dynamic round timer based on map medal time.', default=True) self.setting_dynatime_announce = Setting( 'dynatime_announce', 'Dynatime announce', Setting.CAT_BEHAVIOUR, type=bool, description= 'Announce the current time limit at the start of each round.', default=True) self.setting_dynatime_announce_string = Setting( 'dynatime_announce_string', 'Dynatime announce string', Setting.CAT_BEHAVIOUR, type=str, description= 'Set announce string. Can contain "{map}", "{medal}", "{medal_time}", "{new_time}" to format string.', default= '$ff0Dynatime set new time limit for map $fff{map}$ff0 to $fff⏳ {new_time}$ff0, based on the {medal}-medal of $fff🏆 {medal_time}' ) self.setting_dynatime_medal = Setting( 'dynatime_medal', 'Dynatime medal', Setting.CAT_BEHAVIOUR, type=int, description= 'Set medal to determine map time (0: bronze, 1: silver, 2: gold, 3: author).', default=3) self.setting_dynatime_multiplier = Setting( 'dynatime_multiplier', 'Dynatime multiplier', Setting.CAT_BEHAVIOUR, type=float, description='Set multiplier (1.0 - 10.0).', default=4.0) self.setting_dynatime_minimum_time = Setting( 'dynatime_minimum_time', 'Dynatime minimum time', Setting.CAT_BEHAVIOUR, type=int, description='Set minimum time limit.', default=180) self.setting_dynatime_maximum_time = Setting( 'dynatime_maximum_time', 'Dynatime maximum time', Setting.CAT_BEHAVIOUR, type=int, description='Set maximum time limit.', default=540) self.setting_dynatime_formula = Setting( 'dynatime_formula', 'Dynatime formula', Setting.CAT_BEHAVIOUR, type=str, description= 'Set the formula to calculate the time. Has to contain "{medal_time}" and "{multiplier}" for calculation. Can also contain "{min_time}" and "{max_time}".', default='{medal_time} * {multiplier} + {min_time}') self.setting_dynatime_round_time = Setting( 'dynatime_round_time', 'Dynatime round time', Setting.CAT_BEHAVIOUR, type=int, description= 'Rounds time limit to closest value (0: off 1-30: valid).', default=15)
from pyplanet.contrib.setting import Setting # Performance mode setting performance_mode = Setting( 'performance_mode', 'Performance mode playercount', Setting.CAT_BEHAVIOUR, type=int, description= 'Above this amount of players the performance mode will be enabled.', default=30)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.widget = None self.api = None self.lock = asyncio.Lock() self.current_records = [] self.current_script = None self.player_info = dict() self.v_replay = None self.v_replay_checks = None self.ghost_replay = None self.ghost_files = [] self.server_max_rank = None self.map_status = None self.map_uid = None self.ready = False self.setting_server_login = Setting( 'server_login', 'Dedimania Server Login', Setting.CAT_KEYS, type=str, description= 'Only fill in when you want to override the auto-detected server login!', default=None, change_target=self.reload_settings) self.setting_dedimania_code = Setting( 'dedimania_code', 'Dedimania Server Code', Setting.CAT_KEYS, type=str, description= 'The secret dedimania code. Get one at their site: $lhttp://dedimania.net/tm2stats/?do=register', default=None, change_target=self.reload_settings) self.setting_chat_welcome = Setting( 'chat_welcome', 'Display welcome message', Setting.CAT_BEHAVIOUR, type=bool, description= 'Whether to display a welcome message indicating the ranking limits (server and player).', default=False) self.setting_chat_announce = Setting( 'chat_announce', 'Minimum index for chat announce', Setting.CAT_BEHAVIOUR, type=int, description= 'Minimum record index needed for public new record/recordchange announcement (0 for disable).', default=50) self.setting_sent_announce = Setting( 'sent_announce', 'Announce sending times to dedimania', Setting.CAT_BEHAVIOUR, type=bool, description= 'Enable the announce of successfully sent records to dedimania message.', default=False) self.login = self.code = self.server_version = self.pack_mask = None
class DynamicPoints(AppConfig): game_dependencies = ['shootmania'] app_dependencies = ['core.maniaplanet'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.enabled = False self.current_limit = None self.next_limit = None self.setting_enable_dynamic_points = Setting( 'dynamic_points', 'Enable dynamic points limit', Setting.CAT_FEATURES, type=bool, description='Enable the dynamic points limit for Shootmania Royal.', default=True, change_target=self.enable_changed ) self.setting_min_points = Setting( 'min_points', 'Minimum number of points', Setting.CAT_GENERAL, type=int, description='The points limit will never go bellow this number of points.', default=10, change_target=self.on_changes ) self.setting_max_points = Setting( 'max_points', 'Maximum number of points', Setting.CAT_GENERAL, type=int, description='The points limit will never go above this number of points. Leave at 0 to disable.', default=0, change_target=self.on_changes ) self.setting_points_per_player = Setting( 'per_player_points', 'Points per player', Setting.CAT_GENERAL, type=int, description='The points every player should increase the total points limit of the map.', default=10, change_target=self.on_changes ) self.setting_change_during_map = Setting( 'change_during_map', 'Change during map gameplay', Setting.CAT_FEATURES, type=bool, description='Enable this to change points during a map gameplay.', default=True, change_target=self.on_changes ) self.setting_announce_points_change = Setting( 'announce_change', 'Announce points change at map start/end', Setting.CAT_FEATURES, type=bool, description='The points every player should increase the total points limit of the map.', default=True, change_target=self.on_changes ) def enable_changed(self, old, new): self.enabled = new def is_mode_supported(self, mode): return 'royal' in mode.lower() async def on_start(self): self.context.signals.listen(mp_signals.player.player_connect, self.on_changes) self.context.signals.listen(mp_signals.player.player_disconnect, self.on_changes) self.context.signals.listen(mp_signals.player.player_info_changed, self.on_changes) self.context.signals.listen(mp_signals.map.map_start, self.map_start) await self.context.setting.register( self.setting_enable_dynamic_points, self.setting_min_points, self.setting_max_points, self.setting_points_per_player, self.setting_announce_points_change, self.setting_change_during_map ) self.enabled = await self.setting_enable_dynamic_points.get_value() if self.enabled: await self.on_changes(enable_announce=True) async def on_changes(self, *args, **kwargs): if not self.enabled: return point_per_player = await self.setting_points_per_player.get_value() if point_per_player <= 0: return player_count = self.instance.player_manager.count_players total_points = player_count * point_per_player if await self.setting_change_during_map.get_value(): self.current_limit = total_points await self.set_limit(total_points, disable_announce='enable_announce' not in kwargs) self.next_limit = None else: self.next_limit = total_points async def set_limit(self, new_limit, disable_announce=False): min_limit, max_limit, announce = await asyncio.gather( self.setting_min_points.get_value(), self.setting_max_points.get_value(), self.setting_announce_points_change.get_value(), ) if min_limit > 0 and new_limit < min_limit: new_limit = min_limit if max_limit > 0 and new_limit > max_limit: new_limit = max_limit if new_limit <= 0 or not new_limit: return await self.instance.mode_manager.update_settings({ 'S_MapPointsLimit': int(new_limit) }) if announce and not disable_announce: await self.instance.chat( '$ff0The points limit has been changed to $fff{}$z$s$ff0.'.format(new_limit) ) async def map_start(self, *args, **kwargs): if self.next_limit and not await self.setting_change_during_map.get_value(): self.current_limit = self.next_limit await self.set_limit(self.next_limit, disable_announce=kwargs.get('restarted', False)) self.next_limit = None
def __init__(self, *args, **kwargs): """ Initializes the voting plugin. """ super().__init__(*args, **kwargs) self.current_vote = None self.widget = None self.podium_stage = False self.setting_voting_enabled = Setting( 'voting_enabled', 'Voting enabled', Setting.CAT_BEHAVIOUR, type=bool, description='Whether or not chat-based voting is enabled.', default=True ) self.setting_voting_ratio = Setting( 'voting_ratio', 'Voting ratio', Setting.CAT_BEHAVIOUR, type=float, description='Ratio of players that have to vote in favour for the vote to go through (between 0 and 1).', default=0.6 ) self.setting_voting_timeout = Setting( 'voting_timeout', 'Voting timeout', Setting.CAT_BEHAVIOUR, type=int, description='Timeout in seconds before a vote is cancelled if the required votes aren\'t achieved (0 = no timeout).', default=120 ) self.setting_callvoting_disable = Setting( 'callvoting_disable', 'Disable callvoting', Setting.CAT_BEHAVIOUR, type=bool, description='Disable callvoting when chat-based voting is enabled.', default=True ) self.setting_callvoting_timeout = Setting( 'callvoting_timeout', 'Callvote time-out (chat disabled)', Setting.CAT_BEHAVIOUR, type=int, description='Callvote time-out in milliseconds, set when the chat-voting plugin is disabled (0 = disabled).', default=60000 ) self.setting_enabled_replay = Setting( 'enabled_replay', 'Replay vote enabled', Setting.CAT_BEHAVIOUR, type=bool, description='Whether or not the replay vote is enabled.', default=True ) self.setting_enabled_restart = Setting( 'enabled_restart', 'Restart vote enabled', Setting.CAT_BEHAVIOUR, type=bool, description='Whether or not the restart vote is enabled.', default=True ) self.setting_enabled_skip = Setting( 'enabled_skip', 'Skip vote enabled', Setting.CAT_BEHAVIOUR, type=bool, description='Whether or not the skip vote is enabled.', default=True ) self.setting_enabled_time_extend = Setting( 'enabled_time_extend', 'Time Extend vote enabled', Setting.CAT_BEHAVIOUR, type=bool, description='Whether or not the time extend vote is enabled (only works in TimeAttack mode).', default=True ) self.setting_remind_interval = Setting( 'remind_interval', 'Vote reminder interval', Setting.CAT_BEHAVIOUR, type=int, description='Interval in seconds before players are reminded to vote.', default=30 )
async def on_start(self): await super().on_start() settings = await self.instance.mode_manager.get_settings() if 'S_TimeLimit' in settings: self.time_limit = settings['S_TimeLimit'] echo = callback.Callback('ManiaPlanet.Echo', 'maniaplanet', code='maniaplanet_echo', target=self.handle_echo) self.instance.signal_manager.register_signal(echo, app=None, callback=True) await self.instance.command_manager.register( Command('skip', aliases=['next'], admin=False, target=self.skip_vote)) await self.instance.command_manager.register( Command('restart', aliases=['res'], admin=False, target=self.restart_vote)) await self.instance.command_manager.register( Command('cancelvote', aliases=['cancel'], admin=True, target=self.cancel_vote)) await self.instance.command_manager.register( Command('time', admin=False, target=self.vote_time)) await self.instance.command_manager.register( Command('afk', admin=False, target=self.go_afk)) await self.instance.command_manager.register( Command('re', admin=False, target=self.go_re)) await self.instance.command_manager.register( Command('nextmap', admin=False, target=self.get_next_map)) await self.context.setting.register( Setting( 'max_votes', 'Maximum votes per player and map', category=Setting.CAT_GENERAL, type=int, description= 'Maximum number of votes a player can start on a map (<1 = infinite)', default=1)) await self.context.setting.register( Setting( 'vote_cooldown', 'Minimum time between votes (sec)', category=Setting.CAT_GENERAL, type=int, description= 'Minimum time a player has to wait until they can start a new vote' ' after their last vote failed. In seconds', default=600)) await self.context.setting.register(self.setting_show_bt) await self.context.setting.register(self.setting_vote_time_ratio) await self.context.setting.register(self.setting_vote_time_timeout) self.instance.signal_manager.listen(mp_signals.map.map_start, self.map_start) self.instance.signal_manager.listen(mp_signals.flow.podium_start, self.on_map_end) self.instance.signal_manager.listen(mp_signals.player.player_connect, self.on_connect) await self.display()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Initiate the logo views. self.paypal_view = PayPalLogoView(self, manager=self.context.ui) self.discord_view = DiscordLogoView(self, manager=self.context.ui) self.paypal_donation_url = None self.discord_join_url = None self.discord_server_id = None self.random_future = None self.random_last_message = None # Initiate settings. self.setting_enable_paypal = Setting( 'paypal_enable', 'Show PayPal Donation Logo', Setting.CAT_DESIGN, type=bool, description= 'Show the PayPal logo with clickable link to donation page', change_target=self.reload_settings, default=False) self.setting_paypal_url = Setting( 'paypal_url', 'PayPal Donation URL', Setting.CAT_KEYS, type=str, description='Your personalized PayPal donation link.', change_target=self.reload_settings, ) self.setting_enable_discord = Setting( 'discord_enable', 'Show Discord Logo', Setting.CAT_DESIGN, type=bool, description= 'Show the Discord logo with clickable link to join the server', change_target=self.reload_settings, default=False) self.setting_discord_join_url = Setting( 'discord_url', 'Discord Invite URL', Setting.CAT_KEYS, type=str, description= 'Set the link to not expire in discord for this to keep working!', default='https://discord.gg/x9amg5K', change_target=self.reload_settings) self.setting_discord_server_id = Setting( 'discord_id', 'Discord Server ID', Setting.CAT_KEYS, type=str, description= 'Get your discord server ID and enable the widget in the discord server settings!', default='158349559959912448', change_target=self.reload_settings) self.setting_random_messages = Setting( 'random_messages', 'Random Messages', Setting.CAT_BEHAVIOUR, type=list, description='Show random messages at random moments in the chat. ' 'The messages will be displayed every time the interval passes (another setting).', default=None, change_target=self.reload_settings) self.setting_random_messages_interval = Setting( 'random_messages_interval', 'Random Messages Interval', Setting.CAT_BEHAVIOUR, type=int, description= 'The interval of the random messages in seconds. Default 2 minutes (120 seconds)', default=120, change_target=self.reload_settings)