Search in sources :

Example 6 with BlockEdit

use of watson.db.BlockEdit 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)

Example 7 with BlockEdit

use of watson.db.BlockEdit in project watson by totemo.

the class Controller method selectPosition.

// selectBlockEdit
// --------------------------------------------------------------------------
/**
   * Set the coordinate variables x, y and z.
   *
   * @param x the x.
   * @param y the y.
   * @param z the z.
   */
public void selectPosition(int x, int y, int z) {
    // selected as an edit.
    if (_selection == null || _selection.x != x || _selection.y != y || _selection.z != z) {
        _selection = new BlockEdit(0, "", false, x, y, z, null);
    }
    _variables.put("x", x);
    _variables.put("y", y);
    _variables.put("z", z);
    _selectionChanged = true;
}
Also used : BlockEdit(watson.db.BlockEdit)

Example 8 with BlockEdit

use of watson.db.BlockEdit in project watson by totemo.

the class PrismAnalysis method dateTimeWorldCoords.

// placeBreak
// --------------------------------------------------------------------------
/**
   * Parse date, time, world name and coords from Prism reports in chat.
   */
@SuppressWarnings("unused")
void dateTimeWorldCoords(IChatComponent chat, Matcher m) {
    if (_expectingDateTimeCoords) {
        _expectingDateTimeCoords = false;
        int month = Integer.parseInt(m.group(1));
        int day = Integer.parseInt(m.group(2));
        int year = 2000 + Integer.parseInt(m.group(3));
        int hour = Integer.parseInt(m.group(4));
        int minute = Integer.parseInt(m.group(5));
        int second = Integer.parseInt(m.group(6));
        boolean pm = m.group(7).equalsIgnoreCase("pm");
        if (pm) {
            hour += 12;
        }
        long millis = TimeStamp.toMillis(year, month, day, hour, minute, second);
        int x = Integer.parseInt(m.group(8));
        int y = Integer.parseInt(m.group(9));
        int z = Integer.parseInt(m.group(10));
        Controller.instance.selectPosition(x, y, z);
        if (_player != null && _type != null) {
            if (Controller.instance.getFilters().isAcceptedPlayer(_player)) {
                // Update variables only on the first (most recent) result after an
                // inspector header, but update it on every result from a lookup.
                boolean updateVariables = (!_inspectorResult || _awaitingFirstResult);
                BlockEdit edit = new BlockEdit(millis, _player, _created, x, y, z, _type);
                SyncTaskQueue.instance.addTask(new AddBlockEditTask(edit, updateVariables));
                if (_awaitingFirstResult) {
                    _awaitingFirstResult = false;
                }
            }
        }
    }
}
Also used : AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Example 9 with BlockEdit

use of watson.db.BlockEdit in project watson by totemo.

the class CoreProtectAnalysis method lookupCoords.

// --------------------------------------------------------------------------
/**
   * When the corresponding chat line is matched, we know that we are parsing a
   * lookup coordinates line.
   */
@SuppressWarnings("unused")
void lookupCoords(IChatComponent chat, Matcher m) {
    _isLookup = true;
    if (_lookupDetails) {
        _x = Integer.parseInt(m.group(1));
        _y = Integer.parseInt(m.group(2));
        _z = Integer.parseInt(m.group(3));
        // TODO: String world = m.group(4);
        // https://github.com/totemo/watson/issues/23
        BlockEdit edit = new BlockEdit(_millis, _player, _creation, _x, _y, _z, _type);
        SyncTaskQueue.instance.addTask(new AddBlockEditTask(edit, true));
        _lookupDetails = false;
    }
}
Also used : AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Example 10 with BlockEdit

use of watson.db.BlockEdit in project watson by totemo.

the class LbCoordsAnalysis method lbCoordReplaced.

// lbCoordKills
// --------------------------------------------------------------------------
/**
   * Parse /lb coords results where the edit was replacement of one block with
   * another.
   */
void lbCoordReplaced(IChatComponent chat, Matcher m) {
    try {
        int index = Integer.parseInt(m.group(1));
        int[] ymd = TimeStamp.parseYMD(m.group(2));
        int hour = Integer.parseInt(m.group(3));
        int minute = Integer.parseInt(m.group(4));
        int second = Integer.parseInt(m.group(5));
        long millis = TimeStamp.toMillis(ymd, hour, minute, second);
        String player = m.group(6);
        String oldBlock = m.group(7);
        // UNUSED: String newBlock = m.group(8);
        int x = Integer.parseInt(m.group(9));
        int y = Integer.parseInt(m.group(10));
        int z = Integer.parseInt(m.group(11));
        BlockType type = BlockTypeRegistry.instance.getBlockTypeByName(oldBlock);
        // Store the destruction but don't bother with the creation.
        BlockEdit edit = new BlockEdit(millis, player, false, x, y, z, type);
        SyncTaskQueue.instance.addTask(new AddBlockEditTask(edit, true));
        char colourCode = getChatColourChar(x, y, z);
        String colour = Configuration.instance.getRecolourQueryResults() ? "\247" + colourCode : "";
        if (Configuration.instance.getReformatQueryResults()) {
            // Hacked in re-echoing of coords so we can see TP targets.
            if (type.getId() != 1) {
                // Only show the year if LogBlock is configured to return it.
                String year = (ymd[0] != 0) ? String.format(Locale.US, "%02d-", ymd[0]) : "";
                String output = String.format(Locale.US, "%s(%2d) %s%02d-%02d %02d:%02d:%02d (%d,%d,%d) %C%d %s", colour, index, year, ymd[1], ymd[2], hour, minute, second, x, y, z, '-', type.getId(), player);
                Chat.localChat(output);
            }
        } else {
            // No reformatting of query results. Recolour?
            if (Configuration.instance.getRecolourQueryResults()) {
                Chat.localChat(ChatComponents.getEnumChatFormatting(colourCode), chat.getUnformattedText());
            } else {
                Chat.localChat(chat);
            }
        }
        requestNextPage();
    } catch (Exception ex) {
    // System.out.println(ex);
    }
}
Also used : BlockType(watson.db.BlockType) AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Aggregations

BlockEdit (watson.db.BlockEdit)11 AddBlockEditTask (watson.analysis.task.AddBlockEditTask)7 BlockType (watson.db.BlockType)3 File (java.io.File)1 Date (java.util.Date)1 Minecraft (net.minecraft.client.Minecraft)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)1 AnnoCommand (watson.cli.AnnoCommand)1 CalcCommand (watson.cli.CalcCommand)1 HighlightCommand (watson.cli.HighlightCommand)1 WatsonCommand (watson.cli.WatsonCommand)1 WatsonGuiScreen (watson.gui.WatsonGuiScreen)1