Acctualy, its simpler to just do it all in a thread.

This commit is contained in:
PanFritz
2015-09-11 11:43:57 +02:00
parent ebb893289c
commit d751654ff8

View File

@@ -31,11 +31,14 @@ def get_last_seen(player):
# receive link and email from website # receive link and email from website
def get_webite_data(player): def get_website_data(player):
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
curs = conn.cursor()
uuid = str(uid(player)).replace("-", "") uuid = str(uid(player)).replace("-", "")
async_query(mysql_database,"SELECT DISTINCT `id`, `email` FROM users WHERE `uuid` = ? LIMIT 1",(uuid,),get_website_data_target) curs.execute("SELECT DISTINCT `id`, `email` FROM users WHERE `uuid` = ? LIMIT 1", (uuid,))
results = curs.fetchall()
def get_website_data_target(results): curs.close()
conn.close()
return ("http://redstoner.com/users/%s" % results[0][0], results[0][1]) if results else (None, None) return ("http://redstoner.com/users/%s" % results[0][0], results[0][1]) if results else (None, None)
@@ -83,7 +86,10 @@ def on_hook_command(sender, command, label, args):
plugin_header(sender, "Check") plugin_header(sender, "Check")
msg(sender, "&7Please notice that the data may not be fully accurate!") msg(sender, "&7Please notice that the data may not be fully accurate!")
player = server.getOfflinePlayer(args[0]) if len(args) > 0 else None player = server.getOfflinePlayer(args[0]) if len(args) > 0 else None
get_all_data(sender, player)
t = threading.Thread(target=get_all_data args=(sender, player))
t.daemon = True
t.start()
else: else:
msg(sender, "&4You don't have the required permissions to execute this command!") msg(sender, "&4You don't have the required permissions to execute this command!")
return True return True