Solidify imbusy blocking pms, tpas, etc. #42
15
imbusy.py
15
imbusy.py
@ -154,6 +154,7 @@ class CommandWrapper(Command):
|
|||||||
def tabComplete(self, sender, alias, args):
|
def tabComplete(self, sender, alias, args):
|
||||||
return self.wrapped.tabComplete(sender, alias, args)
|
return self.wrapped.tabComplete(sender, alias, args)
|
||||||
|
|
||||||
|
|
||||||
def msg_command_checker(sender, args):
|
def msg_command_checker(sender, args):
|
||||||
return len(args) <= 1 or whisper(sender, args[0])
|
return len(args) <= 1 or whisper(sender, args[0])
|
||||||
|
|
||||||
@ -172,6 +173,15 @@ def tpa_command_checker(sender, args):
|
|||||||
def tpahere_command_checker(sender, args):
|
def tpahere_command_checker(sender, args):
|
||||||
return tpa_command_checker(sender, args)
|
return tpa_command_checker(sender, args)
|
||||||
|
|
||||||
|
def mail_command_checker(sender, args):
|
||||||
|
if len(args) < 3 or args[0].lower() != "send":
|
||||||
|
return True
|
||||||
|
target = server.getPlayer(args[1])
|
||||||
|
if target is not None and target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players:
|
||||||
|
msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName())
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@hook.event("player.PlayerCommandPreprocessEvent", "monitor")
|
@hook.event("player.PlayerCommandPreprocessEvent", "monitor")
|
||||||
def on_player_command_preprocess(event):
|
def on_player_command_preprocess(event):
|
||||||
@ -196,11 +206,13 @@ def replace_ess_commands():
|
|||||||
ess_reply_cmd = map.get("essentials:reply")
|
ess_reply_cmd = map.get("essentials:reply")
|
||||||
ess_tpa_cmd = map.get("essentials:tpa")
|
ess_tpa_cmd = map.get("essentials:tpa")
|
||||||
ess_tpahere_cmd = map.get("essentials:tpahere")
|
ess_tpahere_cmd = map.get("essentials:tpahere")
|
||||||
|
ess_mail_cmd = map.get("essentials:mail")
|
||||||
|
|
||||||
msg_cmd_wrapper = CommandWrapper(ess_msg_cmd, msg_command_checker)
|
msg_cmd_wrapper = CommandWrapper(ess_msg_cmd, msg_command_checker)
|
||||||
reply_cmd_wrapper = CommandWrapper(ess_reply_cmd, reply_command_checker)
|
reply_cmd_wrapper = CommandWrapper(ess_reply_cmd, reply_command_checker)
|
||||||
tpa_cmd_wrapper = CommandWrapper(ess_tpa_cmd, tpa_command_checker)
|
tpa_cmd_wrapper = CommandWrapper(ess_tpa_cmd, tpa_command_checker)
|
||||||
tpahere_cmd_wrapper = CommandWrapper(ess_tpahere_cmd, tpahere_command_checker)
|
tpahere_cmd_wrapper = CommandWrapper(ess_tpahere_cmd, tpahere_command_checker)
|
||||||
|
mail_cmd_wrapper = CommandWrapper(ess_mail_cmd, mail_command_checker)
|
||||||
|
|
||||||
iterator = map.entrySet().iterator()
|
iterator = map.entrySet().iterator()
|
||||||
while iterator.hasNext():
|
while iterator.hasNext():
|
||||||
@ -218,6 +230,9 @@ def replace_ess_commands():
|
|||||||
elif value is ess_tpahere_cmd:
|
elif value is ess_tpahere_cmd:
|
||||||
entry.setValue(tpahere_cmd_wrapper)
|
entry.setValue(tpahere_cmd_wrapper)
|
||||||
info("[imbusy] wrapped /" + entry.getKey())
|
info("[imbusy] wrapped /" + entry.getKey())
|
||||||
|
elif value is ess_mail_cmd:
|
||||||
|
entry.setValue(mail_cmd_wrapper)
|
||||||
|
info("[imbusy] wrapped /" + entry.getKey())
|
||||||
|
|
||||||
except:
|
except:
|
||||||
error("[Imbusy] Failed to wrap essentials commands")
|
error("[Imbusy] Failed to wrap essentials commands")
|
||||||
|
Reference in New Issue
Block a user