added console support and fixed a small cosmetic bug

This commit is contained in:
Pepich
2015-10-18 16:06:09 +02:00
parent 70662bdd0b
commit fbbbad1853

View File

@@ -11,7 +11,6 @@ iptrack_permission = "utils.iptrack"
@hook.event("player.PlayerJoinEvent", "low") @hook.event("player.PlayerJoinEvent", "low")
def on_player_join(event): def on_player_join(event):
try:
player = event.getPlayer() player = event.getPlayer()
ip = player.getAddress().getHostString() ip = player.getAddress().getHostString()
uuid = uid(player) uuid = uid(player)
@@ -44,15 +43,12 @@ def on_player_join(event):
else: else:
curs.execute("UPDATE iptrack_iptouuids SET uuids = ? WHERE uuid = ?", (ip, json.dumps(uuids), )) curs.execute("UPDATE iptrack_iptouuids SET uuids = ? WHERE uuid = ?", (ip, json.dumps(uuids), ))
conn.commit() conn.commit()
except:
error(trace())
curs.close() curs.close()
conn.close() conn.close()
@hook.command("getinfo") @hook.command("getinfo")
def on_getinfo_command(sender, args): def on_getinfo_command(sender, args):
try:
if(sender.hasPermission(iptrack_permission)): if(sender.hasPermission(iptrack_permission)):
if not checkargs(sender, args, 1, 1): if not checkargs(sender, args, 1, 1):
return false return false
@@ -71,7 +67,10 @@ def on_getinfo_command(sender, args):
msg(sender, "IP " + args[0] + " was seen with " + str(len(uuids)) + " different Accounts:") msg(sender, "IP " + args[0] + " was seen with " + str(len(uuids)) + " different Accounts:")
for i in range(0, len(uuids)): for i in range(0, len(uuids)):
p=Bukkit.getOfflinePlayer(UUID.fromString(uuids[i])) p=Bukkit.getOfflinePlayer(UUID.fromString(uuids[i]))
if is_player(sender):
send_JSON_message(sender.getName(), '["",{"text":"' + p.getName() + ' - (uuid: ' + uuids[i] + '","color":"gold","clickEvent":{"action":"run_command","value":"/getinfo ' + p.getName() + '"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"To search for ' + p.getName() + ' in the database, simply click the name!","color":"gold"}]}}}]') send_JSON_message(sender.getName(), '["",{"text":"' + p.getName() + ' - (uuid: ' + uuids[i] + '","color":"gold","clickEvent":{"action":"run_command","value":"/getinfo ' + p.getName() + '"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"To search for ' + p.getName() + ' in the database, simply click the name!","color":"gold"}]}}}]')
else:
msg(sender,p.getName() + " - (uuid: " + uuids[i] + ")")
else: else:
target = Bukkit.getOfflinePlayer(args[0]) target = Bukkit.getOfflinePlayer(args[0])
uuid = target.getUniqueId() uuid = target.getUniqueId()
@@ -85,11 +84,12 @@ def on_getinfo_command(sender, args):
msg(sender, "Player " + args[0] + " is not registered in the database, maybe you misspelled the name?") msg(sender, "Player " + args[0] + " is not registered in the database, maybe you misspelled the name?")
else: else:
ips = json.loads(results[0][0]) ips = json.loads(results[0][0])
msg(sender, "Player " + sender.getName() + " was seen with " + str(len(ips)) + " different IPs:") msg(sender, "Player " + args[0] + " was seen with " + str(len(ips)) + " different IPs:")
for i in range(0, len(ips)): for i in range(0, len(ips)):
if is_player(sender):
send_JSON_message(sender.getName(), '["",{"text":"' + ips[i] + '","color":"gold","clickEvent":{"action":"run_command","value":"/getinfo ' + ips[i] + '"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"To search for the IP ' + ips[i] + ' in the database, simply click the IP!","color":"gold"}]}}}]') send_JSON_message(sender.getName(), '["",{"text":"' + ips[i] + '","color":"gold","clickEvent":{"action":"run_command","value":"/getinfo ' + ips[i] + '"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"To search for the IP ' + ips[i] + ' in the database, simply click the IP!","color":"gold"}]}}}]')
else:
msg(sender,ips[i])
else: else:
noperm(sender) noperm(sender)
return True return True
except:
error(trace())