mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-17 17:31:02 +02:00
4440101a3a
- Fixed getRetractBlock
28 lines
871 B
Java
28 lines
871 B
Java
package com.Acrobot.ChestShop.DB;
|
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
|
import com.Acrobot.ChestShop.Config.Config;
|
|
import com.Acrobot.ChestShop.Config.Property;
|
|
|
|
import javax.persistence.OptimisticLockException;
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class Queue implements Runnable {
|
|
private static final ArrayList<Transaction> queue = new ArrayList<Transaction>();
|
|
|
|
public static void addToQueue(Transaction t) {
|
|
queue.add(t);
|
|
}
|
|
|
|
public void run() {
|
|
ChestShop.getDB().delete(ChestShop.getDB().find(Transaction.class).where().lt("sec", System.currentTimeMillis() / 1000 - Config.getInteger(Property.RECORD_TIME_TO_LIVE)).findList());
|
|
|
|
ArrayList<Transaction> queueCopy = queue;
|
|
try { ChestShop.getDB().save(queueCopy); } catch (OptimisticLockException ignored) {}
|
|
queue.clear();
|
|
}
|
|
}
|