@Override public ArrayList<Action> getBlockHistory(Block block, WorldManager manager) { PreparedStatement ps = null; ResultSet rs = null; ArrayList<Action> blockList = new ArrayList<Action>(); try { // TODO maybe more customizable actions? ps = BBDB.prepare( "SELECT bbdata.id, date, player, action, x, y, z, type, data, rbacked, bbworlds.name AS world" + " FROM " + BBDataTable.getInstance().getTableName() + " AS bbdata" + " INNER JOIN " + BBWorldsTable.getInstance().getTableName() + " AS bbworlds" + " ON bbworlds.id = bbdata.world" + " WHERE rbacked = false AND x = ? AND y = ? AND z = ? AND bbdata.world = ? ORDER BY bbdata.id ASC;"); ps.setInt(1, block.getX()); ps.setInt(2, block.getY()); ps.setInt(3, block.getZ()); ps.setInt(4, manager.getWorld(block.getWorld().getName())); rs = ps.executeQuery(); BBDB.commit(); while (rs.next()) { String data = rs.getString("data"); Action newBlock = ActionProvider.findAndProvide( rs.getInt("action"), BBUsersTable.getInstance().getUserByID(rs.getInt("player")), rs.getString("world"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("type"), data); newBlock.date = rs.getLong("date"); blockList.add(newBlock); } } catch (SQLException ex) { BBLogging.severe("Find SQL Exception", ex); } finally { BBDB.cleanup("Find", ps, rs); } return blockList; }
private StringBuilder getActionString() { // TODO maybe more customizable actions? StringBuilder ret = new StringBuilder("action IN("); ret.append("'"); ret.append(ActionProvider.findActionID("BrokenBlock")); ret.append("','"); ret.append(ActionProvider.findActionID("PlacedBlock")); ret.append("','"); ret.append(ActionProvider.findActionID("DeltaChest")); ret.append("','"); ret.append(ActionProvider.findActionID("CreateSignText")); ret.append("','"); ret.append(ActionProvider.findActionID("DestroySignText")); ret.append("','"); ret.append(ActionProvider.findActionID("LeafDecay")); ret.append("','"); ret.append(ActionProvider.findActionID("TNTExplosion")); ret.append("','"); ret.append(ActionProvider.findActionID("CreeperExplosion")); ret.append("','"); ret.append(ActionProvider.findActionID("MiscExplosion")); ret.append("','"); ret.append(ActionProvider.findActionID("BlockBurn")); ret.append("','"); ret.append(ActionProvider.findActionID("Flow")); ret.append("')"); return ret; }