Merge branch 'dev' of https://github.com/RedstonerServer/redstoner-utils into dev
This commit is contained in:
@@ -87,7 +87,7 @@ def colorify(text):
|
|||||||
"""
|
"""
|
||||||
replace &-codes with real color codes
|
replace &-codes with real color codes
|
||||||
"""
|
"""
|
||||||
return sub("&(?=[?\\da-fk-or])", u"\u00A7", "%s" % text)
|
return sub("&" + u"\u00A7", "&", "%s" % sub("&(?=[?\\da-fk-or])", u"\u00A7", "%s" % text))
|
||||||
|
|
||||||
|
|
||||||
def stripcolors(text):
|
def stripcolors(text):
|
||||||
|
|||||||
30
iptracker.py
30
iptracker.py
@@ -5,24 +5,31 @@ from java.util import UUID as UUID
|
|||||||
from helpers import *
|
from helpers import *
|
||||||
from org.bukkit import *
|
from org.bukkit import *
|
||||||
from traceback import format_exc as trace
|
from traceback import format_exc as trace
|
||||||
|
from iptracker_secrets import *
|
||||||
|
|
||||||
|
|
||||||
iptrack_permission = "utils.iptrack"
|
iptrack_permission = "utils.iptrack"
|
||||||
|
|
||||||
|
|
||||||
@hook.event("player.PlayerJoinEvent", "low")
|
@hook.event("player.PlayerJoinEvent", "low")
|
||||||
def on_player_join(event):
|
def on_player_join(event):
|
||||||
|
t = threading.Thread(target=on_player_join_thread, args=(event))
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
def on_player_join_thread(event):
|
||||||
player = event.getPlayer()
|
player = event.getPlayer()
|
||||||
ip = player.getAddress().getHostString()
|
ip = player.getAddress().getHostString()
|
||||||
uuid = uid(player)
|
uuid = uid(player)
|
||||||
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()
|
||||||
curs.execute("SELECT ips FROM iptrack_uuidtoips WHERE uuid = ?", (uuid, ))
|
curs.execute("SELECT ips FROM uuid2ips WHERE uuid = ?", (uuid, ))
|
||||||
results = curs.fetchall()
|
results = curs.fetchall()
|
||||||
if len(results) == 0:
|
if len(results) == 0:
|
||||||
ips = []
|
ips = []
|
||||||
else:
|
else:
|
||||||
ips = json.loads(results[0][0])
|
ips = json.loads(results[0][0])
|
||||||
curs.execute("SELECT uuids FROM iptrack_iptouuids WHERE ip = ?", (ip, ))
|
curs.execute("SELECT uuids FROM ip2uuids WHERE ip = ?", (ip, ))
|
||||||
results = curs.fetchall()
|
results = curs.fetchall()
|
||||||
if len(results) == 0:
|
if len(results) == 0:
|
||||||
uuids = []
|
uuids = []
|
||||||
@@ -33,15 +40,15 @@ def on_player_join(event):
|
|||||||
if ip not in ips:
|
if ip not in ips:
|
||||||
ips.append(ip)
|
ips.append(ip)
|
||||||
if new_ip_entry:
|
if new_ip_entry:
|
||||||
curs.execute("INSERT INTO iptrack_uuidtoips VALUES (?,?)", (uuid, json.dumps(ips), ))
|
curs.execute("INSERT INTO uuid2ips VALUES (?,?)", (uuid, json.dumps(ips), ))
|
||||||
else:
|
else:
|
||||||
curs.execute("UPDATE iptrack_uuidtoips SET ips = ? WHERE uuid = ?", (uuid, json.dumps(ips), ))
|
curs.execute("UPDATE uuid2ips SET ips = ? WHERE uuid = ?", (uuid, json.dumps(ips), ))
|
||||||
if uuid not in uuids:
|
if uuid not in uuids:
|
||||||
uuids.append(uuid)
|
uuids.append(uuid)
|
||||||
if new_uuid_entry:
|
if new_uuid_entry:
|
||||||
curs.execute("INSERT INTO iptrack_iptouuids VALUES (?,?)", (ip, json.dumps(uuids), ))
|
curs.execute("INSERT INTO ip2uuids VALUES (?,?)", (ip, json.dumps(uuids), ))
|
||||||
else:
|
else:
|
||||||
curs.execute("UPDATE iptrack_iptouuids SET uuids = ? WHERE uuid = ?", (ip, json.dumps(uuids), ))
|
curs.execute("UPDATE ip2uuids SET uuids = ? WHERE uuid = ?", (ip, json.dumps(uuids), ))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
curs.close()
|
curs.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
@@ -49,14 +56,19 @@ def on_player_join(event):
|
|||||||
|
|
||||||
@hook.command("getinfo")
|
@hook.command("getinfo")
|
||||||
def on_getinfo_command(sender, args):
|
def on_getinfo_command(sender, args):
|
||||||
|
t = threading.Thread(target=on_player_join_thread, args=(sender, args))
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
def on_getinfo_command_thread(sender, args):
|
||||||
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
|
||||||
else:
|
else:
|
||||||
if isIP(args[0]):
|
if isIP(args[0]):
|
||||||
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()
|
||||||
curs.execute("SELECT uuids FROM iptrack_iptouuids WHERE ip = ?", (args[0], ))
|
curs.execute("SELECT uuids FROM ip2uuids WHERE ip = ?", (args[0], ))
|
||||||
results = curs.fetchall()
|
results = curs.fetchall()
|
||||||
curs.close()
|
curs.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
@@ -76,7 +88,7 @@ def on_getinfo_command(sender, args):
|
|||||||
uuid = target.getUniqueId()
|
uuid = target.getUniqueId()
|
||||||
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()
|
||||||
curs.execute("SELECT ips FROM iptrack_uuidtoips WHERE uuid = ?", (uuid.toString(), ))
|
curs.execute("SELECT ips FROM uuid2ips WHERE uuid = ?", (uuid.toString(), ))
|
||||||
results = curs.fetchall()
|
results = curs.fetchall()
|
||||||
curs.close()
|
curs.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -97,7 +97,9 @@ shared["load_modules"] = [
|
|||||||
# obisidian mining punishment plugin
|
# obisidian mining punishment plugin
|
||||||
"punishments",
|
"punishments",
|
||||||
# a simple replacement for the buggy essentials /vanish
|
# a simple replacement for the buggy essentials /vanish
|
||||||
"vanish"
|
"vanish",
|
||||||
|
# ip-tracking utility
|
||||||
|
"iptracker"
|
||||||
]
|
]
|
||||||
shared["modules"] = {}
|
shared["modules"] = {}
|
||||||
for module in shared["load_modules"]:
|
for module in shared["load_modules"]:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from traceback import format_exc as print_traceback
|
|||||||
|
|
||||||
|
|
||||||
mentions = open_json_file("mentio", {}) # contains a list of keywords for each player (uuid)
|
mentions = open_json_file("mentio", {}) # contains a list of keywords for each player (uuid)
|
||||||
max_amount = -1
|
max_amount = 1000
|
||||||
arrow = colorify(u"&r&7\u2192&r")
|
arrow = colorify(u"&r&7\u2192&r")
|
||||||
colors_reg = reg_compile(u"\u00A7[\\da-fk-or]") # finds color codes
|
colors_reg = reg_compile(u"\u00A7[\\da-fk-or]") # finds color codes
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ def command(sender, cmd, label, args):
|
|||||||
msg(sender, "&e-&a There are no people mining obsidian")
|
msg(sender, "&e-&a There are no people mining obsidian")
|
||||||
return True
|
return True
|
||||||
for slave in slaves:
|
for slave in slaves:
|
||||||
msg(sender, "&e-&a %s: %s blocks" % (slave.get_uuid(), slave.get_blocks()))
|
msg(sender, "&e-&a %s: %s blocks" % (server.getOfflinePlayer(juuid(slave.get_uuid())).getName(), slave.get_blocks()))
|
||||||
return True
|
return True
|
||||||
elif args[0] == "add":
|
elif args[0] == "add":
|
||||||
player = server.getOfflinePlayer(str(args[1]))
|
player = server.getOfflinePlayer(str(args[1]))
|
||||||
@@ -106,6 +106,7 @@ def command(sender, cmd, label, args):
|
|||||||
player.teleport(server.getWorld(punish_world).getSpawnLocation())
|
player.teleport(server.getWorld(punish_world).getSpawnLocation())
|
||||||
Slave(False, player, int(args[2]))
|
Slave(False, player, int(args[2]))
|
||||||
save_slaves()
|
save_slaves()
|
||||||
|
msg(player, "&e-&a You have been punished, mine %s blocks of obsidian to get out!" % args[2])
|
||||||
msg(sender, "&e-&a Player %s has been added into punishments for %s blocks of obsidian" % (player.getName(), args[2]))
|
msg(sender, "&e-&a Player %s has been added into punishments for %s blocks of obsidian" % (player.getName(), args[2]))
|
||||||
else:
|
else:
|
||||||
msg(sender, "&cYou can only punish online players")
|
msg(sender, "&cYou can only punish online players")
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ def get_entire_container(container):
|
|||||||
world.getBlockAt(x - 1, y, z),
|
world.getBlockAt(x - 1, y, z),
|
||||||
world.getBlockAt(x, y, z + 1),
|
world.getBlockAt(x, y, z + 1),
|
||||||
world.getBlockAt(x, y, z - 1),
|
world.getBlockAt(x, y, z - 1),
|
||||||
) if block.getType() == target_type
|
) if block.getType() == container_type
|
||||||
]
|
]
|
||||||
|
|
||||||
return container_blocks
|
return container_blocks
|
||||||
@@ -101,7 +101,7 @@ def get_entire_container(container):
|
|||||||
|
|
||||||
|
|
||||||
@simplecommand("signalstrength",
|
@simplecommand("signalstrength",
|
||||||
usage = "(<signal strength> [item] [data]) or (default <item> [data])",
|
usage = "(default) [signalstrength] [item] [data]",
|
||||||
aliases = ["ss", "level"],
|
aliases = ["ss", "level"],
|
||||||
description = "Fills the targeted container with the correct amount of items to achieve the desired signal strength.",
|
description = "Fills the targeted container with the correct amount of items to achieve the desired signal strength.",
|
||||||
amin = 0,
|
amin = 0,
|
||||||
|
|||||||
8
tag.py
8
tag.py
@@ -34,11 +34,11 @@ def command(sender, command, label, args):
|
|||||||
else:
|
else:
|
||||||
msg(sender, "&a-&c Unknown subcommand! (add, check, del)")
|
msg(sender, "&a-&c Unknown subcommand! (add, check, del)")
|
||||||
else:
|
else:
|
||||||
msg(sender, "&a&c Usage: /tag add/check")
|
msg(sender, "&a&c Usage: /tag add/check/del")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def delete(sender, args):
|
def delete(sender, args):
|
||||||
player = server.getPlayer(args[0])
|
player = server.getOfflinePlayer(args[0])
|
||||||
uuid = uid(player)
|
uuid = uid(player)
|
||||||
try:
|
try:
|
||||||
if data[uuid] == None:
|
if data[uuid] == None:
|
||||||
@@ -54,7 +54,7 @@ def delete(sender, args):
|
|||||||
msg(sender, "&a-&e Deleted note at %s" % args[1])
|
msg(sender, "&a-&e Deleted note at %s" % args[1])
|
||||||
|
|
||||||
def add(sender, args):
|
def add(sender, args):
|
||||||
player = server.getPlayer(args[0])
|
player = server.getOfflinePlayer(args[0])
|
||||||
uuid = uid(player)
|
uuid = uid(player)
|
||||||
try:
|
try:
|
||||||
if data[uuid] == None:
|
if data[uuid] == None:
|
||||||
@@ -66,7 +66,7 @@ def add(sender, args):
|
|||||||
save_json_file("tag", data)
|
save_json_file("tag", data)
|
||||||
|
|
||||||
def check(sender, args):
|
def check(sender, args):
|
||||||
player = server.getPlayer(args[0])
|
player = server.getOfflinePlayer(args[0])
|
||||||
uuid = uid(player)
|
uuid = uid(player)
|
||||||
try:
|
try:
|
||||||
num = 0
|
num = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user