Jump to content

Recommended Posts

Posted (edited)

As title says, mines event generating box's each box has chance when u click on it if it's a coin u win if it's a torch u lose.

I didnt include the .mines command handler (aka chat handler) to the share most of u have ur own.

 

Requirements: Your own chat handler + menu handlers <-- i made a share for that.

If u use my menu handler add this to UsermenuHandler.java

else if(command.startsWith("_menuMinesSelect")){
			MinesEventHandler.getInstance().parseCmd(command, activeChar);
		}

Overview 1

Overview 2

Overview 3

Overview 4

 

MinesEventHandler.java

Mines.java

MinesEvent.java

MinesManager.java

minesMW.html

 

pastebin pass : maxcheaters

Edited by LordPanic
Posted (edited)

First of all an offtopic reply:

You did remind me the base version of my coupon manager 🤪

 

 

 

Now, lets focus on your idea.

 

Not bad at all, something new/fresh that in my pov, can be used and run with a simple npc that would ask for a price to play a new round. 

I'm also expecting a better reward when i got 2/3 or 3/3 success hits. The reward can simply be multiplied in that case (if the id,qnt have to be constants).

 

Now lets focus on your code.

You have to care about your bypasses. There are missing important checks for numerous suspicion actions.

The code inside of your if statement if(command.startsWith("_menuMinesSelect")){ ... } does not have any protection and it can be easily bypassed and request full rewards with a 50% chance at all. The reward action should be handled when the 'change icon' action take place. Atm, you have 2 different cases while the imporant one is located at the bypass that i mentioned. As it is now, it looks like that you can succeed the box without reward but also, the opossite.

 

You did care about the ConcurrentException inside of MinesManager but you didnt at the MinesEvent (which is created with an arraylist)

 

You have to debug your code for any possible mistake that you 'forgot' to fix up on the creation state. For example, something is wrong here:

 

case 0:
	Broadcast.announceToOnlinePlayers("[EVENT] ~ [Mines] Registrations closed.", true);

	if(MinesEvent.getInstance().getTotalPlayers() < 1) {
		Broadcast.announceToOnlinePlayers("[EVENT] ~ [Mines] Cancelled due to luck of participants.", true);
	}else {
		MinesEvent.getInstance().start();
	}
	setStarted(false);
	break;

 

You checking the total players count to decide if you have to start the event or abandon it but just after your decision, there is:

 

 setStarted(false);

 

Not a big deal at all but i think you got my point. I'm not seeing somewhere this boolean how and when is taking place but probably, is on the file you are not posting.

 

isStarted()

 

 

Generally, take care about naming policy (with proper lower/upper case and all), delete useless lines 

