Search in sources :

Example 1 with WatsonCommand

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);
            }
        }
    });
}
Also used : WatsonCommand(watson.cli.WatsonCommand) WatsonGuiScreen(watson.gui.WatsonGuiScreen) HighlightCommand(watson.cli.HighlightCommand) Minecraft(net.minecraft.client.Minecraft) Date(java.util.Date) AnnoCommand(watson.cli.AnnoCommand) CalcCommand(watson.cli.CalcCommand) BlockEdit(watson.db.BlockEdit) File(java.io.File)

Aggregations

File (java.io.File)1 Date (java.util.Date)1 Minecraft (net.minecraft.client.Minecraft)1 AnnoCommand (watson.cli.AnnoCommand)1 CalcCommand (watson.cli.CalcCommand)1 HighlightCommand (watson.cli.HighlightCommand)1 WatsonCommand (watson.cli.WatsonCommand)1 BlockEdit (watson.db.BlockEdit)1 WatsonGuiScreen (watson.gui.WatsonGuiScreen)1