def add_map(self, filename, insert=True, save_matchsettings=True):
"""
Add or insert map to current online playlist.
:param filename: Load from filename relative to the 'Maps' directory on the dedicated host server.
:param insert: Insert after the current map, this will make it play directly after the current map. True by default.
:param save_matchsettings: Save match settings as well.
:type filename: str
:type insert: bool
:type save_matchsettings: bool
:raise: pyplanet.contrib.map.exceptions.MapIncompatible
:raise: pyplanet.contrib.map.exceptions.MapException
"""
gbx_method = 'InsertMap' if insert else 'AddMap'
try:
result = await self._instance.gbx(gbx_method, filename)
except Fault as e:
if 'unknown' in e.faultString:
raise MapNotFound('Map is not found on the server.')
elif 'already' in e.faultString:
raise MapException('Map already added to server.')
raise MapException(e.faultString)
# Try to save match settings.
try:
if save_matchsettings:
await self.save_matchsettings()
except Exception as e:
handle_exception(e, __name__, 'add_map', extra_data={'EXTRAHOOK': 'Map Insert bug, see #306'})
return result
评论列表
文章目录