forked from LogBlock/LogBlock
Implement basic entity change lookup
This commit is contained in:
@ -51,9 +51,9 @@ public class EntityChange implements LookupCacheElement {
|
|||||||
loc = p.needCoords ? new Location(p.world, rs.getInt("x"), rs.getInt("y"), rs.getInt("z")) : null;
|
loc = p.needCoords ? new Location(p.world, rs.getInt("x"), rs.getInt("y"), rs.getInt("z")) : null;
|
||||||
actor = p.needPlayer ? new Actor(rs) : null;
|
actor = p.needPlayer ? new Actor(rs) : null;
|
||||||
type = p.needType ? EntityTypeConverter.getEntityType(rs.getInt("entitytypeid")) : null;
|
type = p.needType ? EntityTypeConverter.getEntityType(rs.getInt("entitytypeid")) : null;
|
||||||
entityid = p.needType ? UUID.fromString(rs.getString("entityuuid")) : null;
|
entityid = p.needData ? UUID.fromString(rs.getString("entityuuid")) : null;
|
||||||
changeType = p.needType ? EntityChangeType.valueOf(rs.getInt("action")) : null;
|
changeType = p.needType ? EntityChangeType.valueOf(rs.getInt("action")) : null;
|
||||||
data = p.needType ? rs.getBytes("data") : null;
|
data = p.needData ? rs.getBytes("data") : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,13 @@ public class LookupCacheElementFactory {
|
|||||||
return new SummedKills(rs, params, spaceFactor);
|
return new SummedKills(rs, params, spaceFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (params.bct == BlockChangeType.ENTITIES) {
|
||||||
|
if (params.sum == SummarizationMode.NONE) {
|
||||||
|
return new EntityChange(rs, params);
|
||||||
|
} else if (params.sum == SummarizationMode.PLAYERS) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (params.sum == SummarizationMode.NONE) {
|
if (params.sum == SummarizationMode.NONE) {
|
||||||
return new BlockChange(rs, params);
|
return new BlockChange(rs, params);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,8 @@ public final class QueryParams implements Cloneable {
|
|||||||
keywords.put("both", 0);
|
keywords.put("both", 0);
|
||||||
keywords.put("force", 0);
|
keywords.put("force", 0);
|
||||||
keywords.put("nocache", 0);
|
keywords.put("nocache", 0);
|
||||||
|
keywords.put("entities", 0);
|
||||||
|
keywords.put("entity", 0);
|
||||||
}
|
}
|
||||||
public BlockChangeType bct = BlockChangeType.BOTH;
|
public BlockChangeType bct = BlockChangeType.BOTH;
|
||||||
public int limit = -1, before = 0, since = 0, radius = -1;
|
public int limit = -1, before = 0, since = 0, radius = -1;
|
||||||
@ -127,7 +129,7 @@ public final class QueryParams implements Cloneable {
|
|||||||
if (needPlayer || players.size() > 0) {
|
if (needPlayer || players.size() > 0) {
|
||||||
from += "INNER JOIN `lb-players` USING (playerid) ";
|
from += "INNER JOIN `lb-players` USING (playerid) ";
|
||||||
}
|
}
|
||||||
if (!needCount && needType) {
|
if (!needCount && needData) {
|
||||||
from += "LEFT JOIN `" + getTable() + "-entityids` USING (entityid) ";
|
from += "LEFT JOIN `" + getTable() + "-entityids` USING (entityid) ";
|
||||||
}
|
}
|
||||||
return from;
|
return from;
|
||||||
@ -230,16 +232,22 @@ public final class QueryParams implements Cloneable {
|
|||||||
select += "COUNT(*) AS count ";
|
select += "COUNT(*) AS count ";
|
||||||
} else {
|
} else {
|
||||||
if (needId) {
|
if (needId) {
|
||||||
select += "`" + getTable() + "-blocks`.id, ";
|
if (bct != BlockChangeType.ENTITIES) {
|
||||||
|
select += "`" + getTable() + "-blocks`.id, ";
|
||||||
|
} else {
|
||||||
|
select += "`" + getTable() + "-entities`.id, ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (needDate) {
|
if (needDate) {
|
||||||
select += "date, ";
|
select += "date, ";
|
||||||
}
|
}
|
||||||
if (needType) {
|
if (bct != BlockChangeType.ENTITIES) {
|
||||||
select += "replaced, type, ";
|
if (needType) {
|
||||||
}
|
select += "replaced, type, ";
|
||||||
if (needData) {
|
}
|
||||||
select += "replacedData, typeData, ";
|
if (needData) {
|
||||||
|
select += "replacedData, typeData, ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (needPlayer) {
|
if (needPlayer) {
|
||||||
select += "playername, UUID, ";
|
select += "playername, UUID, ";
|
||||||
@ -250,11 +258,20 @@ public final class QueryParams implements Cloneable {
|
|||||||
if (needCoords) {
|
if (needCoords) {
|
||||||
select += "x, y, z, ";
|
select += "x, y, z, ";
|
||||||
}
|
}
|
||||||
if (needData) {
|
if (bct != BlockChangeType.ENTITIES) {
|
||||||
select += "replacedState, typeState, ";
|
if (needData) {
|
||||||
}
|
select += "replacedState, typeState, ";
|
||||||
if (needChestAccess) {
|
}
|
||||||
select += "item, itemremove, itemtype, ";
|
if (needChestAccess) {
|
||||||
|
select += "item, itemremove, itemtype, ";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (needType) {
|
||||||
|
select += "entitytypeid, action, ";
|
||||||
|
}
|
||||||
|
if(needData) {
|
||||||
|
select += "entityuuid, data, ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
select = select.substring(0, select.length() - 2) + " ";
|
select = select.substring(0, select.length() - 2) + " ";
|
||||||
}
|
}
|
||||||
@ -436,32 +453,7 @@ public final class QueryParams implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (blockChangeType == BlockChangeType.ENTITIES) {
|
||||||
if (loc != null) {
|
|
||||||
if (radius == 0) {
|
|
||||||
compileLocationQuery(
|
|
||||||
where,
|
|
||||||
loc.getBlockX(), loc.getBlockX(),
|
|
||||||
loc.getBlockY(), loc.getBlockY(),
|
|
||||||
loc.getBlockZ(), loc.getBlockZ()
|
|
||||||
);
|
|
||||||
} else if (radius > 0) {
|
|
||||||
compileLocationQuery(
|
|
||||||
where,
|
|
||||||
loc.getBlockX() - radius + 1, loc.getBlockX() + radius - 1,
|
|
||||||
loc.getBlockY() - radius + 1, loc.getBlockY() + radius - 1,
|
|
||||||
loc.getBlockZ() - radius + 1, loc.getBlockZ() + radius - 1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (sel != null) {
|
|
||||||
compileLocationQuery(
|
|
||||||
where,
|
|
||||||
sel.getMinimumPoint().getBlockX(), sel.getMaximumPoint().getBlockX(),
|
|
||||||
sel.getMinimumPoint().getBlockY(), sel.getMaximumPoint().getBlockY(),
|
|
||||||
sel.getMinimumPoint().getBlockZ(), sel.getMaximumPoint().getBlockZ()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
switch (blockChangeType) {
|
switch (blockChangeType) {
|
||||||
@ -546,6 +538,8 @@ public final class QueryParams implements Cloneable {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(blockChangeType != BlockChangeType.CHAT) {
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
if (radius == 0) {
|
if (radius == 0) {
|
||||||
compileLocationQuery(
|
compileLocationQuery(
|
||||||
@ -571,7 +565,6 @@ public final class QueryParams implements Cloneable {
|
|||||||
sel.getMinimumPoint().getBlockZ(), sel.getMaximumPoint().getBlockZ()
|
sel.getMinimumPoint().getBlockZ(), sel.getMaximumPoint().getBlockZ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!players.isEmpty() && sum != SummarizationMode.PLAYERS && blockChangeType != BlockChangeType.KILLS) {
|
if (!players.isEmpty() && sum != SummarizationMode.PLAYERS && blockChangeType != BlockChangeType.KILLS) {
|
||||||
if (!excludePlayersMode) {
|
if (!excludePlayersMode) {
|
||||||
@ -802,7 +795,7 @@ public final class QueryParams implements Cloneable {
|
|||||||
bct = BlockChangeType.CHAT;
|
bct = BlockChangeType.CHAT;
|
||||||
} else if (param.equals("kills")) {
|
} else if (param.equals("kills")) {
|
||||||
bct = BlockChangeType.KILLS;
|
bct = BlockChangeType.KILLS;
|
||||||
} else if (param.equals("entities")) {
|
} else if (param.equals("entities") || param.equals("entity")) {
|
||||||
bct = BlockChangeType.ENTITIES;
|
bct = BlockChangeType.ENTITIES;
|
||||||
} else if (param.equals("all")) {
|
} else if (param.equals("all")) {
|
||||||
bct = BlockChangeType.ALL;
|
bct = BlockChangeType.ALL;
|
||||||
@ -893,6 +886,11 @@ public final class QueryParams implements Cloneable {
|
|||||||
throw new IllegalArgumentException("Invalid summarization for chat");
|
throw new IllegalArgumentException("Invalid summarization for chat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(bct == BlockChangeType.ENTITIES) {
|
||||||
|
if (sum != SummarizationMode.NONE) {
|
||||||
|
throw new IllegalStateException("Summarization not implemented yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(Location loc) {
|
public void setLocation(Location loc) {
|
||||||
|
Reference in New Issue
Block a user