Mineplex2018-withcommit/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java
2015-05-13 14:27:35 -07:00

61 lines
1.5 KiB
Java

package mineplex.chestConverter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
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();
int count = 0;
int batchAmount = 5000;
HashMap<String, Integer> tasks = _repository.getTaskList();
while (true)
{
long time = System.currentTimeMillis();
HashMap<String, List<Integer>> playerMap = new HashMap<String, List<Integer>>();
List<AccountTask> taskList = _repository.getTasks(count, batchAmount);
if (taskList == null || taskList.size() == 0)
return;
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);
try
{
count += batchAmount;
log("Natural sleep. " + batchAmount + " took " + (System.currentTimeMillis() - time) / 1000 + " seconds. Count = " + + count);
Thread.sleep(100);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
private static void log(String message)
{
System.out.println("[" + _dateFormat.format(new Date()) + "] " + message);
}
}