Search in sources :

Example 1 with BlockType

use of watson.db.BlockType 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 2 with BlockType

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

the class LbToolBlockAnalysis method lbEdit.

// lbPosition
// --------------------------------------------------------------------------
/**
   * Parse "created" or "destroyed" result in the logs for a single block using
   * coal ore.
   */
void lbEdit(@SuppressWarnings("unused") IChatComponent chat, Matcher m) {
    if ((System.currentTimeMillis() - _lbPositionTime) < POSITION_TIMEOUT_MILLIS) {
        int[] ymd = TimeStamp.parseYMD(m.group(1));
        int hour = Integer.parseInt(m.group(2));
        int minute = Integer.parseInt(m.group(3));
        int second = Integer.parseInt(m.group(4));
        long millis = TimeStamp.toMillis(ymd, hour, minute, second);
        String player = m.group(5);
        String action = m.group(6);
        boolean created = action.equals("created");
        String block = m.group(7);
        BlockType type = BlockTypeRegistry.instance.getBlockTypeByName(block);
        addBlockEdit(millis, player, created, type);
    }
}
Also used : BlockType(watson.db.BlockType)

Example 3 with BlockType

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

the class LbToolBlockAnalysis method lbEditReplaced.

// lbEdit
// --------------------------------------------------------------------------
/**
   * Parse results where the player replaced one block with another.
   */
void lbEditReplaced(@SuppressWarnings("unused") IChatComponent chat, Matcher m) {
    if ((System.currentTimeMillis() - _lbPositionTime) < POSITION_TIMEOUT_MILLIS) {
        int[] ymd = TimeStamp.parseYMD(m.group(1));
        int hour = Integer.parseInt(m.group(2));
        int minute = Integer.parseInt(m.group(3));
        int second = Integer.parseInt(m.group(4));
        long millis = TimeStamp.toMillis(ymd, hour, minute, second);
        String player = m.group(5);
        String oldBlock = m.group(6);
        BlockType type = BlockTypeRegistry.instance.getBlockTypeByName(oldBlock);
        // Just add the destruction.
        addBlockEdit(millis, player, false, type);
    }
}
Also used : BlockType(watson.db.BlockType)

Example 4 with BlockType

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

Example 5 with BlockType

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

the class LbCoordsAnalysis method lbCoord.

// constructor
// --------------------------------------------------------------------------
/**
   * Parse creation and destruction coords results.
   */
void lbCoord(IChatComponent chat, Matcher m) {
    try {
        // TODO: describe Matcher groups and their conversions in a config file.
        // Provide a way to get a set of named properties of a line.
        // Use reflection or JavaBeans Statement/Expression to create the
        // BlockEdit as directed by config file.
        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 action = m.group(7);
        String block = m.group(8);
        // If there are an extra 4 groups, then we're dealing with a sign.
        String sign1 = null, sign2 = null, sign3 = null, sign4 = null;
        int x, y, z;
        if (m.groupCount() == 15) {
            sign1 = m.group(9);
            sign2 = m.group(10);
            sign3 = m.group(11);
            sign4 = m.group(12);
            x = Integer.parseInt(m.group(13));
            y = Integer.parseInt(m.group(14));
            z = Integer.parseInt(m.group(15));
        } else {
            x = Integer.parseInt(m.group(9));
            y = Integer.parseInt(m.group(10));
            z = Integer.parseInt(m.group(11));
        }
        BlockType type = BlockTypeRegistry.instance.getBlockTypeByName(block);
        boolean created = action.equals("created");
        BlockEdit edit = new BlockEdit(millis, player, created, 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) {
                String signText = (sign1 != null) ? String.format(Locale.US, " [%s] [%s] [%s] [%s]", sign1, sign2, sign3, sign4) : "";
                // 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%s", colour, index, year, ymd[1], ymd[2], hour, minute, second, x, y, z, (created ? '+' : '-'), type.getId(), player, signText);
                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 coords", ex);
    }
}
Also used : BlockType(watson.db.BlockType) AddBlockEditTask(watson.analysis.task.AddBlockEditTask) BlockEdit(watson.db.BlockEdit)

Aggregations

BlockType (watson.db.BlockType)5 AddBlockEditTask (watson.analysis.task.AddBlockEditTask)3 BlockEdit (watson.db.BlockEdit)3