Fixed player subcommand, removed debug outputs #41
20
chatalias.py
20
chatalias.py
@ -27,7 +27,7 @@ error = colorify("&cUnspecified error")
|
|||||||
commands_per_page = 5
|
commands_per_page = 5
|
||||||
global_aliases = {"./":"/"}
|
global_aliases = {"./":"/"}
|
||||||
data = {}
|
data = {}
|
||||||
# DON'T SET THIS TO TRUE! MySQL requestst are NOT async yet! (And for some reason it doesn't want to store any data ._.)
|
# DON'T SET THIS TO TRUE! MySQL requestst are NOT ASYNC yet! (And for some reason it doesn't want to store any data ._.)
|
||||||
use_mysql = False
|
use_mysql = False
|
||||||
|
|
||||||
# Permissions:
|
# Permissions:
|
||||||
@ -55,6 +55,7 @@ permission_FINFO = "utils.alias.finfo"
|
|||||||
# CODE #
|
# CODE #
|
||||||
########
|
########
|
||||||
|
|
||||||
|
# OnEnable
|
||||||
enabled = helpers_version in helpers_versions
|
enabled = helpers_version in helpers_versions
|
||||||
if not enabled:
|
if not enabled:
|
||||||
error = colorify("&6Incompatible versions detected (&chelpers.py&6)")
|
error = colorify("&6Incompatible versions detected (&chelpers.py&6)")
|
||||||
@ -124,7 +125,6 @@ def help(sender, args):
|
|||||||
|
|
||||||
@hook.event("player.PlayerJoinEvent", "high")
|
@hook.event("player.PlayerJoinEvent", "high")
|
||||||
def on_join(event):
|
def on_join(event):
|
||||||
try:
|
|
||||||
if enabled:
|
if enabled:
|
||||||
t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), ))
|
t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), ))
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
@ -132,8 +132,6 @@ def on_join(event):
|
|||||||
else:
|
else:
|
||||||
if event.getPlayer().hasPermission(permission_FINFO):
|
if event.getPlayer().hasPermission(permission_FINFO):
|
||||||
disabled_fallback(event.getPlayer())
|
disabled_fallback(event.getPlayer())
|
||||||
except:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
@hook.event("player.AsyncPlayerChatEvent", "high")
|
@hook.event("player.AsyncPlayerChatEvent", "high")
|
||||||
@ -155,7 +153,8 @@ def on_player_chat(event):
|
|||||||
else:
|
else:
|
||||||
event.setMessage(event.getMessage().replace(alias, value))
|
event.setMessage(event.getMessage().replace(alias, value))
|
||||||
except:
|
except:
|
||||||
return
|
print(trace())
|
||||||
|
|
||||||
|
|
||||||
def hasPerm(player, permission):
|
def hasPerm(player, permission):
|
||||||
return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL))
|
return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL))
|
||||||
@ -279,12 +278,15 @@ def remote(sender, args):
|
|||||||
except:
|
except:
|
||||||
return subcommands["help"](sender, ["2"])
|
return subcommands["help"](sender, ["2"])
|
||||||
|
|
||||||
|
|
||||||
def load_data(uuid):
|
def load_data(uuid):
|
||||||
|
try:
|
||||||
load_data_thread(uuid)
|
load_data_thread(uuid)
|
||||||
# t = threading.Thread(target=load_data_thread, args=(uuid))
|
# t = threading.Thread(target=load_data_thread, args=(uuid))
|
||||||
# t.daemon = True
|
# t.daemon = True
|
||||||
# t.start()
|
# t.start()
|
||||||
|
except:
|
||||||
|
print(trace())
|
||||||
|
|
||||||
def load_data_thread(uuid):
|
def load_data_thread(uuid):
|
||||||
if use_mysql:
|
if use_mysql:
|
||||||
@ -299,11 +301,15 @@ def load_data_thread(uuid):
|
|||||||
else:
|
else:
|
||||||
data[uuid] = safe_open_json(uuid)
|
data[uuid] = safe_open_json(uuid)
|
||||||
|
|
||||||
|
|
||||||
def save_data(uuid):
|
def save_data(uuid):
|
||||||
|
try:
|
||||||
save_data_thread(uuid)
|
save_data_thread(uuid)
|
||||||
# t = threading.Thread(target=save_data_thread, args=(uuid))
|
# t = threading.Thread(target=save_data_thread, args=(uuid))
|
||||||
# t.daemon = True
|
# t.daemon = True
|
||||||
# t.start()
|
# t.start()
|
||||||
|
except:
|
||||||
|
print(trace())
|
||||||
|
|
||||||
def save_data_thread(uuid):
|
def save_data_thread(uuid):
|
||||||
if use_mysql:
|
if use_mysql:
|
||||||
@ -313,8 +319,8 @@ def save_data_thread(uuid):
|
|||||||
else:
|
else:
|
||||||
save_json_file("aliases/" + uuid, data[uuid])
|
save_json_file("aliases/" + uuid, data[uuid])
|
||||||
|
|
||||||
# Subcommands:
|
|
||||||
|
|
||||||
|
# Subcommands:
|
||||||
subcommands = {
|
subcommands = {
|
||||||
"help": help,
|
"help": help,
|
||||||
"add": add,
|
"add": add,
|
||||||
|
Reference in New Issue
Block a user