}
}
public void run() {
synchronized (AutoScrap.lck) {
final Inventory MyInventory = Inventory.fetchInventory(bot.steamClient.getSteamId().convertToLong(), false);
if (MyInventory == null) {
Util.printConsole("Could not fetch own inventory via Steam API! (AutoScrap)", bot, ConsoleColor.White, true);
}
metal.put(0, new ArrayList<Long>());
metal.put(1, new ArrayList<Long>());
metal.put(2, new ArrayList<Long>());
final ResultSet result = Main.sql.selectQuery("SELECT schemaid, classid, (stock - COUNT(reservation.Id) + IF(highvalue=1 and stock - COUNT(reservation.Id) > 1,-2,0)) as stk FROM items LEFT JOIN reservation ON items.schemaid = reservation.itemid WHERE highvalue != 2 GROUP BY items.schemaid HAVING stk > 4");
final Map<Integer, MutableInt> count = new HashMap<Integer, MutableInt>();
final Map<Integer, Byte> classid = new HashMap<Integer, Byte>();
final Map<Integer, MutableInt> scraped = new HashMap<Integer, MutableInt>();
try {
while (result.next()) {
try {
count.put(result.getInt("schemaid"), new MutableInt(result.getInt("stk")));
classid.put(result.getInt("schemaid"), result.getByte("classid"));
scraped.put(result.getInt("schemaid"), new MutableInt(0));
} catch (final SQLException e) {
e.printStackTrace();
}
}
} catch (final SQLException e) {
e.printStackTrace();
}
final Map<Byte, Long> otherid = new HashMap<Byte, Long>();
for (final Long id : MyInventory.getItemIds()) {
final Item item = MyInventory.getItem(id);
if (count.containsKey(item.defIndex) && count.get(item.defIndex).get() > 4) {
count.get(item.defIndex).decrement();
if (otherid.containsKey(classid.get(item.defIndex))) {
final Item item2 = MyInventory.getItem(otherid.get(classid.get(item.defIndex)));
CraftResponseCallback callback = scrap(otherid.get(classid.get(item.defIndex)), id);
if (callback != null) {
for (long itemId : callback.getItems()) {
metal.get(0).add(itemId);
}