Mineplex2018-withcommit/Plugins/Mineplex.ChestConverter/src/mineplex/chestConverter/ChestConverter.java

61 lines
1.5 KiB
Java
Raw Normal View History

package mineplex.chestConverter;
import java.text.SimpleDateFormat;
2015-05-13 09:00:37 +02:00
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
2015-05-13 09:00:37 +02:00
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();
2015-05-13 09:00:37 +02:00
int count = 0;
int batchAmount = 5000;
HashMap<String, Integer> tasks = _repository.getTaskList();
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-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)
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);
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);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
private static void log(String message)
{
System.out.println("[" + _dateFormat.format(new Date()) + "] " + message);
}
}