Merge branch 'dev' of https://github.com/RedstonerServer/redstoner-utils into dev
This commit is contained in:
2
calc.py
2
calc.py
@@ -11,7 +11,7 @@ calc_perm_power = "utils.calc.power"
|
|||||||
|
|
||||||
def calc(sender, text):
|
def calc(sender, text):
|
||||||
try:
|
try:
|
||||||
return do_calc(sender, text)
|
return do_calc(sender, text.lower())
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
107
imbusy.py
Normal file
107
imbusy.py
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# I'M BUSY! Plugin by Curs3d #
|
||||||
|
##############################
|
||||||
|
# Concept by CookieManors :D #
|
||||||
|
# http://bit.ly/1GnNPW8 #
|
||||||
|
##############################
|
||||||
|
# This plugin permits users to
|
||||||
|
# send a command that renders
|
||||||
|
# them "busy", not letting them
|
||||||
|
# to get tpa requests or direct
|
||||||
|
# messages, except from console.
|
||||||
|
# On restart, all busy data will
|
||||||
|
# be cleared.
|
||||||
|
|
||||||
|
from helpers import *
|
||||||
|
from basecommands import simplecommand
|
||||||
|
from traceback import format_exc as trace
|
||||||
|
busy_players = []
|
||||||
|
|
||||||
|
|
||||||
|
def unclear():
|
||||||
|
msg(sender, "Umm, what? Sorry, directions unlclear, got head stuck in washing machine")
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command("busy",
|
||||||
|
aliases = ["focus"],
|
||||||
|
usage = "/<command> <on|off|status>",
|
||||||
|
description = "Sets busy mode on, you cannot recieve tpas and MSGs"
|
||||||
|
)
|
||||||
|
def on_busy_command(sender, cmd, label, args):
|
||||||
|
|
||||||
|
if not is_player(sender):
|
||||||
|
msg(sender, "Sorry, Console cannot be busy")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not sender.hasPermission("utils.busy.allowed"):
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
noperm(sender)
|
||||||
|
return True
|
||||||
|
|
||||||
|
if len(args) == 0:
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
msg(sender, "This plugin allows being busy, and when turned on you will not recieve any direct messages or tpa requests.")
|
||||||
|
msg(sender, "\nCommands:")
|
||||||
|
msg(sender, "/busy on: turns on busy mode")
|
||||||
|
msg(sender, "/busy off: turns off busy mode")
|
||||||
|
msg(sender, "/busy status [player]: shows your or [player]'s current busy status.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif len(args) == 1:
|
||||||
|
if args[0] == "on":
|
||||||
|
if sender.getName() in busy_players:
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
msg(sender, "You cannot be even more focused than this without being a jedi!")
|
||||||
|
return True
|
||||||
|
busy_players.append(sender.getName())
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
broadcast(None, "%s is now SUPER busy! Don't even TRY bothering them, it will not work!" % sender.getName())
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif args[0] == "off":
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
try:
|
||||||
|
busy_players.remove(sender.getName())
|
||||||
|
msg(sender, "Master has sent /busy command, %s is freeee!" % sender.getName())
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?")
|
||||||
|
return True
|
||||||
|
|
||||||
|
elif args[0] == "status":
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
if sender.getName() in busy_players:
|
||||||
|
msg(sender, "You are super-duper busy and concentrated right now. Think, think, think!")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
msg(sender, "You are completely unable to focus right now.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
else:
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
unclear()
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif len(args) == 2 and args[0] == "status":
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
if args[1] in busy_players:
|
||||||
|
msg(sender, "Yes, %s is busy. Shhh..." % args[1])
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
msg(sender, "No, you're good. Feel free to chat with %s!" % args[1])
|
||||||
|
return True
|
||||||
|
|
||||||
|
else:
|
||||||
|
plugin_header(recipient = sender, name = "I'M BUSY!")
|
||||||
|
unclear()
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@hook.event("player.PlayerCommandPreprocessEvent", "monitor")
|
||||||
|
def on_cmd_preprocess_event(event):
|
||||||
|
message = event.getMessage().split(" ")
|
||||||
|
if message[0] == "/msg" or message[0] == "/w" or message[0] == "/m" or \
|
||||||
|
message[0] == "/tell" or message[0] == "/tpa" or message[0] == "/tpahere":
|
||||||
|
if message[1] in busy_players:
|
||||||
|
plugin_header(recipient = event.getPlayer(), name = "I'M BUSY!")
|
||||||
|
msg(event.getPlayer(), "We are sorry, but %s is currently busy. Please try again later." % message[1])
|
||||||
|
event.setCancelled(True)
|
||||||
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()
|
||||||
|
|||||||
6
main.py
6
main.py
@@ -74,6 +74,8 @@ shared["load_modules"] = [
|
|||||||
"check",
|
"check",
|
||||||
# Adds /an, a command you can use to share thoughts/plans/news
|
# Adds /an, a command you can use to share thoughts/plans/news
|
||||||
"adminnotes",
|
"adminnotes",
|
||||||
|
# Adds busy status to players
|
||||||
|
"imbusy",
|
||||||
# Adds /imout, displays fake leave/join messages
|
# Adds /imout, displays fake leave/join messages
|
||||||
"imout",
|
"imout",
|
||||||
#adds snowbrawl minigame
|
#adds snowbrawl minigame
|
||||||
@@ -95,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")
|
||||||
|
|||||||
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