28 Commits

Author SHA1 Message Date
Dico200
c3189639f0 Fixes and stuff 2016-05-28 23:05:43 +02:00
Pepich
c534d9316a Moved OnModuleLoad to bottom of file 2016-05-28 22:40:08 +02:00
Pepich
7da3fd5b71 That's an "s", not an "S" ._. 2016-05-28 22:35:28 +02:00
Pepich
a19f0b5bdc Added support for /rl; Made comments more precise 2016-05-28 22:33:38 +02:00
Dico200
1fdf97f77a Add missing _ ... lol 2016-05-25 16:46:49 +02:00
Dico200
16e78a2677 Add missing ) to chatalias 2016-05-25 16:44:09 +02:00
Dico
2d6725df73 Prevent chained aliases in chatalias
Prevents 1 -> 23 along with 2 -> 3 and similar stuff
2016-05-25 16:40:31 +02:00
Dico200
d88baa4899 What is this.. sorry 2016-05-25 16:37:58 +02:00
Dico200
29f846c8f9 Undo prior changes in favor of pull request 2016-05-25 16:31:32 +02:00
Dico
5592e16200 Solidify imbusy blocking pms, tpas, etc.
I used reflection to get the Map<String, Command> 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.
2016-05-25 15:49:11 +02:00
Dico200
9a1006e711 Imbusy command: status <player> tweaked, cleaned up return statements 2016-05-25 03:05:59 +02:00
Dico200
29e7ce174b Imbusy command: Replace plugin_header calls with a single one at the start 2016-05-25 03:02:01 +02:00
Dico200
8165d5977b Small change to imbusy messages 2016-05-25 03:00:35 +02:00
Dico200
fca3cf250c Imbusy: Fixed typos and some *flaws* which I will disregard here @curs3d 2016-05-25 02:52:24 +02:00
Dico200
7fdaee155a Fix yo shitty chatgroups code 2016-05-25 02:46:53 +02:00
Dico200
4e6bd44c38 Undoing these small changes from last commit... 2016-05-25 02:40:50 +02:00
Dico200
a555676076 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. 2016-05-25 02:39:05 +02:00
Dico
cb1a333a56 Merge pull request #41 from RedstonerServer/chatalias
Fixed player subcommand, removed debug outputs
2016-05-25 01:38:10 +02:00
Dico
07039b3d16 Fix command given for next help page in chatalias.py 2016-05-25 01:37:01 +02:00
Pepich
48251e1e52 Cleanup, adding debug outputs back, removing empty try/catch phrases 2016-04-12 14:52:16 +02:00
Pepich
fa1d5e900d Fixed player subcommand, removed debug outputs 2016-04-11 16:59:42 +02:00
jomo
622971c41c Merge pull request #40 from RedstonerServer/tweaks
Fixed indentation error ll 39-41 (damnspam)
2016-04-11 15:35:43 +02:00
Pepich
d81d17b5f2 Merge pull request #39 from psrcek/dev
removed some unnecesary code
2016-03-26 22:08:34 +01:00
psrcek
c870561f7d 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:
2016-03-26 21:56:10 +01:00
Dico200
286f8751b5 Fix tab -.- lol why did it load locally? 2016-03-12 01:02:48 +01:00
Dico200
fad1ae0f90 Fixed a return message in blockplacemods.py 2016-03-12 01:00:07 +01:00
PixelSergey
621f4ca23b Added a debug decorator, use @debug to nicely print function errors 2016-03-08 20:32:56 +02:00
jomo
f2dfc6c473 Merge pull request #37 from RedstonerServer/tweaks
Minor tweaks
2016-02-15 17:48:22 +01:00
8 changed files with 253 additions and 82 deletions

View File

@@ -150,7 +150,8 @@ def toggle_command(sender, command, label, args):
if arg2 == "clear": if arg2 == "clear":
if enabled: if enabled:
del values[uuid] del values[uuid]
return " &aDisabled " + details[1] return " &aDisabled " + details[1]
return " &cAlready disabled: " + details[1]
if arg2 == "details": if arg2 == "details":
return " &aSetting %s:\n &9%s \n&6Accepted arguments: [<slot>|clear|details]" % (setting, details[2]) return " &aSetting %s:\n &9%s \n&6Accepted arguments: [<slot>|clear|details]" % (setting, details[2])

View File

