use of watson.analysis.task.AddBlockEditTask 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);
}
}
use of watson.analysis.task.AddBlockEditTask 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);
}
}
Aggregations