Search in sources :

Example 1 with BlockEdit

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

the class CoreProtectAnalysis method details.

// inspectorCoords
// --------------------------------------------------------------------------
/**
   * When the corresponding chat line is matched, we know that we are parsing an
   * inspector or lookup details line.
   */
@SuppressWarnings("unused")
void details(IChatComponent chat, Matcher m) {
    _lookupDetails = false;
    if (m.group(3).equals("placed") || m.group(3).equals("removed")) {
        _millis = parseTimeExpression(m.group(1));
        _player = m.group(2);
        _creation = m.group(3).equals("placed");
        // Special case for paintings and item frames, mapped to different IDs.
        String type = m.group(4);
        if (type.equals("321")) {
            _type = BlockTypeRegistry.instance.getBlockTypeByName("painting");
        } else if (type.equals("389")) {
            _type = BlockTypeRegistry.instance.getBlockTypeByName("item frame");
        } else {
            _type = BlockTypeRegistry.instance.getBlockTypeByName(type);
        }
        if (_isLookup) {
            // Record that we can use these details at the next
            // coreprotect.lookupcoords only.
            _lookupDetails = true;
        } else {
            // An inspector result, so it can be queued for addition.
            if (Controller.instance.getFilters().isAcceptedPlayer(_player)) {
                BlockEdit edit = new BlockEdit(_millis, _player, _creation, _x, _y, _z, _type);
                SyncTaskQueue.instance.addTask(new AddBlockEditTask(edit, _firstInspectorResult));
                // The first inspector result to pass the filter sets variables.
                if (_firstInspectorResult) {
                    _firstInspectorResult = false;
                }
            }
        }
    // if inspector result
    }
}
Also used : AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Example 2 with BlockEdit

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

the class LbCoordsAnalysis method lbCoordKills.

// lbCoord
// --------------------------------------------------------------------------
/**
   * Parse kill coords results.
   */
void lbCoordKills(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 victim = m.group(7);
        int x = Integer.parseInt(m.group(8));
        int y = Integer.parseInt(m.group(9));
        int z = Integer.parseInt(m.group(10));
        String weapon = m.group(11);
        // LogBlock doesn't distinguish between player kills and other kills, it
        // just gives the name of what was killed. Since we (hopefully) list all
        // the possible kill types that aren't players in blocks.yml, for things
        // matching the LB_COORD_KILLS pattern we will assume that anything that
        // isn't listed in blocks.yml is a player. getBlockKillTypeByName() does
        // this by assigning any unknown kill to the "unknown" kill ID, which is
        // 219, our generic player model (this is similar to how
        // getBlockTypeByName() assigns any unknown ID to 256.) The downside of
        // this is that true new/unknown kill types will be assigned a player-like
        // looking model over a typical "unknown" bright magenta box.
        BlockType type = BlockTypeRegistry.instance.getBlockKillTypeByName(victim);
        // For our purposes, we'll treat a kill like a block destruction
        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) %s %s > %s", colour, index, year, ymd[1], ymd[2], hour, minute, second, x, y, z, player, weapon, victim);
                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) {
        Log.exception(Level.INFO, "error parsing lb kills coords", ex);
    }
}
Also used : BlockType(watson.db.BlockType) AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Example 3 with BlockEdit

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

the class LbToolBlockAnalysis method addBlockEdit.

// lbEditReplaced
// --------------------------------------------------------------------------
/**
   * Common code for storing an edit if it passes the filter.
   *
   * @param millis the time stamp.
   * @param player the player name.
   * @param created true if a block was created (rather than destroyed).
   * @param type the type of block.
   */
protected void addBlockEdit(long millis, String player, boolean created, BlockType type) {
    if (Controller.instance.getFilters().isAcceptedPlayer(player)) {
        BlockEdit edit = new BlockEdit(millis, player, created, _x, _y, _z, type);
        SyncTaskQueue.instance.addTask(new AddBlockEditTask(edit, _expectingFirstEdit));
        // Once our first edit passes the filter, no need to set variables.
        if (_expectingFirstEdit) {
            _expectingFirstEdit = false;
        }
    }
}
Also used : AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Example 4 with BlockEdit

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

the class TeleportAnalysis method lbTp.

// constructor
// --------------------------------------------------------------------------
/**
   * Parse the message shown when the player uses /lb tp and select the
   * corresponding edit so that /w pre works.
   */
@SuppressWarnings("unused")
void lbTp(IChatComponent chat, Matcher m) {
    try {
        int x = Integer.parseInt(m.group(1));
        int y = Integer.parseInt(m.group(2));
        int z = Integer.parseInt(m.group(3));
        // Multiple players could conceivably edit the block (rarely but it
        // happens). Pass in the most recently queried player, if known.
        // findEdit() currently does an (inefficient) search from oldest to
        // newest edit, meaning that the typical pattern of mining down to an
        // ore, then pillaring up with cobble through the ore will find the ore
        // block destruction (earlier) and not the cobble creation (later).
        String player = (String) Controller.instance.getVariables().get("player");
        BlockEdit edit = Controller.instance.getBlockEditSet().findEdit(x, y, z, player);
        Controller.instance.selectBlockEdit(edit);
    } catch (Exception ex) {
    // System.out.println(ex);
    }
}
Also used : BlockEdit(watson.db.BlockEdit)

Example 5 with BlockEdit

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

the class Controller method drawSelection.

// --------------------------------------------------------------------------
/**
   * Draw a cursor at the currently selected position.
   */
public void drawSelection() {
    if (_selection != null && getDisplaySettings().isSelectionShown()) {
        Tessellator tess = Tessellator.getInstance();
        WorldRenderer wr = tess.getWorldRenderer();
        wr.startDrawing(GL11.GL_LINES);
        wr.setColorRGBA(255, 0, 255, 128);
        GL11.glLineWidth(4.0f);
        final float halfSize = 0.3f;
        float x = _selection.x + 0.5f;
        float y = _selection.y + 0.5f;
        float z = _selection.z + 0.5f;
        wr.addVertex(x - halfSize, y, z);
        wr.addVertex(x + halfSize, y, z);
        wr.addVertex(x, y - halfSize, z);
        wr.addVertex(x, y + halfSize, z);
        wr.addVertex(x, y, z - halfSize);
        wr.addVertex(x, y, z + halfSize);
        tess.draw();
        if (_selection.playerEditSet != null) {
            BlockEdit predecessor = _selection.playerEditSet.getEditBefore(_selection);
            if (predecessor != null) {
                wr.startDrawing(GL11.GL_LINES);
                wr.setColorRGBA(255, 0, 255, 128);
                GL11.glEnable(GL11.GL_LINE_STIPPLE);
                GL11.glLineStipple(8, (short) 0xAAAA);
                GL11.glLineWidth(3.0f);
                wr.addVertex(predecessor.x + 0.5f, predecessor.y + 0.5f, predecessor.z + 0.5f);
                wr.addVertex(x, y, z);
                tess.draw();
                GL11.glDisable(GL11.GL_LINE_STIPPLE);
            }
        }
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BlockEdit(watson.db.BlockEdit) WorldRenderer(net.minecraft.client.renderer.WorldRenderer)

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