@@ -11,6 +11,7 @@
############################################ ############################################
import os import os
import mysqlhack
import org.bukkit as bukkit import org.bukkit as bukkit
from org.bukkit import * from org.bukkit import *
from helpers import * from helpers import *
@@ -26,6 +27,7 @@ error = colorify("&cUnspecified error")
commands_per_page = 5 commands_per_page = 5
global_aliases = {"./":"/"} global_aliases = {"./":"/"}
data = {} 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 = False
# Permissions: # Permissions:
@@ -53,11 +55,6 @@ permission_FINFO = "utils.alias.finfo"
# CODE # # CODE #
######## ########
enabled = helpers_version in helpers_versions
if not enabled:
error = colorify("&6Incompatible versions detected (&chelpers.py&6)")
def safe_open_json(uuid): def safe_open_json(uuid):
if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"): if not os.path.exists("plugins/redstoner-utils.py.dir/files/aliases"):
os.makedirs("plugins/redstoner-utils.py.dir/files/aliases") os.makedirs("plugins/redstoner-utils.py.dir/files/aliases")
@@ -83,7 +80,6 @@ def on_alias_command(sender, cmd, label, args):
return True return True
return subcommands[args[0].lower()](sender, args[1:]) return subcommands[args[0].lower()](sender, args[1:])
except: except:
print(trace())
return subcommands["help"](sender, "1") return subcommands["help"](sender, "1")
@@ -117,22 +113,19 @@ def help(sender, args):
for message in to_display: for message in to_display:
msg(sender, message) msg(sender, message)
if page+1 < pages: 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 return True
@hook.event("player.PlayerJoinEvent", "high") @hook.event("player.PlayerJoinEvent", "high")
def on_join(event): def on_join(event):
try: if enabled:
if enabled: t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), ))
t = threading.Thread(target=load_data, args=(uid(event.getPlayer()), )) t.daemon = True
t.daemon = True t.start()
t.start() else:
else: if event.getPlayer().hasPermission(permission_FINFO):
if event.getPlayer().hasPermission(permission_FINFO): disabled_fallback(event.getPlayer())
disabled_fallback(event.getPlayer())
except:
print(trace())
@hook.event("player.AsyncPlayerChatEvent", "high") @hook.event("player.AsyncPlayerChatEvent", "high")
@@ -156,6 +149,7 @@ def on_player_chat(event):
except: except:
print(trace()) print(trace())
def hasPerm(player, permission): def hasPerm(player, permission):
return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL)) return (player.hasPermission(permission)) or (player.hasPermission(permission_ALL))
@@ -179,39 +173,64 @@ def add(sender, args):
msg(sender, "&cCould not create alias: Max_limit reached!") msg(sender, "&cCould not create alias: Max_limit reached!")
return True return True
args = [args[0]] + [" ".join(args[1:])] args = [args[0]] + [" ".join(args[1:])]
data[str(uid(sender))][str(args[0])] = args[1] if not add_alias_data(uid(sender), str(args[0]), args[1]):
save_data(uid(sender)) 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")) msg(sender, colorify("&7Alias: ") + args[0] + colorify("&7 -> " + args[1] + colorify("&7 was succesfully created!")), usecolor=sender.hasPermission("essentials.chat.color"))
return True return True
def radd(sender, args): def radd(sender, args):
args = [args[0:1]] + [" ".join([args[2:len(args)-2]])] + [args[len(args)-1]]
plugin_header(sender, "Alias") 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": if args[3].lower() == "false":
plugin_header(target, "Alias") plugin_header(target, "Alias")
msg(target, "&cPlayer " + sender_name + " &cis creating an alias for you!") 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)): 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!") msg(sender, "&cCould not create alias: Max_limit reached!")
if args[3].lower() == "false": if args[3].lower() == "false":
msg(target, "&cCould not create alias: Max_limit reached!") msg(target, "&cCould not create alias: Max_limit reached!")
return True 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: if len(args) == 3:
args += ["true"] args += ["true"]
data[str(uid(target))][str(args[1])] = str(args[2]) if not add_alias_data(uid(target), str(args[1]), str(args[2])):
save_data(uid(target)) 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")) 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": 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")) msg(target, colorify("&7Alias: ") + args[1] + colorify("&7 -> " + args[2] + colorify("&7 was succesfully created!")), usecolor=target.hasPermission("essentials.chat.color"))
return True 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): def remove(sender, args):
plugin_header(sender, "Alias") plugin_header(sender, "Alias")
try: try:
@@ -226,11 +245,10 @@ def rremove(sender, args):
plugin_header(sender, "Alias") plugin_header(sender, "Alias")
target = get_player(args[0]) target = get_player(args[0])
if is_player(sender): if is_player(sender):
sender_name = colorify(sender.getDisplayName) sender_name = colorify(sender.getDisplayName())
else: else:
sender_name = colorify("&6Console") sender_name = colorify("&6Console")
if args[2].lower() == "false": if args[2].lower() == "false":
print("WTF")
plugin_header(target, "Alias") plugin_header(target, "Alias")
msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!") msg(target, "&cPlayer " + sender_name + " &cis removing an alias for you!")
try: try:
@@ -258,7 +276,7 @@ def rlist_alias(sender, args):
plugin_header(sender, "Alias") plugin_header(sender, "Alias")
target = get_player(args[0]) target = get_player(args[0])
if is_player(sender): if is_player(sender):
sender_name = colorify(sender.getDisplayName) sender_name = colorify(sender.getDisplayName())
else: else:
sender_name = colorify("&6Console") sender_name = colorify("&6Console")
if len(args) == 1: if len(args) == 1:
@@ -266,23 +284,29 @@ def rlist_alias(sender, args):
msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):") msg(sender, "Player " + args[0] + " has following aliases (" + str(len(data[uid(target)])) + " in total):")
if args[1].lower() == "false": if args[1].lower() == "false":
plugin_header(target, "Alias") 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(): for word, alias in data[str(uid(target))].items():
msg(sender, colorify("&7") + word + colorify("&7 -> ") + alias, usecolor=target.hasPermission("essentials.chat.color")) 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 return True
def remote(sender, args): def remote(sender, args):
try: try:
return remotes[args[1].lower()](sender, [args[0]] + [args[2:]]) return remotes[args[1].lower()](sender, [args[0]] + args[2:])
except: except:
print(trace())
return subcommands["help"](sender, ["2"]) return subcommands["help"](sender, ["2"])
def load_data(uuid): 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: if use_mysql:
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
curs = conn.cursor() curs = conn.cursor()
@@ -297,6 +321,15 @@ def load_data(uuid):
def save_data(uuid): 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: if use_mysql:
conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver") conn = zxJDBC.connect(mysql_database, mysql_user, mysql_pass, "com.mysql.jdbc.Driver")
curs = conn.cursor() curs = conn.cursor()
@@ -304,18 +337,38 @@ def save_data(uuid):
else: else:
save_json_file("aliases/" + uuid, data[uuid]) save_json_file("aliases/" + uuid, data[uuid])
# Subcommands:
# Subcommands:
subcommands = { subcommands = {
"help": help, "help": help,
"?": help,
"add": add, "add": add,
"remove": remove, "remove": remove,
"del": remove,
"delete": remove,
"player": remote, "player": remote,
"remote": remote,
"list": list_alias "list": list_alias
} }
remotes = { remotes = {
"add": radd, "add": radd,
"remove": rremove, "remove": rremove,
"del": rremove,
"delete": rremove,
"list": rlist_alias, "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(player), ))
t.daemon = True
t.start()
else:
if player.hasPermission(permission_FINFO):
disabled_fallback(player)

View File

@@ -89,7 +89,7 @@ def groupchat(sender, message, ann = False):
def do_for_chatgroup(group, func, *args, **kwargs): def do_for_chatgroup(group, func, *args, **kwargs):
for receiver in server.getOnlinePlayers(): for receiver in server.getOnlinePlayers():
if groups.get(uid(receiver)) == group: if groups.get(uid(receiver)) == group:
func(receiver, args, kwargs) func(receiver, *args, **kwargs)
def send_tpa_request(receiver, sender): def send_tpa_request(receiver, sender):
if not receiver == sender: if not receiver == sender:

View File

@@ -47,8 +47,6 @@ def on_dammnspam_command(sender, command, label, args):
timeout_on = round(float(timeout_on), 2) timeout_on = round(float(timeout_on), 2)
timeout_off = timeout_on timeout_off = timeout_on
if 60 >= timeout_on <= -2 or timeout_on == 0: 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.") msg(sender, "&cThe timeout must be within 0-60 or -1.")
return True return True
except ValueError: except ValueError:

View File

@@ -314,3 +314,13 @@ def array_to_list(array):
for a in array: for a in array:
return_list += [a] return_list += [a]
return return_list return return_list
#debug wrapper
def debug(func):
def wrap(*args, **kwargs):
try:
func(*args, **kwargs)
except:
print(trace())
return wrap

188
imbusy.py
View File

@@ -13,12 +13,14 @@
from helpers import * from helpers import *
from basecommands import simplecommand from basecommands import simplecommand
import org.bukkit.command.Command as Command
from traceback import format_exc as trace from traceback import format_exc as trace
busy_players = [] busy_players = []
def unclear(): def unclear(sender):
msg(sender, "Umm, what? Sorry, directions unlclear, got head stuck in washing machine") msg(sender, "Umm, what? Sorry, directions unclear, got head stuck in washing machine")
@hook.command("busy", @hook.command("busy",
@@ -32,83 +34,191 @@ def on_busy_command(sender, cmd, label, args):
msg(sender, "Sorry, Console cannot be busy") msg(sender, "Sorry, Console cannot be busy")
return True return True
plugin_header(recipient = sender, name = "I'M BUSY!")
if not sender.hasPermission("utils.busy.allowed"): if not sender.hasPermission("utils.busy.allowed"):
plugin_header(recipient = sender, name = "I'M BUSY!")
noperm(sender) noperm(sender)
return True return True
if len(args) == 0: 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, "This plugin allows being busy, and when turned on you will not recieve any direct messages or tpa requests.")
msg(sender, "\nCommands:") msg(sender, "\nCommands:")
msg(sender, "/busy on: turns on busy mode") msg(sender, "/busy on: turns on busy mode")
msg(sender, "/busy off: turns off busy mode") msg(sender, "/busy off: turns off busy mode")
msg(sender, "/busy status [player]: shows your or [player]'s current busy status.") msg(sender, "/busy status [player]: shows your or [player]'s current busy status.")
return True
elif len(args) == 1: elif len(args) == 1:
if args[0] == "on": if args[0] == "on":
if sender.getName() in busy_players: 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!") msg(sender, "You cannot be even more focused than this without being a jedi!")
return True else:
busy_players.append(sender.getName()) busy_players.append(sender.getName())
plugin_header(recipient = sender, name = "I'M BUSY!") broadcast(None, "&c[&2Busy&c] &fNow busy: %s&r, don't even TRY bothering them!" % sender.getDisplayName())
broadcast(None, "%s is now SUPER busy! Don't even TRY bothering them, it will not work!" % sender.getName())
return True
elif args[0] == "off": elif args[0] == "off":
plugin_header(recipient = sender, name = "I'M BUSY!")
try: try:
busy_players.remove(sender.getName()) 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&r is freeee of bothering!" % sender.getDisplayName())
return True
except ValueError: except ValueError:
msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?") msg(sender, "You are not busy! You cannot be even less busy! Are you perhaps bored?")
return True
elif args[0] == "status": elif args[0] == "status":
plugin_header(recipient = sender, name = "I'M BUSY!")
if sender.getName() in busy_players: if sender.getName() in busy_players:
msg(sender, "You are super-duper busy and concentrated right now. Think, think, think!") msg(sender, "You are super-duper busy and concentrated right now. Think, think, think!")
return True
else: else:
msg(sender, "You are completely unable to focus right now.") msg(sender, "You are completely unable to focus right now.")
return True
else: else:
plugin_header(recipient = sender, name = "I'M BUSY!") unclear(sender)
unclear()
return False return False
elif len(args) == 2 and args[0] == "status": elif len(args) == 2 and args[0] == "status":
plugin_header(recipient = sender, name = "I'M BUSY!") target = server.getPlayer(args[1])
if args[1] in busy_players: if target is None:
msg(sender, "Yes, %s is busy. Shhh..." % args[1]) msg(sender, "That player is not online, I doubt they are busy.")
return True elif target.getName() in busy_players:
msg(sender, "Yes, %s&r is busy. Shhh..." % target.getDisplayName())
else: else:
msg(sender, "No, you're good. Feel free to chat with %s!" % args[1]) msg(sender, "No, you're good. Feel free to chat with %s&r!" % target.getDisplayName())
return True
else: else:
plugin_header(recipient = sender, name = "I'M BUSY!") unclear(sender)
unclear()
return False return False
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") @hook.event("player.PlayerQuitEvent", "lowest")
def on_player_leave(event): def on_player_leave(event):
try: try:
busy_players.remove(event.getPlayer().getName()) busy_players.remove(event.getPlayer().getName())
except: except:
pass 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())

View File

@@ -43,7 +43,7 @@ shared["load_modules"] = [
# Adds /calc, toggles automatic solving of Math expressions in chat # Adds /calc, toggles automatic solving of Math expressions in chat
"calc", "calc",
# Adds aliasing of chat words # Adds aliasing of chat words
#"chatalias", "chatalias",
# Plugin to locate laggy chunks. /lc <n> lists chunks with more than n entities # Plugin to locate laggy chunks. /lc <n> lists chunks with more than n entities
"lagchunks", "lagchunks",
# Adds /report and /rp, Stores reports with time and location # Adds /report and /rp, Stores reports with time and location

View File

@@ -2,4 +2,3 @@ name: RedstonerUtils
main: main.py main: main.py
version: 3.1.0 version: 3.1.0
author: redstone_sheep author: redstone_sheep