use of watson.cli.WatsonCommand in project watson by totemo.
the class Controller method initialise.
// --------------------------------------------------------------------------
/**
* Mod-wide initialisation tasks, including loading configuration files and
* setting up commands.
*/
public void initialise() {
createBlockEditDirectory();
BlockTypeRegistry.instance.loadBlockTypes();
Chat.getChatHighlighter().loadHighlights();
// Initialise the commands.
ClientCommandManager.instance.registerCommand(new WatsonCommand());
ClientCommandManager.instance.registerCommand(new AnnoCommand());
ClientCommandManager.instance.registerCommand(new HighlightCommand());
ClientCommandManager.instance.registerCommand(new CalcCommand());
// Set up event handlers for key bindings.
final Configuration config = Configuration.instance;
config.KEYBIND_INGAME.setDisplayDependent(false);
config.KEYBIND_INGAME.setHandler(new Runnable() {
@Override
public void run() {
Minecraft.getMinecraft().displayGuiScreen(new WatsonGuiScreen());
}
});
config.KEYBIND_SCREENSHOT.setDisplayDependent(false);
config.KEYBIND_SCREENSHOT.setHandler(new Runnable() {
@Override
public void run() {
Date now = new Date();
Configuration config = Configuration.instance;
String player = (String) Controller.instance.getVariables().get("player");
String subdirectoryName = (player != null && config.isSsPlayerDirectory()) ? player : config.getSsDateDirectory().format(now).toString();
Minecraft mc = Minecraft.getMinecraft();
File screenshotsDir = new File(mc.mcDataDir, "screenshots");
File subdirectory = new File(screenshotsDir, subdirectoryName);
File file = Screenshot.getUniqueFilename(subdirectory, player, now);
Chat.localChat(Screenshot.save(file, mc.displayWidth, mc.displayHeight));
}
});
config.KEYBIND_TP_NEXT.setHandler(new Runnable() {
@Override
public void run() {
getBlockEditSet().getOreDB().tpNext();
}
});
config.KEYBIND_TP_PREV.setHandler(new Runnable() {
@Override
public void run() {
getBlockEditSet().getOreDB().tpPrev();
}
});
Controller.instance.queryPreEdits(config.getPreCount());
config.KEYBIND_QUERY_BEFORE.setHandler(new Runnable() {
@Override
public void run() {
queryPreEdits(config.getPreCount());
}
});
config.KEYBIND_QUERY_AFTER.setHandler(new Runnable() {
@Override
public void run() {
queryPostEdits(config.getPostCount());
}
});
config.KEYBIND_CURSOR_NEXT.setHandler(new Runnable() {
@Override
public void run() {
// in which case it does not belong to a set of player edits.
if (_selection != null && _selection.playerEditSet != null) {
BlockEdit edit = _selection.playerEditSet.getEditAfter(_selection);
if (edit != null) {
selectBlockEdit(edit);
}
}
}
});
config.KEYBIND_CURSOR_PREV.setHandler(new Runnable() {
@Override
public void run() {
// in which case it does not belong to a set of player edits.
if (_selection != null && _selection.playerEditSet != null) {
BlockEdit edit = _selection.playerEditSet.getEditBefore(_selection);
if (edit != null) {
selectBlockEdit(edit);
}
}
}
});
config.KEYBIND_TP_CURSOR.setHandler(new Runnable() {
@Override
public void run() {
if (_selection != null) {
teleport(_selection.x, _selection.y, _selection.z);
}
}
});
}
Aggregations