From b4c485776149ee5b1a854b63b78f0fde889ba52f Mon Sep 17 00:00:00 2001 From: PanFritz Date: Sun, 20 Sep 2015 01:47:36 +0200 Subject: [PATCH 01/95] Attempt to make a sync decorator --- sync.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sync.py diff --git a/sync.py b/sync.py new file mode 100644 index 0000000..0a2cd0b --- /dev/null +++ b/sync.py @@ -0,0 +1,21 @@ +from helpers import * +from java.lang import Runnable + +class Sync_class(Runnable): + + def __init__(self,function,*args,**kwargs): + self.function = function + self.args = args + self.kwargs = kwargs + + def run(self): + self.function(self.args,self.kwargs) + + + +def sync(function): + def wrapper(*args,**kwargs): + sync_function = Sync_class(function) + server.getScheduler().runTask(server.getPluginManager().getPlugin("RedstonerUtils"),sync_function) + return None + return wrapper \ No newline at end of file -- 2.45.2 From 10a5eea68657c33a239897ca45663815a202de46 Mon Sep 17 00:00:00 2001 From: psrcek Date: Mon, 28 Dec 2015 13:05:20 +0100 Subject: [PATCH 02/95] Initial commit, working on a local server --- killpotdisable.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 killpotdisable.py diff --git a/killpotdisable.py b/killpotdisable.py new file mode 100644 index 0000000..6a4ed23 --- /dev/null +++ b/killpotdisable.py @@ -0,0 +1,20 @@ +import org.bukkit.potion.PotionEffect as PotionEffect +import org.bukkit.potion.PotionEffectType as PotionEffectType + + +@hook.event("entity.PotionSplashEvent", "high") +def on_splash(event): + potion_effects = event.getPotion().getEffects() + + for eff in potion_effects: + if eff.getType() == PotionEffectType.HEAL: + if eff.getAmplifier() > 250: + + event.setCancelled(True) + break + + elif eff.getType() == PotionEffectType.HARM: + if eff.getAmplifier() > 250: + + event.setCancelled(True) + break -- 2.45.2 From 883b02acd55da8b2c5c5f3d4528be36c8ecc3fd0 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 9 Jan 2016 16:40:57 +0100 Subject: [PATCH 03/95] Initial commit of chatalias.py v2 --- chatalias.py | 421 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 302 insertions(+), 119 deletions(-) diff --git a/chatalias.py b/chatalias.py index 25e3336..a73decb 100644 --- a/chatalias.py +++ b/chatalias.py @@ -1,138 +1,321 @@ -# Chat Aliasing plugin by Curs3d # -################################## -# Allows users to alias words, -# so that when they send a -# message in chat, it gets -# replaced by their specified -# word. The JSON file for this -# plugin is generated if not -# present. Set values to -1 -# for "unlimited" setting. +############################################ +# Alias v2.0 by Pepich # +# Changes to previous version from curs3d: # +# Dynamic alias limit from permissions # +# AC/CG/MSG support # +# Color support # +# Bugfixes # +# # +# TODO: # +# Add command support... # +############################################ +import os +import org.bukkit as bukkit +from org.bukkit import * from helpers import * -import re from traceback import format_exc as trace +from secrets import * -data = None +# Version number and requirements -max_entries = 10 -max_alias_length = 35 -# Minecraft message limit is 100 so I decided to give a little tolerance (and I added a bit more) -max_overall_length = 100 + max_alias_length +alias_version = "2.0.0" +helpers_versions = ["1.1.0", "2.0.0"] +enabled = False +error = colorify("&cUnspecified error") +commands_per_page = 5 +global_aliases = {"./":"/"} +data = {} +use_mysql = False -alias_perm = "utils.alias.allowed" -exceed_length = "utils.alias.exceedlimit" -exceed_entries = "utils.alias.exceedlimit" -exceed_overall_length = "utils.alias.exceedlimit" +# Permissions: + +# Grants full access immediately +permission_ALL = "utils.alias.*" +# Access to the command to display the help screen +permission_BASE = "utils.alias" +# Make replacements only when the user has this permission +permission_USE = "utils.alias.use" +# Modify aliases +permission_MODIFY = "utils.alias.modify" +permission_MODIFY_OTHERS = "utils.alias.modify.others" +# List aliases +permission_LIST = "utils.alias.list" +permission_LIST_OTHERS = "utils.alias.list.others" +# Set alias amounts/length limits, e.g. utils.alias.amount.420 +permission_AMOUNT = "utils.alias.amount." +permission_LENGTH = "utils.alias.length." +# See when the plugin was disabled due to version errors +permission_INFO = "utils.alias.info" +permission_FINFO = "utils.alias.finfo" + +######## +# CODE # +######## + +enabled = helpers_version in helpers_versions +if not enabled: + error = colorify("&6Incompatible versions detected (&chelpers.py&6)") -def safe_open_json(): - global data - if data is not None: - return data - data = open_json_file("aliases") - if data is None: - data = {} - save_json_file("aliases", data) - return data - -def multiple_replace(aliases, text): - regex = re.compile("|".join(map(re.escape, aliases.keys()))) - return regex.sub(lambda mo: aliases[mo.group(0)], text) +def safe_open_json(uuid): + if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"): + os.makedirs("plugins/redstoner-utils.py.dir/files/aliases") + value = open_json_file("aliases/" + uuid) + if value is None: + value = global_aliases + save_json_file("aliases/" + uuid, value) + return value @hook.command("alias", - usage="/ [to_alias] [alias...]", - desc="Aliases words in chat") + usage="/ [...]", + desc="Allows aliasing of words") def on_alias_command(sender, cmd, label, args): + try: + args = array_to_list(args) + if not enabled: + disabled_fallback(sender) + return True + if not hasPerm(sender, permission_BASE): + plugin_header(recipient=sender, name="Alias") + noperm(sender) + return True + return subcommands[args[0].lower()](sender, args[1:]) + except: + print(trace()) + return subcommands["help"](sender, "1") - if not is_player(sender): - msg(sender, "Sorry, non-players cannot alias words") - return True - if not sender.hasPermission(alias_perm): - plugin_header(recipient=sender, name="Chat Alias") - noperm(sender) - return True - if len(args) == 0: - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7This is a plugin that allows you to get words" + - "replaced by other ones automatically!") - msg(sender, "&7\nCommands:") - msg(sender, "&e/alias &7removes from your aliases. " + - "Use &e/alias * &7to remove all aliases.") - msg(sender, "&e/alias &7will change &e " + - "&7to &e &7in chat") - msg(sender, "&7\nYour Aliases:") - data = safe_open_json() - try: - for alias, value in data[str(sender.getUniqueId())].items(): - msg(sender, "&7%s &7==> %s" % (alias, value)) - except KeyError: - pass - return True - elif len(args) == 1: - data = safe_open_json() - if args[0] == "*": - try: - del data[str(sender.getUniqueId())] - except KeyError: - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7No alias data to remove!") - return True - save_json_file("aliases", data) - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&cALL &7alias data successfuly removed!") - return True - try: - if data[str(sender.getUniqueId())].pop(args[0], None) is None: - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7Could not remove: alias not present!") - return True - except KeyError: - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7Could not remove: you do not have any aliases!") - return True - save_json_file("aliases", data) - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7Alias for %s &7successfuly removed" % args[0]) - return True - elif len(args) >= 2: - data = safe_open_json() - alias = " ".join(args[1:]) - try: - if (len(alias) > max_alias_length) and (max_alias_length >= 0) and (not sender.hasPermission(exceed_length)): - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7Please do not alias long words/sentences.") - return True - if (len(data[str(sender.getUniqueId())]) >= max_entries) and (max_entries >= 0) and (not sender.hasPermission(exceed_entries)): - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7You have reached your alias limit!") - return True - except KeyError: - data[str(sender.getUniqueId())] = {} - data[str(sender.getUniqueId())][args[0]] = alias - save_json_file("aliases", data) - plugin_header(recipient=sender, name="Chat Alias") - msg(sender, "&7Chat Alias %s &7==> %s &7successfully created!" % (args[0], alias)) - return True - else: - return False + +def help(sender, args): + commands = [colorify("&e/alias help [page]")] + if hasPerm(sender, permission_LIST): + commands += [colorify("&e/alias list &7- Lists all your aliases")] + if hasPerm(sender, permission_MODIFY): + commands += [colorify("&e/alias add &7- Add an alias")] + commands += [colorify("&e/alias remove &7- Remove an alias")] + if can_remote(sender): + while len(commands) < commands_per_page: + commands += [""] + commands += [colorify("&7Following commands will be executed on yet all output will be redirected to you, except when you set silent to false, then will see it too.")] + if hasPerm(sender, permission_LIST_OTHERS): + commands += [colorify("&e/alias player list [silent]")] + if hasPerm(sender, permission_MODIFY_OTHERS): + commands += [colorify("&e/alias player add [silent]")] + commands += [colorify("&e/alias player remove [silent]")] + pages = (len(commands)-1)/commands_per_page + 1 + page = 1 + if len(args) != 0: + page = int(args[0]) + if (page > pages): + page = pages + if page < 1: + page = 1 + msg(sender, colorify("&e---- &6Help &e-- &6Page &c" + str(page) + "&6/&c" + str(pages) + " &e----")) + page -= 1 + to_display = commands[5*page:5*page+5] + for message in to_display: + msg(sender, message) + if page+1 < pages: + msg(sender, colorify("&6To display the next page, type &c/help " + str(page+2))) + return True + + +@hook.event("player.PlayerJoinEvent", "high") +def on_join(event): + try: + if enabled: + t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) + t.daemon = True + t.start() + else: + if event.getPlayer().hasPermission(permission_FINFO): + disabled_fallback(event.getPlayer()) + except: + print(trace()) @hook.event("player.AsyncPlayerChatEvent", "high") def on_player_chat(event): - playerid = str(event.getPlayer().getUniqueId()) - data = safe_open_json() - if event.isCancelled(): - return - if not playerid in data: - return + try: + if enabled: + if event.isCancelled(): + return + if not hasPerm(event.getPlayer(), permission_USE): + return + for alias, value in data[str(uid(event.getPlayer()))].items(): + if not event.getPlayer().hasPermission(permission_ALL) and len(event.getMessage()) > int(get_permission_content(event.getPlayer(), permission_LENGTH)): + event.setCanceled(True) + plugin_header(event.getPlayer, "Alias") + msg(event.getPlayer(), "The message you wanted to generate would exceed your limit. Please make it shorter!") + return + if event.getPlayer().hasPermission("essentials.chat.color"): + event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) + else: + event.setMessage(event.getMessage().replace(alias, value)) + except: + print(trace()) - event.setMessage(multiple_replace(data[playerid], event.getMessage())) +def hasPerm(player, permission): + return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL)) - if (event.getPlayer().hasPermission("essentials.chat.color")): - event.setMessage(colorify(event.getMessage())) - if (max_overall_length >= 0) and (len(event.getMessage()) > max_overall_length) and (not event.getPlayer().hasPermission(exceed_overall_length)): - event.setCancelled(True) - plugin_header(recipient=event.getPlayer(), name="Chat Alias") - msg(event.getPlayer(), "&7The message generated was too long and was not sent. :/") + +def disabled_fallback(receiver): + if not hasPerm(receiver, permission_INFO): + msg(receiver, colorify("&cUnknown command. Use &e/help&c, &e/plugins &cor ask a mod.")) + else: + msg(receiver, colorify("&cPlugin alias v" + alias_version + " has experienced an &eEMERGENCY SHUTDOWN:")) + msg(receiver, error) + msg(receiver, colorify("&cPlease contact a dev/admin (especially pep :P) about this to take a look at it.")) + + +def can_remote(player): + return hasPerm(player, permission_LIST_OTHERS) or hasPerm(player, permission_MODIFY_OTHERS) + + +def add(sender, args): + plugin_header(sender, "Alias") + if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(sender, permission_AMOUNT)): + msg(sender, "&cCould not create alias: Max_limit reached!") + return True + args = [args[0]] + [" ".join(args[1:])] + data[str(uid(sender))][str(args[0])] = args[1] + save_data(uid(sender)) + msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) + return True + + +def radd(sender, args): + args = [args[0:1]] + [" ".join([args[2:len(args)-2]])] + [args[len(args)-1]] + plugin_header(sender, "Alias") + if args[3].lower() == "false": + plugin_header(target, "Alias") + msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") + if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(target, permission_AMOUNT)): + msg(sender, "&cCould not create alias: Max_limit reached!") + if args[3].lower() == "false": + msg(target, "&cCould not create alias: Max_limit reached!") + return True + + target = get_player(args[0]) + if is_player(sender): + sender_name = colorify(sender.getDisplayName) + else: + sender_name = colorify("&6Console") + if len(args) == 3: + args += ["true"] + data[str(uid(target))][str(args[1])] = str(args[2]) + save_data(uid(target)) + msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) + if args[3].lower() == "false": + msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) + return True + + +def remove(sender, args): + plugin_header(sender, "Alias") + try: + msg(sender, colorify("&7Successfully removed alias ") + args[0] + colorify(" &7-> ") + data[uid(sender)].pop(args[0]) + colorify("&7!"), usecolor=sender.hasPermission("essentials.chat.color")) + save_data(uid(sender)) + except: + msg(sender, colorify("&cCould not remove alias ") + args[0] + colorify(", it does not exist."), usecolor=sender.hasPermission("essentials.chat.color")) + return True + + +def rremove(sender, args): + plugin_header(sender, "Alias") + target = get_player(args[0]) + if is_player(sender): + sender_name = colorify(sender.getDisplayName) + else: + sender_name = colorify("&6Console") + if args[2].lower() == "false": + print("WTF") + plugin_header(target, "Alias") + msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!") + try: + alias = data[uid(target)].pop(args[1]) + msg(sender, colorify("&7Successfully removed alias ") + args[1] + colorify(" &7-> ") + alias + colorify("&7!"), usecolor=sender.hasPermission("essentials.chat.color")) + if args[2].lower() == "false": + msg(target, colorify("&7Successfully removed alias ") + args[1] + colorify(" &7-> ") + alias + colorify("&7!"), usecolor=sender.hasPermission("essentials.chat.color")) + save_data(uid(target)) + except: + msg(sender, colorify("&cCould not remove alias ") + args[1] + colorify(", it does not exist."), usecolor=sender.hasPermission("essentials.chat.color")) + if args[2].lower() == "false": + msg(target, colorify("&cCould not remove alias ") + args[1] + colorify(", it does not exist."), usecolor=sender.hasPermission("essentials.chat.color")) + return True + + +def list_alias(sender, args): + plugin_header(sender, "Alias") + msg(sender, "&7You have a total of " + str(len(data[uid(sender)])) + " aliases:") + for word, alias in data[str(uid(sender))].items(): + msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=sender.hasPermission("essentials.chat.color")) + return True + + +def rlist_alias(sender, args): + plugin_header(sender, "Alias") + target = get_player(args[0]) + if is_player(sender): + sender_name = colorify(sender.getDisplayName) + else: + sender_name = colorify("&6Console") + if len(args) == 1: + args += ["true"] + msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):") + if args[1].lower() == "false": + plugin_header(target, "Alias") + msg(target, "&cPlayer " + sender_name + " &cis listing your aliases (" + str(len(data[uid(target)])) + " in total):") + for word, alias in data[str(uid(target))].items(): + msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) + if args[1].lower() == "false": + msg(target, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) + return True + + +def remote(sender, args): + try: + return remotes[args[1].lower()](sender, [args[0]] + [args[2:]]) + except: + print(trace()) + return subcommands["help"](sender, ["2"]) + + +def load_data(uuid): + if use_mysql: + conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") + curs = conn.cursor() + curs.execute("SELECT alias FROM alias WHERE uuid = ?", (uuid, )) + results = curs.fetchall() + if len(results) == 0: + results = global_aliases + curs.execute("INSERT INTO alias VALUES (?,?)", (uuid, results, )) + data[uuid] = results + else: + data[uuid] = safe_open_json(uuid) + + +def save_data(uuid): + if use_mysql: + conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") + curs = conn.cursor() + curs.execute("UPDATE alias SET alias = ? WHERE uuid = ?", (data[uuid], uuid, )) + else: + save_json_file("aliases/" + uuid, data[uuid]) + +# Subcommands: + +subcommands = { + "help": help, + "add": add, + "remove": remove, + "player": remote, + "list": list_alias +} + +remotes = { + "add": radd, + "remove": rremove, + "list": rlist_alias, +} -- 2.45.2 From cbc77de8262204b64bb3695a78acafb76c8ca47f Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 9 Jan 2016 16:42:26 +0100 Subject: [PATCH 04/95] Helpers v2.0.0, added versioning, added array_to_list and get_permission_content, renamed isIP to is_ip --- helpers.py | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) mode change 100644 => 100755 helpers.py diff --git a/helpers.py b/helpers.py old mode 100644 new mode 100755 index 79af3a0..8485b2a --- a/helpers.py +++ b/helpers.py @@ -22,7 +22,7 @@ import threading from traceback import format_exc as trace - +helpers_version = "2.0.0" shared = {} # this dict can be used to share stuff across modules server = bukkit.Bukkit.getServer() @@ -87,7 +87,7 @@ def colorify(text): """ replace &-codes with real color codes """ - return sub("&" + u"\u00A7", "&", "%s" % sub("&(?=[?\\da-fk-or])", u"\u00A7", "%s" % text)) + return sub("&(?=[?\\da-fk-or])", u"\u00A7", "%s" % text) def stripcolors(text): @@ -181,16 +181,6 @@ def is_creative(player): return str(player.getGameMode()) == "CREATIVE" -def is_rank(player, rank): - """ - rank: a string equal to the PEX group name found in /pex groups - returns True if one of the following conditions are met: - - the player is of the given rank, - - their rank inherits the given rank. - """ - return player.hasPermission("groups." + rank) - - def uid(player): """ returns the player's UUID @@ -281,7 +271,8 @@ def send_JSON_message(playername, message): bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), "tellraw " + playername + " " + message) -def isIP(tocheck): +# Allows to check if a String is a valid IPv4 or not. Accepts any string, returns true if the String is a valid IPv4 +def is_ip(tocheck): subsets = ["","","",""] i = 0 for j in range(0,len(tocheck)): @@ -299,3 +290,27 @@ def isIP(tocheck): if not ((int(subsets[j]) >= 0) & (int(subsets[j]) <= 255)): return False return True + + +# Allows the use of e.g. numeric permission nodes like "permission.amount.5" and similar. +# To get the data fetch the player and the start of the permission node, looking like "permission.amount." +def get_permission_content(player, permnode): + perms = player.getEffectivePermissions() + for perm in perms: + if str(perm.getPermission()).startswith(permnode): + return str(perm.getPermission()).replace(permnode, "") + + +# Gets an online player from their name +def get_player(name): + for p in bukkit.Bukkit.getServer().getOnlinePlayers(): + if p.getName().lower() == name.lower(): + return p + return None + + +def array_to_list(array): + return_list = [] + for a in array: + return_list += [a] + return return_list -- 2.45.2 From 3a2d1193ca90697bcff0fd977f76cb03adcc3182 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 9 Jan 2016 16:43:19 +0100 Subject: [PATCH 05/95] iptracker v1.1.0 updating to helpers v2.0.0 functions; fixing bugs in data management and command execution --- iptracker.py | 215 ++++++++++++++++++++++++++------------------------- 1 file changed, 108 insertions(+), 107 deletions(-) mode change 100644 => 100755 iptracker.py diff --git a/iptracker.py b/iptracker.py old mode 100644 new mode 100755 index 8bbd053..969a822 --- a/iptracker.py +++ b/iptracker.py @@ -1,107 +1,108 @@ -import mysqlhack -import org.bukkit as bukkit -import json -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 uuid2ips WHERE uuid = ?", (uuid, )) - results = curs.fetchall() - if len(results) == 0: - ips = [] - else: - ips = json.loads(results[0][0]) - curs.execute("SELECT uuids FROM ip2uuids WHERE ip = ?", (ip, )) - results = curs.fetchall() - if len(results) == 0: - uuids = [] - else: - uuids = json.loads(results[0][0]) - new_ip_entry = (len(ips) == 0) - new_uuid_entry = (len(uuids) == 0) - if ip not in ips: - ips.append(ip) - if new_ip_entry: - curs.execute("INSERT INTO uuid2ips VALUES (?,?)", (uuid, json.dumps(ips), )) - else: - 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 ip2uuids VALUES (?,?)", (ip, json.dumps(uuids), )) - else: - curs.execute("UPDATE ip2uuids SET uuids = ? WHERE uuid = ?", (ip, json.dumps(uuids), )) - conn.commit() - curs.close() - conn.close() - - -@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 - 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 ip2uuids WHERE ip = ?", (args[0], )) - results = curs.fetchall() - curs.close() - conn.close() - if len(results) == 0: - msg(sender, "IP " + args[0] + " is not registered in the database, maybe you got a number wrong?") - else: - uuids = json.loads(results[0][0]) - 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() - conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") - curs = conn.cursor() - curs.execute("SELECT ips FROM uuid2ips WHERE uuid = ?", (uuid.toString(), )) - results = curs.fetchall() - curs.close() - conn.close() - if len(results) == 0: - 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 " + 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 +import mysqlhack +import org.bukkit as bukkit +import json +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" +iptrack_version = "1.1.0" + + +@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 uuid2ips WHERE uuid = ?", (uuid, )) + results = curs.fetchall() + if len(results) == 0: + ips = [] + else: + ips = json.loads(results[0][0]) + curs.execute("SELECT uuids FROM ip2uuids WHERE ip = ?", (ip, )) + results = curs.fetchall() + if len(results) == 0: + uuids = [] + else: + uuids = json.loads(results[0][0]) + new_ip_entry = (len(ips) == 0) + new_uuid_entry = (len(uuids) == 0) + if ip not in ips: + ips.append(ip) + if new_ip_entry: + curs.execute("INSERT INTO uuid2ips VALUES (?,?)", (uuid, json.dumps(ips), )) + else: + curs.execute("UPDATE uuid2ips SET ips = ? WHERE uuid = ?", (json.dumps(ips), uuid, )) + if uuid not in uuids: + uuids.append(uuid) + if new_uuid_entry: + curs.execute("INSERT INTO ip2uuids VALUES (?,?)", (ip, json.dumps(uuids), )) + else: + curs.execute("UPDATE ip2uuids SET uuids = ? WHERE ip = ?", (json.dumps(uuids), ip, )) + conn.commit() + curs.close() + conn.close() + + +@hook.command("getinfo") +def on_getinfo_command(sender, args): + t = threading.Thread(target=on_getinfo_command_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 + else: + if is_ip(args[0]): + conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") + curs = conn.cursor() + curs.execute("SELECT uuids FROM ip2uuids WHERE ip = ?", (args[0], )) + results = curs.fetchall() + curs.close() + conn.close() + if len(results) == 0: + msg(sender, "IP " + args[0] + " is not registered in the database, maybe you got a number wrong?") + else: + uuids = json.loads(results[0][0]) + 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() + conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") + curs = conn.cursor() + curs.execute("SELECT ips FROM uuid2ips WHERE uuid = ?", (uuid.toString(), )) + results = curs.fetchall() + curs.close() + conn.close() + if len(results) == 0: + 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 " + 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 -- 2.45.2 From 799584df46a0c53484a3b8cab11efdd4d67d319a Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Sun, 7 Feb 2016 13:15:51 +0200 Subject: [PATCH 06/95] Unbusies on logout --- imbusy.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imbusy.py b/imbusy.py index 64fa30b..37a964e 100644 --- a/imbusy.py +++ b/imbusy.py @@ -105,3 +105,10 @@ def on_cmd_preprocess_event(event): 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) + +@hook.event("player.PlayerQuitEvent", "lowest") +def on_player_leave(event): + try: + busy_players.remove(event.getPlayer().getName()) + except: + pass -- 2.45.2 From f03f34777b1d0ddc95c2ddb17e6eddfd832a8332 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Feb 2016 22:24:11 +0100 Subject: [PATCH 07/95] Added tabnames module, disabled iptracker due to instability --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 7411d17..2d6f253 100644 --- a/main.py +++ b/main.py @@ -98,10 +98,12 @@ shared["load_modules"] = [ "punishments", # a simple replacement for the buggy essentials /vanish "vanish", - # ip-tracking utility - "iptracker", + # ip-tracking utility - disabled as of instability + #"iptracker", #server signs for everyone - "serversigns" + "serversigns", + # tabnames module to make players names colored on their chars and sort tab after ranks + "tabnames" ] shared["modules"] = {} for module in shared["load_modules"]: -- 2.45.2 From 70f2001e7b24bf35202d5d255c3a3f7398c708af Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Feb 2016 22:25:02 +0100 Subject: [PATCH 08/95] initial commit, adding the tabnames module --- tabnames.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 tabnames.py diff --git a/tabnames.py b/tabnames.py new file mode 100755 index 0000000..049098c --- /dev/null +++ b/tabnames.py @@ -0,0 +1,35 @@ +import mysqlhack +import org.bukkit as bukkit +import json +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 * + +tabnames_version = "v1.0.0" + +############################################################## +# # +# This module automatically puts people in the corresponding # +# scoreboard team so that their name is colored properly and # +# tab will be nicely sorted. # +# # +############################################################## + +ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin", "breaker"] +prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"} + +@hook.event("player.PlayerJoinEvent", "low") +def on_player_join(event): + scoreboard_team = prefix(get_Rank(event.getPlayer())) + bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), "scoreboard teams join " + scoreboard_team + " " + event.getPlayer().getName()) + +def get_Rank(player): + for i in range(0, len(ranks) - 1): + if not player.hasPermission("group." + ranks[i]): + break + return ranks[i-1] + +def prefix(rank): + return prefixes.get(rank) + "_" + rank -- 2.45.2 From 91afa684cd09cd4638ee74733a5cb60b2e4a247f Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 14 Feb 2016 22:33:44 +0100 Subject: [PATCH 09/95] removed unnessecary imports, code cleanup --- tabnames.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tabnames.py b/tabnames.py index 049098c..c0848c0 100755 --- a/tabnames.py +++ b/tabnames.py @@ -1,11 +1,6 @@ -import mysqlhack import org.bukkit as bukkit -import json -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 * tabnames_version = "v1.0.0" @@ -23,7 +18,8 @@ prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder @hook.event("player.PlayerJoinEvent", "low") def on_player_join(event): scoreboard_team = prefix(get_Rank(event.getPlayer())) - bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), "scoreboard teams join " + scoreboard_team + " " + event.getPlayer().getName()) + bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), + "scoreboard teams join " + scoreboard_team + " " + event.getPlayer().getName()) def get_Rank(player): for i in range(0, len(ranks) - 1): -- 2.45.2 From 5a0477fdbfaa222350c62ce948d8371c34bd538f Mon Sep 17 00:00:00 2001 From: jomo Date: Sun, 14 Feb 2016 23:52:50 +0100 Subject: [PATCH 10/95] clean up tabnames doesn't throw exceptions when group can't be found, will print warning instead --- tabnames.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tabnames.py b/tabnames.py index c0848c0..65e1a2c 100755 --- a/tabnames.py +++ b/tabnames.py @@ -1,6 +1,4 @@ -import org.bukkit as bukkit from helpers import * -from org.bukkit import * tabnames_version = "v1.0.0" @@ -12,20 +10,29 @@ tabnames_version = "v1.0.0" # # ############################################################## -ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin", "breaker"] +ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin"] prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"} @hook.event("player.PlayerJoinEvent", "low") def on_player_join(event): - scoreboard_team = prefix(get_Rank(event.getPlayer())) - bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), - "scoreboard teams join " + scoreboard_team + " " + event.getPlayer().getName()) + player = event.getPlayer() + team = get_team(player) + if team: + cmd = "scoreboard teams join %s %s" % (team, player.getName()) + server.dispatchCommand(server.getConsoleSender(), cmd) -def get_Rank(player): - for i in range(0, len(ranks) - 1): - if not player.hasPermission("group." + ranks[i]): +def get_rank(player): + player_rank = None + for rank in ranks: + if not player.hasPermission("group.%s" % rank): break - return ranks[i-1] + player_rank = rank + if not player_rank: + warn("Couldn't find rank for player %s" % player.getName()) + return player_rank -def prefix(rank): - return prefixes.get(rank) + "_" + rank +def get_team(player): + rank = get_rank(player) + if rank: + prefix = prefixes.get(rank) + return "_".join([prefix, rank]) \ No newline at end of file -- 2.45.2 From 6a4d1447ece65d7cfcfba6b9596f60003e436490 Mon Sep 17 00:00:00 2001 From: jomo Date: Mon, 15 Feb 2016 01:27:13 +0100 Subject: [PATCH 11/95] rename tabnames to nametags I think it's a more descriptive name --- main.py | 6 +++--- tabnames.py => nametags.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) rename tabnames.py => nametags.py (94%) diff --git a/main.py b/main.py index 2d6f253..be3a65b 100644 --- a/main.py +++ b/main.py @@ -89,7 +89,7 @@ shared["load_modules"] = [ # Servercontrol extension for telnet access to logs/AC #"servercontrol", # Script helper plugin - "scriptutils", + "scriptutils", # Per-player notes "tag", # vanish toggle module - temporary fix @@ -102,8 +102,8 @@ shared["load_modules"] = [ #"iptracker", #server signs for everyone "serversigns", - # tabnames module to make players names colored on their chars and sort tab after ranks - "tabnames" + # Makes player's names colored, sorts tab list by rank + "nametags" ] shared["modules"] = {} for module in shared["load_modules"]: diff --git a/tabnames.py b/nametags.py similarity index 94% rename from tabnames.py rename to nametags.py index 65e1a2c..88c0696 100755 --- a/tabnames.py +++ b/nametags.py @@ -1,7 +1,5 @@ from helpers import * -tabnames_version = "v1.0.0" - ############################################################## # # # This module automatically puts people in the corresponding # @@ -11,6 +9,7 @@ tabnames_version = "v1.0.0" ############################################################## ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin"] +# prefixes are used for sorting in the tab list prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"} @hook.event("player.PlayerJoinEvent", "low") -- 2.45.2 From 34ed3a1023a757f4cdecb13d9e72bcbc188a269f Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 15 Feb 2016 16:50:21 +0100 Subject: [PATCH 12/95] Fixed naming error in rank trainingmod --- nametags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nametags.py b/nametags.py index 88c0696..4d86bbe 100755 --- a/nametags.py +++ b/nametags.py @@ -8,9 +8,9 @@ from helpers import * # # ############################################################## -ranks = ["visitor", "member", "builder", "trusted", "modintraining", "mod", "admin"] +ranks = ["visitor", "member", "builder", "trusted", "trainingmod", "mod", "admin"] # prefixes are used for sorting in the tab list -prefixes = {"admin":"a", "mod":"b", "modintraining":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"} +prefixes = {"admin":"a", "mod":"b", "trainingmod":"c", "trusted":"d", "builder":"e", "member":"f","visitor":"g"} @hook.event("player.PlayerJoinEvent", "low") def on_player_join(event): -- 2.45.2 From 9160c85d09248b031b5378d48d188148d8cb8c56 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 15 Feb 2016 17:32:50 +0100 Subject: [PATCH 13/95] Added automatic disabling of cgt when leaving a chatgroup --- chatgroups.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/chatgroups.py b/chatgroups.py index 9965b96..aed22cd 100644 --- a/chatgroups.py +++ b/chatgroups.py @@ -21,6 +21,8 @@ def on_chatgroup_command(sender, command, label, args): if len(args) == 1 and args[0] == "leave": if sender_id in groups.keys(): groupchat(sender, "left the group", True) + if sender in cg_toggle_list: + cg_toggle_list.remove(p) group = groups[sender_id] del(groups[sender_id]) save_groups() -- 2.45.2 From 412ed59225a864e9c59d36fa11ad670410a44fe2 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 15 Feb 2016 17:33:14 +0100 Subject: [PATCH 14/95] Added aliases and proper command description --- pmtoggle.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pmtoggle.py b/pmtoggle.py index e1bac06..1cdf17b 100644 --- a/pmtoggle.py +++ b/pmtoggle.py @@ -5,7 +5,11 @@ from java.util.UUID import fromString as juuid toggle_dict = {} permission = "utils.pmtoggle" -@hook.command("tm") +@hook.command("tm", + aliases = ["tmsg", "mt", "msgt"], + usage = "/ [player]", + description = "Toggle automatic sending of messages" + ) def on_toggle_message_command(sender, command, label, args): if not sender.hasPermission(permission) or not is_player(sender): noperm(sender) -- 2.45.2 From 0aad531f9ec75f3e133f7d6060a1d1b64e17b7dc Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 15 Feb 2016 17:38:19 +0100 Subject: [PATCH 15/95] Added more aliases --- pmtoggle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmtoggle.py b/pmtoggle.py index 1cdf17b..19caf9e 100644 --- a/pmtoggle.py +++ b/pmtoggle.py @@ -5,8 +5,8 @@ from java.util.UUID import fromString as juuid toggle_dict = {} permission = "utils.pmtoggle" -@hook.command("tm", - aliases = ["tmsg", "mt", "msgt"], +@hook.command("pmtoggle", + aliases = ["tm", "mt", "tmsg", "msgt", "pmt", "tpm"], usage = "/ [player]", description = "Toggle automatic sending of messages" ) -- 2.45.2 From 621f4ca23b1a1befacfb71c85255a19db0d260e1 Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 8 Mar 2016 20:32:56 +0200 Subject: [PATCH 16/95] Added a debug decorator, use @debug to nicely print function errors --- helpers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helpers.py b/helpers.py index 8485b2a..4c32e24 100755 --- a/helpers.py +++ b/helpers.py @@ -314,3 +314,13 @@ def array_to_list(array): for a in array: return_list += [a] return return_list + + +#debug wrapper +def debug(func): + def wrap(*args, **kwargs): + try: + func(*args, **kwargs) + except: + print(trace()) + return wrap -- 2.45.2 From fad1ae0f90022aee9d336618dd2c0cc3b8ba95a2 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sat, 12 Mar 2016 01:00:07 +0100 Subject: [PATCH 17/95] Fixed a return message in blockplacemods.py --- blockplacemods.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blockplacemods.py b/blockplacemods.py index fd7071e..b87c5ee 100644 --- a/blockplacemods.py +++ b/blockplacemods.py @@ -150,7 +150,8 @@ def toggle_command(sender, command, label, args): if arg2 == "clear": if enabled: del values[uuid] - return " &aDisabled " + details[1] + return " &aDisabled " + details[1] + return " &cAlready disabled: " + details[1] if arg2 == "details": return " &aSetting %s:\n &9%s \n&6Accepted arguments: [|clear|details]" % (setting, details[2]) -- 2.45.2 From 286f8751b5d3edcaa2e1f8c22b47f292887c979f Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sat, 12 Mar 2016 01:02:48 +0100 Subject: [PATCH 18/95] Fix tab -.- lol why did it load locally? --- blockplacemods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockplacemods.py b/blockplacemods.py index b87c5ee..8d18699 100644 --- a/blockplacemods.py +++ b/blockplacemods.py @@ -150,7 +150,7 @@ def toggle_command(sender, command, label, args): if arg2 == "clear": if enabled: del values[uuid] - return " &aDisabled " + details[1] + return " &aDisabled " + details[1] return " &cAlready disabled: " + details[1] if arg2 == "details": -- 2.45.2 From c870561f7db96d0ab010e99fdd22699a24e0630b Mon Sep 17 00:00:00 2001 From: psrcek Date: Sat, 26 Mar 2016 21:56:10 +0100 Subject: [PATCH 19/95] removed some unnecesary code The below if statement is always true and the value of timeout_on isn't used before a return statement. timeout_on = False if timeout_on == False: --- damnspam.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/damnspam.py b/damnspam.py index 6a4c2b3..af800af 100644 --- a/damnspam.py +++ b/damnspam.py @@ -47,8 +47,6 @@ def on_dammnspam_command(sender, command, label, args): timeout_on = round(float(timeout_on), 2) timeout_off = timeout_on if 60 >= timeout_on <= -2 or timeout_on == 0: - timeout_on = False - if timeout_on == False: msg(sender, "&cThe timeout must be within 0-60 or -1.") return True except ValueError: -- 2.45.2 From 46f1564af03a35c006448df77b1207f516592489 Mon Sep 17 00:00:00 2001 From: Pepich Date: Mon, 11 Apr 2016 15:18:59 +0200 Subject: [PATCH 20/95] Fixed indentation error ll 39-41 --- damnspam.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/damnspam.py b/damnspam.py index 6a4c2b3..83dfb5f 100644 --- a/damnspam.py +++ b/damnspam.py @@ -36,9 +36,9 @@ def on_dammnspam_command(sender, command, label, args): msg(sender, "&c/damnspam &e(Levers only)") return True #Gittestlol - if not is_creative(sender): - msg(sender, "&cYou can only do this in Creative mode.") - return True + if not is_creative(sender): + msg(sender, "&cYou can only do this in Creative mode.") + return True # /damnspam if len(args) == 1: -- 2.45.2 From fa1d5e900d13c546ddf069849e14eadafdc79377 Mon Sep 17 00:00:00 2001 From: Pepich Date: Mon, 11 Apr 2016 16:59:42 +0200 Subject: [PATCH 21/95] Fixed player subcommand, removed debug outputs --- chatalias.py | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/chatalias.py b/chatalias.py index a73decb..530cc90 100644 --- a/chatalias.py +++ b/chatalias.py @@ -11,6 +11,7 @@ ############################################ import os +import mysqlhack import org.bukkit as bukkit from org.bukkit import * from helpers import * @@ -26,6 +27,7 @@ error = colorify("&cUnspecified error") commands_per_page = 5 global_aliases = {"./":"/"} data = {} +# DON'T SET THIS TO TRUE! MySQL requestst are NOT async yet! (And for some reason it doesn't want to store any data ._.) use_mysql = False # Permissions: @@ -83,7 +85,6 @@ def on_alias_command(sender, cmd, label, args): return True return subcommands[args[0].lower()](sender, args[1:]) except: - print(trace()) return subcommands["help"](sender, "1") @@ -132,7 +133,7 @@ def on_join(event): if event.getPlayer().hasPermission(permission_FINFO): disabled_fallback(event.getPlayer()) except: - print(trace()) + return @hook.event("player.AsyncPlayerChatEvent", "high") @@ -154,7 +155,7 @@ def on_player_chat(event): else: event.setMessage(event.getMessage().replace(alias, value)) except: - print(trace()) + return def hasPerm(player, permission): return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL)) @@ -186,8 +187,13 @@ def add(sender, args): def radd(sender, args): - args = [args[0:1]] + [" ".join([args[2:len(args)-2]])] + [args[len(args)-1]] plugin_header(sender, "Alias") + args = args[0:2] + [" ".join(args[2:len(args)-1])] + [args[len(args)-1]] + if is_player(sender): + sender_name = colorify(sender.getDisplayName()) + else: + sender_name = colorify("&6Console") + target = get_player(args[0]) if args[3].lower() == "false": plugin_header(target, "Alias") msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") @@ -196,12 +202,6 @@ def radd(sender, args): if args[3].lower() == "false": msg(target, "&cCould not create alias: Max_limit reached!") return True - - target = get_player(args[0]) - if is_player(sender): - sender_name = colorify(sender.getDisplayName) - else: - sender_name = colorify("&6Console") if len(args) == 3: args += ["true"] data[str(uid(target))][str(args[1])] = str(args[2]) @@ -226,11 +226,10 @@ def rremove(sender, args): plugin_header(sender, "Alias") target = get_player(args[0]) if is_player(sender): - sender_name = colorify(sender.getDisplayName) + sender_name = colorify(sender.getDisplayName()) else: sender_name = colorify("&6Console") if args[2].lower() == "false": - print("WTF") plugin_header(target, "Alias") msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!") try: @@ -276,13 +275,18 @@ def rlist_alias(sender, args): def remote(sender, args): try: - return remotes[args[1].lower()](sender, [args[0]] + [args[2:]]) + return remotes[args[1].lower()](sender, [args[0]] + args[2:]) except: - print(trace()) return subcommands["help"](sender, ["2"]) - def load_data(uuid): + load_data_thread(uuid) +# t = threading.Thread(target=load_data_thread, args=(uuid)) +# t.daemon = True +# t.start() + + +def load_data_thread(uuid): if use_mysql: conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") curs = conn.cursor() @@ -295,8 +299,13 @@ def load_data(uuid): else: data[uuid] = safe_open_json(uuid) - def save_data(uuid): + save_data_thread(uuid) +# t = threading.Thread(target=save_data_thread, args=(uuid)) +# t.daemon = True +# t.start() + +def save_data_thread(uuid): if use_mysql: conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") curs = conn.cursor() -- 2.45.2 From 48251e1e520a2f3ad42d30a2ab8e11fd09abee19 Mon Sep 17 00:00:00 2001 From: Pepich Date: Tue, 12 Apr 2016 14:52:16 +0200 Subject: [PATCH 22/95] Cleanup, adding debug outputs back, removing empty try/catch phrases --- chatalias.py | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/chatalias.py b/chatalias.py index 530cc90..de18f78 100644 --- a/chatalias.py +++ b/chatalias.py @@ -27,7 +27,7 @@ error = colorify("&cUnspecified error") commands_per_page = 5 global_aliases = {"./":"/"} data = {} -# DON'T SET THIS TO TRUE! MySQL requestst are NOT async yet! (And for some reason it doesn't want to store any data ._.) +# DON'T SET THIS TO TRUE! MySQL requestst are NOT ASYNC yet! (And for some reason it doesn't want to store any data ._.) use_mysql = False # Permissions: @@ -55,6 +55,7 @@ permission_FINFO = "utils.alias.finfo" # CODE # ######## +# OnEnable enabled = helpers_version in helpers_versions if not enabled: error = colorify("&6Incompatible versions detected (&chelpers.py&6)") @@ -124,16 +125,13 @@ def help(sender, args): @hook.event("player.PlayerJoinEvent", "high") def on_join(event): - try: - if enabled: - t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) - t.daemon = True - t.start() - else: - if event.getPlayer().hasPermission(permission_FINFO): - disabled_fallback(event.getPlayer()) - except: - return + if enabled: + t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) + t.daemon = True + t.start() + else: + if event.getPlayer().hasPermission(permission_FINFO): + disabled_fallback(event.getPlayer()) @hook.event("player.AsyncPlayerChatEvent", "high") @@ -155,7 +153,8 @@ def on_player_chat(event): else: event.setMessage(event.getMessage().replace(alias, value)) except: - return + print(trace()) + def hasPerm(player, permission): return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL)) @@ -279,12 +278,15 @@ def remote(sender, args): except: return subcommands["help"](sender, ["2"]) -def load_data(uuid): - load_data_thread(uuid) -# t = threading.Thread(target=load_data_thread, args=(uuid)) -# t.daemon = True -# t.start() +def load_data(uuid): + try: + load_data_thread(uuid) +# t = threading.Thread(target=load_data_thread, args=(uuid)) +# t.daemon = True +# t.start() + except: + print(trace()) def load_data_thread(uuid): if use_mysql: @@ -299,11 +301,15 @@ def load_data_thread(uuid): else: data[uuid] = safe_open_json(uuid) + def save_data(uuid): - save_data_thread(uuid) -# t = threading.Thread(target=save_data_thread, args=(uuid)) -# t.daemon = True -# t.start() + try: + save_data_thread(uuid) +# t = threading.Thread(target=save_data_thread, args=(uuid)) +# t.daemon = True +# t.start() + except: + print(trace()) def save_data_thread(uuid): if use_mysql: @@ -313,8 +319,8 @@ def save_data_thread(uuid): else: save_json_file("aliases/" + uuid, data[uuid]) -# Subcommands: +# Subcommands: subcommands = { "help": help, "add": add, -- 2.45.2 From 07039b3d1601b67056044c45a7ee88d4e0062c97 Mon Sep 17 00:00:00 2001 From: Dico Date: Wed, 25 May 2016 01:37:01 +0200 Subject: [PATCH 23/95] Fix command given for next help page in chatalias.py --- chatalias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatalias.py b/chatalias.py index de18f78..da1a657 100644 --- a/chatalias.py +++ b/chatalias.py @@ -119,7 +119,7 @@ def help(sender, args): for message in to_display: msg(sender, message) if page+1 < pages: - msg(sender, colorify("&6To display the next page, type &c/help " + str(page+2))) + msg(sender, colorify("&6To display the next page, type &c/alias help " + str(page+2))) return True -- 2.45.2 From a5556760761974590b0666c3e89043aa5fc98a1d Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 02:39:05 +0200 Subject: [PATCH 24/95] Prevent complete multi-replacement in chatalias. Doesn't prevent 1 -> 2 and 23 -> 5 to make for 13 -> 5, but does prevent a -> 20 and 2 -> 3. Tested. --- chatalias.py | 25 +++++++++++++++++++++---- main.py | 2 +- plugin.yml | 3 +-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/chatalias.py b/chatalias.py index da1a657..be97228 100644 --- a/chatalias.py +++ b/chatalias.py @@ -86,6 +86,7 @@ def on_alias_command(sender, cmd, label, args): return True return subcommands[args[0].lower()](sender, args[1:]) except: + print(trace()) return subcommands["help"](sender, "1") @@ -179,8 +180,9 @@ def add(sender, args): msg(sender, "&cCould not create alias: Max_limit reached!") return True args = [args[0]] + [" ".join(args[1:])] - data[str(uid(sender))][str(args[0])] = args[1] - save_data(uid(sender)) + if not add_alias_data(uid(sender), str(args[0]), args[1]): + msg(sender, colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it") + return True msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) return True @@ -203,14 +205,29 @@ def radd(sender, args): return True if len(args) == 3: args += ["true"] - data[str(uid(target))][str(args[1])] = str(args[2]) - save_data(uid(target)) + if not add_alias_data(uid(target), str(args[1]), str(args[2])): + message = colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it" + msg(sender, message) + if args[3].lower() == "false": + msg(target, message) + return True msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) if args[3].lower() == "false": msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) return True +def add_alias_data(puuid, aliased, new_alias): + prior = data[puuid] + if aliased not in prior: + for alias in prior.values(): + if aliased in alias: + return False + prior[aliased] = new_alias + save_data(puuid) + return True + + def remove(sender, args): plugin_header(sender, "Alias") try: diff --git a/main.py b/main.py index be3a65b..651a547 100644 --- a/main.py +++ b/main.py @@ -43,7 +43,7 @@ shared["load_modules"] = [ # Adds /calc, toggles automatic solving of Math expressions in chat "calc", # Adds aliasing of chat words - #"chatalias", + "chatalias", # Plugin to locate laggy chunks. /lc lists chunks with more than n entities "lagchunks", # Adds /report and /rp, Stores reports with time and location diff --git a/plugin.yml b/plugin.yml index 4991e40..97e69a1 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,4 @@ name: RedstonerUtils main: main.py version: 3.1.0 -author: redstone_sheep - +author: redstone_sheep \ No newline at end of file -- 2.45.2 From 4e6bd44c387b4956da5bf39a3a80b25b0b495aba Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 02:40:50 +0200 Subject: [PATCH 25/95] Undoing these small changes from last commit... --- chatalias.py | 1 - plugin.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/chatalias.py b/chatalias.py index be97228..24a445e 100644 --- a/chatalias.py +++ b/chatalias.py @@ -86,7 +86,6 @@ def on_alias_command(sender, cmd, label, args): return True return subcommands[args[0].lower()](sender, args[1:]) except: - print(trace()) return subcommands["help"](sender, "1") diff --git a/plugin.yml b/plugin.yml index 97e69a1..bdd5acb 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,4 +1,4 @@ name: RedstonerUtils main: main.py version: 3.1.0 -author: redstone_sheep \ No newline at end of file +author: redstone_sheep -- 2.45.2 From 7fdaee155aabc69e658d5eaf4d6aa502ab90239c Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 02:46:53 +0200 Subject: [PATCH 26/95] Fix yo shitty chatgroups code --- chatgroups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatgroups.py b/chatgroups.py index aed22cd..be29e53 100644 --- a/chatgroups.py +++ b/chatgroups.py @@ -89,7 +89,7 @@ def groupchat(sender, message, ann = False): def do_for_chatgroup(group, func, *args, **kwargs): for receiver in server.getOnlinePlayers(): if groups.get(uid(receiver)) == group: - func(receiver, args, kwargs) + func(receiver, *args, **kwargs) def send_tpa_request(receiver, sender): if not receiver == sender: -- 2.45.2 From fca3cf250c10c47d849c2faef7a1a1f2d601d57b Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 02:52:24 +0200 Subject: [PATCH 27/95] Imbusy: Fixed typos and some *flaws* which I will disregard here @curs3d --- imbusy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imbusy.py b/imbusy.py index 37a964e..153c00f 100644 --- a/imbusy.py +++ b/imbusy.py @@ -17,8 +17,8 @@ from traceback import format_exc as trace busy_players = [] -def unclear(): - msg(sender, "Umm, what? Sorry, directions unlclear, got head stuck in washing machine") +def unclear(sender): + msg(sender, "Umm, what? Sorry, directions unclear, got head stuck in washing machine") @hook.command("busy", @@ -39,7 +39,7 @@ def on_busy_command(sender, cmd, label, args): 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, "This plugin allows being busy, and when turned on you will not receive 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") @@ -78,7 +78,7 @@ def on_busy_command(sender, cmd, label, args): else: plugin_header(recipient = sender, name = "I'M BUSY!") - unclear() + unclear(sender) return False elif len(args) == 2 and args[0] == "status": @@ -92,7 +92,7 @@ def on_busy_command(sender, cmd, label, args): else: plugin_header(recipient = sender, name = "I'M BUSY!") - unclear() + unclear(sender) return False -- 2.45.2 From 8165d5977b407d10b97e65a2e15bbcf97855f224 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 03:00:35 +0200 Subject: [PATCH 28/95] Small change to imbusy messages --- imbusy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imbusy.py b/imbusy.py index 153c00f..049d721 100644 --- a/imbusy.py +++ b/imbusy.py @@ -54,14 +54,14 @@ def on_busy_command(sender, cmd, label, args): 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()) + broadcast(None, "&c[&2Busy&c] &fNow busy: %s&f, don't even TRY bothering them!" % sender.getDisplayName()) 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()) + msg(sender, "Master has sent /busy command, %s&f is freeee of bothering!" % sender.getDisplayName()) return True except ValueError: msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?") @@ -82,7 +82,7 @@ def on_busy_command(sender, cmd, label, args): return False elif len(args) == 2 and args[0] == "status": - plugin_header(recipient = sender, name = "I'M BUSY!") + 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 -- 2.45.2 From 29e7ce174b5f353d79773f1e73f047bb0007acbc Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 03:02:01 +0200 Subject: [PATCH 29/95] Imbusy command: Replace plugin_header calls with a single one at the start --- imbusy.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/imbusy.py b/imbusy.py index 049d721..8e84cbd 100644 --- a/imbusy.py +++ b/imbusy.py @@ -32,13 +32,13 @@ def on_busy_command(sender, cmd, label, args): msg(sender, "Sorry, Console cannot be busy") return True + plugin_header(recipient = sender, name = "I'M BUSY!") + 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 receive any direct messages or tpa requests.") msg(sender, "\nCommands:") msg(sender, "/busy on: turns on busy mode") @@ -49,16 +49,13 @@ def on_busy_command(sender, cmd, label, args): 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, "&c[&2Busy&c] &fNow busy: %s&f, don't even TRY bothering them!" % sender.getDisplayName()) 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&f is freeee of bothering!" % sender.getDisplayName()) @@ -68,7 +65,6 @@ def on_busy_command(sender, cmd, label, args): 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 @@ -77,12 +73,10 @@ def on_busy_command(sender, cmd, label, args): return True else: - plugin_header(recipient = sender, name = "I'M BUSY!") unclear(sender) 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 @@ -91,7 +85,6 @@ def on_busy_command(sender, cmd, label, args): return True else: - plugin_header(recipient = sender, name = "I'M BUSY!") unclear(sender) return False -- 2.45.2 From 9a1006e7114e9ed63b67e1197a3ec934a9089814 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 03:05:59 +0200 Subject: [PATCH 30/95] Imbusy command: status tweaked, cleaned up return statements --- imbusy.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/imbusy.py b/imbusy.py index 8e84cbd..a480e2e 100644 --- a/imbusy.py +++ b/imbusy.py @@ -44,49 +44,45 @@ def on_busy_command(sender, cmd, label, args): 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: msg(sender, "You cannot be even more focused than this without being a jedi!") - return True - busy_players.append(sender.getName()) - broadcast(None, "&c[&2Busy&c] &fNow busy: %s&f, don't even TRY bothering them!" % sender.getDisplayName()) - return True + else: + busy_players.append(sender.getName()) + broadcast(None, "&c[&2Busy&c] &fNow busy: %s&r, don't even TRY bothering them!" % sender.getDisplayName()) elif args[0] == "off": try: busy_players.remove(sender.getName()) - msg(sender, "Master has sent /busy command, %s&f is freeee of bothering!" % sender.getDisplayName()) - return True + msg(sender, "Master has sent /busy command, %s&r is freeee of bothering!" % sender.getDisplayName()) except ValueError: msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?") - return True elif args[0] == "status": 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: unclear(sender) return False elif len(args) == 2 and args[0] == "status": - if args[1] in busy_players: - msg(sender, "Yes, %s is busy. Shhh..." % args[1]) - return True + target = server.getPlayer(args[1]) + if target is None: + msg(sender, "That player is not online, I doubt they are busy.") + elif target.getName() in busy_players: + msg(sender, "Yes, %s&r is busy. Shhh..." % target.getDisplayName()) else: - msg(sender, "No, you're good. Feel free to chat with %s!" % args[1]) - return True + msg(sender, "No, you're good. Feel free to chat with %s&r!" % target.getDisplayName()) else: unclear(sender) return False + return True @hook.event("player.PlayerCommandPreprocessEvent", "monitor") -- 2.45.2 From 5592e16200212b22f61f358183740d8a34030bc9 Mon Sep 17 00:00:00 2001 From: Dico Date: Wed, 25 May 2016 15:49:11 +0200 Subject: [PATCH 31/95] Solidify imbusy blocking pms, tpas, etc. I used reflection to get the Map object from the SimpleCommandMap instance stored in the implementation of PluginManager. I replaced all Command instances in there that handle /msg, /tpa, /tpahere and /reply, minus /minecraft:tell, with a wrapper that checks if the target is busy. Tested adequately, but some more would be nice. --- imbusy.py | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 131 insertions(+), 10 deletions(-) diff --git a/imbusy.py b/imbusy.py index a480e2e..8d7ae74 100644 --- a/imbusy.py +++ b/imbusy.py @@ -13,7 +13,9 @@ from helpers import * from basecommands import simplecommand +import org.bukkit.command.Command as Command from traceback import format_exc as trace + busy_players = [] @@ -85,19 +87,138 @@ def on_busy_command(sender, cmd, label, args): return True -@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) - @hook.event("player.PlayerQuitEvent", "lowest") def on_player_leave(event): try: busy_players.remove(event.getPlayer().getName()) except: pass + + +#---- Dicode for catching any bothering of busy people ---- + + +reply_targets = {} +override_perm = "utils.imbusy.override" + + +def whisper(sender, target_name): + target = server.getPlayer(target_name) + + if target is not None: + if target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) + return False + + reply_targets[sender.getName()] = target.getName() + + # allow the target to reply regardless of sender being busy + if target.getName() in reply_targets: + del reply_targets[target.getName()] + return True + + +def reply(sender): + if sender.getName() in reply_targets: + target = server.getPlayer(reply_targets[sender.getName()]) + if target is not None: + if target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) + return False + + # allow the target to reply regardless of sender being busy + if target.getName() in reply_targets: + del reply_targets[target.getName()] + return True + + +class CommandWrapper(Command): + + def __init__(self, wrapped, checker): + Command.__init__(self, wrapped.getName()) + self.setDescription(wrapped.getDescription()) + self.setPermission(wrapped.getPermission()) + self.setUsage(wrapped.getUsage()) + self.setAliases(wrapped.getAliases()) + self.wrapped = wrapped + self.checker = checker + + def execute(self, sender, label, args): + try: + if self.checker(sender, args): + return self.wrapped.execute(sender, label, args) + except: + error(trace()) + return True + + def tabComplete(self, sender, alias, args): + return self.wrapped.tabComplete(sender, alias, args) + +def msg_command_checker(sender, args): + return len(args) <= 1 or whisper(sender, args[0]) + +def reply_command_checker(sender, args): + return len(args) == 0 or reply(sender) + +def tpa_command_checker(sender, args): + if len(args) == 0: + return True + target = server.getPlayer(args[0]) + if target is not None and target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) + return False + return True + +def tpahere_command_checker(sender, args): + return tpa_command_checker(sender, args) + + +@hook.event("player.PlayerCommandPreprocessEvent", "monitor") +def on_player_command_preprocess(event): + message = event.getMessage().split(" ") + if len(message) > 1 and message[0].lower() in ("/tell", "/minecraft:tell") and not whisper(event.getPlayer(), message[1]): + event.setCancelled(True) + + +@hook.enable +def replace_ess_commands(): + + try: + mapField = server.getPluginManager().getClass().getDeclaredField("commandMap") + mapField.setAccessible(True) + commandMap = mapField.get(server.getPluginManager()) + + commandsField = commandMap.getClass().getDeclaredField("knownCommands") + commandsField.setAccessible(True) + map = commandsField.get(commandMap) + + essMsgCmd = map.get("essentials:msg") + essReplyCmd = map.get("essentials:reply") + essTpaCmd = map.get("essentials:tpa") + essTpahereCmd = map.get("essentials:tpahere") + + msgCmdWrapper = CommandWrapper(essMsgCmd, msg_command_checker) + replyCmdWrapper = CommandWrapper(essReplyCmd, reply_command_checker) + tpaCmdWrapper = CommandWrapper(essTpaCmd, tpa_command_checker) + tpahereCmdWrapper = CommandWrapper(essTpahereCmd, tpahere_command_checker) + + iterator = map.entrySet().iterator() + while iterator.hasNext(): + entry = iterator.next() + value = entry.getValue() + if value is essMsgCmd: + entry.setValue(msgCmdWrapper) + info("[imbusy] wrapped /" + entry.getKey()) + elif value is essReplyCmd: + entry.setValue(replyCmdWrapper) + info("[imbusy] wrapped /" + entry.getKey()) + elif value is essTpaCmd: + entry.setValue(tpaCmdWrapper) + info("[imbusy] wrapped /" + entry.getKey()) + elif value is essTpahereCmd: + entry.setValue(tpahereCmdWrapper) + info("[imbusy] wrapped /" + entry.getKey()) + + except: + error("[Imbusy] Failed to wrap essentials commands") + error(trace()) -- 2.45.2 From a2a43ed464edbafe9548c156371d8013cc9e054d Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 16:13:36 +0200 Subject: [PATCH 32/95] Replace camelCase with _ stuff --- imbusy.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/imbusy.py b/imbusy.py index 8d7ae74..2baefa3 100644 --- a/imbusy.py +++ b/imbusy.py @@ -144,6 +144,7 @@ class CommandWrapper(Command): self.checker = checker def execute(self, sender, label, args): + info("/" + self.getLabel() + " executed by " + sender.getName()) try: if self.checker(sender, args): return self.wrapped.execute(sender, label, args) @@ -184,39 +185,40 @@ def on_player_command_preprocess(event): def replace_ess_commands(): try: - mapField = server.getPluginManager().getClass().getDeclaredField("commandMap") - mapField.setAccessible(True) - commandMap = mapField.get(server.getPluginManager()) + info("[imbusy] Wrapping ess commands") + map_field = server.getPluginManager().getClass().getDeclaredField("commandMap") + map_field.setAccessible(True) + command_map = map_field.get(server.getPluginManager()) - commandsField = commandMap.getClass().getDeclaredField("knownCommands") - commandsField.setAccessible(True) - map = commandsField.get(commandMap) + commands_field = command_map.getClass().getDeclaredField("knownCommands") + commands_field.setAccessible(True) + map = commands_field.get(command_map) - essMsgCmd = map.get("essentials:msg") - essReplyCmd = map.get("essentials:reply") - essTpaCmd = map.get("essentials:tpa") - essTpahereCmd = map.get("essentials:tpahere") + ess_msg_cmd = map.get("essentials:msg") + ess_reply_cmd = map.get("essentials:reply") + ess_tpa_cmd = map.get("essentials:tpa") + ess_tpahere_cmd = map.get("essentials:tpahere") - msgCmdWrapper = CommandWrapper(essMsgCmd, msg_command_checker) - replyCmdWrapper = CommandWrapper(essReplyCmd, reply_command_checker) - tpaCmdWrapper = CommandWrapper(essTpaCmd, tpa_command_checker) - tpahereCmdWrapper = CommandWrapper(essTpahereCmd, tpahere_command_checker) + msg_cmd_wrapper = CommandWrapper(ess_msg_cmd, msg_command_checker) + reply_cmd_wrapper = CommandWrapper(ess_reply_cmd, reply_command_checker) + tpa_cmd_wrapper = CommandWrapper(ess_tpa_cmd, tpa_command_checker) + tpahere_cmd_wrapper = CommandWrapper(ess_tpahere_cmd, tpahere_command_checker) iterator = map.entrySet().iterator() while iterator.hasNext(): entry = iterator.next() value = entry.getValue() - if value is essMsgCmd: - entry.setValue(msgCmdWrapper) + if value is ess_msg_cmd: + entry.setValue(msg_cmd_wrapper) info("[imbusy] wrapped /" + entry.getKey()) - elif value is essReplyCmd: - entry.setValue(replyCmdWrapper) + elif value is ess_reply_cmd: + entry.setValue(reply_cmd_wrapper) info("[imbusy] wrapped /" + entry.getKey()) - elif value is essTpaCmd: - entry.setValue(tpaCmdWrapper) + elif value is ess_tpa_cmd: + entry.setValue(tpa_cmd_wrapper) info("[imbusy] wrapped /" + entry.getKey()) - elif value is essTpahereCmd: - entry.setValue(tpahereCmdWrapper) + elif value is ess_tpahere_cmd: + entry.setValue(tpahere_cmd_wrapper) info("[imbusy] wrapped /" + entry.getKey()) except: -- 2.45.2 From 29f846c8f9532ac0950c4187171b042d8e5dee49 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 16:31:32 +0200 Subject: [PATCH 33/95] Undo prior changes in favor of pull request --- chatalias.py | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/chatalias.py b/chatalias.py index 24a445e..d1c1b62 100644 --- a/chatalias.py +++ b/chatalias.py @@ -1,3 +1,19 @@ +Skip to content +This repository +Search +Pull requests +Issues +Gist + @Dico200 + Unwatch 13 + Star 5 + Fork 3 RedstonerServer/redstoner-utils + Code Issues 8 Pull requests 3 Wiki Pulse Graphs Settings +Tree: cb1a333a56 Find file Copy pathredstoner-utils/chatalias.py +07039b3 15 hours ago +@Dico200 Dico200 Fix command given for next help page in chatalias.py +5 contributors @PixelSergey @Pepich @NEMESIS13cz @Dico200 @invalid-email-address +RawBlameHistory 337 lines (290 sloc) 12.9 KB ############################################ # Alias v2.0 by Pepich # # Changes to previous version from curs3d: # @@ -179,9 +195,8 @@ def add(sender, args): msg(sender, "&cCould not create alias: Max_limit reached!") return True args = [args[0]] + [" ".join(args[1:])] - if not add_alias_data(uid(sender), str(args[0]), args[1]): - msg(sender, colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it") - return True + data[str(uid(sender))][str(args[0])] = args[1] + save_data(uid(sender)) msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) return True @@ -204,29 +219,14 @@ def radd(sender, args): return True if len(args) == 3: args += ["true"] - if not add_alias_data(uid(target), str(args[1]), str(args[2])): - message = colorify("&c") + "Could not add an alias for this sequence because a priorly added alias contains it" - msg(sender, message) - if args[3].lower() == "false": - msg(target, message) - return True + data[str(uid(target))][str(args[1])] = str(args[2]) + save_data(uid(target)) msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) if args[3].lower() == "false": msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) return True -def add_alias_data(puuid, aliased, new_alias): - prior = data[puuid] - if aliased not in prior: - for alias in prior.values(): - if aliased in alias: - return False - prior[aliased] = new_alias - save_data(puuid) - return True - - def remove(sender, args): plugin_header(sender, "Alias") try: @@ -350,3 +350,5 @@ remotes = { "remove": rremove, "list": rlist_alias, } +Status API Training Shop Blog About +© 2016 GitHub, Inc. Terms Privacy Security Contact Help \ No newline at end of file -- 2.45.2 From d88baa4899d49b3224732e513bb05ea224b6c9f3 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 16:37:58 +0200 Subject: [PATCH 34/95] What is this.. sorry --- chatalias.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/chatalias.py b/chatalias.py index d1c1b62..5560c5f 100644 --- a/chatalias.py +++ b/chatalias.py @@ -1,19 +1,3 @@ -Skip to content -This repository -Search -Pull requests -Issues -Gist - @Dico200 - Unwatch 13 - Star 5 - Fork 3 RedstonerServer/redstoner-utils - Code Issues 8 Pull requests 3 Wiki Pulse Graphs Settings -Tree: cb1a333a56 Find file Copy pathredstoner-utils/chatalias.py -07039b3 15 hours ago -@Dico200 Dico200 Fix command given for next help page in chatalias.py -5 contributors @PixelSergey @Pepich @NEMESIS13cz @Dico200 @invalid-email-address -RawBlameHistory 337 lines (290 sloc) 12.9 KB ############################################ # Alias v2.0 by Pepich # # Changes to previous version from curs3d: # -- 2.45.2 From 2d6725df73df9d92a36aea2ab76f8573f32faf75 Mon Sep 17 00:00:00 2001 From: Dico Date: Wed, 25 May 2016 16:40:31 +0200 Subject: [PATCH 35/95] Prevent chained aliases in chatalias Prevents 1 -> 23 along with 2 -> 3 and similar stuff --- chatalias.py | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/chatalias.py b/chatalias.py index 5560c5f..7163245 100644 --- a/chatalias.py +++ b/chatalias.py @@ -179,8 +179,9 @@ def add(sender, args): msg(sender, "&cCould not create alias: Max_limit reached!") return True args = [args[0]] + [" ".join(args[1:])] - data[str(uid(sender))][str(args[0])] = args[1] - save_data(uid(sender)) + if not add_alias_data(uid(sender), str(args[0]), args[1]): + msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times" + return True msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) return True @@ -203,14 +204,37 @@ def radd(sender, args): return True if len(args) == 3: args += ["true"] - data[str(uid(target))][str(args[1])] = str(args[2]) - save_data(uid(target)) + if not add_alias_data(uid(target), str(args[1]), str(args[2])): + message = colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times" + msg(sender, message) + if args[3].lower() == "false": + msg(target, message) + return True msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) if args[3].lower() == "false": msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) return True +def add_alias_data(puuid, aliased, new_alias): + prior = data[puuid] + + # prevent 2 -> 3 if there is 1 -> 2 + if aliased not in prior: + for alias in prior.values(): + if aliased in alias: + return False + + # prevent 1 -> 2 if there is 2 -> 3 + for sequence in prior: + if sequence in new alias: + return False + + prior[aliased] = new_alias + save_data(puuid) + return True + + def remove(sender, args): plugin_header(sender, "Alias") try: @@ -334,5 +358,3 @@ remotes = { "remove": rremove, "list": rlist_alias, } -Status API Training Shop Blog About -© 2016 GitHub, Inc. Terms Privacy Security Contact Help \ No newline at end of file -- 2.45.2 From 16e78a267766192486b88195bac1ee6c6ea45667 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 16:44:09 +0200 Subject: [PATCH 36/95] Add missing ) to chatalias --- chatalias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatalias.py b/chatalias.py index 7163245..708179c 100644 --- a/chatalias.py +++ b/chatalias.py @@ -180,7 +180,7 @@ def add(sender, args): return True args = [args[0]] + [" ".join(args[1:])] if not add_alias_data(uid(sender), str(args[0]), args[1]): - msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times" + msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times", usecolor = False) return True msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) return True -- 2.45.2 From 1fdf97f77a3c5f1a263fa252802a7840416a7bc5 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 16:46:49 +0200 Subject: [PATCH 37/95] Add missing _ ... lol --- chatalias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatalias.py b/chatalias.py index 708179c..07f132f 100644 --- a/chatalias.py +++ b/chatalias.py @@ -227,7 +227,7 @@ def add_alias_data(puuid, aliased, new_alias): # prevent 1 -> 2 if there is 2 -> 3 for sequence in prior: - if sequence in new alias: + if sequence in new_alias: return False prior[aliased] = new_alias -- 2.45.2 From a532c6b42c2c2629c7772e5538012446047da197 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 18:18:27 +0200 Subject: [PATCH 38/95] Changed broadcast message, removed two debugs --- imbusy.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/imbusy.py b/imbusy.py index 2baefa3..4dc6f59 100644 --- a/imbusy.py +++ b/imbusy.py @@ -53,7 +53,7 @@ def on_busy_command(sender, cmd, label, args): msg(sender, "You cannot be even more focused than this without being a jedi!") else: busy_players.append(sender.getName()) - broadcast(None, "&c[&2Busy&c] &fNow busy: %s&r, don't even TRY bothering them!" % sender.getDisplayName()) + broadcast(None, "&c[&2Busy&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) elif args[0] == "off": try: @@ -144,7 +144,6 @@ class CommandWrapper(Command): self.checker = checker def execute(self, sender, label, args): - info("/" + self.getLabel() + " executed by " + sender.getName()) try: if self.checker(sender, args): return self.wrapped.execute(sender, label, args) @@ -185,7 +184,6 @@ def on_player_command_preprocess(event): def replace_ess_commands(): try: - info("[imbusy] Wrapping ess commands") map_field = server.getPluginManager().getClass().getDeclaredField("commandMap") map_field.setAccessible(True) command_map = map_field.get(server.getPluginManager()) -- 2.45.2 From 00e38efd14eaa3261b1dd66f71157a7f048bd92c Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 18:32:20 +0200 Subject: [PATCH 39/95] Added catcher for /mail send --- imbusy.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/imbusy.py b/imbusy.py index 4dc6f59..225862b 100644 --- a/imbusy.py +++ b/imbusy.py @@ -154,6 +154,7 @@ class CommandWrapper(Command): def tabComplete(self, sender, alias, args): return self.wrapped.tabComplete(sender, alias, args) + def msg_command_checker(sender, args): return len(args) <= 1 or whisper(sender, args[0]) @@ -172,6 +173,15 @@ def tpa_command_checker(sender, args): def tpahere_command_checker(sender, args): return tpa_command_checker(sender, args) +def mail_command_checker(sender, args): + if len(args) < 3 or args[0].lower() != "send": + return True + target = server.getPlayer(args[1]) + if target is not None and target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) + return False + return True + @hook.event("player.PlayerCommandPreprocessEvent", "monitor") def on_player_command_preprocess(event): @@ -196,11 +206,13 @@ def replace_ess_commands(): ess_reply_cmd = map.get("essentials:reply") ess_tpa_cmd = map.get("essentials:tpa") ess_tpahere_cmd = map.get("essentials:tpahere") + ess_mail_cmd = map.get("essentials:mail") msg_cmd_wrapper = CommandWrapper(ess_msg_cmd, msg_command_checker) reply_cmd_wrapper = CommandWrapper(ess_reply_cmd, reply_command_checker) tpa_cmd_wrapper = CommandWrapper(ess_tpa_cmd, tpa_command_checker) tpahere_cmd_wrapper = CommandWrapper(ess_tpahere_cmd, tpahere_command_checker) + mail_cmd_wrapper = CommandWrapper(ess_mail_cmd, mail_command_checker) iterator = map.entrySet().iterator() while iterator.hasNext(): @@ -218,6 +230,9 @@ def replace_ess_commands(): elif value is ess_tpahere_cmd: entry.setValue(tpahere_cmd_wrapper) info("[imbusy] wrapped /" + entry.getKey()) + elif value is ess_mail_cmd: + entry.setValue(mail_cmd_wrapper) + info("[imbusy] wrapped /" + entry.getKey()) except: error("[Imbusy] Failed to wrap essentials commands") -- 2.45.2 From 8629b39ce10242da9d4686f6bb2dcd7c24b53832 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 18:41:42 +0200 Subject: [PATCH 40/95] Make /busy a toggle, move help page to /busy help. Changed a few messages --- imbusy.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/imbusy.py b/imbusy.py index 225862b..1fc9e63 100644 --- a/imbusy.py +++ b/imbusy.py @@ -40,34 +40,44 @@ def on_busy_command(sender, cmd, label, args): noperm(sender) return True + sender_name = sender.getName() + if len(args) == 0: - msg(sender, "This plugin allows being busy, and when turned on you will not receive 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.") + if sender_name in busy_players: + busy_players.remove(sender_name) + msg(sender, "Your busy status was removed, you can be bothered again") + else: + busy_players.append(sender_name) + broadcast(None, "&c[&2Busy&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) elif len(args) == 1: - if args[0] == "on": - if sender.getName() in busy_players: + if args[0].lower() == "on": + if sender_name in busy_players: msg(sender, "You cannot be even more focused than this without being a jedi!") else: - busy_players.append(sender.getName()) + busy_players.append(sender_name) broadcast(None, "&c[&2Busy&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) - elif args[0] == "off": + elif args[0].lower() == "off": try: - busy_players.remove(sender.getName()) - msg(sender, "Master has sent /busy command, %s&r is freeee of bothering!" % sender.getDisplayName()) + busy_players.remove(sender_name) + msg(sender, "Your busy status was removed, you can be bothered again") except ValueError: msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?") - elif args[0] == "status": - if sender.getName() in busy_players: + elif args[0].lower() == "status": + if sender_name in busy_players: msg(sender, "You are super-duper busy and concentrated right now. Think, think, think!") else: msg(sender, "You are completely unable to focus right now.") + elif args[0].lower() in ("?", "help"): + msg(sender, "Let's you put yourself in busy status, preventing pms and tpa requests from other players") + msg(sender, "\nCommands:") + msg(sender, "/busy: toggles busy status") + msg(sender, "/busy on: turns on busy status") + msg(sender, "/busy off: turns off busy status") + msg(sender, "/busy status [player]: shows your or [player]'s current busy status.") else: unclear(sender) return False @@ -75,7 +85,7 @@ def on_busy_command(sender, cmd, label, args): elif len(args) == 2 and args[0] == "status": target = server.getPlayer(args[1]) if target is None: - msg(sender, "That player is not online, I doubt they are busy.") + msg(sender, "That player is not online, they may be busy IRL, we never know") elif target.getName() in busy_players: msg(sender, "Yes, %s&r is busy. Shhh..." % target.getDisplayName()) else: -- 2.45.2 From 28afa1ddcf9d9d43c7cc076e6091b33452bf2b1c Mon Sep 17 00:00:00 2001 From: Dico200 Date: Wed, 25 May 2016 18:54:32 +0200 Subject: [PATCH 41/95] Changed debug output, tweaked [busy] broadcast prefix --- imbusy.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/imbusy.py b/imbusy.py index 1fc9e63..380c920 100644 --- a/imbusy.py +++ b/imbusy.py @@ -48,7 +48,7 @@ def on_busy_command(sender, cmd, label, args): msg(sender, "Your busy status was removed, you can be bothered again") else: busy_players.append(sender_name) - broadcast(None, "&c[&2Busy&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) + broadcast(None, "&c[&fBUSY&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) elif len(args) == 1: if args[0].lower() == "on": @@ -56,7 +56,7 @@ def on_busy_command(sender, cmd, label, args): msg(sender, "You cannot be even more focused than this without being a jedi!") else: busy_players.append(sender_name) - broadcast(None, "&c[&2Busy&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) + broadcast(None, "&c[&fBUSY&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) elif args[0].lower() == "off": try: @@ -184,6 +184,7 @@ def tpahere_command_checker(sender, args): return tpa_command_checker(sender, args) def mail_command_checker(sender, args): + info("Mail command executed") if len(args) < 3 or args[0].lower() != "send": return True target = server.getPlayer(args[1]) @@ -225,24 +226,26 @@ def replace_ess_commands(): mail_cmd_wrapper = CommandWrapper(ess_mail_cmd, mail_command_checker) iterator = map.entrySet().iterator() + wrapped_commands = [] while iterator.hasNext(): entry = iterator.next() value = entry.getValue() + changed = True if value is ess_msg_cmd: entry.setValue(msg_cmd_wrapper) - info("[imbusy] wrapped /" + entry.getKey()) elif value is ess_reply_cmd: entry.setValue(reply_cmd_wrapper) - info("[imbusy] wrapped /" + entry.getKey()) elif value is ess_tpa_cmd: entry.setValue(tpa_cmd_wrapper) - info("[imbusy] wrapped /" + entry.getKey()) elif value is ess_tpahere_cmd: entry.setValue(tpahere_cmd_wrapper) - info("[imbusy] wrapped /" + entry.getKey()) elif value is ess_mail_cmd: entry.setValue(mail_cmd_wrapper) - info("[imbusy] wrapped /" + entry.getKey()) + else: + changed = False + if changed: + wrapped_commands.append(entry.getKey()) + info("[imbusy] wrapped commands: /" + ", /".join(wrapped_commands)) except: error("[Imbusy] Failed to wrap essentials commands") -- 2.45.2 From 89e3982a299d94173704784438ac9393ebd6acaf Mon Sep 17 00:00:00 2001 From: Dico200 Date: Thu, 26 May 2016 04:37:47 +0200 Subject: [PATCH 42/95] Implement some of pizza's changes from imbusy branch --- imbusy.py | 186 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 106 insertions(+), 80 deletions(-) diff --git a/imbusy.py b/imbusy.py index 380c920..2df0a03 100644 --- a/imbusy.py +++ b/imbusy.py @@ -1,99 +1,126 @@ -# 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. +################################## +# I'M BUSY! Plugin by Curs3d # +# Concept by CookieManors :D # +################################## +# 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 import org.bukkit.command.Command as Command -from traceback import format_exc as trace + +imbusy_version = "v1.1.0" + +base_permission = "utils.busy" # for /busy status +use_permission = "utils.busy.use" # for being busy +override_permission = "utils.busy.override" # for being able to bother busy people + busy_players = [] -def unclear(sender): - msg(sender, "Umm, what? Sorry, directions unclear, got head stuck in washing machine") - - -@hook.command("busy", - aliases = ["focus"], - usage = "/ ", - description = "Sets busy mode on, you cannot recieve tpas and MSGs" +@hook.command("imbusy", + aliases = ["busy"], + usage = "/ [on, off, status/check]", + description = "Offers control over your busy status" ) def on_busy_command(sender, cmd, label, args): - if not is_player(sender): - msg(sender, "Sorry, Console cannot be busy") - return True + msg(sender, "&7Sorry, Console cannot be busy") + return True plugin_header(recipient = sender, name = "I'M BUSY!") - if not sender.hasPermission("utils.busy.allowed"): + #args = array_to_list(args) + if not sender.hasPermission(base_permission): noperm(sender) return True - sender_name = sender.getName() - if len(args) == 0: - if sender_name in busy_players: - busy_players.remove(sender_name) - msg(sender, "Your busy status was removed, you can be bothered again") - else: - busy_players.append(sender_name) - broadcast(None, "&c[&fBUSY&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) + return toggle(sender) - elif len(args) == 1: - if args[0].lower() == "on": - if sender_name in busy_players: - msg(sender, "You cannot be even more focused than this without being a jedi!") - else: - busy_players.append(sender_name) - broadcast(None, "&c[&fBUSY&c] %s&r is now busy, don't even TRY bothering them!" % sender.getDisplayName()) + arg0 = args[0].lower() + if arg0 == "on": + return on(sender) + if arg0 == "off": + return off(sender) + if arg0 in ("status", "check"): + return status(sender, args[1:]) + return help(sender) - elif args[0].lower() == "off": - try: - busy_players.remove(sender_name) - msg(sender, "Your busy status was removed, you can be bothered again") - except ValueError: - msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?") - - elif args[0].lower() == "status": - if sender_name in busy_players: - msg(sender, "You are super-duper busy and concentrated right now. Think, think, think!") - else: - msg(sender, "You are completely unable to focus right now.") - - elif args[0].lower() in ("?", "help"): - msg(sender, "Let's you put yourself in busy status, preventing pms and tpa requests from other players") - msg(sender, "\nCommands:") - msg(sender, "/busy: toggles busy status") - msg(sender, "/busy on: turns on busy status") - msg(sender, "/busy off: turns off busy status") - msg(sender, "/busy status [player]: shows your or [player]'s current busy status.") - else: - unclear(sender) - return False - - elif len(args) == 2 and args[0] == "status": - target = server.getPlayer(args[1]) - if target is None: - msg(sender, "That player is not online, they may be busy IRL, we never know") - elif target.getName() in busy_players: - msg(sender, "Yes, %s&r is busy. Shhh..." % target.getDisplayName()) - else: - msg(sender, "No, you're good. Feel free to chat with %s&r!" % target.getDisplayName()) +def toggle(sender): + if not sender.hasPermission(use_permission): + noperm(sender) + return True + sender_name = sender.getName() + if sender_name in busy_players: + busy_players.remove(sender_name) + broadcast(None, colorify(sender.getDisplayName() + " &7is no longer busy...")) else: - unclear(sender) - return False + busy_players.append(sender_name) + broadcast(None, colorify(sender.getDisplayName() + " &7is now busy...")) + return True + + +def help(sender): + msg(sender, "Let's you put yourself in busy status, preventing pms and tpa requests from other players") + msg(sender, "\n&eCommands:") + msg(sender, "&e/busy &7- Toggles busy status") + msg(sender, "&e/busy on &7- Turns on busy status") + msg(sender, "&e/busy off &7- Turns off busy status") + msg(sender, "&e/busy status [player] &7- shows your or [player]'s current busy status") + return True + + +def on(sender): + if not sender.hasPermission(use_permission): + noperm(sender) + return True + sender_name = sender.getName() + if sender_name in busy_players: + msg(sender, "&7You are already busy!") + return True + busy_players.append(sender_name) + broadcast(None, colorify(sender.getDisplayName() + " &7is now busy...")) + return True + + +def off(sender): + if not sender.hasPermission(use_permission): + noperm(sender) + return True + sender_name = sender.getName() + if sender_name not in busy_players: + msg(sender, "&7You are not busy! You cannot be even less busy! Are you perhaps bored?") + return True + busy_players.remove(sender_name) + broadcast(None, colorify(sender.getDisplayName() + " &7is no longer busy...")) + return True + + +def status(sender, args): + if not sender.hasPermission(base_permission): + noperm(sender) + return True + if len(args) == 0: + if sender.getName() in busy_players: + msg(sender, "&7You are currently busy.") + else: + msg(sender, "&7You are currently not busy.") + else: + target = server.getPlayer(args[0]) + if target is None: + msg(sender, "&7That player is not online") + elif target.getName() in busy_players: + msg(sender, "&7Player &e" + args[0] + " &7is currently busy.") + else: + msg(sender, "&7Player &e" + args[0] + " &7is currently not busy.") return True @@ -109,14 +136,13 @@ def on_player_leave(event): reply_targets = {} -override_perm = "utils.imbusy.override" def whisper(sender, target_name): target = server.getPlayer(target_name) if target is not None: - if target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + if target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False @@ -132,7 +158,7 @@ def reply(sender): if sender.getName() in reply_targets: target = server.getPlayer(reply_targets[sender.getName()]) if target is not None: - if target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + if target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False @@ -175,7 +201,7 @@ def tpa_command_checker(sender, args): if len(args) == 0: return True target = server.getPlayer(args[0]) - if target is not None and target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + if target is not None and target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False return True @@ -188,7 +214,7 @@ def mail_command_checker(sender, args): if len(args) < 3 or args[0].lower() != "send": return True target = server.getPlayer(args[1]) - if target is not None and target is not sender and not sender.hasPermission(override_perm) and target.getName() in busy_players: + if target is not None and target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False return True -- 2.45.2 From 3859ad8e4065730458e990eabb9ae8d0fa14799a Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sat, 28 May 2016 21:43:59 +0200 Subject: [PATCH 43/95] Fix error on player quit for player.py --- player.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/player.py b/player.py index 0f4a47f..b1a2ddd 100644 --- a/player.py +++ b/player.py @@ -25,5 +25,6 @@ def on_join(event): @hook.event("player.PlayerQuitEvent","highest") def on_leave(event): - py_players.remove(get_py_player(event.getPlayer())) - + player = get_py_player(event.getPlayer()) + if player in py_players: + py_players.remove(player) -- 2.45.2 From 7a905643eb772fd15c9fbd92942655c66b8dff0d Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sat, 28 May 2016 22:18:27 +0200 Subject: [PATCH 44/95] Enabled friends module, added friends check in imbusy, fixed small mistakes --- friends.py | 4 +++ imbusy.py | 74 ++++++++++++++++++++++++++++++++++++++---------------- main.py | 2 ++ 3 files changed, 58 insertions(+), 22 deletions(-) diff --git a/friends.py b/friends.py index 870560e..130954a 100644 --- a/friends.py +++ b/friends.py @@ -5,6 +5,10 @@ friends = open_json_file("friends", {}) # {Player_UUID:[List_of_friend friend_join_sound = "random.orb" +def is_friend_of(player, other): + lst = friends.get(uid(player)) + return lst is not None and uid(other) in lst + @hook.event("player.PlayerJoinEvent", "high") # creates sound and sends a bold message on friend join def fjm(event): # friend join message diff --git a/imbusy.py b/imbusy.py index 2df0a03..c56ee69 100644 --- a/imbusy.py +++ b/imbusy.py @@ -12,6 +12,7 @@ ################################## from helpers import * +from friends import is_friend_of import org.bukkit.command.Command as Command imbusy_version = "v1.1.0" @@ -21,7 +22,7 @@ use_permission = "utils.busy.use" # for being busy override_permission = "utils.busy.override" # for being able to bother busy people -busy_players = [] +busy_players = {} # name : false/true where false is normal busy and true is super busy @hook.command("imbusy", @@ -51,6 +52,8 @@ def on_busy_command(sender, cmd, label, args): return off(sender) if arg0 in ("status", "check"): return status(sender, args[1:]) + if arg0 == "super": + return super_cmd(sender) return help(sender) @@ -60,11 +63,11 @@ def toggle(sender): return True sender_name = sender.getName() if sender_name in busy_players: - busy_players.remove(sender_name) - broadcast(None, colorify(sender.getDisplayName() + " &7is no longer busy...")) + del busy_players[sender_name] + broadcast(None, sender.getDisplayName() + " &7is no longer busy...") else: busy_players.append(sender_name) - broadcast(None, colorify(sender.getDisplayName() + " &7is now busy...")) + broadcast(None, sender.getDisplayName() + " &7is now busy...") return True @@ -75,6 +78,7 @@ def help(sender): msg(sender, "&e/busy on &7- Turns on busy status") msg(sender, "&e/busy off &7- Turns off busy status") msg(sender, "&e/busy status [player] &7- shows your or [player]'s current busy status") + msg(sender, "&e/busy super &7- sets your status to SUPER busy such that even friends can not bother you") return True @@ -83,11 +87,11 @@ def on(sender): noperm(sender) return True sender_name = sender.getName() - if sender_name in busy_players: + if busy_players.get(sender_name) is False: # can be None, False or True msg(sender, "&7You are already busy!") - return True - busy_players.append(sender_name) - broadcast(None, colorify(sender.getDisplayName() + " &7is now busy...")) + else: + busy_players[sender_name] = False # busy but not super busy + broadcast(None, sender.getDisplayName() + " &7is now busy...") return True @@ -99,8 +103,8 @@ def off(sender): if sender_name not in busy_players: msg(sender, "&7You are not busy! You cannot be even less busy! Are you perhaps bored?") return True - busy_players.remove(sender_name) - broadcast(None, colorify(sender.getDisplayName() + " &7is no longer busy...")) + del busy_players[sender_name] + broadcast(None, sender.getDisplayName() + " &7is no longer busy...") return True @@ -110,7 +114,10 @@ def status(sender, args): return True if len(args) == 0: if sender.getName() in busy_players: - msg(sender, "&7You are currently busy.") + if busy_players[sender_name] is False: + msg(sender, "&7You are currently busy.") + else: + msg(sender, "&7You are currently SUPER busy.") else: msg(sender, "&7You are currently not busy.") else: @@ -118,18 +125,33 @@ def status(sender, args): if target is None: msg(sender, "&7That player is not online") elif target.getName() in busy_players: - msg(sender, "&7Player &e" + args[0] + " &7is currently busy.") + if busy_players[target.getName()] is False: + msg(sender, "&7Player %s &7is currently busy." % target.getDisplayName()) + else: + msg(sender, "&7Player %s &7is currently SUPER busy." % target.getDisplayName()) else: - msg(sender, "&7Player &e" + args[0] + " &7is currently not busy.") + msg(sender, "&7Player %s &7is currently not busy." % target.getDisplayName()) + return True + + +def super_cmd(sender): + if not sender.hasPermission(use_permission): + noperm(sender) + return True + sender_name = sender.getName() + if busy_players.get(sender_name) is True: + msg(sender, "&7You are already SUPER busy!") + else: + busy_players[sender_name] = True # SUPER busy + broadcast(None, sender.getDisplayName() + " &7is now SUPER busy...") return True @hook.event("player.PlayerQuitEvent", "lowest") def on_player_leave(event): - try: - busy_players.remove(event.getPlayer().getName()) - except: - pass + player_name = event.getPlayer().getName() + if player_name in busy_players: + del busy_players[player_name] #---- Dicode for catching any bothering of busy people ---- @@ -138,11 +160,19 @@ def on_player_leave(event): reply_targets = {} +def can_send(sender, target): + if not target.getName() in busy_players: + return True + if target is sender or sender.hasPermission(override_permission): + return True + return busy_players[target.getName()] is False and is_friend_of(target, sender) + + def whisper(sender, target_name): target = server.getPlayer(target_name) if target is not None: - if target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: + if not can_send(sender, target): msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False @@ -158,7 +188,7 @@ def reply(sender): if sender.getName() in reply_targets: target = server.getPlayer(reply_targets[sender.getName()]) if target is not None: - if target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: + if not can_send(sender, target): msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False @@ -181,7 +211,7 @@ class CommandWrapper(Command): def execute(self, sender, label, args): try: - if self.checker(sender, args): + if not is_player(sender) or self.checker(sender, args): return self.wrapped.execute(sender, label, args) except: error(trace()) @@ -201,7 +231,7 @@ def tpa_command_checker(sender, args): if len(args) == 0: return True target = server.getPlayer(args[0]) - if target is not None and target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: + if target is not None and not can_send(sender, target): msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False return True @@ -214,7 +244,7 @@ def mail_command_checker(sender, args): if len(args) < 3 or args[0].lower() != "send": return True target = server.getPlayer(args[1]) - if target is not None and target is not sender and not sender.hasPermission(override_permission) and target.getName() in busy_players: + if target is not None and not can_send(sender, target): msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False return True diff --git a/main.py b/main.py index 651a547..64405eb 100644 --- a/main.py +++ b/main.py @@ -44,6 +44,8 @@ shared["load_modules"] = [ "calc", # Adds aliasing of chat words "chatalias", + # For players to point friends + "friends", # Plugin to locate laggy chunks. /lc lists chunks with more than n entities "lagchunks", # Adds /report and /rp, Stores reports with time and location -- 2.45.2 From 28ac05ce0ae43b4598a01cbacbb7ee13f32b350a Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sat, 28 May 2016 22:22:51 +0200 Subject: [PATCH 45/95] Tweak imbusy permission nodes --- imbusy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imbusy.py b/imbusy.py index c56ee69..5382f32 100644 --- a/imbusy.py +++ b/imbusy.py @@ -17,9 +17,9 @@ import org.bukkit.command.Command as Command imbusy_version = "v1.1.0" -base_permission = "utils.busy" # for /busy status -use_permission = "utils.busy.use" # for being busy -override_permission = "utils.busy.override" # for being able to bother busy people +base_permission = "utils.imbusy" # for /busy status +use_permission = "utils.imbusy.use" # for being busy +override_permission = "utils.imbusy.override" # for being able to bother busy people busy_players = {} # name : false/true where false is normal busy and true is super busy -- 2.45.2 From a19f0b5bdc5b05496b2d70c78f891fbc7cc7711e Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 28 May 2016 22:33:38 +0200 Subject: [PATCH 46/95] Added support for /rl; Made comments more precise --- chatalias.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chatalias.py b/chatalias.py index 07f132f..7295cca 100644 --- a/chatalias.py +++ b/chatalias.py @@ -55,11 +55,18 @@ permission_FINFO = "utils.alias.finfo" # CODE # ######## -# OnEnable +# OnModuleLoad enabled = helpers_version in helpers_versions if not enabled: error = colorify("&6Incompatible versions detected (&chelpers.py&6)") - +for player in Server.getOnlinePlayers(): + if enabled: + t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) + t.daemon = True + t.start() + else: + if event.getPlayer().hasPermission(permission_FINFO): + disabled_fallback(event.getPlayer()) def safe_open_json(uuid): if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"): -- 2.45.2 From 7da3fd5b717c9bb73576802a8b1e73ac40e8214f Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 28 May 2016 22:35:28 +0200 Subject: [PATCH 47/95] That's an "s", not an "S" ._. --- chatalias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chatalias.py b/chatalias.py index 7295cca..1069ef3 100644 --- a/chatalias.py +++ b/chatalias.py @@ -59,7 +59,7 @@ permission_FINFO = "utils.alias.finfo" enabled = helpers_version in helpers_versions if not enabled: error = colorify("&6Incompatible versions detected (&chelpers.py&6)") -for player in Server.getOnlinePlayers(): +for player in server.getOnlinePlayers(): if enabled: t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) t.daemon = True -- 2.45.2 From c534d9316a06ed732ff1f3d0daca19dd693b1761 Mon Sep 17 00:00:00 2001 From: Pepich Date: Sat, 28 May 2016 22:40:08 +0200 Subject: [PATCH 48/95] Moved OnModuleLoad to bottom of file --- chatalias.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/chatalias.py b/chatalias.py index 1069ef3..cb7d80c 100644 --- a/chatalias.py +++ b/chatalias.py @@ -55,19 +55,6 @@ permission_FINFO = "utils.alias.finfo" # CODE # ######## -# OnModuleLoad -enabled = helpers_version in helpers_versions -if not enabled: - error = colorify("&6Incompatible versions detected (&chelpers.py&6)") -for player in server.getOnlinePlayers(): - if enabled: - t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) - t.daemon = True - t.start() - else: - if event.getPlayer().hasPermission(permission_FINFO): - disabled_fallback(event.getPlayer()) - def safe_open_json(uuid): if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"): os.makedirs("plugins/redstoner-utils.py.dir/files/aliases") @@ -365,3 +352,17 @@ remotes = { "remove": rremove, "list": rlist_alias, } + +# OnModuleLoad + +enabled = helpers_version in helpers_versions +if not enabled: + error = colorify("&6Incompatible versions detected (&chelpers.py&6)") +for player in server.getOnlinePlayers(): + if enabled: + t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) + t.daemon = True + t.start() + else: + if event.getPlayer().hasPermission(permission_FINFO): + disabled_fallback(event.getPlayer()) -- 2.45.2 From c3189639f09723500f6597917369e601a44c68cb Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sat, 28 May 2016 23:05:43 +0200 Subject: [PATCH 49/95] Fixes and stuff --- chatalias.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/chatalias.py b/chatalias.py index cb7d80c..449a68f 100644 --- a/chatalias.py +++ b/chatalias.py @@ -191,6 +191,8 @@ def radd(sender, args): if args[3].lower() == "false": plugin_header(target, "Alias") msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") + elif args[3].lower() != "true": + args[2] += " " + args[3] if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(target, permission_AMOUNT)): msg(sender, "&cCould not create alias: Max_limit reached!") if args[3].lower() == "false": @@ -274,7 +276,7 @@ def rlist_alias(sender, args): plugin_header(sender, "Alias") target = get_player(args[0]) if is_player(sender): - sender_name = colorify(sender.getDisplayName) + sender_name = colorify(sender.getDisplayName()) else: sender_name = colorify("&6Console") if len(args) == 1: @@ -282,11 +284,9 @@ def rlist_alias(sender, args): msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):") if args[1].lower() == "false": plugin_header(target, "Alias") - msg(target, "&cPlayer " + sender_name + " &cis listing your aliases (" + str(len(data[uid(target)])) + " in total):") + msg(target, "&cPlayer " + sender_name + " &cis listing your aliases") for word, alias in data[str(uid(target))].items(): msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) - if args[1].lower() == "false": - msg(target, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) return True @@ -341,15 +341,21 @@ def save_data_thread(uuid): # Subcommands: subcommands = { "help": help, + "?": help, "add": add, "remove": remove, + "del": remove, + "delete": remove, "player": remote, + "remote": remote, "list": list_alias } remotes = { "add": radd, "remove": rremove, + "del": rremove, + "delete": rremove, "list": rlist_alias, } @@ -360,9 +366,9 @@ if not enabled: error = colorify("&6Incompatible versions detected (&chelpers.py&6)") for player in server.getOnlinePlayers(): if enabled: - t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) + t = threading.Thread(target=load_data, args=(uid(player), )) t.daemon = True t.start() else: - if event.getPlayer().hasPermission(permission_FINFO): - disabled_fallback(event.getPlayer()) + if player.hasPermission(permission_FINFO): + disabled_fallback(player) -- 2.45.2 From e35fadc353f764a22d1d2c4b29463c81d091b36b Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 29 May 2016 20:55:10 +0200 Subject: [PATCH 50/95] Added/fixed torch breaker setting. Added a few missing saveSettings() calls. Fixed /set on turning it off and vice-versa for boolean settings that are enabled by default. A few more tweaks. --- blockplacemods.py | 165 ++++++++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 72 deletions(-) diff --git a/blockplacemods.py b/blockplacemods.py index 8d18699..d012e54 100644 --- a/blockplacemods.py +++ b/blockplacemods.py @@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack as ItemStack import org.bukkit.Material as Material import org.bukkit.event.block.Action as Action import org.bukkit.block.BlockFace as BlockFace -import org.bukkit.scheduler.BukkitRunnable as Runnable +import org.bukkit.scheduler.BukkitRunnable as BukkitRunnable """ # Permissions: @@ -38,11 +38,11 @@ settingInformation = dict( #[setting type, identifying description, detailed des "Sets your preferred default furnace contents to your currently held itemstack. Use an empty hand to empty a slot, or /toggle furnace clear to clear all slots.", ["cooker", "fillf"], 2 ], - #torch = [0, - # "removal of torches you place on redstone blocks", - # "Toggles whether redstone torches which you place on redstone blocks will be deleted after a short amount of delay.", - # ["redstonetorch", "tor"] - #], + torch = [0, + "removal of torches you place on redstone blocks", + "Toggles whether redstone torches which you place on redstone blocks will be deleted after a short amount of delay.", + ["redstonetorch", "tor"] + ], piston = [2, "rotating pistons, droppers and hoppers to face the block you place them against", "Toggles whether pistons or sticky pistons which you place will be rotated to face the block which you placed them against.", @@ -66,7 +66,7 @@ defaults = { 2: list } -faces = { +piston_faces = { BlockFace.DOWN : 0, BlockFace.UP : 1, BlockFace.NORTH : 2, @@ -75,6 +75,14 @@ faces = { BlockFace.EAST : 5 } +torch_faces = { + 1: BlockFace.WEST, + 2: BlockFace.EAST, + 3: BlockFace.NORTH, + 4: BlockFace.SOUTH, + 5: BlockFace.DOWN +} + playerSettings = open_json_file("blockplacemods", {}) for setting, details in settingInformation.iteritems(): @@ -128,14 +136,14 @@ def toggle_command(sender, command, label, args): elif arg2 in ("toggle", "switch"): new = not enabled elif arg2 in ("on", "enable"): - new = not default + new = True elif arg2 in ("off", "disable"): - new = default + new = False else: return " &cArgument '%s' was not recognized. \n Use &o/toggle %s info &cfor more information" % (arg2, setting) - if enabled == new: + if enabled is new: return " &cAlready %s: &a%s" % ("enabled" if enabled else "disabled", details[1]) - if new == default: + if new is default: values.remove(uuid) else: values.append(uuid) @@ -150,10 +158,11 @@ def toggle_command(sender, command, label, args): if arg2 == "clear": if enabled: del values[uuid] + saveSettings() return " &aDisabled " + details[1] return " &cAlready disabled: " + details[1] - if arg2 == "details": + if arg2 == "info": return " &aSetting %s:\n &9%s \n&6Accepted arguments: [|clear|details]" % (setting, details[2]) slot = int(arg2) if arg2.isdigit() else 0 @@ -166,10 +175,11 @@ def toggle_command(sender, command, label, args): items = values[uuid] if slot in items: del items[slot] - saveSettings() if len(items) == 0: del items + saveSettings() return " &aDisabled " + details[1] + saveSettings() return " &aCleared slot %s of setting %s" % (slot, setting) return " &cSlot %s of setting %s was already cleared!" % (slot, setting) return " &cAlready disabled: " + details[1] @@ -198,59 +208,63 @@ def isEnabled(toggleSetting, uuid): @hook.event("block.BlockPlaceEvent", "monitor") def on_block_place(event): - if event.isCancelled(): - return - player = event.getPlayer() - if not is_creative(player): - return + try: - uuid = uid(player) - block = event.getBlockPlaced() - material = block.getType() + if event.isCancelled(): + return + player = event.getPlayer() + if not is_creative(player): + return + + uuid = uid(player) + block = event.getBlockPlaced() + material = block.getType() - if (material in (Material.WOOD_STEP, Material.STEP) - and isEnabled("slab", uuid) - and player.hasPermission("utils.toggle.slab") - and block.getData() < 8 - ): - block.setData(block.getData() + 8) # Flip upside down + if (material in (Material.WOOD_STEP, Material.STEP) + and isEnabled("slab", uuid) + and player.hasPermission("utils.toggle.slab") + and block.getData() < 8 + ): + block.setData(block.getData() + 8) # Flip upside down - elif (material == Material.CAULDRON - and isEnabled("cauldron", uuid) - and player.hasPermission("utils.toggle.cauldron") - ): - block.setData(3) #3 layers of water, 3 signal strength + elif (material == Material.CAULDRON + and isEnabled("cauldron", uuid) + and player.hasPermission("utils.toggle.cauldron") + ): + block.setData(3) #3 layers of water, 3 signal strength - elif ((material == Material.FURNACE and player.hasPermission("utils.toggle.furnace")) - or (material == Material.DROPPER and player.hasPermission("utils.toggle.dropper")) - or (material == Material.HOPPER and player.hasPermission("utils.toggle.hopper")) - ): - stacks = get(str(material).lower()).get(uuid) - if stacks != None: # Enabled - state = block.getState() - inv = state.getInventory() - for slot, stack in stacks.iteritems(): - inv.setItem(int(slot), toStack(stack)) - state.update() - - """ - elif (material == Material.REDSTONE_TORCH_ON - and event.getBlockAgainst().getType() == Material.REDSTONE_BLOCK - and isEnabled("torch", uuid) - and player.hasPermission("utils.toggle.torch") - ): - torches_to_break.append(block) - """ + elif ((material == Material.FURNACE and player.hasPermission("utils.toggle.furnace")) + or (material == Material.DROPPER and player.hasPermission("utils.toggle.dropper")) + or (material == Material.HOPPER and player.hasPermission("utils.toggle.hopper")) + ): + stacks = get(str(material).lower()).get(uuid) + if stacks != None: # Enabled + state = block.getState() + inv = state.getInventory() + for slot, stack in stacks.iteritems(): + inv.setItem(int(slot), toStack(stack)) + state.update() - if (material in (Material.PISTON_BASE, Material.PISTON_STICKY_BASE) - and isEnabled("piston", uuid) - and player.hasPermission("utils.toggle.piston") - ): - block.setData(faces[block.getFace(event.getBlockAgainst())]) + elif (material == Material.REDSTONE_TORCH_ON + and isEnabled("torch", uuid) + and player.hasPermission("utils.toggle.torch") + and block.getData() in torch_faces + and block.getRelative(torch_faces[block.getData()]).getType() is Material.REDSTONE_BLOCK + ): + torches_to_break.append(block) + + + elif (material in (Material.PISTON_BASE, Material.PISTON_STICKY_BASE) + and isEnabled("piston", uuid) + and player.hasPermission("utils.toggle.piston") + ): + block.setData(piston_faces[block.getFace(event.getBlockAgainst())]) + except: + error(trace()) @hook.event("player.PlayerInteractEvent", "monitor") @@ -269,29 +283,36 @@ def on_interact(event): if not event2.isCancelled(): block.setData(block.getData() - 1 if block.getData() > 0 else 3) -""" + break_torches = True torches_to_break = deque() def stop_breaking_torches(): break_torches = False - info("Interrupted torch breaking thread") + info("[BlockPlaceMods] Interrupted torch breaking thread") -class torch_breaker(Runnable): +class JBukkitRunnable(BukkitRunnable): - def run(): + def __init__(self, func): + self.run = func - try: - if break_torches: - for i in range(len(torches_to_break)): - block = torches_to_break.popleft() - mat = block.getType() - if mat == Material.REDSTONE_TORCH_OFF: - block.setTypeId(0) - elif mat == Material.REDSTONE_TORCH_ON: + +def torch_breaker(): + + try: + if break_torches: + for i in range(len(torches_to_break)): + block = torches_to_break.popleft() + mat = block.getType() + if mat == Material.REDSTONE_TORCH_OFF: + block.setTypeId(0) + elif mat == Material.REDSTONE_TORCH_ON: + if block.getData() in torch_faces and block.getRelative(torch_faces[block.getData()]).getType() is Material.REDSTONE_BLOCK: torches_to_break.append(block) - except: - error(trace()) -""" + except: + error(trace()) + +def schedule_torch_breaker(): + JBukkitRunnable(torch_breaker).runTaskTimer(server.getPluginManager().getPlugin("RedstonerUtils"), 0, 1) -- 2.45.2 From 5a757b7fb10a959c245d29b3eaddd69325f1ba55 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 29 May 2016 20:56:29 +0200 Subject: [PATCH 51/95] Removed @hook.enable decs from modules, added them to the on_enable() method of main.py. --- imbusy.py | 1 - main.py | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/imbusy.py b/imbusy.py index 5382f32..05049c5 100644 --- a/imbusy.py +++ b/imbusy.py @@ -257,7 +257,6 @@ def on_player_command_preprocess(event): event.setCancelled(True) -@hook.enable def replace_ess_commands(): try: diff --git a/main.py b/main.py index 64405eb..fba0c5a 100644 --- a/main.py +++ b/main.py @@ -19,12 +19,17 @@ except: @hook.enable def on_enable(): + if "blockplacemods" in shared["modules"]: + shared["modules"]["blockplacemods"].schedule_torch_breaker() + if "imbusy" in shared["modules"]: + shared["modules"]["imbusy"].replace_ess_commands() info("RedstonerUtils enabled!") @hook.disable def on_disable(): - shared["modules"]["reports"].stop_reporting() + if "reports" in shared["modules"]: + shared["modules"]["reports"].stop_reporting() info("RedstonerUtils disabled!") -- 2.45.2 From 8e4f30a017650fc103ccf580aba37986728abd64 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 29 May 2016 21:08:28 +0200 Subject: [PATCH 52/95] Changed command blacklist to a whitelist. Added /svs commands to show whitelisted commands. Added a few more command aliases. Added maximum line count and maximum line size. --- serversigns.py | 61 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/serversigns.py b/serversigns.py index d9f2a44..d5a4829 100644 --- a/serversigns.py +++ b/serversigns.py @@ -5,7 +5,23 @@ import java.util.UUID as UUID import org.bukkit.Material as Material import org.bukkit.block.BlockFace as BlockFace -blocked_cmds = tuple(shared["modules"]["misc"].sudo_blacklist) + ("pex", "kick", "ban", "tempban", "reload", "op", "deop", "whitelist") +commands_whitelist = ( + "mail", "email", "memo", + "echo", "ping", + "cg join", + "cg info", + "chatgroup join", + "chatgroup info", + "i", + "item", + "p h", "plot home", "plot h", "p home", "plotme home", "plotme h", + "up", + "tppos", + "seen" +) + +max_line_length = 256 +max_lines = 20 def load_signs(): signs_obj = open_json_file("serversigns", []) @@ -20,9 +36,11 @@ def save_signs(): signs_obj.append(key + tuple(value)) save_json_file("serversigns", signs_obj) -signs = load_signs() # {("world", x, y, z): ["owner_id", "msg1", "msg2"]} +# {("world", x, y, z): ["owner_id", "msg1", "msg2"]} +signs = load_signs() -lines = {} # Accumulated messages so players can have longer messages: {"Dico200": "Message...........", ""} +# Accumulated messages so players can have longer messages: {"Dico200": "Message...........", ""} +lines = {} def fromLoc(bLoc): """ @@ -92,7 +110,8 @@ def signsMsg(msg, colour = '4'): senderLimit = 0) def svs_command(sender, command, label, args): arg1 = args[0].lower() - Validate.isTrue(arg1 in ("claim", "reset", "add", "remove", "info", "clear", "help", "switch", "reverse", "unclaim"), + Validate.isTrue(arg1 in ("claim", "reset", "add", "remove", "rem", "del", "delete", "info", "lines", + "clear", "help", "switch", "reverse", "unclaim", "commands", "whitelist", "wl"), signsMsg("That argument could not be recognized, use &o/svs help &4for expected arguments")) Validate.isAuthorized(sender, "utils.serversigns." + arg1) @@ -105,7 +124,7 @@ def svs_command(sender, command, label, args): msg += "\nHow to use &b/serversigns&a:" msg += "\n&b/svs claim" + ("" if not sender.hasPermission("utils.serversigns.admin") else " [owner]") msg += "\n&a- Claims the sign so that you can add messages to it" - msg += "\n&b/svs info" + msg += "\n&b/svs info|lines" msg += "\n&a- Displays information about the (claimed) sign" msg += "\n&b/svs add [++]" msg += "\n&a- Adds the message to the sign. Use ++ at the end" @@ -120,7 +139,12 @@ def svs_command(sender, command, label, args): msg += "\n&a- Removes all messages from the sign." msg += "\n&b/svs reset|unclaim" msg += "\n&a- Resets the sign, removing all messages and its owner." + msg += "\n&b/svs commands|whitelist|wl" + msg += "\n&a- Shows a list of whitelisted commands" return msg + + if arg1 in ("commands", "whitelist", "wl"): + return signsMsg("Whitelisted commands: &3" + ", ".join(commands_whitelist), 'a') #------------------------------------------------------------------------------------------- block = sender.getTargetBlock(None, 5) @@ -144,7 +168,7 @@ def svs_command(sender, command, label, args): uuid = uid(target) if sign != None: if sign[0] == uuid: - return signsMsg("The" + signName + " was already owned by that player") + return signsMsg("The " + signName + " was already owned by that player") else: sign[0] = uuid else: @@ -156,7 +180,7 @@ def svs_command(sender, command, label, args): Validate.notNone(sign, signsMsg("The %s has not been claimed" % signName)) #----------------------Sub commands that require the sign to be claimed as well------------------------------------ - if arg1 == "info": + if arg1 in ("info", "lines"): sign_lines = "" for id, line in enumerate(sign[1:]): sign_lines += ("\n &a%s: \"&f%s&a\"" % (id + 1, line)) @@ -167,25 +191,43 @@ def svs_command(sender, command, label, args): #---------------------- Sub commands that require you to own targeted sign as well ------------------------- if arg1 == "add": + Validate.isTrue(len(sign) - 1 <= max_lines, signsMsg("This sign already has the maximum amount of lines, you cannot add more")) + line = " ".join(args[1:]) Validate.isTrue(line != "" and line != None, signsMsg("You have to enter a message to add or accumulate")) key = sender.getName() global lines Validate.isTrue(key in lines or line[:1] != "/" or sender.hasPermission("utils.serversigns.command"), signsMsg("You cannot add commands to a sign!")) + if line[-2:] == "++": if key not in lines: lines[key] = "" + Validate.isTrue(len(lines[key]) + len(line[:-2]) + 1 <= max_line_length, signsMsg("This line would be too long, so the given message was not added to the accumulated message")) lines[key] += " " + line[:-2] return signsMsg("Added given message to the message you're accumulating. \nYour accumulated message is now as follows: \n&f%s" % lines[key], 'a') + if key in lines: line = (lines[key] + " " + line)[1:] - Validate.isTrue(line[0] != "/" or line.split(" ")[0][1:] not in blocked_cmds, signsMsg("Usage of that command with server signs is prohibited")) + Validate.isTrue(len(line) <= max_line_length, signsMsg("This line would be too long, so it was not added to the sign. It is however still accumulated.")) + + if line[0] == "/": + cmd = line[1:].lower() + whitelisted = False + for wl_cmd in commands_whitelist: + if cmd[:len(wl_cmd)] == wl_cmd: + whitelisted = True + break + Validate.isTrue(whitelisted, signsMsg("That command is not whitelisted for use with serversigns")) + + if key in lines: + del lines[key] + sign.append(colorify(line) if line[0] != "/" else line) save_signs() return signsMsg("Added line \"&f%s&a\" to the %s" % (line, signName), 'a') - if arg1 == "remove": + if arg1 in ("remove", "rem", "del", "delete"): Validate.notNone(arg2, signsMsg("You have to enter the ID of the message to remove!")) try: id = int(arg2) @@ -220,6 +262,7 @@ def svs_command(sender, command, label, args): del signs[loc] save_signs() return signsMsg("Removed all messages and the owner from the %s, it can now be claimed" % signName, 'a') + #------------------------------------------------------------------------------------------------------- -- 2.45.2 From a0a7d43a3820b8daeede9b0b85a8a2f5a19c122d Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 29 May 2016 21:29:36 +0200 Subject: [PATCH 53/95] Tweak comment above imbusy, removed credits, removed a useless comment with an old line of code --- imbusy.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/imbusy.py b/imbusy.py index 05049c5..ec6c57b 100644 --- a/imbusy.py +++ b/imbusy.py @@ -1,15 +1,12 @@ -################################## -# I'M BUSY! Plugin by Curs3d # -# Concept by CookieManors :D # -################################## -# 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. # -################################## +""" +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 friends import is_friend_of @@ -37,7 +34,6 @@ def on_busy_command(sender, cmd, label, args): plugin_header(recipient = sender, name = "I'M BUSY!") - #args = array_to_list(args) if not sender.hasPermission(base_permission): noperm(sender) return True -- 2.45.2 From 33d8fd2f08df21052cb2c9a6b30b49baa61305cd Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 29 May 2016 22:18:42 +0200 Subject: [PATCH 54/95] Removed Pan from pythoners, added Pep, added essentials:esudo to sudo_blacklist --- misc.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/misc.py b/misc.py index 0fd4a6a..026650e 100644 --- a/misc.py +++ b/misc.py @@ -127,7 +127,7 @@ def on_interact(event): sudo_blacklist = ["pyeval", "script_backup_begin", "script_backup_end", "script_backup_error", "script_backup_database_begin", "script_backup_database_dumps", "script_backup_database_end", "script_backup_database_error", "script_backup_database_abort", "script_trim", "script_trim_result", "script_spigot_update", "script_disk_filled", "script_restart", "script_restart_abort", -"script_stop", "script_stop_abort", "script_shutdown", "stop", "esudo", "essentials:sudo", "sudo"] +"script_stop", "script_stop_abort", "script_shutdown", "stop", "esudo", "essentials:sudo", "sudo", "essentials:esudo"] @simplecommand("sudo", usage = " [cmd..]", @@ -212,12 +212,12 @@ def eval_thread(sender, code): msg(sender, ">>> %s: %s" % (eclass.__name__, e) + "\n ", False, "c") thread.exit() -pythoners = [ -"e452e012-2c82-456d-853b-3ac8e6b581f5", # Nemes -"ae795aa8-6327-408e-92ab-25c8a59f3ba1", # jomo -"305ccbd7-0589-403e-a45b-d791dcfdee7d", # PanFritz -"51f2ad3c-6cc8-40ea-aa2b-f25970316921" # Dico -] +pythoners = ( + "e452e012-2c82-456d-853b-3ac8e6b581f5", # Nemes + "ae795aa8-6327-408e-92ab-25c8a59f3ba1", # jomo + "d2693e91-93e1-4e3f-929f-f38e1ce8df03", # Pepich1851 + "51f2ad3c-6cc8-40ea-aa2b-f25970316921" # Dico200 +) @simplecommand("pyeval", usage = "[code..]", -- 2.45.2 From 361da9e049ec9b575b2b78eb7b663e6efeff6950 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 29 May 2016 23:49:45 +0200 Subject: [PATCH 55/95] Chatalias: Fixed all the things (permission AMOUNT, permission LENGTH, and more), incremented version number --- chatalias.py | 164 ++++++++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 75 deletions(-) diff --git a/chatalias.py b/chatalias.py index 449a68f..0e2b297 100644 --- a/chatalias.py +++ b/chatalias.py @@ -1,14 +1,4 @@ -############################################ -# Alias v2.0 by Pepich # -# Changes to previous version from curs3d: # -# Dynamic alias limit from permissions # -# AC/CG/MSG support # -# Color support # -# Bugfixes # -# # -# TODO: # -# Add command support... # -############################################ +# TODO: Add cg/ac/msg support import os import mysqlhack @@ -20,15 +10,14 @@ from secrets import * # Version number and requirements -alias_version = "2.0.0" +alias_version = "2.1.0" helpers_versions = ["1.1.0", "2.0.0"] enabled = False -error = colorify("&cUnspecified error") +error_msg = colorify("&cUnspecified error") commands_per_page = 5 global_aliases = {"./":"/"} data = {} -# DON'T SET THIS TO TRUE! MySQL requestst are NOT ASYNC yet! (And for some reason it doesn't want to store any data ._.) -use_mysql = False +use_mysql = True # Permissions: @@ -60,8 +49,8 @@ def safe_open_json(uuid): os.makedirs("plugins/redstoner-utils.py.dir/files/aliases") value = open_json_file("aliases/" + uuid) if value is None: - value = global_aliases - save_json_file("aliases/" + uuid, value) + value = dict(global_aliases) + save_json_file("aliases/" + uuid, value) return value @@ -69,6 +58,9 @@ def safe_open_json(uuid): usage="/ [...]", desc="Allows aliasing of words") def on_alias_command(sender, cmd, label, args): + if not is_player(sender): + msg(sender, "&cThe console cannot use aliases!") + return True try: args = array_to_list(args) if not enabled: @@ -130,24 +122,23 @@ def on_join(event): @hook.event("player.AsyncPlayerChatEvent", "high") def on_player_chat(event): - try: - if enabled: - if event.isCancelled(): + if enabled: + if event.isCancelled(): + return + player = event.getPlayer() + if not hasPerm(player, permission_USE): + return + msg_limit = int(get_permission_content(player, permission_LENGTH)) + for alias, value in data[str(uid(player))].items(): + if player.hasPermission("essentials.chat.color"): + event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) + else: + event.setMessage(event.getMessage().replace(alias, value)) + if not player.hasPermission(permission_ALL) and len(event.getMessage()) > msg_limit: + event.setCancelled(True) + plugin_header(player, "Alias") + msg(player, "The message you wanted to generate would exceed the length limit limit of %d. Please make it shorter!" % msg_limit) return - if not hasPerm(event.getPlayer(), permission_USE): - return - for alias, value in data[str(uid(event.getPlayer()))].items(): - if not event.getPlayer().hasPermission(permission_ALL) and len(event.getMessage()) > int(get_permission_content(event.getPlayer(), permission_LENGTH)): - event.setCanceled(True) - plugin_header(event.getPlayer, "Alias") - msg(event.getPlayer(), "The message you wanted to generate would exceed your limit. Please make it shorter!") - return - if event.getPlayer().hasPermission("essentials.chat.color"): - event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) - else: - event.setMessage(event.getMessage().replace(alias, value)) - except: - print(trace()) def hasPerm(player, permission): @@ -159,7 +150,7 @@ def disabled_fallback(receiver): msg(receiver, colorify("&cUnknown command. Use &e/help&c, &e/plugins &cor ask a mod.")) else: msg(receiver, colorify("&cPlugin alias v" + alias_version + " has experienced an &eEMERGENCY SHUTDOWN:")) - msg(receiver, error) + msg(receiver, error_msg) msg(receiver, colorify("&cPlease contact a dev/admin (especially pep :P) about this to take a look at it.")) @@ -169,11 +160,11 @@ def can_remote(player): def add(sender, args): plugin_header(sender, "Alias") - if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(sender, permission_AMOUNT)): - msg(sender, "&cCould not create alias: Max_limit reached!") - return True + uuid = uid(sender) args = [args[0]] + [" ".join(args[1:])] - if not add_alias_data(uid(sender), str(args[0]), args[1]): + if (args[0] not in data[uuid]) and is_alias_limit_reached(sender, sender): + return True + if not add_alias_data(uuid, str(args[0]), args[1]): msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times", usecolor = False) return True msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) @@ -187,20 +178,21 @@ def radd(sender, args): sender_name = colorify(sender.getDisplayName()) else: sender_name = colorify("&6Console") - target = get_player(args[0]) + target = server.getPlayer(args[0]) + if target == None: + msg(sender, "&cThat player is not online") + return True + uuid = uid(target) if args[3].lower() == "false": plugin_header(target, "Alias") msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") elif args[3].lower() != "true": args[2] += " " + args[3] - if not sender.hasPermission(permission_ALL) and len(data[uid(sender)]) >= int(get_permission_content(target, permission_AMOUNT)): - msg(sender, "&cCould not create alias: Max_limit reached!") - if args[3].lower() == "false": - msg(target, "&cCould not create alias: Max_limit reached!") + if (args[1] not in data[uuid]) and is_alias_limit_reached(target, sender, args[3].lower() == "false"): return True if len(args) == 3: args += ["true"] - if not add_alias_data(uid(target), str(args[1]), str(args[2])): + if not add_alias_data(uuid, str(args[1]), str(args[2])): message = colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times" msg(sender, message) if args[3].lower() == "false": @@ -212,6 +204,19 @@ def radd(sender, args): return True +def is_alias_limit_reached(player, recipient, not_silent = False): + if player.hasPermission(permission_ALL): + return False + alias_limit = int(get_permission_content(player, permission_AMOUNT)) + if len(data[uid(player)]) > alias_limit: + message = ("&cYour limit of %d has been reached" if player is recipient else "&cThe limit of %d has been reached for that player") % alias_limit + msg(recipient, message) + if not_silent: + msg(player, message) + return True + return False + + def add_alias_data(puuid, aliased, new_alias): prior = data[puuid] @@ -298,45 +303,54 @@ def remote(sender, args): def load_data(uuid): - try: - load_data_thread(uuid) -# t = threading.Thread(target=load_data_thread, args=(uuid)) -# t.daemon = True -# t.start() - except: - print(trace()) - -def load_data_thread(uuid): if use_mysql: - conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") - curs = conn.cursor() - curs.execute("SELECT alias FROM alias WHERE uuid = ?", (uuid, )) - results = curs.fetchall() - if len(results) == 0: - results = global_aliases - curs.execute("INSERT INTO alias VALUES (?,?)", (uuid, results, )) - data[uuid] = results + try: + t = threading.Thread(target=load_data_thread, args=(uuid,)) + t.daemon = True + t.start() + except: + error(trace()) else: data[uuid] = safe_open_json(uuid) +def load_data_thread(uuid): + conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") + curs = conn.cursor() + curs.execute("SELECT `alias` FROM `chatalias` WHERE `uuid` = ?;", (uuid, )) + results = curs.fetchall() + if len(results) == 0: + value = dict(global_aliases) + curs.execute("INSERT INTO `chatalias` VALUES (?,?);", (uuid, json_dumps(results), )) + conn.commit() + else: + value = json_loads(results[0][0]) + curs.close() + conn.close() + data[uuid] = value + def save_data(uuid): - try: - save_data_thread(uuid) -# t = threading.Thread(target=save_data_thread, args=(uuid)) -# t.daemon = True -# t.start() - except: - print(trace()) - -def save_data_thread(uuid): if use_mysql: - conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") - curs = conn.cursor() - curs.execute("UPDATE alias SET alias = ? WHERE uuid = ?", (data[uuid], uuid, )) + try: + t = threading.Thread(target=save_data_thread, args=(uuid,)) + t.daemon = True + t.start() + except: + error(trace()) else: save_json_file("aliases/" + uuid, data[uuid]) +def save_data_thread(uuid): + conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") + curs = conn.cursor() + try: + curs.execute("UPDATE `chatalias` SET `alias` = ? WHERE `uuid` = ?;", (json_dumps(data[uuid]), uuid, )) + except: + error(trace()) + conn.commit() + curs.close() + conn.close() + # Subcommands: subcommands = { @@ -363,7 +377,7 @@ remotes = { enabled = helpers_version in helpers_versions if not enabled: - error = colorify("&6Incompatible versions detected (&chelpers.py&6)") + error_msg = colorify("&6Incompatible versions detected (&chelpers.py&6)") for player in server.getOnlinePlayers(): if enabled: t = threading.Thread(target=load_data, args=(uid(player), )) -- 2.45.2 From fe32e7a49cea69678101da332827ca7603a8fe90 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 00:05:49 +0200 Subject: [PATCH 56/95] Cleaned up some of helpers.py --- chatalias.py | 4 +--- helpers.py | 27 ++------------------------- loginsecurity.py | 1 + 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/chatalias.py b/chatalias.py index 0e2b297..bc21e13 100644 --- a/chatalias.py +++ b/chatalias.py @@ -5,8 +5,6 @@ import mysqlhack import org.bukkit as bukkit from org.bukkit import * from helpers import * -from traceback import format_exc as trace -from secrets import * # Version number and requirements @@ -208,7 +206,7 @@ def is_alias_limit_reached(player, recipient, not_silent = False): if player.hasPermission(permission_ALL): return False alias_limit = int(get_permission_content(player, permission_AMOUNT)) - if len(data[uid(player)]) > alias_limit: + if len(data[uid(player)]) >= alias_limit: message = ("&cYour limit of %d has been reached" if player is recipient else "&cThe limit of %d has been reached for that player") % alias_limit msg(recipient, message) if not_silent: diff --git a/helpers.py b/helpers.py index 4c32e24..d6e46bd 100755 --- a/helpers.py +++ b/helpers.py @@ -11,8 +11,6 @@ import org.bukkit.block as bblock import org.bukkit.event.entity as entity import org.bukkit.command.ConsoleCommandSender from org.bukkit.entity import * -from player import get_py_player -from player import py_players #Imports for async query from secrets import * @@ -254,19 +252,6 @@ def save_json_file(filename, obj): error("Failed to write to %s: %s" % (filename, e)) -def toggle(player, ls, name = "Toggle", add = None): - """ - Toggles presence of a player's UUID in a list - If add is given, True explicitely adds it whereas False removes it - """ - pid = uid(player) - if pid in ls or add == False: - ls.remove(pid) - msg(player, "&a%s turned off!" % name) - elif add != False: - ls.append(pid) - msg(player, "&a%s turned on!" % name) - def send_JSON_message(playername, message): bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), "tellraw " + playername + " " + message) @@ -298,21 +283,13 @@ def get_permission_content(player, permnode): perms = player.getEffectivePermissions() for perm in perms: if str(perm.getPermission()).startswith(permnode): - return str(perm.getPermission()).replace(permnode, "") - - -# Gets an online player from their name -def get_player(name): - for p in bukkit.Bukkit.getServer().getOnlinePlayers(): - if p.getName().lower() == name.lower(): - return p - return None + return str(perm.getPermission())[len(permnode):] def array_to_list(array): return_list = [] for a in array: - return_list += [a] + return_list.append(a) return return_list diff --git a/loginsecurity.py b/loginsecurity.py index edf51e9..4fbb307 100644 --- a/loginsecurity.py +++ b/loginsecurity.py @@ -7,6 +7,7 @@ from login_secrets import * #Don't forget to make login_secrets aswell import mysqlhack from com.ziclix.python.sql import zxJDBC from java.lang import Runnable +from player import get_py_player, py_players wait_time = 30 #seconds admin_perm = "utils.loginsecurity.admin" -- 2.45.2 From c78d0f651bd1250ad2de34005edd782e11218e7a Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 01:11:34 +0200 Subject: [PATCH 57/95] Hotfix for chatalias --- chatalias.py | 52 ++++++++++++++++++++++++++-------------------------- helpers.py | 14 +++++++++----- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/chatalias.py b/chatalias.py index bc21e13..9db8fdb 100644 --- a/chatalias.py +++ b/chatalias.py @@ -120,23 +120,26 @@ def on_join(event): @hook.event("player.AsyncPlayerChatEvent", "high") def on_player_chat(event): - if enabled: - if event.isCancelled(): - return - player = event.getPlayer() - if not hasPerm(player, permission_USE): - return - msg_limit = int(get_permission_content(player, permission_LENGTH)) - for alias, value in data[str(uid(player))].items(): - if player.hasPermission("essentials.chat.color"): - event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) - else: - event.setMessage(event.getMessage().replace(alias, value)) - if not player.hasPermission(permission_ALL) and len(event.getMessage()) > msg_limit: - event.setCancelled(True) - plugin_header(player, "Alias") - msg(player, "The message you wanted to generate would exceed the length limit limit of %d. Please make it shorter!" % msg_limit) + try: + if enabled: + if event.isCancelled(): return + player = event.getPlayer() + if not hasPerm(player, permission_USE): + return + msg_limit = int(get_permission_content(player, permission_LENGTH)) + for alias, value in data[uid(player)].iteritems(): + if player.hasPermission("essentials.chat.color"): + event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) + else: + event.setMessage(event.getMessage().replace(alias, value)) + if not player.hasPermission(permission_ALL) and len(event.getMessage()) > msg_limit: + event.setCancelled(True) + plugin_header(player, "Alias") + msg(player, "The message you wanted to generate would exceed the length limit limit of %d. Please make it shorter!" % msg_limit) + return + except: + error(trace()) def hasPerm(player, permission): @@ -316,14 +319,12 @@ def load_data_thread(uuid): curs = conn.cursor() curs.execute("SELECT `alias` FROM `chatalias` WHERE `uuid` = ?;", (uuid, )) results = curs.fetchall() - if len(results) == 0: - value = dict(global_aliases) - curs.execute("INSERT INTO `chatalias` VALUES (?,?);", (uuid, json_dumps(results), )) - conn.commit() - else: - value = json_loads(results[0][0]) curs.close() conn.close() + if len(results) == 0: + value = dict(global_aliases) + else: + value = json_loads(results[0][0]) data[uuid] = value @@ -341,10 +342,9 @@ def save_data(uuid): def save_data_thread(uuid): conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") curs = conn.cursor() - try: - curs.execute("UPDATE `chatalias` SET `alias` = ? WHERE `uuid` = ?;", (json_dumps(data[uuid]), uuid, )) - except: - error(trace()) + value = json_dumps(data[uuid]) + curs.execute("INSERT INTO `chatalias` VALUES (?, ?) ON DUPLICATE KEY UPDATE `alias` = ?;", + (uuid, value, value)) conn.commit() curs.close() conn.close() diff --git a/helpers.py b/helpers.py index d6e46bd..da0d423 100755 --- a/helpers.py +++ b/helpers.py @@ -279,11 +279,15 @@ def is_ip(tocheck): # Allows the use of e.g. numeric permission nodes like "permission.amount.5" and similar. # To get the data fetch the player and the start of the permission node, looking like "permission.amount." -def get_permission_content(player, permnode): - perms = player.getEffectivePermissions() - for perm in perms: - if str(perm.getPermission()).startswith(permnode): - return str(perm.getPermission())[len(permnode):] +def get_permission_content(player, permnode, default_value = None): + try: + perms = player.getEffectivePermissions() + for perm in perms: + if str(perm.getPermission()).startswith(permnode): + return str(perm.getPermission())[len(permnode):] + return default_value + except: + error(trace()) def array_to_list(array): -- 2.45.2 From 1fb6e08d42449d84fbcd4461e0628a228cd1acdf Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 03:53:33 +0200 Subject: [PATCH 58/95] Serversigns hotfix --- main.py | 2 ++ serversigns.py | 41 +++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/main.py b/main.py index fba0c5a..ffea209 100644 --- a/main.py +++ b/main.py @@ -23,6 +23,8 @@ def on_enable(): shared["modules"]["blockplacemods"].schedule_torch_breaker() if "imbusy" in shared["modules"]: shared["modules"]["imbusy"].replace_ess_commands() + if "serversigns" in shared["modules"]: + shared["modules"]["serversigns"].check_all_signs() info("RedstonerUtils enabled!") diff --git a/serversigns.py b/serversigns.py index d5a4829..c5238e1 100644 --- a/serversigns.py +++ b/serversigns.py @@ -266,8 +266,6 @@ def svs_command(sender, command, label, args): #------------------------------------------------------------------------------------------------------- - - @hook.event("player.PlayerInteractEvent") def on_click(event): if str(event.getAction()) != "RIGHT_CLICK_BLOCK": @@ -297,39 +295,37 @@ faces = { @hook.event("block.BlockBreakEvent", "monitor") def on_break(event): - try: - global checking_block - if checking_block or event.isCancelled(): - return + if checking_block or event.isCancelled(): + return - block = event.getBlock() - if block.getType() in (Material.SIGN_POST, Material.WALL_SIGN): - check_sign(event, block, attached = False) + block = event.getBlock() + if block.getType() in (Material.SIGN_POST, Material.WALL_SIGN): + check_sign(event, block, attached = False) - for block_face, data_values in faces.iteritems(): - block2 = block.getRelative(block_face) - if block2.getType() == Material.WALL_SIGN and block2.getData() in data_values: - check_sign(event, block2) + for block_face, data_values in faces.iteritems(): + block2 = block.getRelative(block_face) + if block2.getType() == Material.WALL_SIGN and block2.getData() in data_values: + check_sign(event, block2) - block3 = block.getRelative(BlockFace.UP) - if block3.getType() == Material.SIGN_POST: - check_sign(event, block3) - except: - error(trace()) + block3 = block.getRelative(BlockFace.UP) + if block3.getType() == Material.SIGN_POST: + check_sign(event, block3) def check_sign(event, block, attached = True): player = event.getPlayer() - sign = getSign(fromLoc(block.getLocation())) + loc = fromLoc(block.getLocation()) + if block.getType() not in (Material.WALL_SIGN, Material.SIGN_POST) or getSign(loc) is None: + return if not can_build2(player, block): event.setCancelled(True) msg(event.getPlayer(), signsMsg("You cannot break %s" % ("the sign attached to that block" if attached else "that sign"))) else: - loc = fromLoc(block.getLocation()) del signs[loc] save_signs() msg(player, signsMsg("Reset the %s which you just broke" % identifySign(loc))) + def can_build2(player, block): global checking_block event = BlockBreakEvent(block, player) @@ -338,3 +334,8 @@ def can_build2(player, block): checking_block = False return not event.isCancelled() + +def check_all_signs(): + for loc in signs: + if server.getWorld(loc[0]).getBlockAt(loc[1], loc[2], loc[3]).getType() not in (Material.WALL_SIGN, Material.SIGN_POST): + del signs[loc] -- 2.45.2 From d66e8f3294114b82f903effb812691e0b55e14fb Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 04:07:09 +0200 Subject: [PATCH 59/95] Imbusy hotfix... --- imbusy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imbusy.py b/imbusy.py index ec6c57b..d84249d 100644 --- a/imbusy.py +++ b/imbusy.py @@ -62,7 +62,7 @@ def toggle(sender): del busy_players[sender_name] broadcast(None, sender.getDisplayName() + " &7is no longer busy...") else: - busy_players.append(sender_name) + busy_players[sender_name] = False broadcast(None, sender.getDisplayName() + " &7is now busy...") return True -- 2.45.2 From 1da9aa25785e9fd5bd09174155ad9cd1b7306273 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 04:15:06 +0200 Subject: [PATCH 60/95] Friends hotfix... Did I really write this code? --- friends.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/friends.py b/friends.py index 130954a..1f41212 100644 --- a/friends.py +++ b/friends.py @@ -98,7 +98,7 @@ def rem(sender, names): notafriend = [] for name in names: - player = server.Player(name) + player = server.getPlayer(name) if player: player_id = uid(player) if player_id in friends.get(sender_id, []): -- 2.45.2 From e08666995cc14436a2566cc03c250ca2e8ff0b3e Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 04:52:10 +0200 Subject: [PATCH 61/95] Friends fix --- friends.py | 93 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/friends.py b/friends.py index 1f41212..51243ac 100644 --- a/friends.py +++ b/friends.py @@ -29,6 +29,13 @@ def friendmessage(player, message): # sends a message with a prefix msg(player, "&7[&aFriends&7] " + message) +def get_player(name): + result = server.getOfflinePlayer(name) + if result is not None and (result.hasPlayedBefore() or result.isOnline()): + return result + return None + + def ls(sender): try: sender_friends = friends.get(uid(sender), False) @@ -59,21 +66,25 @@ def add(sender, names): added = [] notfound = [] friendalready = [] + added_self = False if not sender_id in friends: friends[sender_id] = [] for name in names: - player = server.getPlayer(name) + player = get_player(name) if player: player_id = uid(player) - not_yourself = player != sender + not_yourself = sender != player if not player_id in friends[sender_id]: if not_yourself: friends[sender_id].append(player_id) added.append(player.getName()) - friendmessage(player.getPlayer(), "&a&o%s &aadded you to their friends list" % stripcolors(sender.getDisplayName())) + if player.isOnline(): + friendmessage(player.getPlayer(), "&a&o%s &aadded you to their friends list" % stripcolors(sender.getDisplayName())) + else: + added_self = True else: friendalready.append(player.getName()) @@ -84,10 +95,10 @@ def add(sender, names): if added: friendmessage(sender, "&a&o%s&a added." % ", ".join(added)) if notfound: - friendmessage(sender, "&c&o%s&c not found. (must be online)" % ", ".join(notfound)) + friendmessage(sender, "&c&o%s&c not found." % ", ".join(notfound)) if friendalready: friendmessage(sender, "&c&o%s&c is/are already your friend." % ", ".join(friendalready)) - if not not_yourself: + if added_self: friendmessage(sender, "&cYou can't add yourself to your friends list.") @@ -98,18 +109,21 @@ def rem(sender, names): notafriend = [] for name in names: - player = server.getPlayer(name) + player = get_player(name) if player: player_id = uid(player) if player_id in friends.get(sender_id, []): friends[sender_id].remove(player_id) removed.append(player.getName()) - friendmessage(player.getPlayer(), "&c&o%s &cremoved you from their friends list" % stripcolors(sender.getDisplayName())) + if player.isOnline(): + friendmessage(player.getPlayer(), "&c&o%s &cremoved you from their friends list" % stripcolors(sender.getDisplayName())) else: notafriend.append(player.getName()) else: notfound.append(name) + if not friends.get(sender_id, False): + del friends[sender_id] save_friends() if removed: friendmessage(sender, "&a&o%s&a removed." % ", ".join(removed)) @@ -130,35 +144,38 @@ def fhelp(sender): @hook.command("friends") def on_friend_command(sender, command, label, args): - if not is_player(sender): - friendmessage(sender, "&c&lYou can't have friends!") + try: + if not is_player(sender): + friendmessage(sender, "&c&lYou can't have friends!") + return True + + cmd = args[0] if args else None + fargs = args[1:] + + # /friends list + if cmd in ["list", "lst", "*"]: + thread.start_new_thread(ls, (sender,)) + + # /friends clear + elif cmd in ["clear", "/"]: + clear(sender) + + # /friends add + elif cmd in ["add", "+"]: + if fargs: + add(sender, fargs) + else: + fhelp(sender) + + # /friends remove + elif cmd in ["remove", "rem", "delete", "del", "-"]: + if fargs: + rem(sender, fargs) + else: + fhelp(sender) + + else: + fhelp(sender) return True - - cmd = args[0] if args else None - fargs = args[1:] - - # /friends list - if cmd in ["list", "lst", "*"]: - thread.start_new_thread(ls, (sender,)) - - # /friends clear - elif cmd in ["clear", "/"]: - clear(sender) - - # /friends add - elif cmd in ["add", "+"]: - if fargs: - add(sender, fargs) - else: - fhelp(sender) - - # /friends remove - elif cmd in ["remove", "rem", "delete", "del", "-"]: - if fargs: - rem(sender, fargs) - else: - fhelp(sender) - - else: - fhelp(sender) - return True \ No newline at end of file + except: + error(trace()) -- 2.45.2 From 4e4acc6b3d26fe7b00231dc220b69f55dae34367 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 05:26:07 +0200 Subject: [PATCH 62/95] Remove sync.py file --- imbusy.py | 1 - sync.py | 21 --------------------- 2 files changed, 22 deletions(-) delete mode 100644 sync.py diff --git a/imbusy.py b/imbusy.py index d84249d..48f3e69 100644 --- a/imbusy.py +++ b/imbusy.py @@ -236,7 +236,6 @@ def tpahere_command_checker(sender, args): return tpa_command_checker(sender, args) def mail_command_checker(sender, args): - info("Mail command executed") if len(args) < 3 or args[0].lower() != "send": return True target = server.getPlayer(args[1]) diff --git a/sync.py b/sync.py deleted file mode 100644 index 0a2cd0b..0000000 --- a/sync.py +++ /dev/null @@ -1,21 +0,0 @@ -from helpers import * -from java.lang import Runnable - -class Sync_class(Runnable): - - def __init__(self,function,*args,**kwargs): - self.function = function - self.args = args - self.kwargs = kwargs - - def run(self): - self.function(self.args,self.kwargs) - - - -def sync(function): - def wrapper(*args,**kwargs): - sync_function = Sync_class(function) - server.getScheduler().runTask(server.getPluginManager().getPlugin("RedstonerUtils"),sync_function) - return None - return wrapper \ No newline at end of file -- 2.45.2 From d00301ccc3de42c6b66bf986e79ce84ca2c09d07 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 15:45:05 +0200 Subject: [PATCH 63/95] Updated damnspam, made block breaking check attached levers and buttons, denied clicking now mentions timeout left, tweaked command slightly to perceive setting the timeout to 0 as removing it. --- damnspam.py | 165 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 108 insertions(+), 57 deletions(-) diff --git a/damnspam.py b/damnspam.py index e9f9b84..a72c254 100644 --- a/damnspam.py +++ b/damnspam.py @@ -1,12 +1,15 @@ #pylint: disable = F0401 from helpers import * from time import time as now -import org.bukkit.event.block.BlockBreakEvent as BlockBreakEvent +import org.bukkit.Material as Material +import org.bukkit.block.BlockFace as BlockFace inputs = open_json_file("damnspam", {}) # format "x;y;z;World" accepted_inputs = ["WOOD_BUTTON", "STONE_BUTTON", "LEVER"] changing_input = False removing_input = False +max_timeout = 240 +timeout_error_str = "&cThe timeout must be -1 or within 0 and %d" % max_timeout def save_inputs(): @@ -26,29 +29,35 @@ def add_input(creator, block, timeout_off, timeout_on): } +def is_acceptable_timeout(timeout): + return (0 < timeout <= max_timeout) or timeout == -1 + + @hook.command("damnspam") def on_dammnspam_command(sender, command, label, args): - global changing_input - plugin_header(sender, "DamnSpam") + if not checkargs(sender, args, 1, 2): msg(sender, "&c/damnspam &e(Buttons/Levers)") msg(sender, "&c/damnspam &e(Levers only)") return True #Gittestlol if not is_creative(sender): - msg(sender, "&cYou can only do this in Creative mode.") + msg(sender, "&cYou can only do this in Creative mode") return True # /damnspam + destroying_input = False # if both timeouts are 0, the plugin will attempt to remove the protection if len(args) == 1: timeout_on = args[0] try: timeout_on = round(float(timeout_on), 2) - timeout_off = timeout_on - if 60 >= timeout_on <= -2 or timeout_on == 0: - msg(sender, "&cThe timeout must be within 0-60 or -1.") + if timeout_on == 0: + destroying_input = True + elif not is_acceptable_timeout(timeout_on): + msg(sender, "&cThe timeout must be -1 or within 0 and %d" % max_timeout) return True + timeout_off = timeout_on except ValueError: msg(sender, "&cThe timeout must be a number") return True @@ -60,12 +69,10 @@ def on_dammnspam_command(sender, command, label, args): try: timeout_on = round(float(timeout_on), 2) timeout_off = round(float(timeout_off), 2) - if 60 >= timeout_on <= -2 or timeout_on == 0: - timeout_on = False - if 60 >= timeout_off <= -2 or timeout_off == 0: - timeout_off = False - if timeout_on == False or timeout_off == False: - msg(sender, "&cThe timeout must be within 0-60 or -1.") + if timeout_on == 0 and timeout_off == 0: + destroying_input = True + elif not (is_acceptable_timeout(timeout_on) and is_acceptable_timeout(timeout_off)): + msg(sender, "&cThe timeout must be -1 or within 0 and %d" % max_timeout) return True except ValueError: msg(sender, "&cThe timeout must be a number") @@ -78,72 +85,116 @@ def on_dammnspam_command(sender, command, label, args): msg(sender, "&cPlease look at a button or lever while executing this command!") return True - if location_str(target) in inputs: + global changing_input + target_loc_str = location_str(target) + if target_loc_str in inputs: changing_input = True # this input already has a timeout + + type_str = ttype.lower().replace("_", " ") + # test if player is allowed to build here - test_event = BlockBreakEvent(target, sender) - server.getPluginManager().callEvent(test_event) + build_check = can_build(sender, target) changing_input = False - if test_event.isCancelled(): - msg(sender, "&cYou are not allowed to modify this %s" % str(target.getType()).lower()) + if not build_check: + msg(sender, "&cYou are not allowed to modify this %s" % type_str) return True # add block to inputs - add_input(sender, target, timeout_off, timeout_on) + if destroying_input: + if target_loc_str not in inputs: + msg(sender, "&cThere is no timeout to remove on this %s (by setting the timeout to 0)" % type_str) + return True + del inputs[target_loc_str] + msg(sender, "&aSuccessfully removed the timeout for this %s" % type_str) + else: + add_input(sender, target, timeout_off, timeout_on) + msg(sender, "&aSuccessfully set a timeout for this %s" % type_str) save_inputs() - msg(sender, "&aSuccessfully set a timeout for this %s." % ttype.lower().replace("_", " ")) return True -@hook.event("block.BlockBreakEvent", "normal") -def on_block_break(event): - global removing_input - - if removing_input: +def check_block_break(break_event, block): + if str(block.getType()) not in accepted_inputs: return - sender = event.getPlayer() - block = event.getBlock() - btype = str(block.getType()).lower() - if str(block.getType()) in accepted_inputs and not event.isCancelled(): - pos_str = location_str(block) - if inputs.get(pos_str): - if sender.isSneaking(): - # test if player is allowed to build here - removing_input = True - test_event = BlockBreakEvent(block, sender) - server.getPluginManager().callEvent(test_event) - removing_input = False - if test_event.isCancelled(): - event.setCancelled(True) - msg(sender, "&cYou are not allowed to remove this %s" % btype) - return True - inputs.pop(pos_str) # remove - save_inputs() - msg(sender, "&eSuccessfully removed this %s!" % btype) - return True - elif not changing_input: - event.setCancelled(True) - msg(sender, "&cYou cannot destroy this %s!" % btype) - msg(sender, "&c&nSneak&c and break if you want to remove it.") - return True + pos_str = location_str(block) + if pos_str not in inputs: + return + sender = break_event.getPlayer() + input_str = ("this %s" if block is break_event.getBlock() else "the %s attached to that block") % str(block.getType()).lower().replace("_", " ") + if not sender.isSneaking(): + msg(sender, "&cYou cannot destroy " + input_str) + msg(sender, "&c&nSneak&c and break or set the timeout to 0 if you want to remove it.") + break_event.setCancelled(True) + return + global removing_input + removing_input = True + success = can_build(sender, block) + removing_input = False + if success: + del inputs[pos_str] + save_inputs() + msg(sender, "&aSuccessfully removed %s!" % input_str) + else: + msg(sender, "&cYou are not allowed to remove " + input_str) + break_event.setCancelled(True) + + +# a dict for levers and buttons, with a tuple of tuples as value. The tuples in the tuple represent +# the data values which the block must have if the block were placed towards the linked blockface to be affected. +# The order is DOWN, UP, NORTH, SOUTH, WEST, EAST +attached_blocks = { + + Material.LEVER: ((0, 7, 8, 15), (5, 6, 13, 14), (4, 12), (3, 11), (2, 10), (1, 9)), + Material.STONE_BUTTON: ((0, 8), (5, 6, 7, 13, 14, 15), (4, 12), (3, 11), (2, 10), (1, 9)), + Material.WOOD_BUTTON: ((0, 8), (5, 6, 7, 13, 14, 15), (4, 12), (3, 11), (2, 10), (1, 9)), + +} + +# returns a generator containing the levers or buttons that would be broken if this block were broken +def get_attached_blocks(block): + for i, face in ((0, BlockFace.DOWN), (1, BlockFace.UP), (2, BlockFace.NORTH), (3, BlockFace.SOUTH), (4, BlockFace.WEST), (5, BlockFace.EAST)): + side = block.getRelative(face) + dvalues = attached_blocks.get(side.getType()) + if dvalues is not None and side.getData() in dvalues[i]: + yield side + + +@hook.event("block.BlockBreakEvent", "highest") +def on_block_break(event): + try: + if removing_input or changing_input or event.isCancelled(): + return + block = event.getBlock() + check_block_break(event, event.getBlock()) + for affected_block in get_attached_blocks(block): + check_block_break(event, affected_block) + except: + error(trace()) @hook.event("player.PlayerInteractEvent", "normal") def on_interact(event): if (str(event.getAction()) == "RIGHT_CLICK_BLOCK") and not event.isCancelled(): - sender = event.getPlayer() + sender = event.getPlayer() + if sender.isSneaking(): + return block = event.getClickedBlock() - btype = str(block.getType()).lower() - powered = (block.getData() & 0x8) == 0x8 if btype == "lever" else False # data > 7, but this is how bukkit does it pos_str = location_str(block) data = inputs.get(pos_str) if data: - checktime = data["timeout_on"] if powered else data["timeout_off"] + sender = event.getPlayer() + btype = str(block.getType()).lower().replace("_", " ") + if btype == "lever" and block.getData() < 8: + checktime = data["timeout_off"] + else: + checktime = data["timeout_on"] + time_left = data["last_time"] + checktime - now() + if checktime == -1: event.setCancelled(True) msg(sender, "&cThis %s is locked permanently by /damnspam." % (btype)) - elif data["last_time"] + checktime > now(): + elif time_left > 0: event.setCancelled(True) - msg(sender, "&cThis %s has a damnspam timeout of %ss." % (btype, checktime)) + msg(sender, "&cThis %s has a damnspam timeout of %.2fs, with %.2fs left." % (btype, checktime, time_left)) else: - inputs[pos_str]["last_time"] = round(now(), 2) + data["last_time"] = round(now(), 2) -- 2.45.2 From 6539c34a82b997ddf3cb00715fca838354e2c807 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 15:47:24 +0200 Subject: [PATCH 64/95] Removed unneeded try/except clause --- damnspam.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/damnspam.py b/damnspam.py index a72c254..b3cbb0f 100644 --- a/damnspam.py +++ b/damnspam.py @@ -161,15 +161,12 @@ def get_attached_blocks(block): @hook.event("block.BlockBreakEvent", "highest") def on_block_break(event): - try: - if removing_input or changing_input or event.isCancelled(): - return - block = event.getBlock() - check_block_break(event, event.getBlock()) - for affected_block in get_attached_blocks(block): - check_block_break(event, affected_block) - except: - error(trace()) + if removing_input or changing_input or event.isCancelled(): + return + block = event.getBlock() + check_block_break(event, event.getBlock()) + for affected_block in get_attached_blocks(block): + check_block_break(event, affected_block) @hook.event("player.PlayerInteractEvent", "normal") -- 2.45.2 From e46bea31c85aade29aa8a55f1b271ed3a974b6db Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 21:42:30 +0200 Subject: [PATCH 65/95] Cleaned up chatalias, notable changes: Fixed remotes list and remove, improved prior alias checks for multi-aliasing, fixed color chat permission implementations, grouped the file properly, removed unreasonable complications, changed header from Alias to Chatalias, fixed a mistake where 2 threads are created per player for online players during server reload, moved a lot of repeated code to remote() base function --- chatalias.py | 366 +++++++++++++++++++++++++++------------------------ 1 file changed, 191 insertions(+), 175 deletions(-) diff --git a/chatalias.py b/chatalias.py index 9db8fdb..6febf17 100644 --- a/chatalias.py +++ b/chatalias.py @@ -33,14 +33,13 @@ permission_LIST = "utils.alias.list" permission_LIST_OTHERS = "utils.alias.list.others" # Set alias amounts/length limits, e.g. utils.alias.amount.420 permission_AMOUNT = "utils.alias.amount." +default_alias_limit = 15 permission_LENGTH = "utils.alias.length." +default_length_limit = 120 # See when the plugin was disabled due to version errors permission_INFO = "utils.alias.info" permission_FINFO = "utils.alias.finfo" -######## -# CODE # -######## def safe_open_json(uuid): if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"): @@ -52,25 +51,91 @@ def safe_open_json(uuid): return value +def get_player_alias_limit(player): + value = get_permission_content(player, permission_AMOUNT) + if value is not None and value.isdigit(): + return int(value) + return default_alias_limit + + +def get_player_length_limit(player): + value = get_permission_content(player, permission_LENGTH) + if value is not None and value.isdigit(): + return int(value) + return default_length_limit + + +@hook.event("player.PlayerJoinEvent", "high") +def on_join(event): + if enabled: + t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) + t.daemon = True + t.start() + else: + if event.getPlayer().hasPermission(permission_FINFO): + disabled_fallback(event.getPlayer()) + + +@hook.event("player.AsyncPlayerChatEvent", "high") +def on_player_chat(event): + if enabled: + if event.isCancelled(): + return + player = event.getPlayer() + if not hasPerm(player, permission_USE): + return + msg_limit = get_player_length_limit(player) + for alias, value in data[uid(player)].iteritems(): + if player.hasPermission("essentials.chat.color"): + event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) + else: + event.setMessage(event.getMessage().replace(alias, value)) + if not player.hasPermission(permission_ALL) and len(event.getMessage()) > msg_limit: + event.setCancelled(True) + plugin_header(player, "Chatalias") + msg(player, "The message you wanted to generate would exceed the length limit limit of %d. Please make it shorter!" % msg_limit) + return + + +def hasPerm(player, permission): + return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL)) + + +def disabled_fallback(receiver): + if not hasPerm(receiver, permission_INFO): + msg(receiver, colorify("&cUnknown command. Use &e/help&c, &e/plugins &cor ask a mod.")) + else: + msg(receiver, colorify("&cPlugin alias v" + alias_version + " has experienced an &eEMERGENCY SHUTDOWN:")) + msg(receiver, error_msg) + msg(receiver, colorify("&cPlease contact a dev/admin (especially pep :P) about this to take a look at it.")) + + +def can_remote(player): + return hasPerm(player, permission_LIST_OTHERS) or hasPerm(player, permission_MODIFY_OTHERS) + + +# Command + @hook.command("alias", usage="/ [...]", desc="Allows aliasing of words") def on_alias_command(sender, cmd, label, args): - if not is_player(sender): - msg(sender, "&cThe console cannot use aliases!") - return True + plugin_header(sender, "Chatalias") try: args = array_to_list(args) if not enabled: disabled_fallback(sender) - return True + return if not hasPerm(sender, permission_BASE): - plugin_header(recipient=sender, name="Alias") noperm(sender) - return True - return subcommands[args[0].lower()](sender, args[1:]) + return + if args[0].lower() != "player" and not is_player(sender): + msg(sender, "&cThe console cannot have aliases") + return + subcommands[args[0].lower()](sender, args[1:]) except: - return subcommands["help"](sender, "1") + subcommands["help"](sender, "1") + return True def help(sender, args): @@ -104,205 +169,179 @@ def help(sender, args): msg(sender, message) if page+1 < pages: msg(sender, colorify("&6To display the next page, type &c/alias help " + str(page+2))) - return True - - -@hook.event("player.PlayerJoinEvent", "high") -def on_join(event): - if enabled: - t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) - t.daemon = True - t.start() - else: - if event.getPlayer().hasPermission(permission_FINFO): - disabled_fallback(event.getPlayer()) - - -@hook.event("player.AsyncPlayerChatEvent", "high") -def on_player_chat(event): - try: - if enabled: - if event.isCancelled(): - return - player = event.getPlayer() - if not hasPerm(player, permission_USE): - return - msg_limit = int(get_permission_content(player, permission_LENGTH)) - for alias, value in data[uid(player)].iteritems(): - if player.hasPermission("essentials.chat.color"): - event.setMessage(event.getMessage().replace(colorify(alias), colorify(value))) - else: - event.setMessage(event.getMessage().replace(alias, value)) - if not player.hasPermission(permission_ALL) and len(event.getMessage()) > msg_limit: - event.setCancelled(True) - plugin_header(player, "Alias") - msg(player, "The message you wanted to generate would exceed the length limit limit of %d. Please make it shorter!" % msg_limit) - return - except: - error(trace()) - - -def hasPerm(player, permission): - return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL)) - - -def disabled_fallback(receiver): - if not hasPerm(receiver, permission_INFO): - msg(receiver, colorify("&cUnknown command. Use &e/help&c, &e/plugins &cor ask a mod.")) - else: - msg(receiver, colorify("&cPlugin alias v" + alias_version + " has experienced an &eEMERGENCY SHUTDOWN:")) - msg(receiver, error_msg) - msg(receiver, colorify("&cPlease contact a dev/admin (especially pep :P) about this to take a look at it.")) - - -def can_remote(player): - return hasPerm(player, permission_LIST_OTHERS) or hasPerm(player, permission_MODIFY_OTHERS) def add(sender, args): - plugin_header(sender, "Alias") uuid = uid(sender) args = [args[0]] + [" ".join(args[1:])] if (args[0] not in data[uuid]) and is_alias_limit_reached(sender, sender): - return True - if not add_alias_data(uuid, str(args[0]), args[1]): + return + if not add_alias_data(uuid, args[0], args[1]): msg(sender, colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times", usecolor = False) - return True - msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color")) - return True + return + msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> ") + args[1] + colorify("&7 was succesfully created!"), usecolor=sender.hasPermission("essentials.chat.color")) -def radd(sender, args): - plugin_header(sender, "Alias") - args = args[0:2] + [" ".join(args[2:len(args)-1])] + [args[len(args)-1]] - if is_player(sender): - sender_name = colorify(sender.getDisplayName()) - else: - sender_name = colorify("&6Console") - target = server.getPlayer(args[0]) - if target == None: - msg(sender, "&cThat player is not online") - return True +def radd(sender, sender_name, target, args, silent): + if len(args) < 2: + msg(sender, "&cYou must pass a sequence and an alias for it") + return + replaced = args[0] + alias = " ".join(args[1:]) uuid = uid(target) - if args[3].lower() == "false": - plugin_header(target, "Alias") - msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") - elif args[3].lower() != "true": - args[2] += " " + args[3] - if (args[1] not in data[uuid]) and is_alias_limit_reached(target, sender, args[3].lower() == "false"): - return True - if len(args) == 3: - args += ["true"] - if not add_alias_data(uuid, str(args[1]), str(args[2])): + if not silent: + if sender is not target: + plugin_header(target, "Chatalias") + msg(target, "&cPlayer %s &cis creating an alias for you!" % sender_name) + if (replaced not in data[uuid]) and is_alias_limit_reached(target, sender, silent): + return + if not add_alias_data(uuid, replaced, alias): message = colorify("&c") + "Could not add this alias because it would cause some sequences to be replaced multiple times" - msg(sender, message) - if args[3].lower() == "false": - msg(target, message) - return True - msg(sender, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) - if args[3].lower() == "false": - msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color")) - return True + msg(sender, message, usecolor = False) + if not silent: + msg(target, message, usecolor = False) + return + message = colorify("&7Alias: &7%s&7 -> &7%s&7 was successfully created!") % ((colorify(replaced), colorify(alias)) if target.hasPermission("essentials.chat.color") else (replaced, alias)) + msg(sender, message, usecolor = False) + if not silent: + msg(target, message, usecolor = False) -def is_alias_limit_reached(player, recipient, not_silent = False): +def is_alias_limit_reached(player, recipient, silent = True): if player.hasPermission(permission_ALL): return False - alias_limit = int(get_permission_content(player, permission_AMOUNT)) + alias_limit = get_player_alias_limit(player) if len(data[uid(player)]) >= alias_limit: message = ("&cYour limit of %d has been reached" if player is recipient else "&cThe limit of %d has been reached for that player") % alias_limit msg(recipient, message) - if not_silent: + if not silent: msg(player, message) return True return False def add_alias_data(puuid, aliased, new_alias): - prior = data[puuid] + prior = dict(data[puuid]) + if aliased in prior: + info("Checking prior, removing previous alias for " + aliased) + del prior[aliased] # prevent 2 -> 3 if there is 1 -> 2 - if aliased not in prior: - for alias in prior.values(): - if aliased in alias: - return False + for alias in prior.values(): + if aliased in alias: + info("aliased %s in alias %s" % (aliased, alias)) + return False # prevent 1 -> 2 if there is 2 -> 3 for sequence in prior: if sequence in new_alias: + info("sequence %s in new_alias %s" % (sequence, new_alias)) return False - prior[aliased] = new_alias + data[puuid][aliased] = new_alias save_data(puuid) return True def remove(sender, args): - plugin_header(sender, "Alias") try: msg(sender, colorify("&7Successfully removed alias ") + args[0] + colorify(" &7-> ") + data[uid(sender)].pop(args[0]) + colorify("&7!"), usecolor=sender.hasPermission("essentials.chat.color")) save_data(uid(sender)) except: msg(sender, colorify("&cCould not remove alias ") + args[0] + colorify(", it does not exist."), usecolor=sender.hasPermission("essentials.chat.color")) - return True -def rremove(sender, args): - plugin_header(sender, "Alias") - target = get_player(args[0]) - if is_player(sender): - sender_name = colorify(sender.getDisplayName()) +def rremove(sender, sender_name, target, args, silent): + if len(args) < 1: + msg(sender, "&cYou must specify a sequence whose alias is to be removed") + return + removed = args[0] + uuid = uid(target) + aliases = data[uuid] + if not silent: + msg(target, "&cPlayer %s &cis removing an alias for you!" % sender_name) + if removed in aliases: + alias = aliases.pop(removed) + message = colorify("&7Alias: &7%s&7 -> &7%s&7 successfully removed!") % ((colorify(removed), colorify(alias)) if target.hasPermission("essentials.chat.color") else (removed, alias)) + msg(sender, message, usecolor = False) + if not silent: + msg(target, message, usecolor = False) + save_data(uuid) else: - sender_name = colorify("&6Console") - if args[2].lower() == "false": - plugin_header(target, "Alias") - msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!") - try: - alias = data[uid(target)].pop(args[1]) - msg(sender, colorify("&7Successfully removed alias ") + args[1] + colorify(" &7-> ") + alias + colorify("&7!"), usecolor=sender.hasPermission("essentials.chat.color")) - if args[2].lower() == "false": - msg(target, colorify("&7Successfully removed alias ") + args[1] + colorify(" &7-> ") + alias + colorify("&7!"), usecolor=sender.hasPermission("essentials.chat.color")) - save_data(uid(target)) - except: - msg(sender, colorify("&cCould not remove alias ") + args[1] + colorify(", it does not exist."), usecolor=sender.hasPermission("essentials.chat.color")) - if args[2].lower() == "false": - msg(target, colorify("&cCould not remove alias ") + args[1] + colorify(", it does not exist."), usecolor=sender.hasPermission("essentials.chat.color")) - return True + message = colorify("&cCould not remove alias &7%s&c, it does not exist") % colorify(removed) if target.hasPermission("essentials.chat.color") else removed + msg(sender, message, usecolor = False) + if not silent: + msg(target, message, usecolor = False) def list_alias(sender, args): - plugin_header(sender, "Alias") msg(sender, "&7You have a total of " + str(len(data[uid(sender)])) + " aliases:") for word, alias in data[str(uid(sender))].items(): msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=sender.hasPermission("essentials.chat.color")) - return True -def rlist_alias(sender, args): - plugin_header(sender, "Alias") - target = get_player(args[0]) - if is_player(sender): - sender_name = colorify(sender.getDisplayName()) +def rlist_alias(sender, sender_name, target, args, silent): + aliases = data[uid(target)] + msg(sender, "&7Player %s has a total of %d aliases:" % (target.getName(), len(aliases))) + if not silent: + if sender is not target: + plugin_header(target, "Chatalias") + msg(target, "&cPlayer %s &cis listing your aliases" % sender_name) + if target.hasPermission("essentials.chat.color"): + for pair in aliases.iteritems(): + msg(sender, colorify("&7%s&7 -> %s" % pair), usecolor = False) else: - sender_name = colorify("&6Console") - if len(args) == 1: - args += ["true"] - msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):") - if args[1].lower() == "false": - plugin_header(target, "Alias") - msg(target, "&cPlayer " + sender_name + " &cis listing your aliases") - for word, alias in data[str(uid(target))].items(): - msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) - return True + for pair in aliases.iteritems(): + msg(sender, colorify("&7%s&7 -> %s") % pair, usecolor = False) def remote(sender, args): - try: - return remotes[args[1].lower()](sender, [args[0]] + args[2:]) - except: - return subcommands["help"](sender, ["2"]) + if len(args) < 2: + msg(sender, "&cAlias remotes take at least 3 arguments") + return + target_remote = remotes.get(args[1].lower()) + if target_remote is None: + msg(sender, "&cThat remote command does not exist") + return + target = server.getOfflinePlayer(args[0]) + if target is None or not (target.hasPlayedBefore() or target.isOnline()): + msg(sender, "&cThat player could not be found") + return + silent = True + if len(args) > (2 if target_remote is rlist_alias else 3 if target_remote is rremove else 4): + if args[-1].lower() == "false": + silent = sender is target or not target.isOnline() + args = args[:-1] + elif args[-1].lower() == "true": + args = args[:-1] + target_remote(sender, sender.getDisplayName() if is_player(sender) else colorify("&6Console"), target, args[2:], silent) +subcommands = { + "help": help, + "?": help, + "add": add, + "remove": remove, + "del": remove, + "delete": remove, + "player": remote, + "remote": remote, + "list": list_alias +} + +remotes = { + "add": radd, + "remove": rremove, + "del": rremove, + "delete": rremove, + "list": rlist_alias, +} + + +# Storage +# MySQL Table: +# CREATE TABLE `chatalias` (`uuid` VARCHAR(36) PRIMARY KEY, `alias` TEXT); + def load_data(uuid): if use_mysql: try: @@ -350,27 +389,6 @@ def save_data_thread(uuid): conn.close() -# Subcommands: -subcommands = { - "help": help, - "?": help, - "add": add, - "remove": remove, - "del": remove, - "delete": remove, - "player": remote, - "remote": remote, - "list": list_alias -} - -remotes = { - "add": radd, - "remove": rremove, - "del": rremove, - "delete": rremove, - "list": rlist_alias, -} - # OnModuleLoad enabled = helpers_version in helpers_versions @@ -378,9 +396,7 @@ if not enabled: error_msg = colorify("&6Incompatible versions detected (&chelpers.py&6)") for player in server.getOnlinePlayers(): if enabled: - t = threading.Thread(target=load_data, args=(uid(player), )) - t.daemon = True - t.start() + load_data(uid(player)) else: if player.hasPermission(permission_FINFO): disabled_fallback(player) -- 2.45.2 From c7d872c93b26b66a84a075fe0a6d3ed72dca473c Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 22:55:06 +0200 Subject: [PATCH 66/95] Fix @debug decorator not returning results --- helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers.py b/helpers.py index da0d423..a72af2e 100755 --- a/helpers.py +++ b/helpers.py @@ -301,7 +301,7 @@ def array_to_list(array): def debug(func): def wrap(*args, **kwargs): try: - func(*args, **kwargs) + return func(*args, **kwargs) except: - print(trace()) + error(trace()) return wrap -- 2.45.2 From 5d3530242ed2088d1fca8a211e9ec05835fe9ee0 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 22:58:27 +0200 Subject: [PATCH 67/95] Another tiny tweak to @debug --- helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/helpers.py b/helpers.py index a72af2e..40c313b 100755 --- a/helpers.py +++ b/helpers.py @@ -304,4 +304,5 @@ def debug(func): return func(*args, **kwargs) except: error(trace()) + return None return wrap -- 2.45.2 From edf5fa6d32d37a02613c5d99ce53fad166ced46b Mon Sep 17 00:00:00 2001 From: Dico200 Date: Mon, 30 May 2016 22:59:09 +0200 Subject: [PATCH 68/95] Fix /busy status --- imbusy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/imbusy.py b/imbusy.py index 48f3e69..10d1bca 100644 --- a/imbusy.py +++ b/imbusy.py @@ -109,7 +109,8 @@ def status(sender, args): noperm(sender) return True if len(args) == 0: - if sender.getName() in busy_players: + sender_name = sender.getName() + if sender_name in busy_players: if busy_players[sender_name] is False: msg(sender, "&7You are currently busy.") else: @@ -120,8 +121,9 @@ def status(sender, args): target = server.getPlayer(args[0]) if target is None: msg(sender, "&7That player is not online") - elif target.getName() in busy_players: - if busy_players[target.getName()] is False: + target_name = target.getName() + elif target_name in busy_players: + if busy_players[target_name] is False: msg(sender, "&7Player %s &7is currently busy." % target.getDisplayName()) else: msg(sender, "&7Player %s &7is currently SUPER busy." % target.getDisplayName()) -- 2.45.2 From ae706e8e12fe792c2574f0f0746b2cd8d1603485 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Tue, 31 May 2016 00:13:51 +0200 Subject: [PATCH 69/95] Clean up imbusy. Improve replying to busy people. All working perfectly, tested thoroughly. --- imbusy.py | 136 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 61 deletions(-) diff --git a/imbusy.py b/imbusy.py index 10d1bca..2b81973 100644 --- a/imbusy.py +++ b/imbusy.py @@ -11,6 +11,7 @@ be cleared. from helpers import * from friends import is_friend_of import org.bukkit.command.Command as Command +from time import time as now imbusy_version = "v1.1.0" @@ -18,8 +19,10 @@ base_permission = "utils.imbusy" # for /busy status use_permission = "utils.imbusy.use" # for being busy override_permission = "utils.imbusy.override" # for being able to bother busy people +busy_status_change_timeout = 2 # seconds -busy_players = {} # name : false/true where false is normal busy and true is super busy +busy_players = {} # name : (status, timeout_expire) +# possible statuses: True if SUPER busy, False if normal busy, None if not busy @hook.command("imbusy", @@ -27,6 +30,7 @@ busy_players = {} # name : false/true where false is normal busy and true is sup usage = "/ [on, off, status/check]", description = "Offers control over your busy status" ) +@debug def on_busy_command(sender, cmd, label, args): if not is_player(sender): msg(sender, "&7Sorry, Console cannot be busy") @@ -53,17 +57,47 @@ def on_busy_command(sender, cmd, label, args): return help(sender) +def change_status(target, status): + target_name = target.getName() + old_status = None + if target_name in busy_players: + value = busy_players[target_name] + time_left = value[1] - now() + if time_left > 0: + msg(target, "&cYou must wait %.2fs untill you can change your status" % time_left) + return + old_status = value[0] + + if old_status is status: + if status is True: + msg(target, "&cYou are already SUPER busy") + elif status is False: + msg(target, "&cYou are already busy") + else: + msg(target, "&cYou weren't busy yet") + return + + busy_players[target_name] = (status, now() + busy_status_change_timeout) + if status is True: + broadcast(None, target.getDisplayName() + " &7is now SUPER busy") + elif status is False: + broadcast(None, target.getDisplayName() + " &7is now busy") + else: + broadcast(None, target.getDisplayName() + " &7is not busy anymore") + + +def get_status(target): + return busy_players.get(target.getName(), (None,))[0] + + def toggle(sender): if not sender.hasPermission(use_permission): noperm(sender) return True - sender_name = sender.getName() - if sender_name in busy_players: - del busy_players[sender_name] - broadcast(None, sender.getDisplayName() + " &7is no longer busy...") + if get_status(sender) is None: + change_status(sender, False) else: - busy_players[sender_name] = False - broadcast(None, sender.getDisplayName() + " &7is now busy...") + change_status(sender, None) return True @@ -82,12 +116,7 @@ def on(sender): if not sender.hasPermission(use_permission): noperm(sender) return True - sender_name = sender.getName() - if busy_players.get(sender_name) is False: # can be None, False or True - msg(sender, "&7You are already busy!") - else: - busy_players[sender_name] = False # busy but not super busy - broadcast(None, sender.getDisplayName() + " &7is now busy...") + change_status(sender, False) return True @@ -95,12 +124,7 @@ def off(sender): if not sender.hasPermission(use_permission): noperm(sender) return True - sender_name = sender.getName() - if sender_name not in busy_players: - msg(sender, "&7You are not busy! You cannot be even less busy! Are you perhaps bored?") - return True - del busy_players[sender_name] - broadcast(None, sender.getDisplayName() + " &7is no longer busy...") + change_status(sender, None) return True @@ -109,26 +133,20 @@ def status(sender, args): noperm(sender) return True if len(args) == 0: - sender_name = sender.getName() - if sender_name in busy_players: - if busy_players[sender_name] is False: - msg(sender, "&7You are currently busy.") - else: - msg(sender, "&7You are currently SUPER busy.") - else: - msg(sender, "&7You are currently not busy.") + target = sender else: target = server.getPlayer(args[0]) if target is None: - msg(sender, "&7That player is not online") - target_name = target.getName() - elif target_name in busy_players: - if busy_players[target_name] is False: - msg(sender, "&7Player %s &7is currently busy." % target.getDisplayName()) - else: - msg(sender, "&7Player %s &7is currently SUPER busy." % target.getDisplayName()) - else: - msg(sender, "&7Player %s &7is currently not busy." % target.getDisplayName()) + msg(sender, "&cThat player is not online") + return True + status = get_status(target) + if status is True: + status_str = "SUPER busy" + elif status is False: + status_str = "busy" + else: + status_str = "not busy" + msg(sender, "&7%s currently %s" % ("You are" if target is sender else "Player %s&7 is" % target.getDisplayName()), status_str) return True @@ -136,12 +154,7 @@ def super_cmd(sender): if not sender.hasPermission(use_permission): noperm(sender) return True - sender_name = sender.getName() - if busy_players.get(sender_name) is True: - msg(sender, "&7You are already SUPER busy!") - else: - busy_players[sender_name] = True # SUPER busy - broadcast(None, sender.getDisplayName() + " &7is now SUPER busy...") + change_status(sender, True) return True @@ -152,47 +165,48 @@ def on_player_leave(event): del busy_players[player_name] -#---- Dicode for catching any bothering of busy people ---- +# Block any bothering if should be. If a busy player msgs someone else, they can be replied to and /msg'd as well. +# It's not entirely perfect in that regard as the ability to reply is lost when you are /msg'd by someone else. - -reply_targets = {} +reply_targets = {} # name : (reply_target_name, true if initiated by target) def can_send(sender, target): - if not target.getName() in busy_players: - return True if target is sender or sender.hasPermission(override_permission): return True - return busy_players[target.getName()] is False and is_friend_of(target, sender) + status = get_status(target) + if status is None: + return True + return status is False and is_friend_of(target, sender) def whisper(sender, target_name): target = server.getPlayer(target_name) if target is not None: + sender_name = sender.getName() if not can_send(sender, target): - msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) - return False + value = reply_targets[sender_name] + if value[0] != target_name or value[1] is False: + msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) + return False - reply_targets[sender.getName()] = target.getName() - - # allow the target to reply regardless of sender being busy - if target.getName() in reply_targets: - del reply_targets[target.getName()] + reply_targets[sender_name] = (target_name, False) + reply_targets[target_name] = (sender_name, True) return True def reply(sender): - if sender.getName() in reply_targets: - target = server.getPlayer(reply_targets[sender.getName()]) + sender_name = sender.getName() + if sender_name in reply_targets: + value = reply_targets[sender_name] + target = server.getPlayer(value[0]) if target is not None: - if not can_send(sender, target): + if not value[1] and not can_send(sender, target): msg(sender, "&c[&fBUSY&c] %s&r is busy!" % target.getDisplayName()) return False - # allow the target to reply regardless of sender being busy - if target.getName() in reply_targets: - del reply_targets[target.getName()] + reply_targets[target.getName()] = (sender_name, True) return True -- 2.45.2 From fe2d6eb701179054b0d0fe2e8fd10df16883179a Mon Sep 17 00:00:00 2001 From: Dico200 Date: Tue, 31 May 2016 01:00:15 +0200 Subject: [PATCH 70/95] Forgot to set this timeout back up after testing... Derp --- imbusy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imbusy.py b/imbusy.py index 2b81973..a8c5280 100644 --- a/imbusy.py +++ b/imbusy.py @@ -19,7 +19,7 @@ base_permission = "utils.imbusy" # for /busy status use_permission = "utils.imbusy.use" # for being busy override_permission = "utils.imbusy.override" # for being able to bother busy people -busy_status_change_timeout = 2 # seconds +busy_status_change_timeout = 15 # seconds busy_players = {} # name : (status, timeout_expire) # possible statuses: True if SUPER busy, False if normal busy, None if not busy -- 2.45.2 From 6f4357fad785f9e1f0c3d6d09ac9ea5ef3542f1b Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 31 May 2016 15:39:34 +0300 Subject: [PATCH 71/95] Add lol list pageing. Tested, works perf. --- saylol.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/saylol.py b/saylol.py index f1854df..e031b3a 100644 --- a/saylol.py +++ b/saylol.py @@ -5,7 +5,7 @@ from random import randrange lols = open_json_file("lol", []) timeout = 15 last_msg = 0 - +list_limit = 20 def save_lols(): @@ -69,8 +69,23 @@ def on_lol_command(sender, command, label, args): noperm(sender) elif cmd == "list": - for i in range(len(lols)): + arg1 = args[1] if len(args) > 1 else None + if not arg1: + arg1 = "1" + if not arg1.isdigit() or arg1 == "0": + msg(sender, "&cUwot m8 putting invalid data here") + return True + arg1 = int(arg1) - 1 + offset = list_limit * arg1 + if offset > len(lols): + msg(sender, "&cNot enough lol to display. Please pick a smaller page number.") + return True + msg(sender, " &9&nLol list page %s" % str(arg1 + 1)) #"\t" symbol displays weirdly, hence the 4 spaces + for i in range(offset, min(offset + list_limit, len(lols))): msg(sender, "&a%s: &e%s" % (str(i).rjust(3), lols[i])) + msg(sender, "") + msg(sender, "&eFor a specific page, type &a/lol list &e.") + msg(sender, "") #emptyline elif cmd == "search": if sender.hasPermission("utils.lol.search"): @@ -95,9 +110,9 @@ def on_lol_command(sender, command, label, args): msg(sender, "&cInvalid number '&e%s&c'" % args[1]) else: - msg(sender, "&a/lol &eSay random message") - msg(sender, "&a/lol list &eList all messages") - msg(sender, "&a/lol id &eSay specific message") - msg(sender, "&a/lol add &eAdd message") - msg(sender, "&a/lol del &eDelete message") + msg(sender, "&a/lol &eSay random message") + msg(sender, "&a/lol list [page] &eList messages") + msg(sender, "&a/lol id &eSay specific message") + msg(sender, "&a/lol add &eAdd message") + msg(sender, "&a/lol del &eDelete message") return True -- 2.45.2 From 1e34a9b39bcc78bbfd43579ac2a70e19f33b679b Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 31 May 2016 17:09:42 +0300 Subject: [PATCH 72/95] Fix saylol.py for dico By the way, dico, some of your line notes on the previous commit were completely wrong Once again, this has been tested I didn't clean up the code, I think it's good enough. And it works perfectly. --- saylol.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saylol.py b/saylol.py index e031b3a..902e801 100644 --- a/saylol.py +++ b/saylol.py @@ -73,12 +73,12 @@ def on_lol_command(sender, command, label, args): if not arg1: arg1 = "1" if not arg1.isdigit() or arg1 == "0": - msg(sender, "&cUwot m8 putting invalid data here") + msg(sender, "&cInvalid argument \"%s\"" % arg1) return True arg1 = int(arg1) - 1 offset = list_limit * arg1 if offset > len(lols): - msg(sender, "&cNot enough lol to display. Please pick a smaller page number.") + msg(sender, "&cNot a valid page (too high).") return True msg(sender, " &9&nLol list page %s" % str(arg1 + 1)) #"\t" symbol displays weirdly, hence the 4 spaces for i in range(offset, min(offset + list_limit, len(lols))): -- 2.45.2 From 5d00af8cedae09b66a0569e03635a04b0b188a1e Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 31 May 2016 17:34:49 +0300 Subject: [PATCH 73/95] Fix checking for page 0 in saylol.py listing I hope I'm not making this too messy --- saylol.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/saylol.py b/saylol.py index 902e801..3fe2fe5 100644 --- a/saylol.py +++ b/saylol.py @@ -72,9 +72,11 @@ def on_lol_command(sender, command, label, args): arg1 = args[1] if len(args) > 1 else None if not arg1: arg1 = "1" - if not arg1.isdigit() or arg1 == "0": + if not arg1.isdigit(): msg(sender, "&cInvalid argument \"%s\"" % arg1) return True + if int(arg1) == 0: + msg(sender, "&cPage 0 does not exist") arg1 = int(arg1) - 1 offset = list_limit * arg1 if offset > len(lols): -- 2.45.2 From f0ada788bfecd00c2d467f46bbc442af9ed1ecca Mon Sep 17 00:00:00 2001 From: Dico200 Date: Tue, 31 May 2016 16:39:54 +0200 Subject: [PATCH 74/95] Made serversigns force its commands into the command map (to replace the java plugin ServerSigns its commands) --- main.py | 2 +- serversigns.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index ffea209..1b9e3f4 100644 --- a/main.py +++ b/main.py @@ -24,7 +24,7 @@ def on_enable(): if "imbusy" in shared["modules"]: shared["modules"]["imbusy"].replace_ess_commands() if "serversigns" in shared["modules"]: - shared["modules"]["serversigns"].check_all_signs() + shared["modules"]["serversigns"].check_all_signs_and_force_commands() info("RedstonerUtils enabled!") diff --git a/serversigns.py b/serversigns.py index c5238e1..d680acb 100644 --- a/serversigns.py +++ b/serversigns.py @@ -335,7 +335,26 @@ def can_build2(player, block): return not event.isCancelled() -def check_all_signs(): +def check_all_signs_and_force_commands(): for loc in signs: if server.getWorld(loc[0]).getBlockAt(loc[1], loc[2], loc[3]).getType() not in (Material.WALL_SIGN, Material.SIGN_POST): del signs[loc] + + try: + map_field = server.getPluginManager().getClass().getDeclaredField("commandMap") + map_field.setAccessible(True) + command_map = map_field.get(server.getPluginManager()) + + commands_field = command_map.getClass().getDeclaredField("knownCommands") + commands_field.setAccessible(True) + map = commands_field.get(command_map) + + rsutils_cmd = map.get("redstonerutils:serversigns") + info(str(rsutils_cmd)) + map.put("svs", rsutils_cmd) + map.put("serversigns", rsutils_cmd) + map.put("signsmsg", rsutils_cmd) + + except: + error("[Serversigns] failed to force commands") + error(trace()) -- 2.45.2 From 83e75055651eff3a7b1287adc61e92a35b6b03de Mon Sep 17 00:00:00 2001 From: Dico200 Date: Tue, 31 May 2016 16:41:13 +0200 Subject: [PATCH 75/95] Remove debug I forgot to remove in prior commit --- serversigns.py | 1 - 1 file changed, 1 deletion(-) diff --git a/serversigns.py b/serversigns.py index d680acb..722edf8 100644 --- a/serversigns.py +++ b/serversigns.py @@ -350,7 +350,6 @@ def check_all_signs_and_force_commands(): map = commands_field.get(command_map) rsutils_cmd = map.get("redstonerutils:serversigns") - info(str(rsutils_cmd)) map.put("svs", rsutils_cmd) map.put("serversigns", rsutils_cmd) map.put("signsmsg", rsutils_cmd) -- 2.45.2 From f0f32abbfa5cf0c3c710e5816785fd742587b5ab Mon Sep 17 00:00:00 2001 From: PixelSergey Date: Tue, 31 May 2016 17:52:56 +0300 Subject: [PATCH 76/95] Final fix to lol list pageing Can someone tell me whether it's paging or pageing or both? --- saylol.py | 1 + 1 file changed, 1 insertion(+) diff --git a/saylol.py b/saylol.py index 3fe2fe5..b9f0ccb 100644 --- a/saylol.py +++ b/saylol.py @@ -77,6 +77,7 @@ def on_lol_command(sender, command, label, args): return True if int(arg1) == 0: msg(sender, "&cPage 0 does not exist") + return True arg1 = int(arg1) - 1 offset = list_limit * arg1 if offset > len(lols): -- 2.45.2 From 13606638b735acb1112b0aee07c3bb93ffc6f310 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Tue, 31 May 2016 18:03:46 +0200 Subject: [PATCH 77/95] Fix calc --- helpers.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/helpers.py b/helpers.py index 40c313b..285a0f5 100755 --- a/helpers.py +++ b/helpers.py @@ -252,6 +252,21 @@ def save_json_file(filename, obj): error("Failed to write to %s: %s" % (filename, e)) +def toggle(player, ls, name = "Toggle", add = None): + """ + Toggles presence of a player's UUID in a list + If add is given, True explicitely adds it whereas False removes it + """ + pid = uid(player) + if pid in ls or add is False: + ls.remove(pid) + msg(player, "&a%s turned off!" % name) + elif add is not False: + ls.append(pid) + msg(player, "&a%s turned on!" % name) + + + def send_JSON_message(playername, message): bukkit.Bukkit.getServer().dispatchCommand(bukkit.Bukkit.getServer().getConsoleSender(), "tellraw " + playername + " " + message) -- 2.45.2 From 2f943e8b12ac6c8c4d163fe18888e12f7f234df9 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Fri, 3 Jun 2016 20:29:25 +0200 Subject: [PATCH 78/95] Add /clear to serversigns command whitelist --- serversigns.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serversigns.py b/serversigns.py index 722edf8..cc0b119 100644 --- a/serversigns.py +++ b/serversigns.py @@ -17,7 +17,8 @@ commands_whitelist = ( "p h", "plot home", "plot h", "p home", "plotme home", "plotme h", "up", "tppos", - "seen" + "seen", + "clear", ) max_line_length = 256 -- 2.45.2 From 2c94c40c77dcfd10a5c05e89c7119c17c22c82e2 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 5 Jun 2016 13:51:12 +0200 Subject: [PATCH 79/95] Remove /clear from commands whitelist for the time being --- serversigns.py | 1 - 1 file changed, 1 deletion(-) diff --git a/serversigns.py b/serversigns.py index cc0b119..1b6742e 100644 --- a/serversigns.py +++ b/serversigns.py @@ -18,7 +18,6 @@ commands_whitelist = ( "up", "tppos", "seen", - "clear", ) max_line_length = 256 -- 2.45.2 From 8e2ff33dbbdcc52e869d697697a5000771f83476 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 5 Jun 2016 17:46:35 +0200 Subject: [PATCH 80/95] Serversigns permissions fix, adapted help page to user permissions, implemented help pages --- serversigns.py | 133 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 95 insertions(+), 38 deletions(-) diff --git a/serversigns.py b/serversigns.py index 1b6742e..4fe952e 100644 --- a/serversigns.py +++ b/serversigns.py @@ -4,6 +4,7 @@ import org.bukkit.Material as Material import java.util.UUID as UUID import org.bukkit.Material as Material import org.bukkit.block.BlockFace as BlockFace +from math import ceil commands_whitelist = ( "mail", "email", "memo", @@ -22,6 +23,7 @@ commands_whitelist = ( max_line_length = 256 max_lines = 20 +help_page_size = 12 def load_signs(): signs_obj = open_json_file("serversigns", []) @@ -103,6 +105,46 @@ def signsMsg(msg, colour = '4'): return "&c[Signs] &" + colour + msg +# /svs command + + +subcommand_info = ( + + (("claim",), ( + "Claims the sign so that you can add messages to it", + ), (("[owner]", "claims.other"),)), + (("info", "lines"), ( + "Displays information about the (claimed) sign", + )), + (("add",), ( + "Adds the message to the sign. Use ++ at the end", + "to add the message to your buffer. You can then use", + "the same command again to create a longer message", + ), (("[++]", None),)), + (("remove", "rem", "del", "delete"), ( + "Removes the message with the given ID from the sign.", + "The ID is given before each message by &b/svs info&a.", + ), (("", None),)), + (("switch", "reverse"), ( + "Reverses the order in which the given messages are shown.", + ), ((" ", None),)), + (("clear",), ( + "Removes all messages from the sign.", + )), + (("reset", "unclaim"), ( + "Resets the sign, removing all messages and its owner.", + )), + (("whitelist", "commands", "wl"), ( + "Displays a list of whitelisted commands", + )), + (("help",), ( + "Displays this help page", + ), (("[page]", None),)), + +) + + + @simplecommand(cmd = "serversigns", aliases = ["svs", "signmsg"], description = "Makes something happen when you right click signs. \nUse /svs help for more details.", usage = "[++]|remove |clear|info|help>", @@ -110,40 +152,55 @@ def signsMsg(msg, colour = '4'): senderLimit = 0) def svs_command(sender, command, label, args): arg1 = args[0].lower() - Validate.isTrue(arg1 in ("claim", "reset", "add", "remove", "rem", "del", "delete", "info", "lines", - "clear", "help", "switch", "reverse", "unclaim", "commands", "whitelist", "wl"), - signsMsg("That argument could not be recognized, use &o/svs help &4for expected arguments")) - Validate.isAuthorized(sender, "utils.serversigns." + arg1) + + cmd_info = None + for cmd in subcommand_info: + if arg1 in cmd[0]: + cmd_info = cmd + break + + Validate.notNone(cmd_info, signsMsg("That command could not be recognized, use &o/svs help &4for expected arguments")) + cmd = cmd_info[0][0] + Validate.isAuthorized(sender, "utils.serversigns." + cmd) #-------------------- Sub commands that don't require any conditions ----------------------- - if arg1 == "help": - admin = sender.hasPermission("utils.serversigns.admin") - msg = signsMsg("Server signs lets you add messages to a sign.", 'a') - msg += "\nRight clicking the sign will display all the messages. Commands" - msg += "\ncan also be added, by prefixing the message with a '/'." - msg += "\nHow to use &b/serversigns&a:" - msg += "\n&b/svs claim" + ("" if not sender.hasPermission("utils.serversigns.admin") else " [owner]") - msg += "\n&a- Claims the sign so that you can add messages to it" - msg += "\n&b/svs info|lines" - msg += "\n&a- Displays information about the (claimed) sign" - msg += "\n&b/svs add [++]" - msg += "\n&a- Adds the message to the sign. Use ++ at the end" - msg += "\n&a- to add the message to your buffer. You can then use" - msg += "\n&a- the same command again to create a longer message." - msg += "\n&b/svs remove " - msg += "\n&a- Removes the message with the given ID from the sign." - msg += "\n&a- The ID is given before each message by &b/svs info&a." - msg += "\n&b/svs switch|reverse " - msg += "\n&a- Reverses the order in which the given messages are shown." - msg += "\n&b/svs clear" - msg += "\n&a- Removes all messages from the sign." - msg += "\n&b/svs reset|unclaim" - msg += "\n&a- Resets the sign, removing all messages and its owner." - msg += "\n&b/svs commands|whitelist|wl" - msg += "\n&a- Shows a list of whitelisted commands" - return msg + if cmd == "help": + all_lines = [ + "&aServer signs let's you add messages to a sign.", + "Right clicking the sign will display all the messages. Commands", + "can also be added, by prefixing the message with a '/'.", + "How to use &b/serversigns&a:", + ] - if arg1 in ("commands", "whitelist", "wl"): + for cmd in subcommand_info: + if sender.hasPermission("utils.serversigns." + cmd[0][0]): + params = "" + if len(cmd) == 3: + for param, perm in cmd[2]: + if perm is None or sender.hasPermission("utils.serversigns." + perm): + params += param + " " + all_lines.append("&b/svs %s %s" % ("|".join(cmd[0]), params)) + for info_line in cmd[1]: + all_lines.append("&a- " + info_line) + + last_page = int(ceil(len(all_lines) / help_page_size)) + info("last page: %d" % last_page) + page = 1 + if len(args) > 1 and args[1].isdigit(): + page = int(args[1]) + if page <= 0: + page = 1 + elif page > last_page: + page = last_page + + first_line = signsMsg("Serversigns help page %d" % page, '6') + if page < last_page: + first_line += ", &e/svs help %d&6 for the next" % (page + 1) + page_lines = [first_line] + all_lines[(page - 1) * help_page_size : min(page * help_page_size, len(all_lines))] + return "\n".join(page_lines) + + + if cmd == "whitelist": return signsMsg("Whitelisted commands: &3" + ", ".join(commands_whitelist), 'a') #------------------------------------------------------------------------------------------- @@ -156,7 +213,7 @@ def svs_command(sender, command, label, args): arg2 = args[1].lower() if len(args) > 1 else None #------------------------ Sub commands that require the block to be a sign ------------------------------- - if arg1 == "claim": + if cmd == "claim": Validate.isTrue(not sign, signsMsg("The %s was already claimed" % signName)) Validate.isTrue(can_build2(sender, block), signsMsg("You are not permitted to claim signs here")) target = sender @@ -180,7 +237,7 @@ def svs_command(sender, command, label, args): Validate.notNone(sign, signsMsg("The %s has not been claimed" % signName)) #----------------------Sub commands that require the sign to be claimed as well------------------------------------ - if arg1 in ("info", "lines"): + if cmd == "info": sign_lines = "" for id, line in enumerate(sign[1:]): sign_lines += ("\n &a%s: \"&f%s&a\"" % (id + 1, line)) @@ -190,7 +247,7 @@ def svs_command(sender, command, label, args): Validate.isTrue(canEdit(sign, sender), signsMsg("You do not own the %s!" % signName)) #---------------------- Sub commands that require you to own targeted sign as well ------------------------- - if arg1 == "add": + if cmd == "add": Validate.isTrue(len(sign) - 1 <= max_lines, signsMsg("This sign already has the maximum amount of lines, you cannot add more")) line = " ".join(args[1:]) @@ -227,7 +284,7 @@ def svs_command(sender, command, label, args): return signsMsg("Added line \"&f%s&a\" to the %s" % (line, signName), 'a') - if arg1 in ("remove", "rem", "del", "delete"): + if cmd == "remove": Validate.notNone(arg2, signsMsg("You have to enter the ID of the message to remove!")) try: id = int(arg2) @@ -238,7 +295,7 @@ def svs_command(sender, command, label, args): return signsMsg("Removed message with id %s from the %s" % (id, signName), 'a') - if arg1 in ("switch", "reverse"): + if cmd == "switch": Validate.isTrue(len(args) == 3, signsMsg("You have to enter the 2 IDs of the messages to reverse")) try: id1 = int(args[1]) @@ -252,13 +309,13 @@ def svs_command(sender, command, label, args): return signsMsg("Reversed the messages with IDs %s and %s of the %s" % (id1, id2, signName), 'a') - if arg1 == "clear": + if cmd == "clear": signs[loc] = [sign[0]] save_signs() return signsMsg("Removed all messages from the %s" % signName, 'a') - if arg1 in ("reset", "unclaim"): + if cmd == "reset": del signs[loc] save_signs() return signsMsg("Removed all messages and the owner from the %s, it can now be claimed" % signName, 'a') -- 2.45.2 From f5c51645d28ff9e2ded97924d491900be2860ead Mon Sep 17 00:00:00 2001 From: psrcek Date: Sun, 12 Jun 2016 13:34:33 +0200 Subject: [PATCH 81/95] Fixed typo --- blockplacemods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockplacemods.py b/blockplacemods.py index d012e54..37027f4 100644 --- a/blockplacemods.py +++ b/blockplacemods.py @@ -185,7 +185,7 @@ def toggle_command(sender, command, label, args): return " &cAlready disabled: " + details[1] if arglen == 2 and not arg2.isdigit(): - return " &cArgument '%s' was not recognized. \nUse &o/toggle %s details &cfor more detailsrmation." % (arg2, setting) + return " &cArgument '%s' was not recognized. \nUse &o/toggle %s info &cfor more information." % (arg2, setting) if not enabled: values[uuid] = {} -- 2.45.2 From a6ea05a4599dd54f15fc1b164b7ff61cb17b6005 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 12 Jun 2016 18:04:17 +0200 Subject: [PATCH 82/95] made /check display email not confirmed warning --- check.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/check.py b/check.py index 33ffb57..3eb4026 100644 --- a/check.py +++ b/check.py @@ -35,11 +35,11 @@ def get_website_data(player): conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") curs = conn.cursor() uuid = str(uid(player)).replace("-", "") - curs.execute("SELECT DISTINCT `id`, `email` FROM users WHERE `uuid` = ? LIMIT 1", (uuid,)) + curs.execute("SELECT DISTINCT `id`, `email`, `confirmed` FROM users WHERE `uuid` = ? LIMIT 1", (uuid,)) results = curs.fetchall() curs.close() conn.close() - return ("http://redstoner.com/users/%s" % results[0][0], results[0][1]) if results else (None, None) + return ("http://redstoner.com/users/%s" % results[0][0], results[0][1], False if results[0][2] == 0 else True) if results else (None, None, True) # receive country based on the user's IP @@ -68,6 +68,8 @@ def get_all_data(sender, player): website = get_website_data(player) msg(sender, "&6> Website account: &e%s" % website[0]) msg(sender, "&6> email: &e%s" % website[1]) + if not website[2]: + msg(sender, "&6> &cEmail NOT Confirmed!") msg(sender, "&7 -- Data provided by ipinfo.io") msg(sender, "&6> Country: &e%s" % get_country(data)) msg(sender, "&7 -- Data provided by Mojang") -- 2.45.2 From 6320d78a37683966c781b66b40997498c1baeee7 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 12 Jun 2016 18:13:42 +0200 Subject: [PATCH 83/95] Mysql update tweak --- chatalias.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chatalias.py b/chatalias.py index 6febf17..67de106 100644 --- a/chatalias.py +++ b/chatalias.py @@ -6,6 +6,7 @@ import org.bukkit as bukkit from org.bukkit import * from helpers import * + # Version number and requirements alias_version = "2.1.0" @@ -131,7 +132,7 @@ def on_alias_command(sender, cmd, label, args): return if args[0].lower() != "player" and not is_player(sender): msg(sender, "&cThe console cannot have aliases") - return + return True subcommands[args[0].lower()](sender, args[1:]) except: subcommands["help"](sender, "1") @@ -381,9 +382,8 @@ def save_data(uuid): def save_data_thread(uuid): conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") curs = conn.cursor() - value = json_dumps(data[uuid]) - curs.execute("INSERT INTO `chatalias` VALUES (?, ?) ON DUPLICATE KEY UPDATE `alias` = ?;", - (uuid, value, value)) + curs.execute("INSERT INTO `chatalias` (`uuid`, `alias`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `alias` = VALUES(`alias`);", + (uuid, json_dumps(data[uuid]))) conn.commit() curs.close() conn.close() -- 2.45.2 From cebdb90d601cf4cb0889212cc804893a112f10e7 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Sun, 12 Jun 2016 20:02:06 +0200 Subject: [PATCH 84/95] Fix cycle for 1.10 (will break in 1.8 now..) --- cycle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cycle.py b/cycle.py index 2caeac2..17889c9 100644 --- a/cycle.py +++ b/cycle.py @@ -56,7 +56,7 @@ def on_slot_change(event): def do_cycle(player, down): inv = player.getInventory() - items = inv.getContents() + items = inv.getStorageContents() shift = -9 if down else 9 shift = shift % len(items) for _ in range(4): @@ -64,7 +64,7 @@ def do_cycle(player, down): uniq_items = sorted(set(list(items)[:9])) # get unique inventory if uniq_items != [None]: # row not empty break - inv.setContents(items) + inv.setStorageContents(items) def save_cyclers(): save_json_file("cycle", no_cyclers) \ No newline at end of file -- 2.45.2 From 1602ad2185907543e19de100d0c8088150254c2a Mon Sep 17 00:00:00 2001 From: psrcek Date: Tue, 21 Jun 2016 21:46:48 +0200 Subject: [PATCH 85/95] Fix for bug, where you can shift click and toggle levers --- damnspam.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/damnspam.py b/damnspam.py index b3cbb0f..a81d3cf 100644 --- a/damnspam.py +++ b/damnspam.py @@ -173,8 +173,6 @@ def on_block_break(event): def on_interact(event): if (str(event.getAction()) == "RIGHT_CLICK_BLOCK") and not event.isCancelled(): sender = event.getPlayer() - if sender.isSneaking(): - return block = event.getClickedBlock() pos_str = location_str(block) data = inputs.get(pos_str) -- 2.45.2 From 00e936532a93940f41603f18adb37a9a14b268a8 Mon Sep 17 00:00:00 2001 From: psrcek Date: Tue, 21 Jun 2016 22:12:13 +0200 Subject: [PATCH 86/95] Added max page number --- saylol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saylol.py b/saylol.py index b9f0ccb..c5a0705 100644 --- a/saylol.py +++ b/saylol.py @@ -83,7 +83,7 @@ def on_lol_command(sender, command, label, args): if offset > len(lols): msg(sender, "&cNot a valid page (too high).") return True - msg(sender, " &9&nLol list page %s" % str(arg1 + 1)) #"\t" symbol displays weirdly, hence the 4 spaces + msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(len(lols) / list_limit)))) #"\t" symbol displays weirdly, hence the 4 spaces for i in range(offset, min(offset + list_limit, len(lols))): msg(sender, "&a%s: &e%s" % (str(i).rjust(3), lols[i])) msg(sender, "") -- 2.45.2 From 5788cd0b3e2ae37340418d8e546ea245b2d78e21 Mon Sep 17 00:00:00 2001 From: psrcek Date: Wed, 22 Jun 2016 15:13:35 +0200 Subject: [PATCH 87/95] Fixed page showing 1 page too little --- saylol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saylol.py b/saylol.py index c5a0705..e79edf1 100644 --- a/saylol.py +++ b/saylol.py @@ -83,7 +83,7 @@ def on_lol_command(sender, command, label, args): if offset > len(lols): msg(sender, "&cNot a valid page (too high).") return True - msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(len(lols) / list_limit)))) #"\t" symbol displays weirdly, hence the 4 spaces + msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(len(lols) / list_limit) + 1))) #"\t" symbol displays weirdly, hence the 4 spaces for i in range(offset, min(offset + list_limit, len(lols))): msg(sender, "&a%s: &e%s" % (str(i).rjust(3), lols[i])) msg(sender, "") -- 2.45.2 From ae44dade8005bcdcb2cb7328c70c428c2ed723f4 Mon Sep 17 00:00:00 2001 From: psrcek Date: Wed, 22 Jun 2016 15:21:28 +0200 Subject: [PATCH 88/95] fixed derp, should use math.ceil instead of +1 --- saylol.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/saylol.py b/saylol.py index e79edf1..fce356e 100644 --- a/saylol.py +++ b/saylol.py @@ -1,6 +1,7 @@ from time import time from helpers import * from random import randrange +import math lols = open_json_file("lol", []) timeout = 15 @@ -83,7 +84,7 @@ def on_lol_command(sender, command, label, args): if offset > len(lols): msg(sender, "&cNot a valid page (too high).") return True - msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(len(lols) / list_limit) + 1))) #"\t" symbol displays weirdly, hence the 4 spaces + msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(math.ceil(len(lols) / list_limit))))) #"\t" symbol displays weirdly, hence the 4 spaces for i in range(offset, min(offset + list_limit, len(lols))): msg(sender, "&a%s: &e%s" % (str(i).rjust(3), lols[i])) msg(sender, "") -- 2.45.2 From 5da7180bfd89e8fe3ac57a84ba3a2d027bdb1715 Mon Sep 17 00:00:00 2001 From: psrcek Date: Wed, 22 Jun 2016 15:35:52 +0200 Subject: [PATCH 89/95] derp... integer division --- saylol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saylol.py b/saylol.py index fce356e..0d74506 100644 --- a/saylol.py +++ b/saylol.py @@ -84,7 +84,7 @@ def on_lol_command(sender, command, label, args): if offset > len(lols): msg(sender, "&cNot a valid page (too high).") return True - msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(math.ceil(len(lols) / list_limit))))) #"\t" symbol displays weirdly, hence the 4 spaces + msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(math.ceil(len(lols) / float(list_limit)))))) #"\t" symbol displays weirdly, hence the 4 spaces for i in range(offset, min(offset + list_limit, len(lols))): msg(sender, "&a%s: &e%s" % (str(i).rjust(3), lols[i])) msg(sender, "") -- 2.45.2 From a2daa5c0b67c09470050b2a050b2cb4173a36383 Mon Sep 17 00:00:00 2001 From: psrcek Date: Wed, 22 Jun 2016 15:48:20 +0200 Subject: [PATCH 90/95] removed unnecesarry str calls --- saylol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saylol.py b/saylol.py index 0d74506..84172af 100644 --- a/saylol.py +++ b/saylol.py @@ -84,7 +84,7 @@ def on_lol_command(sender, command, label, args): if offset > len(lols): msg(sender, "&cNot a valid page (too high).") return True - msg(sender, " &9&nLol list page %s/%s" % (str(arg1 + 1), str(int(math.ceil(len(lols) / float(list_limit)))))) #"\t" symbol displays weirdly, hence the 4 spaces + msg(sender, " &9&nLol list page %s/%s" % (arg1 + 1, int(math.ceil(len(lols) / float(list_limit))))) #"\t" symbol displays weirdly, hence the 4 spaces for i in range(offset, min(offset + list_limit, len(lols))): msg(sender, "&a%s: &e%s" % (str(i).rjust(3), lols[i])) msg(sender, "") -- 2.45.2 From fd368a8aac7e7eb0a0220476c9d68681dc6ae3d3 Mon Sep 17 00:00:00 2001 From: Dico Date: Thu, 23 Jun 2016 05:21:24 +0200 Subject: [PATCH 91/95] Patch buggy movement blocking when logging in Added a separate event handler for PlayerMoveEvent which instead of cancelling the event, sets the new position to the old one. This should fix the buggy, flashy screen you get when you move your cursor while not yet logged in. --- loginsecurity.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/loginsecurity.py b/loginsecurity.py index 4fbb307..d1607ef 100644 --- a/loginsecurity.py +++ b/loginsecurity.py @@ -12,7 +12,7 @@ from player import get_py_player, py_players wait_time = 30 #seconds admin_perm = "utils.loginsecurity.admin" min_pass_length = 8 -blocked_events = ["block.BlockBreakEvent", "block.BlockPlaceEvent", "player.PlayerMoveEvent","player.AsyncPlayerChatEvent"] +blocked_events = ["block.BlockBreakEvent", "block.BlockPlaceEvent", "player.AsyncPlayerChatEvent"] @@ -273,4 +273,10 @@ def pre_command_proccess(event): args = event.getMessage().split(" ") if not args[0].lower() == "/login": msg(player.player, "&4You need to login before you do that!") - event.setCancelled(True) \ No newline at end of file + event.setCancelled(True) + +@hook.event("player.PlayerMoveEvent","normal") +def player_move(event): + user = get_py_player(event.getPlayer()) + if user.logging_in: + event.setTo(event.getFrom()) -- 2.45.2 From 2b803e8de818302e2a13f76cc5b248e24bf0ef24 Mon Sep 17 00:00:00 2001 From: psrcek Date: Wed, 3 Aug 2016 21:57:40 +0200 Subject: [PATCH 92/95] Added psrcek to pythoners --- misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misc.py b/misc.py index 026650e..e495317 100644 --- a/misc.py +++ b/misc.py @@ -216,7 +216,8 @@ pythoners = ( "e452e012-2c82-456d-853b-3ac8e6b581f5", # Nemes "ae795aa8-6327-408e-92ab-25c8a59f3ba1", # jomo "d2693e91-93e1-4e3f-929f-f38e1ce8df03", # Pepich1851 - "51f2ad3c-6cc8-40ea-aa2b-f25970316921" # Dico200 + "51f2ad3c-6cc8-40ea-aa2b-f25970316921", # Dico200 + "15ad0e60-8691-4e29-9de9-2d6b538bf56d" # psrcek ) @simplecommand("pyeval", -- 2.45.2 From 94accc238a61fbef836cb98ddfd704300f126f78 Mon Sep 17 00:00:00 2001 From: psrcek Date: Wed, 3 Aug 2016 23:48:15 +0200 Subject: [PATCH 93/95] Delete plotter.py We have https://github.com/RedstonerServer/Parcels now. --- plotter.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 plotter.py diff --git a/plotter.py b/plotter.py deleted file mode 100644 index d598554..0000000 --- a/plotter.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/python - -""" -*Very basic* start of a custom plot-plugin like PlotMe -on hold because the PlotMe developer continued to develop PlotMe -""" - -import sys - -x_plot_size = 3 -z_plot_size = 3 -padding = 1 - -def base_coords(x, z): - pid = plot_id(x, z) - return [pid[0] * (x_plot_size + padding), pid[1] * (z_plot_size + padding)] - -def bounds(x, z): - base = base_coords(x, z) - return [base, [base[0] + x_plot_size, base[1] + z_plot_size]] - -def plot_id(x, z): - return [x // (x_plot_size + padding), z // (z_plot_size + padding)] - - -x = int(sys.argv[1]) -z = int(sys.argv[2]) -print "id: %s" % plot_id(x, z) -print "base: %s" % base_coords(x, z) -print "bounds: %s" % bounds(x, z) -- 2.45.2 From 6e497a266270d8ad6ee561abe0cb0e1d7943ce5f Mon Sep 17 00:00:00 2001 From: psrcek Date: Thu, 4 Aug 2016 13:13:56 +0200 Subject: [PATCH 94/95] Fix for bug, where you can use cg without logging in https://redstoner.com/forums/threads/3653-chatgroup-bug --- chatgroups.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chatgroups.py b/chatgroups.py index be29e53..b3838a0 100644 --- a/chatgroups.py +++ b/chatgroups.py @@ -102,8 +102,9 @@ def save_groups(): @hook.event("player.AsyncPlayerChatEvent", "normal") def on_chat(event): sender = event.getPlayer() + user = get_py_player(sender) msge = event.getMessage() - if not event.isCancelled(): + if (not user.logging_in) and (not event.isCancelled()): sender_id = uid(sender) key = get_key(sender_id) keylen = len(key) -- 2.45.2 From 347f6969bf411b160b2fc734a2c52bd4dea6a5be Mon Sep 17 00:00:00 2001 From: psrcek Date: Sun, 11 Sep 2016 19:25:45 +0200 Subject: [PATCH 95/95] Teleport the player twice to fix #50 --- punishments.py | 1 + 1 file changed, 1 insertion(+) diff --git a/punishments.py b/punishments.py index 4b57be1..886d026 100644 --- a/punishments.py +++ b/punishments.py @@ -55,6 +55,7 @@ class Slave(object): def update(self): self.blocks -= 1 if self.blocks <= 0: + server.getPlayer(juuid(self.get_uuid())).teleport(server.getWorld(spawn_world).getSpawnLocation()) server.getPlayer(juuid(self.get_uuid())).teleport(server.getWorld(spawn_world).getSpawnLocation()) slaves.remove(self) save_slaves() -- 2.45.2