Search in sources :

Example 11 with BlockEdit

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

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