|
| 1 | +# ============================================================================= |
| 2 | +# >> IMPORTS |
| 3 | +# ============================================================================= |
| 4 | +# Source.Python Admin |
| 5 | +from admin.admin import main_menu |
| 6 | +from admin.core.features import PlayerBasedFeature |
| 7 | +from admin.core.frontends.menus import ( |
| 8 | + AdminMenuSection, PlayerBasedAdminCommand) |
| 9 | +from admin.core.helpers import log_admin_action |
| 10 | +from admin.core.plugins.strings import PluginStrings |
| 11 | + |
| 12 | + |
| 13 | +# ============================================================================= |
| 14 | +# >> GLOBAL VARIABLES |
| 15 | +# ============================================================================= |
| 16 | +plugin_strings = PluginStrings("admin_life_management") |
| 17 | + |
| 18 | + |
| 19 | +# ============================================================================= |
| 20 | +# >> CLASSES |
| 21 | +# ============================================================================= |
| 22 | +class _SlayFeature(PlayerBasedFeature): |
| 23 | + flag = "admin.admin_life_management.slay" |
| 24 | + |
| 25 | + def execute(self, client, player): |
| 26 | + player.slay() |
| 27 | + |
| 28 | + log_admin_action(plugin_strings['message slayed'].tokenized( |
| 29 | + admin_name=client.player.name, |
| 30 | + player_name=player.name, |
| 31 | + )) |
| 32 | + |
| 33 | +# The singleton object of the _SlayFeature class. |
| 34 | +slay_feature = _SlayFeature() |
| 35 | + |
| 36 | + |
| 37 | +class _ResurrectFeature(PlayerBasedFeature): |
| 38 | + flag = "admin.admin_life_management.resurrect" |
| 39 | + |
| 40 | + def execute(self, client, player): |
| 41 | + player.spawn() |
| 42 | + |
| 43 | + log_admin_action(plugin_strings['message resurrected'].tokenized( |
| 44 | + admin_name=client.player.name, |
| 45 | + player_name=player.name, |
| 46 | + )) |
| 47 | + |
| 48 | +# The singleton object of the _ResurrectFeature class. |
| 49 | +resurrect_feature = _ResurrectFeature() |
| 50 | + |
| 51 | + |
| 52 | +# ============================================================================= |
| 53 | +# >> MENU ENTRIES |
| 54 | +# ============================================================================= |
| 55 | +menu_section = main_menu.add_entry(AdminMenuSection( |
| 56 | + main_menu, plugin_strings['section_title'])) |
| 57 | + |
| 58 | +slay_menu_command = menu_section.add_entry(PlayerBasedAdminCommand( |
| 59 | + slay_feature, |
| 60 | + menu_section, |
| 61 | + plugin_strings['popup_title slay'] |
| 62 | +)) |
| 63 | + |
| 64 | +resurrect_menu_command = menu_section.add_entry(PlayerBasedAdminCommand( |
| 65 | + resurrect_feature, |
| 66 | + menu_section, |
| 67 | + plugin_strings['popup_title resurrect'] |
| 68 | +)) |
0 commit comments