summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDico200 <dico.karssiens@gmail.com>2015-10-31 15:53:25 +0100
committerDico200 <dico.karssiens@gmail.com>2015-10-31 15:53:25 +0100
commit085360c331ec58b6eddd23e71cb8dca2dff86854 (patch)
tree647d250ec18a8850c8261765902b84adc3698838
parent9c3d9696959d6f4d95cb8171163c2a101f53f295 (diff)
parent278f0b411cf963ba5606a45a4d8666c29aeccefa (diff)
Merge branch 'dev' of https://github.com/RedstonerServer/redstoner-utils into dev
-rw-r--r--calc.py2
-rw-r--r--helpers.py2
-rw-r--r--imbusy.py107
-rw-r--r--iptracker.py30
-rw-r--r--main.py6
-rw-r--r--mentio.py2
-rw-r--r--punishments.py3
-rw-r--r--tag.py8
8 files changed, 142 insertions, 18 deletions
diff --git a/calc.py b/calc.py
index 1da634b..47326b3 100644
--- a/calc.py
+++ b/calc.py
@@ -11,7 +11,7 @@ calc_perm_power = "utils.calc.power"
def calc(sender, text):
try:
- return do_calc(sender, text)
+ return do_calc(sender, text.lower())
except:
return None
diff --git a/helpers.py b/helpers.py
index dcf5cc3..898dea7 100644
--- a/helpers.py
+++ b/helpers.py
@@ -87,7 +87,7 @@ def colorify(text):
"""
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):
diff --git a/imbusy.py b/imbusy.py
new file mode 100644
index 0000000..64fa30b
--- /dev/null
+++ b/imbusy.py
@@ -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)
diff --git a/iptracker.py b/iptracker.py
index a25dcce..70cab1a 100644
--- a/iptracker.py
+++ b/iptracker.py
@@ -5,24 +5,31 @@ from java.util import UUID as UUID
from helpers import *
from org.bukkit import *
from traceback import format_exc as trace
+from iptracker_secrets import *
+
iptrack_permission = "utils.iptrack"
@hook.event("player.PlayerJoinEvent", "low")
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()
ip = player.getAddress().getHostString()
uuid = uid(player)
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
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()
if len(results) == 0:
ips = []
else:
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()
if len(results) == 0:
uuids = []
@@ -33,15 +40,15 @@ def on_player_join(event):
if ip not in ips:
ips.append(ip)
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:
- 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:
uuids.append(uuid)
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:
- 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()
curs.close()
conn.close()
@@ -49,14 +56,19 @@ def on_player_join(event):
@hook.command("getinfo")
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 not checkargs(sender, args, 1, 1):
- return false
+ return False
else:
if isIP(args[0]):
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
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()
curs.close()
conn.close()
@@ -76,7 +88,7 @@ def on_getinfo_command(sender, args):
uuid = target.getUniqueId()
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
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()
curs.close()
conn.close()
diff --git a/main.py b/main.py
index b66b3ac..4769bc5 100644
--- a/main.py
+++ b/main.py
@@ -74,6 +74,8 @@ shared["load_modules"] = [
"check",
# Adds /an, a command you can use to share thoughts/plans/news
"adminnotes",
+ # Adds busy status to players
+ "imbusy",
# Adds /imout, displays fake leave/join messages
"imout",
#adds snowbrawl minigame
@@ -95,7 +97,9 @@ shared["load_modules"] = [
# obisidian mining punishment plugin
"punishments",
# a simple replacement for the buggy essentials /vanish
- "vanish"
+ "vanish",
+ # ip-tracking utility
+ "iptracker"
]
shared["modules"] = {}
for module in shared["load_modules"]:
diff --git a/mentio.py b/mentio.py
index 936b424..f6496a3 100644
--- a/mentio.py
+++ b/mentio.py
@@ -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)
-max_amount = -1
+max_amount = 1000
arrow = colorify(u"&r&7\u2192&r")
colors_reg = reg_compile(u"\u00A7[\\da-fk-or]") # finds color codes
diff --git a/punishments.py b/punishments.py
index 4c39092..4b57be1 100644
--- a/punishments.py
+++ b/punishments.py
@@ -98,7 +98,7 @@ def command(sender, cmd, label, args):
msg(sender, "&e-&a There are no people mining obsidian")
return True
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
elif args[0] == "add":
player = server.getOfflinePlayer(str(args[1]))
@@ -106,6 +106,7 @@ def command(sender, cmd, label, args):
player.teleport(server.getWorld(punish_world).getSpawnLocation())
Slave(False, player, int(args[2]))
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]))
else:
msg(sender, "&cYou can only punish online players")
diff --git a/tag.py b/tag.py
index 0a312aa..b2aa98d 100644
--- a/tag.py
+++ b/tag.py
@@ -34,11 +34,11 @@ def command(sender, command, label, args):
else:
msg(sender, "&a-&c Unknown subcommand! (add, check, del)")
else:
- msg(sender, "&a&c Usage: /tag add/check")
+ msg(sender, "&a&c Usage: /tag add/check/del")
return True
def delete(sender, args):
- player = server.getPlayer(args[0])
+ player = server.getOfflinePlayer(args[0])
uuid = uid(player)
try:
if data[uuid] == None:
@@ -54,7 +54,7 @@ def delete(sender, args):
msg(sender, "&a-&e Deleted note at %s" % args[1])
def add(sender, args):
- player = server.getPlayer(args[0])
+ player = server.getOfflinePlayer(args[0])
uuid = uid(player)
try:
if data[uuid] == None:
@@ -66,7 +66,7 @@ def add(sender, args):
save_json_file("tag", data)
def check(sender, args):
- player = server.getPlayer(args[0])
+ player = server.getOfflinePlayer(args[0])
uuid = uid(player)
try:
num = 0