Fixed hypercommand exceptions
Apparently jython, nested functions, decorators, and wildcard import don't work well together. I changed the import to non-wildcard and prefixed all function calls with the module name
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
from helpers import *
|
||||
|
||||
#########################################################
|
||||
# #
|
||||
# I may or may have not trademarked the name -Nemes #
|
||||
# #
|
||||
#########################################################
|
||||
|
||||
debug_perm = "utils.hypercommand.debug"
|
||||
# can't import * because that's not working with nested functions & decorators
|
||||
import helpers
|
||||
|
||||
# cmd = the actual command
|
||||
# tree = the subcommand/argument/permission/function tree
|
||||
# tree = e.g. [{ "name": "subcommand", "perm": "utils.cmd.command.subcommand", "func": <function>, "type": "cmd", "cont": [<tree>] }]
|
||||
# helpnoargs = print help if no args given, else run the command function below decorator
|
||||
# console = can be ran by console
|
||||
def hypercommand(cmd, tree = [], helpnoargs = False, console = False):
|
||||
@@ -25,9 +18,9 @@ def hypercommand(cmd, tree = [], helpnoargs = False, console = False):
|
||||
def help_msg(sender, tree):
|
||||
for data in tree:
|
||||
if len(data["cont"]) > 0:
|
||||
msg(sender, "&e-&a " + (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">")) + " " + help_msg_get(data["cont"])
|
||||
helpers.msg(sender, "&e-&a " + (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">")) + " " + help_msg_get(data["cont"]))
|
||||
else:
|
||||
msg(sender, "&e-&a " + (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">"))
|
||||
helpers.msg(sender, "&e-&a " + (data["name"] if data["type"] == "cmd" else ("<" + data["name"] + ">")))
|
||||
return None
|
||||
|
||||
has_help = False
|
||||
@@ -73,24 +66,22 @@ def hypercommand(cmd, tree = [], helpnoargs = False, console = False):
|
||||
def call(sender, command, label, args):
|
||||
message = run(sender, command, label, args)
|
||||
if message:
|
||||
msg(sender, message)
|
||||
helpers.msg(sender, message)
|
||||
return True
|
||||
|
||||
def run(sender, command, label, args):
|
||||
if not is_player(sender) and not console:
|
||||
return "This command can only be executed by players"
|
||||
if not helpers.is_player(sender) and not console:
|
||||
return "&cThis command can only be executed by players"
|
||||
try:
|
||||
if len(args) == 0:
|
||||
if helpnoargs:
|
||||
help_msg(sender, tree)
|
||||
return None
|
||||
else:
|
||||
try:
|
||||
return function(sender, command, label, args)
|
||||
except:
|
||||
print trace()
|
||||
return "&cAn internal error occured while attempting to perform this command"
|
||||
return get_next(sender, tree, args, args)
|
||||
|
||||
except:
|
||||
helpers.error(helpers.trace())
|
||||
return "&cInternal Error. Please report to staff!"
|
||||
return call
|
||||
return decorator
|
||||
|
||||
|
||||
Reference in New Issue
Block a user