if(command.startsWith("_menuMinesSelect")){
            String selected = ""; // Where this variable is taking place?
            String cmdContent = st.nextToken(); // Where also this variable taking place?
            int position = Integer.valueOf(st.nextToken());
            int chance = Integer.valueOf(st.nextToken());
            Mines newMine =  MinesManager.getInstance().getMine(activeChar.getObjectId());
 
            if(chance > 50)
                newMine.soloRewards(activeChar);
 
            newMine.selectedBox(position);
            newMine.minesWindow(activeChar);

 

Read the java 8 features and get into stream . The addition of the Stream was one of the major features added to Java 8. Don't miss it.

 

For example, this code:

    public class MineBox{
        public int position;
        public int chance;
        public boolean selected;
        public String content;
    }
 
    public void feedList(){
        for(int i=0; i < 30; i++){
            MineBox bx = new MineBox();
            bx.position = i;
            bx.chance = Rnd.get(100);
            bx.selected = false;
            _boxs.add(bx);
        }
    }

 

Can be improved to this one:

 

public class MineBox
{
	public final int position;
	public final int chance = Rnd.get(100);
	public boolean selected = false;
	public String content;
	
	public MineBox(int pos) 
	{
		position = pos;
		_boxs.add(this);
	}
}

public final void feedList()
{
	IntStream.of(30).forEach(MineBox::new);
}

 

The only real problem impacting the stability is the ConcurrentException. Use ConcurrentHashMap.newKeySet() to handle it properly. All the other changes are about readability, performance and optimization.

 

I like you and i admire your effort. Keep sharing :yeih:

Edited by melron
Posted (edited)

@melronThanks a lot for ur usefull tips ! I fixed most of the things u mentioned. I also added a win streak condition on soloRewards method it's up to u guys to add different rewards depending on the win streak 😄

 

About the setStarted,isStarted i use them on my chat handler to avoid ppl registering while event is running or not open for registrations.

 

Edit: Since i made a few changes for the multiplier, check the updated versions of Mines.java and MinesEvent.java:

Bonus Multiplier vid

Edited by LordPanic
Posted (edited)
 
Modification if you 
want to edit item by properties.
Config.java


+	public static int MINA_REWARD_ID;
+	public static int MINA_REWARD_COUNT;
	
+   MINA_REWARD_ID = players.parseIntIntList("MinaReward", "57");
+   MINA_REWARD_COUNT = players.getProperty("RewardCount", 500000);



+# Minas Event Custom reward
+MinaReward = 57
+RewardCount = 50000



net.sf.l2j.gameserver.util.Broadcast;
+ net.sf.l2j.Config;

     original 
	 
    //add the item to give for reward
    private final static int _rewardItemID = 0;
    //add the quantity of reward items
    private final static int _itemQuantity = 0;
	
	modificada 
	
    //add the item to give for reward
-	private final static int _rewardItemID = 0;
+   private final static int _rewardItemID = {Config.CHANGESEX_COIN_ID};
    //add the quantity of reward items
-   private final static int _itemQuantity = 0;
+   private final static int _itemQuantity = {Config.CHANGESEX_COIN_ID};

 

Edited by LucasDesigner

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

    • Complete development packages for Lineage 2 UI development, across all chronicles and an automated tool to update and patch Interface.u & Interface.xdat What I Offer Clean Sources: 100% clean, retail-based interface source code with zero unwanted custom modifications. Interface.u Update Tool: A standalone tool designed to patch, rebuild, and update Interface.u efficiently. Custom Modifications: Custom UI features and tailoring can be implemented upon request. Turnaround Time: Most major versions and protocols are ready for immediate delivery; other versions take up to 1 week. How It Works Let me know the specific chronicle or protocol version you are targeting. I will provide the tool, which is HWID-bound to your machine, for your setup. Once satisfied with the results, we finalize the deal. Pricing & Notes Both products are priced separately based on the target protocol and requirements. Package deals are negotiable if purchasing both. DM for inquiries, demos, and pricing quotes.    
    • Well u need to change when sm1 press exit it keeps it in game..  
    • That’s just part of buying and selling; if your service didn't appeal to me at the time, there's no reason for me to force myself to buy it. After all, I regularly buy other interfaces and clients from other users mostly Russians using USDT. But *I'm* the child here, even though *you're* the incredibly arrogant one.   The payment method or the amounts were never the problem you were. But life goes on; you’d rather stay caught up in your delusions, thinking you’re the protagonist of some anime. Princess Alice 😂   I have all the interfaces for the 474/506/509/520/542/563/557. and olds too.  Some were created by me, including the ARENA P140 interface, which will soon be released for free. This includes everything you make available. It will no longer be a monopoly held by just a few people.   Including your clients with system. like  
    • NEW: Ryzen 9 9950X VPS now Available! Our most Powerful VPS plans now available with dedicated Zen 5 cores clocked up to 5.7 GHz, DDR5 ECC, blazing NVMe Gen4 storage (~7 GB/s), 10 Gbit/s uplink with up to 50 TB traffic, and premium Anti-DDoS included on every plan. No KYC, crypto payments accepted, deployed in minutes. ⭐ RYZEN 9 9950X VPS: [ 9.99 ] 2vCore | 6GB DDR5 | 30GB NVMe - DEPLOY [ 19.99 ] 4vCore | 12GB DDR5 | 50GB NVMe - DEPLOY [ 39.99 ] 8vCore | 24GB DDR5 | 80GB NVMe - DEPLOY [ 69.99 ] 12vCore | 48GB DDR5 | 120GB NVMe - DEPLOY - 10 Gbit/s Port included in ALL Plans - Premium Anti-DDoS included in ALL Plans - No-KYC signup, crypto payments accepted ✅ Ryzen 9 9950X VPS ( vpslab.cloud )
    • I thiunk RU Federation having issues now with paypal?
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..