Skip to content

Commit cead363

Browse files
author
KirillMysnik
committed
Fix command front end not unregistering its callback when admin included/custom plugin is unloaded
1 parent 3ba93be commit cead363

File tree

1 file changed

+17
-7
lines changed
  • srcds/addons/source-python/plugins/admin/core/frontends

1 file changed

+17
-7
lines changed

srcds/addons/source-python/plugins/admin/core/frontends/commands.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Source.Python
55
from commands import CommandReturn
66
from commands.typed import TypedClientCommand, TypedSayCommand
7+
from core import AutoUnload
78
from filters.players import PlayerIter
89

910
# Source.Python Admin
@@ -61,7 +62,7 @@ def iter_filter_targets(filter_str, filter_args, issuer):
6162
# =============================================================================
6263
# >> CLASSES
6364
# =============================================================================
64-
class BaseFeatureCommand:
65+
class BaseFeatureCommand(AutoUnload):
6566
def __init__(self, commands, feature):
6667
if isinstance(commands, str):
6768
commands = [commands, ]
@@ -70,17 +71,21 @@ def __init__(self, commands, feature):
7071

7172
self.feature = feature
7273

73-
TypedSayCommand(
74+
self._public_chat_command = TypedSayCommand(
7475
['!spa', ] + commands, feature.flag
75-
)(self._get_public_chat_callback())
76+
)
7677

77-
TypedSayCommand(
78+
self._private_chat_command = TypedSayCommand(
7879
['/spa', ] + commands, feature.flag
79-
)(self._get_private_chat_callback())
80+
)
8081

81-
TypedClientCommand(
82+
self._client_command = TypedClientCommand(
8283
['spa', ] + commands, feature.flag
83-
)(self._get_client_callback())
84+
)
85+
86+
self._public_chat_command(self._get_public_chat_callback())
87+
self._private_chat_command(self._get_private_chat_callback())
88+
self._client_command(self._get_client_callback())
8489

8590
def _get_public_chat_callback(self):
8691
raise NotImplementedError
@@ -91,6 +96,11 @@ def _get_private_chat_callback(self):
9196
def _get_client_callback(self):
9297
raise NotImplementedError
9398

99+
def _unload_instance(self):
100+
self._public_chat_command._unload_instance()
101+
self._private_chat_command._unload_instance()
102+
self._client_command._unload_instance()
103+
94104

95105
class FeatureCommand(BaseFeatureCommand):
96106
def _execute(self, command_info):

0 commit comments

Comments
 (0)