Fixed player subcommand, removed debug outputs #41
41
chatalias.py
41
chatalias.py
@ -11,6 +11,7 @@
|
|||||||
############################################
|
############################################
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import mysqlhack
|
||||||
import org.bukkit as bukkit
|
import org.bukkit as bukkit
|
||||||
from org.bukkit import *
|
from org.bukkit import *
|
||||||
from helpers import *
|
from helpers import *
|
||||||
@ -26,6 +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 ._.)
|
||||||
use_mysql = False
|
use_mysql = False
|
||||||
|
|
||||||
# Permissions:
|
# Permissions:
|
||||||
@ -83,7 +85,6 @@ 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")
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ def on_join(event):
|
|||||||
if event.getPlayer().hasPermission(permission_FINFO):
|
if event.getPlayer().hasPermission(permission_FINFO):
|
||||||
disabled_fallback(event.getPlayer())
|
disabled_fallback(event.getPlayer())
|
||||||
except:
|
except:
|
||||||
print(trace())
|
return
|
||||||
|
|
||||||
|
|
||||||
@hook.event("player.AsyncPlayerChatEvent", "high")
|
@hook.event("player.AsyncPlayerChatEvent", "high")
|
||||||
@ -154,7 +155,7 @@ def on_player_chat(event):
|
|||||||
else:
|
else:
|
||||||
event.setMessage(event.getMessage().replace(alias, value))
|
event.setMessage(event.getMessage().replace(alias, value))
|
||||||
except:
|
except:
|
||||||
print(trace())
|
return
|
||||||
|
|
||||||
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))
|
||||||
@ -186,8 +187,13 @@ def add(sender, args):
|
|||||||
|
|
||||||
|
|
||||||
def radd(sender, args):
|
def radd(sender, args):
|
||||||
args = [args[0:1]] + [" ".join([args[2:len(args)-2]])] + [args[len(args)-1]]
|
|
||||||
plugin_header(sender, "Alias")
|
plugin_header(sender, "Alias")
|
||||||
|
args = args[0:2] + [" ".join(args[2:len(args)-1])] + [args[len(args)-1]]
|
||||||
|
if is_player(sender):
|
||||||
|
sender_name = colorify(sender.getDisplayName())
|
||||||
|
else:
|
||||||
|
sender_name = colorify("&6Console")
|
||||||
|
target = get_player(args[0])
|
||||||
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!")
|
||||||
@ -196,12 +202,6 @@ def radd(sender, args):
|
|||||||
if args[3].lower() == "false":
|
if args[3].lower() == "false":
|
||||||
msg(target, "&cCould not create alias: Max_limit reached!")
|
msg(target, "&cCould not create alias: Max_limit reached!")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
target = get_player(args[0])
|
|
||||||
if is_player(sender):
|
|
||||||
sender_name = colorify(sender.getDisplayName)
|
|
||||||
else:
|
|
||||||
sender_name = colorify("&6Console")
|
|
||||||
if len(args) == 3:
|
if len(args) == 3:
|
||||||
args += ["true"]
|
args += ["true"]
|
||||||
data[str(uid(target))][str(args[1])] = str(args[2])
|
data[str(uid(target))][str(args[1])] = str(args[2])
|
||||||
@ -226,11 +226,10 @@ def rremove(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 args[2].lower() == "false":
|
if args[2].lower() == "false":
|
||||||
print("WTF")
|
|
||||||
plugin_header(target, "Alias")
|
plugin_header(target, "Alias")
|
||||||
msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!")
|
msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!")
|
||||||
try:
|
try:
|
||||||
@ -276,13 +275,18 @@ def rlist_alias(sender, args):
|
|||||||
|
|
||||||
def remote(sender, args):
|
def remote(sender, args):
|
||||||
try:
|
try:
|
||||||
return remotes[args[1].lower()](sender, [args[0]] + [args[2:]])
|
return remotes[args[1].lower()](sender, [args[0]] + args[2:])
|
||||||
except:
|
except:
|
||||||
print(trace())
|
|
||||||
return subcommands["help"](sender, ["2"])
|
return subcommands["help"](sender, ["2"])
|
||||||
|
|
||||||
|
|
||||||
def load_data(uuid):
|
def load_data(uuid):
|
||||||
|
load_data_thread(uuid)
|
||||||
|
# t = threading.Thread(target=load_data_thread, args=(uuid))
|
||||||
|
# t.daemon = True
|
||||||
|
# t.start()
|
||||||
|
|
||||||
|
|
||||||
|
def load_data_thread(uuid):
|
||||||
if use_mysql:
|
if use_mysql:
|
||||||
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
||||||
curs = conn.cursor()
|
curs = conn.cursor()
|
||||||
@ -295,8 +299,13 @@ def load_data(uuid):
|
|||||||
else:
|
else:
|
||||||
data[uuid] = safe_open_json(uuid)
|
data[uuid] = safe_open_json(uuid)
|
||||||
|
|
||||||
|
|
||||||
def save_data(uuid):
|
def save_data(uuid):
|
||||||
|
save_data_thread(uuid)
|
||||||
|
# t = threading.Thread(target=save_data_thread, args=(uuid))
|
||||||
|
# t.daemon = True
|
||||||
|
# t.start()
|
||||||
|
|
||||||
|
def save_data_thread(uuid):
|
||||||
if use_mysql:
|
if use_mysql:
|
||||||
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
|
||||||
curs = conn.cursor()
|
curs = conn.cursor()
|
||||||
|
Reference in New Issue
Block a user