import types
import sys
__CONSOLE_LOCK = False
import java
from com.smartfoxserver.v2.entities.data import *
__scripts = [
{'name':'version()', 'doc':'Shows the Console extension version'},
{'name':'reloadScripts()', 'doc':'Reload the dynamic server scripts'},
{'name':'execute()', 'doc':'Launches the last loaded script again'},
{'name':'files(path)', 'doc':'Shows the files at the specified path'},
{'name':'controller(id)', 'doc':'Obtain one of the controllers from its id. 0=System, 1=Extension, 2=Smasher'},
{'name':'zones()', 'doc':'List of active zones'}
]
__shortcuts = [
{'name':'ESC', 'doc':'Clears current command'},
{'name':'UP ARROW', 'doc':'Previous command in history'},
{'name':'DOWN ARROW', 'doc':'Next command in history'},
{'name':'CTRL + SPACE', 'doc':'Show command history'},
{'name':'CTRL + BACKSPACE', 'doc':'Clear console text'}
]
grid = None
if sfs.isGrid():
from com.smartfoxserver.grid import SFSGrid
grid = SFSGrid.manager()
_2XGlobals_['grid'] = grid
def help():
"""Shows a list of useful global objects"""
text = ""
for (key, value) in _2XGlobals_.items():
if value != None:
cl = str(value.getClass())
text += "" + key + "\t\t\t" + cl.split(".")[-1] + "\n"
text += "\nextras()\t\tFor more custom function calls"
text += "\nshortcuts()\tFor keyboard shortcuts details\n"
return text
def shortcuts():
"""Shows list of useful keyboard shortcuts"""
return __showList__(__shortcuts)
def extras():
"""Shows list of useful methods"""
return __showList__(__scripts)
def version():
return __parent__.VER
def controller(id):
from java.lang import Byte
bb = Byte(id)
return eng.controllerManager.getControllerById(bb)
def reloadScripts():
__parent__.init()
return "[[ Reload success! ]]"
def files(path='.'):
import os
return os.listdir(path)
def zones():
return zm.getZoneList()
def __showList__(someList):
text = ""
for item in someList:
text += "" + item['name'] + ""
text += ":" + __getSpacer__(item['name']) + item['doc'] + "\n"
return text
def __hints__(obj, target):
if obj == None:
return
hints = None
try:
hints = [item for item in dir(obj)]
except:
pass
# No hints available
if hints == None or len(hints) == 0:
hints = []
# Send hint list
from com.smartfoxserver.v2.entities.data import SFSObject
sfso = SFSObject()
sfso.putUtfStringArray('h', hints)
return sfso
def __getSpacer__(inputStr):
DEFAULT_SPACES = 25
spacer = " "
nSpaces = DEFAULT_SPACES - len(inputStr)
if nSpaces > 0:
spacer = " " * nSpaces
return spacer