If you are this new to java, I would strongly recommend using IntelliJ Community Edition (free) instead of Eclipse since it indexes your entire source and makes it extremely easy to navigate forward and backward dependencies and method calls.
Now, on the topic.
Unless your Mobius sources are ancient, they should already have native support. It is called `DailyTaskManager`.
It would be impossible to give you a mould without such a DailyTaskManager. I would suggest you parse/adapt it from a newer source version if you don't have it.
The logic is rather simple once you get to understand it.
1. You need a handler to count the mobs and give rewards, etc.
2. You need to keep mission status for each individual player in the database.
3. You need to INSERT the data when a player takes the mission, UPDATE it whenever you like, be it on every single mob or not (I would only update the DB on player disconnect/log out, or on mission completion), and SELECT/extract it when the player logs in (EnterWorld.java).
4. You need a way to get the Mission Reset Type (Daily/Weekly), and you should call a reset method similar to the one at the bottom of my post from within the DailyTaskManager every day at 9am or whenever you like.
Keep in mind that the above is not an exhaustive list, but some generalised approach aimed at helping you see the bigger picture.
public synchronized void reset()
{
DailyMissionResetType reset = _holder.getResetType();
switch (reset)
{
case NEVER ->
{
return;
}
case MONTHLY ->
{
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) != 1)
{
return;
}
}
case WEEKLY ->
{
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY)
{
return;
}
}
case WEEKEND ->
{
if (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY)
{
return;
}
}
case DAILY ->
{
}
default ->
{
LOGGER.warning("Unhandled daily mission reset type: " + reset);
return;
}
}
try (
Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_daily_rewards WHERE missionId = ? AND status = ?"))
{
ps.setInt(1, _holder.getId());
ps.setInt(2, DailyMissionStatus.COMPLETED.getClientId());
ps.execute();
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Error while clearing data for: " + getClass().getSimpleName(), e);
}
finally
{
_entries.clear();
// resets the entries in the Manager.
DailyMissionsManager.getInstance().clearEntries();
}
}
*Disclaimer: The provided code snippet is just an adaptation of Mobius' implementation on newer chronicles.