Prevent chained aliases in chatalias #43

Merged
Dico200 merged 7 commits from chatalias-chained-aliases-patch into dev 2016-05-28 21:06:32 +00:00
Showing only changes of commit c3189639f0 - Show all commits

View File

@ -191,6 +191,8 @@ def radd(sender, args):
if args[3].lower() == "false": if args[3].lower() == "false":
plugin_header(target, "Alias") plugin_header(target, "Alias")
msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!")
elif args[3].lower() != "true":
args[2] += " " + args[3]
if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(target, permission_AMOUNT)): if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(target, permission_AMOUNT)):
msg(sender, "&cCould not create alias: Max_limit reached!") msg(sender, "&cCould not create alias: Max_limit reached!")
if args[3].lower() == "false": if args[3].lower() == "false":
@ -274,7 +276,7 @@ def rlist_alias(sender, args):
plugin_header(sender, "Alias") plugin_header(sender, "Alias")
target = get_player(args[0]) target = get_player(args[0])
if is_player(sender): if is_player(sender):
sender_name = colorify(sender.getDisplayName) sender_name = colorify(sender.getDisplayName())
else: else:
sender_name = colorify("&6Console") sender_name = colorify("&6Console")
if len(args) == 1: if len(args) == 1:
@ -282,11 +284,9 @@ def rlist_alias(sender, args):
msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):") msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):")
if args[1].lower() == "false": if args[1].lower() == "false":
plugin_header(target, "Alias") plugin_header(target, "Alias")
msg(target, "&cPlayer " + sender_name + " &cis listing your aliases (" + str(len(data[uid(target)])) + " in total):") msg(target, "&cPlayer " + sender_name + " &cis listing your aliases")
for word, alias in data[str(uid(target))].items(): for word, alias in data[str(uid(target))].items():
msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color"))
if args[1].lower() == "false":
msg(target, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color"))
return True return True
@ -341,15 +341,21 @@ def save_data_thread(uuid):
# Subcommands: # Subcommands:
subcommands = { subcommands = {
"help": help, "help": help,
"?": help,
"add": add, "add": add,
"remove": remove, "remove": remove,
"del": remove,
"delete": remove,
"player": remote, "player": remote,
"remote": remote,
"list": list_alias "list": list_alias
} }
remotes = { remotes = {
"add": radd, "add": radd,
"remove": rremove, "remove": rremove,
"del": rremove,
"delete": rremove,
"list": rlist_alias, "list": rlist_alias,
} }
@ -360,9 +366,9 @@ if not enabled:
error = colorify("&6Incompatible versions detected (&chelpers.py&6)") error = colorify("&6Incompatible versions detected (&chelpers.py&6)")
for player in server.getOnlinePlayers(): for player in server.getOnlinePlayers():
if enabled: if enabled:
t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) t = threading.Thread(target=load_data, args=(uid(player), ))
t.daemon = True t.daemon = True
t.start() t.start()
else: else:
if event.getPlayer().hasPermission(permission_FINFO): if player.hasPermission(permission_FINFO):
disabled_fallback(event.getPlayer()) disabled_fallback(player)