From fb7871bb3b65d0300cc08a97cb0a2413a866feed Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 20 Oct 2015 19:42:14 +0300 Subject: Added I'M BUSY! plugin --- imbusy.py | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 imbusy.py 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 = "/ ", + 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) -- cgit v1.2.3 From e036716a62e7e011c2d9df6a4aa37d9f17770c73 Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 20 Oct 2015 19:45:53 +0300 Subject: Remembered to edit main.py :) --- main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.py b/main.py index b66b3ac..0f436a8 100644 --- a/main.py +++ b/main.py @@ -54,8 +54,11 @@ shared["load_modules"] = [ "webtoken", # Adds /lol, broadcasts random funyy messages. A bit like the splash text in the menu "saylol", +<<<<<<< HEAD +======= # Adds /signalstrength, lets you request a signal strength and an amount of items will be inserted into target container to meet that strength. "signalstrength", +>>>>>>> b4f5a68e4e3ba4993e8326d2f11f9582933b694e # Shows the owner of a skull when right-clicked "skullclick", # Adds /listen, highlights chat and plays a sound when your name was mentioned @@ -74,6 +77,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 -- cgit v1.2.3 From 3d34f15c41c6b8960c12a19d07877315c66189ac Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Tue, 27 Oct 2015 17:05:55 +0100 Subject: Changed to ignore lower/upper case --- calc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From b369ea75575c5cb387378e8d3a87f49372c0594a Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 28 Oct 2015 18:49:52 +0200 Subject: Removed random crap How did it get there?! --- main.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/main.py b/main.py index 0f436a8..d9aa66b 100644 --- a/main.py +++ b/main.py @@ -54,11 +54,8 @@ shared["load_modules"] = [ "webtoken", # Adds /lol, broadcasts random funyy messages. A bit like the splash text in the menu "saylol", -<<<<<<< HEAD -======= # Adds /signalstrength, lets you request a signal strength and an amount of items will be inserted into target container to meet that strength. "signalstrength", ->>>>>>> b4f5a68e4e3ba4993e8326d2f11f9582933b694e # Shows the owner of a skull when right-clicked "skullclick", # Adds /listen, highlights chat and plays a sound when your name was mentioned -- cgit v1.2.3 From 45a9b260d91ba9a324e27c4317171f9761de921e Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Fri, 30 Oct 2015 16:31:23 +0100 Subject: Now works with offline players --- tag.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 -- cgit v1.2.3 From 086eade43f18df65bee40ec7f1bd8c1f4bde2989 Mon Sep 17 00:00:00 2001 From: Pepich Date: Fri, 30 Oct 2015 16:36:47 +0100 Subject: fixed colorify method --- helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): -- cgit v1.2.3 From 4ed319f15db990f3623b28f3ac876e7d39393041 Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Fri, 30 Oct 2015 16:37:47 +0100 Subject: Fixed offline players and no notification for the punished player --- punishments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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") -- cgit v1.2.3 From c66fb40df54ef30b5513f7986f72960e1da71ba5 Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Fri, 30 Oct 2015 16:44:07 +0100 Subject: changed limit to 1000 --- mentio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 743d42f71958b1a81dafebc9a6c3187b09a376cc Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Fri, 30 Oct 2015 16:47:51 +0100 Subject: added iptracker to main.py --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index d9aa66b..4769bc5 100644 --- a/main.py +++ b/main.py @@ -97,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"]: -- cgit v1.2.3 From 629a938b3ec3c086e810a74bc06b67299eaa6dc5 Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Fri, 30 Oct 2015 17:06:59 +0100 Subject: Changed database stuff --- iptracker.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/iptracker.py b/iptracker.py index a25dcce..517bb87 100644 --- a/iptracker.py +++ b/iptracker.py @@ -5,6 +5,7 @@ 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" @@ -16,13 +17,13 @@ def on_player_join(event): 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 +34,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() @@ -56,7 +57,7 @@ def on_getinfo_command(sender, args): 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 +77,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() -- cgit v1.2.3 From 278f0b411cf963ba5606a45a4d8666c29aeccefa Mon Sep 17 00:00:00 2001 From: NEMESIS13cz Date: Fri, 30 Oct 2015 17:16:31 +0100 Subject: Made iptracker async --- iptracker.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/iptracker.py b/iptracker.py index 517bb87..70cab1a 100644 --- a/iptracker.py +++ b/iptracker.py @@ -7,11 +7,17 @@ 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) @@ -50,9 +56,14 @@ 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") -- cgit v1.2.3