Added command intercepter tool, used it for //calc #49

Closed
Dico200 wants to merge 8 commits from command-intercepter into dev
Showing only changes of commit 5b118669b6 - Show all commits

10
misc.py
View File

@ -55,7 +55,10 @@ class CommandInterceptions:
# But without this snippet, the server shuts itself down because
# commands can't be aliases for themselves (shrug) :)
aliases = wrapped.getAliases()
try:
aliases.remove(wrapped.getLabel())
except:
pass
self.setAliases(aliases)
self.wrapped = wrapped
self.intercepter = intercepter
@ -74,8 +77,6 @@ class CommandInterceptions:
@staticmethod
def add_interception(key, intercepted):
try:
info("Adding interception for /" + key)
registration = CommandInterceptions.registrations[key]
tab_completer = registration[1]
if tab_completer is None:
@ -85,8 +86,6 @@ class CommandInterceptions:
for entry in CommandInterceptions.cmd_map.entrySet():
if entry.getValue() is intercepted:
entry.setValue(cmd_intercepter)
except:
error(trace())
@staticmethod
def init_interceptions():
@ -103,7 +102,6 @@ class CommandInterceptions:
return HashMap.put(self, key, value)
def put(self, key, value):
try:
for intercepted in CommandInterceptions.interceptions:
if value is intercepted:
return self.java_put(key, CommandInterceptions.interceptions[intercepted])
@ -111,8 +109,6 @@ class CommandInterceptions:
if key in CommandInterceptions.registrations:
CommandInterceptions.add_interception(key, value)
return ret
except:
error(trace())
try:
map_field = server.getPluginManager().getClass().getDeclaredField("commandMap")