Jump to content
  • 0

prohibit dualbox IP or HWID onEnter zone


Question

Posted (edited)

Hello guys. I am looking for code/line that prohibit dualbox inside a zone ..
Like when player enter in a Zone (L2RaidBoss as example) check Ip or HWID and not allow to a second char to enter and teleport back ..

Spoiler

    protected void onEnter(final L2Character character)
    {
        if (_enabled)
        {
            if (character instanceof L2PcInstance)
            {
                // Thread.dumpStack();
                L2PcInstance player = (L2PcInstance) character;
                
                if (player.isGM() || Config.ALLOW_DIRECT_TP_TO_BOSS_ROOM)
                {
                    player.sendMessage("You entered " + _zoneName);

 

Thank you in advance
Edit: i just see one more guy just LF that aswell (i guess perfect timming)

L2jfrozen 1132. java 7

Edited by scraw

15 answers to this question

Recommended Posts

  • 0
Posted (edited)
@Override
	protected void onEnter(final L2Character character)
	{
		if (character instanceof L2PcInstance)
		{
			final L2PcInstance player = character.getActingPlayer();
			if (L2World.getInstance().getAllPlayers().stream().filter(p->p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
			{
				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
				return;
			}
			player.setInsideZone(L2Character.ZONE_PEACE, true);
		}
	}

Instead of zone_peace you should put your desired zone. Also in L2PcInstance

 

public String getIpAddress()
	{
		if (getClient()==null)
			return null;
		
		return getClient().getConnection().getInetAddress().getHostAddress();
	}

 

 

Edited by Zake
  • 0
Posted

@Zake thanks for reply.. i just need this line to java 1.7 
 

Spoiler

 if (L2World.getInstance().getAllPlayers().stream().filter(p>p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
 

 

  • 0
Posted (edited)
15 minutes ago, scraw said:

@Zake thanks for reply.. i just need this line to java 1.7 
 

  Hide contents

 if (L2World.getInstance().getAllPlayers().stream().filter(p>p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
 

 

Lel i though java streams were introduced in java 7. nvm

 

@Override
	protected void onEnter(final L2Character character)
	{
		if (character instanceof L2PcInstance)
		{
			final L2PcInstance player = character.getActingPlayer();
			int count=0;
			for (L2PcInstance p : L2World.getInstance().getAllPlayers())
			{
				if (p == null || p.getIpAddress() ==null || p.getObjectId() == player.getObjectId() || !p.isInsideZone(L2Character.ZONE_PEACE) || p.getIpAddress()!= player.getIpAddress())
					continue;
				
				count++;
			}
			if (count > 0)
			{
				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
				return;
			}
			player.setInsideZone(L2Character.ZONE_PEACE, true);
		}
	}

 

Edited by Zake
  • 0
Posted
8 minutes ago, scraw said:

@Zakecode has no error (i havent build yet) i just cant find what zone is the bosszone ..i go to l2character and there is no boss_zone :/

If there is not you should create one.

  • 0
Posted
Just now, Zake said:

If there is not you should create one.

im my zones.xml is BossZone ..but ZONE_BOSS or BOSS_ZONE isnt working  :/ in L2Character isnt that zone at all..any way i will insert into another zone to check and if it works i will find the way (i think)

@Zake https://ibb.co/XJd6H6h

  • 0
Posted (edited)
4 hours ago, scraw said:

im my zones.xml is BossZone ..but ZONE_BOSS or BOSS_ZONE isnt working  :/ in L2Character isnt that zone at all..any way i will insert into another zone to check and if it works i will find the way (i think)

@Zake https://ibb.co/XJd6H6h

 

The error is very clearly. An object of type L2ChestInstance cannot be casted as L2PcInstance.

Java basically is trying to cast a furniture as a human. It's not same type therefore you get this error.

 

5 hours ago, Zake said:






@Override
	protected void onEnter(final L2Character character)
	{
		if (character instanceof L2PcInstance)
		{
			final L2PcInstance player = character.getActingPlayer();
			if (L2World.getInstance().getAllPlayers().stream().filter(p->p.isInsideZone(L2Character.ZONE_PEACE) && p.getIpAddress()!=null && p.getIpAddress().equals(player.getIpAddress())).count() > 0)
			{
				player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
				return;
			}
			player.setInsideZone(L2Character.ZONE_PEACE, true);
		}
	}

 

 

And no this is not how you use count() or isPresent(). 

 

You need to read the documentations of newer java versions and their methods. 

 

anyMatch will quit after it find an element. isPresent() and count() iterates the whole stream and cause further delay for no reason.

 

L2World.getInstance().getPlayers().stream().anyMatch(s -> s.getIPAddress() == target.getIPAddress());

 

In addition why go though all L2World players and not simply the one contained in zone?

 

Also you don't need to check for null... both equal and == does a null check like instanceof 

 

@scraw Install java 8. You don't need any special engine to parse external java files or py. We live in 2021. JDK 7 is banned.

 

 

Edited by Kara
  • 0
Posted
9 hours ago, Kara said:

 

The error is very clearly. An object of type L2ChestInstance cannot be casted as L2PcInstance.

Java basically is trying to cast a furniture as a human. It's not same type therefore you get this error.

 

 

there is a check which he apparently missed

if (character instanceof L2PcInstance)

so there is no need to count furnitures

 

9 hours ago, Kara said:

And no this is not how you use count() 

 

If you are referring to Collectors.counting() this is the exact same way to count elements in a stream. There are also 5(+?) more ways, none of them makes an actual difference

9 hours ago, Kara said:

In addition why go though all L2World players and not simply the one contained in zone?

You have to store them upon enter/remove upon exit .If this guy wants to create 100 raid(custom?) zones, there would be like 100 concurrent maps/lists(whatever he wants to use) in memory, unfortunately most of them empty. This is still a faster road for a cpu though (especially for high player counts), but almost redundant.

9 hours ago, Kara said:

Also you don't need to check for null

 

this is indeed unnecessary, my apologies

  • 0
Posted
13 minutes ago, Zake said:

 

You have to store them upon enter/remove upon exit .If this guy wants to create 100 raid(custom?) zones, there would be like 100 concurrent maps/lists(whatever he wants to use) in memory, unfortunately most of them empty. This is still a faster road for a cpu though (especially for high player counts), but almost redundant.

Doesn't frozen have getPlayersInside/getCharactersInside method? :yeih:

  • 0
Posted
3 minutes ago, melron said:

Doesn't frozen have getPlayersInside/getCharactersInside method? :yeih:

Oh my apologies too then, i didn't expect that frozen would store them. 

  • Haha 1
  • 0
Posted
1 minute ago, Zake said:

Oh my apologies too then, i didn't expect that frozen would store them. 

To be honest, i didn't too... :P

  • 0
Posted (edited)

When a person is telling you that anyMatch iterate until it find an element while yours keep busy the stream until all elements scanned and your logic is "It works so it's fine" then OK

Edited by Kara
  • 0
Posted
16 minutes ago, Kara said:

When a person is telling you that anyMatch iterate until it find an element while yours keep busy the stream until all elements scanned and your logic is "It works so it's fine" then OK

Lol, i NEVER said that anyMatch() or count() do not iterate through all the elements of a stream. I also never said that this is the optimal way to do, this was just a quick example written in np++ using just a method of l2jfrozen's svn.

  • 0
Posted
6 minutes ago, Zake said:

Lol, i NEVER said that anyMatch() or count() do not iterate through all the elements of a stream. I also never said that this is the optimal way to do, this was just a quick example written in np++ using just a method of l2jfrozen's svn.

 

wkM3q6E.gif

  • 0
Posted
5 minutes ago, Kara said:

 

wkM3q6E.gif

Still never said any of these 2, you may read the posts above and confirm on your own. Nevermind topic locked

  • Thanks 1
Guest
This topic is now closed to further replies.


  • Posts

    • Good luck with your project!
    • Hola Fissban , che queria preguntarte algo estoy tratando de hacer que el testserver ande pro que cuando logeo y voy a elejir el servidor no aparece y he estado con la ia incluso buscando que puede ser pero no e logrado decifrarlo me darias una mano o alguien ?  
    • The Return of L2Elixir – A Legacy Reborn in 2025 Read more features: https://l2elixir.org/features/ It’s time to relive the magic. Many of you remember L2Elixir, first launched in 2008 – a server that brought players together, created friendships, rivalries, and unforgettable memories. For two+ incredible years, until its closure in 2010, Elixir was more than just a server… it was home. In 2018, a fake project borrowed the name and damaged that legacy, but the true memories of L2Elixir never died. Today, in 2025, we are proud to announce that a new dedicated team has taken up the mantle to bring L2Elixir back to life – with respect for the past and a fresh vision for the future.   What to Expect We’re not here to be “just another server.” Our mission is to bring back nostalgia with innovation, offering a unique progression experience: Interlude-Like start, capturing that classic old-school feeling. A natural evolution into Gracia Final. Followed by Gracia Epilogue, keeping the journey alive without losing balance. This is not a copy-paste server – it’s a carefully crafted world designed to honor the spirit of Lineage II while introducing fresh ideas to keep the gameplay alive and rewarding. Why L2Elixir? A balanced environment where community comes first. A project built with passion, not profit. A server that values longevity, fairness, and nostalgia.   📅 Launch Date & Details Closed Beta: Online. Open Beta & Rewards: November 15 & 21:00 UTC +2 Launch: November 28 & 21:00 UTC +2   🔗 Join the Community Be part of history once again. Follow our Discord, join the discussion, and prepare to step back into the world where legends were made.   https://l2elixir.org/ https://discord.gg/5ydPHvhbxs L2Elixir 2025 – Honoring the Past. Building the Future.
    • 10-24-2025 - OUR TOPIC IS RELEVANT! CONTACT US BY THE CONTACTS BELOW
    • Can someone decompile in classes this LineageSkilleffect.u ? I am willing to pay if needed,  protocol god any. https://wormhole.app/BEj0pr#osVXtnL9Q-AmmVmxOcEZfw found, ty
  • 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