11from base_plugin import SimpleCommandPlugin , BasePlugin
22from core_plugins .player_manager import permissions , UserLevels
33from packets import chat_sent
4- from utility_functions import give_item_to_player
4+ from utility_functions import give_item_to_player , extract_name
55
66
77class UserCommandPlugin (SimpleCommandPlugin ):
@@ -18,25 +18,6 @@ def activate(self):
1818 self .player_manager = self .plugins ['player_manager' ].player_manager
1919 self .godmode = {}
2020
21- @staticmethod
22- def extract_name (l ):
23- name = []
24- if l [0 ][0 ] not in ["'" , '"' ]:
25- return l [0 ], l [1 :]
26- name .append (l [0 ][1 :])
27- terminator = l [0 ][0 ]
28- for idx , s in enumerate (l [1 :]):
29- if s [- 1 ] == terminator :
30- name .append (s [:- 1 ])
31- if idx + 2 != len (l ):
32- return " " .join (name ), l [idx + 2 :]
33- else :
34- return " " .join (name ), None
35- else :
36- name .append (s )
37- raise ValueError ("Final terminator character of <%s> not found" %
38- terminator )
39-
4021 def who (self , data ):
4122 """Returns all current users on the server. Syntax: /who"""
4223 who = [w .colored_name (self .config .colors ) for w in self .player_manager .who ()]
@@ -122,7 +103,7 @@ def make_admin(self, player):
122103 @permissions (UserLevels .MODERATOR )
123104 def kick (self , data ):
124105 """Kicks a user from the server. Usage: /kick [username] [reason]"""
125- name , reason = self . extract_name (data )
106+ name , reason = extract_name (data )
126107 if reason is None :
127108 reason = "no reason given"
128109 info = self .player_manager .whois (name )
@@ -169,7 +150,7 @@ def unban(self, data):
169150 def give_item (self , data ):
170151 """Gives an item to a player. Syntax: /give [target player] [item name] [optional: item count]"""
171152 if len (data ) >= 2 :
172- name , item = self . extract_name (data )
153+ name , item = extract_name (data )
173154 target_player = self .player_manager .get_logged_in_by_name (name )
174155 target_protocol = self .protocol .factory .protocols [target_player .protocol ]
175156 if target_player is not None :
@@ -225,6 +206,7 @@ def passthrough(self, data):
225206 """Sets the server to passthrough mode. *This is irreversible without restart.* Syntax: /passthrough"""
226207 self .config .passthrough = True
227208
209+
228210class MuteManager (BasePlugin ):
229211 name = "mute_manager"
230212 def on_chat_sent (self , data ):
0 commit comments