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... 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • SocNet is now on Medium! Check out our new article showcasing the full potential of our store and SMM Panel! Article: Click   🚀 Promo code: MEDIUM5 (5% Discount)   ➡️ Online Store: Click ✅ ➡️ Telegram Bot: Click ✅ ➡️ SMM Panel: Click ✅   Regular customers receive additional discounts and promo codes!   Support: ➡️ Telegram: https://t.me/solomon_bog ✅ ➡️ Discord: https://discord.gg/y9AStFFsrh ✅ ➡️ WhatsApp: https://wa.me/79051904467 ✅ ➡️ Email: solomonbog@socnet.store ✅   ➡️ Telegram Channel: https://t.me/accsforyou_shop ✅   You can also contact us for: — Wholesale inquiries — Partnership opportunities (Current partners: https://socnet.bgng.io/partners )  — Becoming a supplier   SocNet — your store for digital goods and premium subscriptions ✅
    • SocNet is now on Medium! Check out our new article showcasing the full potential of our store and SMM Panel! Article: Click Promo code: MEDIUM5 (5% Discount) Online Store: Click Telegram Bot: Click SMM Panel: Click Regular customers receive additional discounts and promo codes! Support: Telegram: https://t.me/solomon_bog Discord: https://discord.gg/y9AStFFsrh WhatsApp: https://wa.me/79051904467 Email: solomonbog@socnet.store  Telegram Channel: https://t.me/accsforyou_shop You can also contact us for: — Wholesale inquiries — Partnership opportunities (Current partners: https://socnet.bgng.io/partners ) — Becoming a supplier SocNet — your store for digital goods and premium subscriptions  Want to expand your business network or promote services through the largest B2B platform? LinkedIn accounts are your tool for marketing, recruiting, and outreach automation. Perfect for SMM, hiring, lead generation, and business scaling. ➡ Ready-made accounts — fast, convenient, no hassle. Promo code: LINKEDIN5 (5% discount) Payment: Bank cards · Cryptocurrency · Other popular methods How to buy: ➡ Online Store: Click ➡ Telegram Bot: Click Other services: ➡ SMM Panel: Click Product range: ➡ LINKEDIN.COM ACCOUNTS | EMAIL INCLUDED @OUTLOOK.COM / @HOTMAIL.COM / @FIRSTMAIL.COM, MALE OR FEMALE, PARTIALLY FILLED PROFILES, REGISTERED FROM USA IP | Price from: $2.5 ➡ LINKEDIN.COM ACCOUNTS | EMAIL INCLUDED @OUTLOOK.COM / @HOTMAIL.COM / @FIRSTMAIL.COM, MALE OR FEMALE, PARTIALLY FILLED PROFILES, REGISTERED FROM EUROPE IP | Price from: $2.5 ➡ LINKEDIN.COM ACCOUNTS | EMAIL INCLUDED @OUTLOOK.COM / @HOTMAIL.COM / @FIRSTMAIL.COM, MALE OR FEMALE, PARTIALLY FILLED PROFILES, REGISTERED FROM MIX IP | Price from: $2.5 ➡ LinkedIn Old Brute Account with Real Connections (0 connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $10 ➡ LinkedIn Premium Brute Account (Premium) with active 1-month Premium subscription | Geo: MIX | Registered on real device | Full account access | Price from: $20 ➡ LinkedIn Old Brute Account with Real Connections (50 connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $20 ➡ LinkedIn Old Brute Account with Real Connections (100+ connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $39 ➡ LinkedIn Old Brute Account with Real Connections (500+ connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $69 ➡ LinkedIn Verified Brute Account with verified documents | Geo: MIX | Registered on real device | Full account access | Price from: $89 Loyal customers — additional discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop Also via these contacts you can: — Consult about wholesale purchases — Set up a partnership (current partners: https://socnet.bgng.io/partners ) — Become our supplier SocNet — Digital Goods and Premium Subscriptions Store
    • SocNet is now on Medium! Check out our new article showcasing the full potential of our store and SMM Panel! Article: Click Promo code: MEDIUM5 (5% Discount) Online Store: Click Telegram Bot: Click SMM Panel: Click Regular customers receive additional discounts and promo codes! Support: Telegram: https://t.me/solomon_bog Discord: https://discord.gg/y9AStFFsrh WhatsApp: https://wa.me/79051904467 Email: solomonbog@socnet.store  Telegram Channel: https://t.me/accsforyou_shop You can also contact us for: — Wholesale inquiries — Partnership opportunities (Current partners: https://socnet.bgng.io/partners ) — Becoming a supplier SocNet — your store for digital goods and premium subscriptions  Want to expand your business network or promote services through the largest B2B platform? LinkedIn accounts are your tool for marketing, recruiting, and outreach automation. Perfect for SMM, hiring, lead generation, and business scaling. ➡ Ready-made accounts — fast, convenient, no hassle. Promo code: LINKEDIN5 (5% discount) Payment: Bank cards · Cryptocurrency · Other popular methods How to buy: ➡ Online Store: Click ➡ Telegram Bot: Click Other services: ➡ SMM Panel: Click Product range: ➡ LINKEDIN.COM ACCOUNTS | EMAIL INCLUDED @OUTLOOK.COM / @HOTMAIL.COM / @FIRSTMAIL.COM, MALE OR FEMALE, PARTIALLY FILLED PROFILES, REGISTERED FROM USA IP | Price from: $2.5 ➡ LINKEDIN.COM ACCOUNTS | EMAIL INCLUDED @OUTLOOK.COM / @HOTMAIL.COM / @FIRSTMAIL.COM, MALE OR FEMALE, PARTIALLY FILLED PROFILES, REGISTERED FROM EUROPE IP | Price from: $2.5 ➡ LINKEDIN.COM ACCOUNTS | EMAIL INCLUDED @OUTLOOK.COM / @HOTMAIL.COM / @FIRSTMAIL.COM, MALE OR FEMALE, PARTIALLY FILLED PROFILES, REGISTERED FROM MIX IP | Price from: $2.5 ➡ LinkedIn Old Brute Account with Real Connections (0 connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $10 ➡ LinkedIn Premium Brute Account (Premium) with active 1-month Premium subscription | Geo: MIX | Registered on real device | Full account access | Price from: $20 ➡ LinkedIn Old Brute Account with Real Connections (50 connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $20 ➡ LinkedIn Old Brute Account with Real Connections (100+ connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $39 ➡ LinkedIn Old Brute Account with Real Connections (500+ connections) | Mix Geo | Filled Profile | Registered on real device | Price from: $69 ➡ LinkedIn Verified Brute Account with verified documents | Geo: MIX | Registered on real device | Full account access | Price from: $89 Loyal customers — additional discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop Also via these contacts you can: — Consult about wholesale purchases — Set up a partnership (current partners: https://socnet.bgng.io/partners ) — Become our supplier SocNet — Digital Goods and Premium Subscriptions Store
    • Buying & Selling Torn City Cash
  • 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