Jump to content
  • 0

[Help] Daily/Weekly quest


Question

Posted

Hello!!

I'm trying to make a quest to kill X mobs and give you a reward. I already have it ready, or so I think.

 

Now I would like to add the function of making it daily or weekly. I've tried to control this in the same java file of the quest, but I haven't been able to...

 

I was thinking of putting a marker on the quest so that it is "daily" or "weekly" and ¿generating another java program? that is in charge of restarting all the quests with the daily marker at 9 in the morning every day and on Wednesdays at 9 every Wednesday.

 

Since I'm new to java programming (I had already programmed in bash) and developing l2j I don't know where I should create that program. Could it be in the java folder with a name like "org.l2jmobius.xxx.xxx"?

 

I don't know how to approach it because I don't understand the logic of the files and that how runs every day to reset quest with marker.

 

Could anyone help me understand this and explain how I should do it? I'm not asking for ready-made code, I can do that myself, but how to deal with it 😛

 

I also don't know if this method is better or in the java file itself (but I haven't managed to do it this way).

 

See you guys and thanks for all. 

2 answers to this question

Recommended Posts

  • 0
Posted (edited)
16 hours ago, gripao said:

Hello!!

I'm trying to make a quest to kill X mobs and give you a reward. I already have it ready, or so I think.

 

Now I would like to add the function of making it daily or weekly. I've tried to control this in the same java file of the quest, but I haven't been able to...

 

I was thinking of putting a marker on the quest so that it is "daily" or "weekly" and ¿generating another java program? that is in charge of restarting all the quests with the daily marker at 9 in the morning every day and on Wednesdays at 9 every Wednesday.

 

Since I'm new to java programming (I had already programmed in bash) and developing l2j I don't know where I should create that program. Could it be in the java folder with a name like "org.l2jmobius.xxx.xxx"?

 

I don't know how to approach it because I don't understand the logic of the files and that how runs every day to reset quest with marker.

 

Could anyone help me understand this and explain how I should do it? I'm not asking for ready-made code, I can do that myself, but how to deal with it 😛

 

I also don't know if this method is better or in the java file itself (but I haven't managed to do it this way).

 

See you guys and thanks for all. 


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.
 

Edited by Salty Mike
  • 0
Posted
18 hours ago, gripao said:

Hello!!

I'm trying to make a quest to kill X mobs and give you a reward. I already have it ready, or so I think.

 

Now I would like to add the function of making it daily or weekly. I've tried to control this in the same java file of the quest, but I haven't been able to...

 

I was thinking of putting a marker on the quest so that it is "daily" or "weekly" and ¿generating another java program? that is in charge of restarting all the quests with the daily marker at 9 in the morning every day and on Wednesdays at 9 every Wednesday.

 

Since I'm new to java programming (I had already programmed in bash) and developing l2j I don't know where I should create that program. Could it be in the java folder with a name like "org.l2jmobius.xxx.xxx"?

 

I don't know how to approach it because I don't understand the logic of the files and that how runs every day to reset quest with marker.

 

Could anyone help me understand this and explain how I should do it? I'm not asking for ready-made code, I can do that myself, but how to deal with it 😛

 

I also don't know if this method is better or in the java file itself (but I haven't managed to do it this way).

 

See you guys and thanks for all. 

make an item that expires either a week or a day when u press the accept , if u try to redo it and u have the item it wont let you, can be in quest items and not destroyable... 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • I’ve been using SMS.To for a while now and it’s been solid. No issues with delays so far, and the text messaging works right away for verification. Way easier than dealing with local SIM cards for every site.
    • Good evening, I have a problem with the items+ when I enchant, for example, the armors, the weapons, all the stats are normal. When I put them on my inventory, the +4+5 etc. that I have done do not appear. The project is h5 with the salvation protocol. Can any expert help me fix it? Thanks in advance. some screens... this items is +12   https://prnt.sc/fh2i0pjCHDY_ https://prnt.sc/qc1kLl-S4hn6 https://prnt.sc/CTFw3HOdZDPz  
    • GRAND OPENING TODAY !!!  FROM - 10 OCTOBER 2025, FRIDAY, 20:00 +2GMT.
    • Grand Opening On 08/10/2025 Server Rates: Exp: x3 Sp: x3 Adena: x3 Items: x3 Spoil: x4 Quests Drop: x3 Rate in some quests: x2-x6 ENCHANT Weapons / Armor / Jewelry: Safe +3 Max +21/+20/+20 Rates of Enchant: Normal 70% Bless 80%, from +15 Normal 55% Bless 65% Server Commands: .menu .vote .npcinfo Augmentation: NGS : 5% Mid : 8% High: 10% Top: 15% Other: According to the concept of a Olympiad NCSoft. No Donate things affect the game balance. Bonuses for voting on TOP sites. / unstuck 2 minutes. Free Tp until lvl 40. According to the concept of a castle siege NCSoft. The maximum number of windows from one PC is 4 Buffs  Number of slots: 25 Number of debuff slots: 6 Duration of the buffs: Retail RAID/GRAND BOSSES Retail like. Rate Raid Drop Items = x2 Seven Signs: According to the concept of NCSoft. GM Donate Shop All items you need are there One shop all items B-A-S grade for Donation Coins Finery / Misc / Recipes / Quest and much more. Offline Shops Just exit your client when you have shop. Offline Max Days: 7 Offline Place: Only in Peace Zone Custom Vip / Hero for: 3, 10, 30 Days Vip Benefits Exp: x8 Sp: x8 Adena: x8 Items: x8 Spoil: x10 Quests: x8 Raid Drop Items: x3 Rate in some quests: x2-x6 And more in Vip Manager Join us and discover many more features in our server! https://l2doll.com/
    • Results don’t come instantly   Sometimes it feels like nothing is moving. You take small steps, and the results barely show. But it’s exactly these steps that build your tomorrow. Every day, every effort is an investment in yourself and your success. Patience isn’t about sitting and waiting for miracles—it’s about moving forward with confidence. Real victories take time, effort, and your constant determination. Don’t rush the process-the journey itself is valuable, and it’s what shapes results that last.   …The right energy always comes back. 💫 VibeSMS Website: https://vibe-sms.net/ Telegram channel: https://t.me/vibe_sms
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock