Bulk process when players join, if new missions are added.

This commit is contained in:
Sam 2018-07-04 14:08:16 +01:00 committed by Alexander Meech
parent 9509ae0672
commit 2bd4b1889b
2 changed files with 19 additions and 13 deletions

View File

@ -444,6 +444,7 @@ public class MissionManager extends MiniDbClientPlugin<MissionClient>
if (started > 0)
{
player.sendMessage(F.main(getName(), "You started " + F.count(started) + " new mission" + (started == 1 ? "" : "s") + ". Visit " + NPC_NAME + C.mBody + " to view them."));
runAsync(_repository::bulkProcess);
}
}

View File

@ -49,12 +49,14 @@ public class MissionRepository extends RepositoryBase
}
private final List<MissionQuery> _queries;
private final Object _lock;
MissionRepository()
{
super(DBPool.getAccount());
_queries = new ArrayList<>();
_lock = new Object();
}
public void addQueryToQueue(MissionQuery query)
@ -68,6 +70,8 @@ public class MissionRepository extends RepositoryBase
}
public void bulkProcess()
{
synchronized (_lock)
{
if (_queries.isEmpty())
{
@ -85,6 +89,7 @@ public class MissionRepository extends RepositoryBase
_queries.clear();
}
}
public boolean completeMission(int accountId, int missionId)
{