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 *
|
# can't import * because that's not working with nested functions & decorators
|
||||||
|
import helpers
|
||||||
#########################################################
|
|
||||||
# #
|
|
||||||
# I may or may have not trademarked the name -Nemes #
|
|
||||||
# #
|
|
||||||
#########################################################
|
|
||||||
|
|
||||||
debug_perm = "utils.hypercommand.debug"
|
|
||||||
|
|
||||||
# cmd = the actual command
|
# 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
|
# helpnoargs = print help if no args given, else run the command function below decorator
|
||||||
# console = can be ran by console
|
# console = can be ran by console
|
||||||
def hypercommand(cmd, tree = [], helpnoargs = False, console = False):
|
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):
|
def help_msg(sender, tree):
|
||||||
for data in tree:
|
for data in tree:
|
||||||
if len(data["cont"]) > 0:
|
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:
|
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
|
return None
|
||||||
|
|
||||||
has_help = False
|
has_help = False
|
||||||
@@ -73,24 +66,22 @@ def hypercommand(cmd, tree = [], helpnoargs = False, console = False):
|
|||||||
def call(sender, command, label, args):
|
def call(sender, command, label, args):
|
||||||
message = run(sender, command, label, args)
|
message = run(sender, command, label, args)
|
||||||
if message:
|
if message:
|
||||||
msg(sender, message)
|
helpers.msg(sender, message)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def run(sender, command, label, args):
|
def run(sender, command, label, args):
|
||||||
if not is_player(sender) and not console:
|
if not helpers.is_player(sender) and not console:
|
||||||
return "This command can only be executed by players"
|
return "&cThis command can only be executed by players"
|
||||||
|
try:
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
if helpnoargs:
|
if helpnoargs:
|
||||||
help_msg(sender, tree)
|
help_msg(sender, tree)
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
return function(sender, command, label, args)
|
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)
|
return get_next(sender, tree, args, args)
|
||||||
|
except:
|
||||||
|
helpers.error(helpers.trace())
|
||||||
|
return "&cInternal Error. Please report to staff!"
|
||||||
return call
|
return call
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user