Prevent complete multi-replacement in chatalias. Doesn't prevent 1 -> 2 and 23 -> 5 to make for 13 -> 5, but does prevent a -> 20 and 2 -> 3. Tested.
This commit is contained in:
25
chatalias.py
25
chatalias.py
@@ -86,6 +86,7 @@ def on_alias_command(sender, cmd, label, args):
|
|||||||
return True
|
return True
|
||||||
return subcommands[args[0].lower()](sender, args[1:])
|
return subcommands[args[0].lower()](sender, args[1:])
|
||||||
except:
|
except:
|
||||||
|
print(trace())
|
||||||
return subcommands["help"](sender, "1")
|
return subcommands["help"](sender, "1")
|
||||||
|
|
||||||
|
|
||||||
@@ -179,8 +180,9 @@ def add(sender, args):
|
|||||||
msg(sender, "&cCould not create alias: Max_limit reached!")
|
msg(sender, "&cCould not create alias: Max_limit reached!")
|
||||||
return True
|
return True
|
||||||
args = [args[0]] + [" ".join(args[1:])]
|
args = [args[0]] + [" ".join(args[1:])]
|
||||||
data[str(uid(sender))][str(args[0])] = args[1]
|
if not add_alias_data(uid(sender), str(args[0]), args[1]):
|
||||||
save_data(uid(sender))
|
msg(sender, colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it")
|
||||||
|
return True
|
||||||
msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color"))
|
msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color"))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -203,14 +205,29 @@ def radd(sender, args):
|
|||||||
return True
|
return True
|
||||||
if len(args) == 3:
|
if len(args) == 3:
|
||||||
args += ["true"]
|
args += ["true"]
|
||||||
data[str(uid(target))][str(args[1])] = str(args[2])
|
if not add_alias_data(uid(target), str(args[1]), str(args[2])):
|
||||||
save_data(uid(target))
|
message = colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it"
|
||||||
|
msg(sender, message)
|
||||||
|
if args[3].lower() == "false":
|
||||||
|
msg(target, message)
|
||||||
|
return True
|
||||||
msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
||||||
if args[3].lower() == "false":
|
if args[3].lower() == "false":
|
||||||
msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def add_alias_data(puuid, aliased, new_alias):
|
||||||
|
prior = data[puuid]
|
||||||
|
if aliased not in prior:
|
||||||
|
for alias in prior.values():
|
||||||
|
if aliased in alias:
|
||||||
|
return False
|
||||||
|
prior[aliased] = new_alias
|
||||||
|
save_data(puuid)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def remove(sender, args):
|
def remove(sender, args):
|
||||||
plugin_header(sender, "Alias")
|
plugin_header(sender, "Alias")
|
||||||
try:
|
try:
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -43,7 +43,7 @@ shared["load_modules"] = [
|
|||||||
# Adds /calc, toggles automatic solving of Math expressions in chat
|
# Adds /calc, toggles automatic solving of Math expressions in chat
|
||||||
"calc",
|
"calc",
|
||||||
# Adds aliasing of chat words
|
# Adds aliasing of chat words
|
||||||
#"chatalias",
|
"chatalias",
|
||||||
# Plugin to locate laggy chunks. /lc <n> lists chunks with more than n entities
|
# Plugin to locate laggy chunks. /lc <n> lists chunks with more than n entities
|
||||||
"lagchunks",
|
"lagchunks",
|
||||||
# Adds /report and /rp, Stores reports with time and location
|
# Adds /report and /rp, Stores reports with time and location
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
name: RedstonerUtils
|
name: RedstonerUtils
|
||||||
main: main.py
|
main: main.py
|
||||||
version: 3.1.0
|
version: 3.1.0
|
||||||
author: redstone_sheep
|
author: redstone_sheep
|
||||||
|
|
||||||
Reference in New Issue
Block a user