9 Commits

Author SHA1 Message Date
Dico200
c3189639f0 Fixes and stuff 2016-05-28 23:05:43 +02:00
Pepich
c534d9316a Moved OnModuleLoad to bottom of file 2016-05-28 22:40:08 +02:00
Pepich
7da3fd5b71 That's an "s", not an "S" ._. 2016-05-28 22:35:28 +02:00
Pepich
a19f0b5bdc Added support for /rl; Made comments more precise 2016-05-28 22:33:38 +02:00
Dico200
1fdf97f77a Add missing _ ... lol 2016-05-25 16:46:49 +02:00
Dico200
16e78a2677 Add missing ) to chatalias 2016-05-25 16:44:09 +02:00
Dico
2d6725df73 Prevent chained aliases in chatalias
Prevents 1 -> 23 along with 2 -> 3 and similar stuff
2016-05-25 16:40:31 +02:00
Dico200
d88baa4899 What is this.. sorry 2016-05-25 16:37:58 +02:00
Dico200
29f846c8f9 Undo prior changes in favor of pull request 2016-05-25 16:31:32 +02:00

View File

@@ -55,12 +55,6 @@ permission_FINFO = "utils.alias.finfo"
# CODE #
########
# OnEnable
enabled = helpers_version in helpers_versions
if not enabled:
error = colorify("&6Incompatible versions detected (&chelpers.py&6)")
def safe_open_json(uuid):
if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"):
os.makedirs("plugins/redstoner-utils.py.dir/files/aliases")
@@ -180,7 +174,7 @@ def add(sender, args):
return True
args = [args[0]] + [" ".join(args[1:])]
if not add_alias_data(uid(sender), str(args[0]), args[1]):
msg(sender, colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it")
msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times", usecolor = False)
return True
msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color"))
return True
@@ -197,6 +191,8 @@ def radd(sender, args):
if args[3].lower() == "false":
plugin_header(target, "Alias")
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)):
msg(sender, "&cCould not create alias: Max_limit reached!")
if args[3].lower() == "false":
@@ -205,7 +201,7 @@ def radd(sender, args):
if len(args) == 3:
args += ["true"]
if not add_alias_data(uid(target), str(args[1]), str(args[2])):
message = colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it"
message = colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times"
msg(sender, message)
if args[3].lower() == "false":
msg(target, message)
@@ -218,10 +214,18 @@ def radd(sender, args):
def add_alias_data(puuid, aliased, new_alias):
prior = data[puuid]
# prevent 2 -> 3 if there is 1 -> 2
if aliased not in prior:
for alias in prior.values():
if aliased in alias:
return False
# prevent 1 -> 2 if there is 2 -> 3
for sequence in prior:
if sequence in new_alias:
return False
prior[aliased] = new_alias
save_data(puuid)
return True
@@ -272,7 +276,7 @@ def rlist_alias(sender, args):
plugin_header(sender, "Alias")
target = get_player(args[0])
if is_player(sender):
sender_name = colorify(sender.getDisplayName)
sender_name = colorify(sender.getDisplayName())
else:
sender_name = colorify("&6Console")
if len(args) == 1:
@@ -280,11 +284,9 @@ def rlist_alias(sender, args):
msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):")
if args[1].lower() == "false":
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():
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
@@ -339,14 +341,34 @@ def save_data_thread(uuid):
# Subcommands:
subcommands = {
"help": help,
"?": help,
"add": add,
"remove": remove,
"del": remove,
"delete": remove,
"player": remote,
"remote": remote,
"list": list_alias
}
remotes = {
"add": radd,
"remove": rremove,
"del": rremove,
"delete": rremove,
"list": rlist_alias,
}
# OnModuleLoad
enabled = helpers_version in helpers_versions
if not enabled:
error = colorify("&6Incompatible versions detected (&chelpers.py&6)")
for player in server.getOnlinePlayers():
if enabled:
t = threading.Thread(target=load_data, args=(uid(player), ))
t.daemon = True
t.start()
else:
if player.hasPermission(permission_FINFO):
disabled_fallback(player)