@@ -93,49 +93,63 @@ def _get_client_callback(self):
93
93
94
94
95
95
class FeatureCommand (BaseFeatureCommand ):
96
- def _get_public_chat_callback (self ):
97
- def public_chat_callback (command_info ):
98
- client = clients [command_info .index ]
96
+ def _execute (self , command_info ):
97
+ client = clients [command_info .index ]
99
98
100
- # Sync execution to avoid issuer replacement if the feature itself
101
- # is going to execute any commands
102
- client .sync_execution (self .feature .execute , (client , ))
99
+ # Sync execution to avoid issuer replacement if the feature itself
100
+ # is going to execute any commands
101
+ client .sync_execution (self .feature .execute , (client ,))
103
102
103
+ def _get_public_chat_callback (self ):
104
+ def public_chat_callback (command_info ):
105
+ self ._execute (command_info )
104
106
return CommandReturn .CONTINUE
105
107
106
108
return public_chat_callback
107
109
108
110
def _get_private_chat_callback (self ):
109
111
def private_chat_callback (command_info ):
110
- client = clients [command_info .index ]
111
- client .sync_execution (self .feature .execute , (client ,))
112
+ self ._execute (command_info )
112
113
return CommandReturn .BLOCK
113
114
114
115
return private_chat_callback
115
116
116
117
def _get_client_callback (self ):
117
118
def client_callback (command_info ):
118
- client = clients [command_info .index ]
119
- client .sync_execution (self .feature .execute , (client ,))
119
+ self ._execute (command_info )
120
120
121
121
return client_callback
122
122
123
123
124
124
class PlayerBasedFeatureCommand (BaseFeatureCommand ):
125
- def _get_public_chat_callback (self ):
126
- def public_chat_callback (
127
- command_info , filter_str :str , filter_args :str = "" ):
125
+ def __init__ (self , commands , feature , deny_mass_execution = False ):
126
+ super ().__init__ (commands , feature )
127
+
128
+ self ._deny_mass_execution = deny_mass_execution
129
+
130
+ def _execute (self , command_info , filter_str , filter_args ):
131
+ client = clients [command_info .index ]
128
132
129
- client = clients [command_info .index ]
133
+ players = []
134
+ for player in iter_filter_targets (
135
+ filter_str , filter_args , client .player ):
130
136
131
- for player in iter_filter_targets (
132
- filter_str , filter_args , client . player ):
137
+ if not self . feature . filter ( client , player ):
138
+ continue
133
139
134
- if not self .feature .filter (client , player ):
135
- continue
140
+ players .append (player )
136
141
137
- client .sync_execution (self .feature .execute , (client , player ))
142
+ if self ._deny_mass_execution and len (players ) > 1 :
143
+ return
138
144
145
+ for player in players :
146
+ client .sync_execution (self .feature .execute , (client , player ))
147
+
148
+ def _get_public_chat_callback (self ):
149
+ def public_chat_callback (
150
+ command_info , filter_str :str , filter_args :str = "" ):
151
+
152
+ self ._execute (command_info , filter_str , filter_args )
139
153
return CommandReturn .CONTINUE
140
154
141
155
return public_chat_callback
@@ -144,30 +158,13 @@ def _get_private_chat_callback(self):
144
158
def private_chat_callback (
145
159
command_info , filter_str :str , filter_args :str = "" ):
146
160
147
- client = clients [command_info .index ]
148
-
149
- for player in iter_filter_targets (
150
- filter_str , filter_args , client .player ):
151
-
152
- if not self .feature .filter (client , player ):
153
- continue
154
-
155
- client .sync_execution (self .feature .execute , (client , player ))
156
-
161
+ self ._execute (command_info , filter_str , filter_args )
157
162
return CommandReturn .BLOCK
158
163
159
164
return private_chat_callback
160
165
161
166
def _get_client_callback (self ):
162
167
def client_callback (command_info , filter_str :str , filter_args :str = "" ):
163
- client = clients [command_info .index ]
164
-
165
- for player in iter_filter_targets (
166
- filter_str , filter_args , client .player ):
167
-
168
- if not self .feature .filter (client , player ):
169
- continue
170
-
171
- client .sync_execution (self .feature .execute , (client , player ))
168
+ self ._execute (command_info , filter_str , filter_args )
172
169
173
170
return client_callback
0 commit comments