added console support and fixed a small cosmetic bug
This commit is contained in:
14
iptracker.py
14
iptracker.py
@@ -11,7 +11,6 @@ iptrack_permission = "utils.iptrack"
|
||||
|
||||
@hook.event("player.PlayerJoinEvent", "low")
|
||||
def on_player_join(event):
|
||||
try:
|
||||
player = event.getPlayer()
|
||||
ip = player.getAddress().getHostString()
|
||||
uuid = uid(player)
|
||||
@@ -44,15 +43,12 @@ def on_player_join(event):
|
||||
else:
|
||||
curs.execute("UPDATE iptrack_iptouuids SET uuids = ? WHERE uuid = ?", (ip, json.dumps(uuids), ))
|
||||
conn.commit()
|
||||
except:
|
||||
error(trace())
|
||||
curs.close()
|
||||
conn.close()
|
||||
|
||||
|
||||
@hook.command("getinfo")
|
||||
def on_getinfo_command(sender, args):
|
||||
try:
|
||||
if(sender.hasPermission(iptrack_permission)):
|
||||
if not checkargs(sender, args, 1, 1):
|
||||
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:")
|
||||
for i in range(0, len(uuids)):
|
||||
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"}]}}}]')
|
||||
else:
|
||||
msg(sender,p.getName() + " - (uuid: " + uuids[i] + ")")
|
||||
else:
|
||||
target = Bukkit.getOfflinePlayer(args[0])
|
||||
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?")
|
||||
else:
|
||||
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)):
|
||||
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"}]}}}]')
|
||||
else:
|
||||
msg(sender,ips[i])
|
||||
else:
|
||||
noperm(sender)
|
||||
return True
|
||||
except:
|
||||
error(trace())
|
||||
|
||||
Reference in New Issue
Block a user