2015-03-25 23:10:59 +01:00
|
|
|
package mineplex.chestConverter;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
2015-05-13 09:00:37 +02:00
|
|
|
import java.util.ArrayList;
|
2015-03-25 23:10:59 +01:00
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
2015-05-13 09:00:37 +02:00
|
|
|
import java.util.List;
|
2015-03-25 23:10:59 +01:00
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
public class ChestConverter
|
|
|
|
{
|
|
|
|
private static ChestConverterRepository _repository = null;
|
|
|
|
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
|
|
|
|
|
|
|
public static void main (String args[])
|
|
|
|
{
|
|
|
|
_repository = new ChestConverterRepository();
|
2015-05-13 09:00:37 +02:00
|
|
|
int count = 0;
|
|
|
|
int batchAmount = 5000;
|
|
|
|
|
|
|
|
HashMap<String, Integer> tasks = _repository.getTaskList();
|
2015-03-25 23:10:59 +01:00
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
long time = System.currentTimeMillis();
|
2015-05-13 09:00:37 +02:00
|
|
|
HashMap<String, List<Integer>> playerMap = new HashMap<String, List<Integer>>();
|
|
|
|
|
2015-03-25 23:10:59 +01:00
|
|
|
|
2015-05-13 09:00:37 +02:00
|
|
|
List<AccountTask> taskList = _repository.getTasks(count, batchAmount);
|
|
|
|
|
2015-05-13 23:27:35 +02:00
|
|
|
if (taskList == null || taskList.size() == 0)
|
2015-03-25 23:10:59 +01:00
|
|
|
return;
|
|
|
|
|
2015-05-13 09:00:37 +02:00
|
|
|
for (AccountTask task : taskList)
|
|
|
|
{
|
|
|
|
if (!playerMap.containsKey(task.UUID))
|
|
|
|
playerMap.put(task.UUID, new ArrayList<Integer>());
|
|
|
|
|
|
|
|
playerMap.get(task.UUID).add(tasks.get(task.Task));
|
|
|
|
}
|
|
|
|
|
|
|
|
_repository.incrementClients(playerMap);
|
2015-03-25 23:10:59 +01:00
|
|
|
try
|
|
|
|
{
|
2015-05-13 09:00:37 +02:00
|
|
|
count += batchAmount;
|
|
|
|
log("Natural sleep. " + batchAmount + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + count);
|
|
|
|
Thread.sleep(100);
|
2015-03-25 23:10:59 +01:00
|
|
|
}
|
|
|
|
catch (InterruptedException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void log(String message)
|
|
|
|
{
|
|
|
|
System.out.println("[" + _dateFormat.format(new Date()) + "] " + message);
|
|
|
|
}
|
|
|
|
}
|