Change to /modules... trying to make @command work.

@command throws an error when it tries to access current_subs, which
supposedly didn't exist. current_subs stores all subcommands found when
defining the method which @command was added to. (These SHOULD be called
first)
This commit is contained in:
Dico200
2015-04-08 22:32:14 +02:00
parent f7abc20ca1
commit 201c766119
2 changed files with 14 additions and 7 deletions

View File

@@ -7,7 +7,6 @@ current_main = None
to_see_permission = "utils.showpermission" # See cmd permission in help to_see_permission = "utils.showpermission" # See cmd permission in help
def maincommand(function): def maincommand(function):
global current_main
current_main = function current_main = function
return function return function
@@ -37,7 +36,6 @@ class subcommand():
self.call = None self.call = None
def __call__(self, f): def __call__(self, f):
global current_subs
def call_sub(sender, command, label, args): def call_sub(sender, command, label, args):
isPlayer = is_player(sender) isPlayer = is_player(sender)
if not isSenderValid(senderLimit, isPlayer): if not isSenderValid(senderLimit, isPlayer):
@@ -85,7 +83,6 @@ def command(cmd,
cmd = cmd.lower() cmd = cmd.lower()
global curent_subs
subcommands = [] subcommands = []
for subcmd in current_subs: for subcmd in current_subs:
subcmd.setParent(cmd) subcmd.setParent(cmd)
@@ -93,7 +90,6 @@ def command(cmd,
info(subcommands) info(subcommands)
current_subs = [] current_subs = []
global current_main
main_function = current_main main_function = current_main
current_main = None current_main = None
if main_function == None and len(subcommands) != 0: if main_function == None and len(subcommands) != 0:

17
misc.py
View File

@@ -6,6 +6,7 @@ import thread
import org.bukkit.inventory.ItemStack as ItemStack import org.bukkit.inventory.ItemStack as ItemStack
import org.bukkit.Bukkit as Bukkit import org.bukkit.Bukkit as Bukkit
import org.bukkit.event.player.PlayerChatEvent as PlayerChatEvent import org.bukkit.event.player.PlayerChatEvent as PlayerChatEvent
import basecommands
from basecommands import simplecommand from basecommands import simplecommand
""" """
@@ -86,6 +87,18 @@ def on_me_command(sender, command, label, args):
broadcast("utils.me", "&7- %s &7%s %s" % (sender.getDisplayName() if isinstance(sender, Player) else "&9CONSOLE", u"\u21E6", " ".join(args))) broadcast("utils.me", "&7- %s &7%s %s" % (sender.getDisplayName() if isinstance(sender, Player) else "&9CONSOLE", u"\u21E6", " ".join(args)))
return None return None
"""
@basecommands.command("damnyou", aliases = ["dam"])
def damnyou_command():
@basecommands.subcommand("me")
def me(sender, command, label, args):
info("me ran")
@basecommands.maincommand
def main(sender, command, label, args):
info("main ran")
"""
#@hook.command("gm") #@hook.command("gm")
#def on_gm_command(sender, args): #def on_gm_command(sender, args):
@@ -192,9 +205,7 @@ def on_modules_command(sender, command, label, args):
list all modules, unloaded modules in red list all modules, unloaded modules in red
""" """
plugin_header(sender, "Modules") plugin_header(sender, "Modules")
for mod in shared["load_modules"]: msg(sender, ", ".join([(("&a" if mod in shared["modules"] else "&c") + mod) for mod in shared["load_modules"]]))
color = "a" if mod in shared["modules"] else "c"
msg(sender, "&" + color + mod)
@hook.event("player.PlayerTeleportEvent") @hook.event("player.PlayerTeleportEvent")