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

    • Opening December 6th at 19:00 (GMT +3)! Open Beta Test from November 30th!   https://l2soe.com/   🌟 Introducing L2 Saga of Eternia: A Revolution in Lineage 2 High Five! 🌟   Dear Lineage 2 enthusiasts, Prepare to witness the future of private servers! L2 Saga of Eternia is not just another High Five project—it’s a game-changing experience designed to compete with the giants of the Lineage 2 private server scene. Built for the community, by the community, we’re here to raise the bar in quality, innovation, and longevity. What Sets Us Apart? 💎 No Wipes, Ever Say goodbye to the fear of losing your progress. Our server is built to last and will never close. Stability and consistency are our promises to you. ⚔️ Weekly New Content Our dedicated development team ensures fresh challenges, events, and updates every week. From custom quests to exclusive features, there will always be something exciting to explore. 💰 No Pay-to-Win Skill and strategy matter most here. Enjoy a balanced gameplay environment where your achievements come from effort, not your wallet. 🌍 A Massive Community With 2000+ players expected, join a vibrant and active community of like-minded adventurers ready to conquer the world of Aden. 🏆 Fair and Competitive Gameplay Our systems are designed to promote healthy competition while avoiding abusive mechanics and exploits. 🔧 Professional Development From advanced bug fixes to carefully curated content, we pride ourselves on smooth performance, no lag, and unparalleled server quality. Key Features Chronicle: High Five with unique interface Rate: Dynamic x10 rates Class Balance: Carefully fine-tuned for a fair experience PvP Focused: PvP Ranking & aura display effect for 3 Top PvPers every week Custom Events: Seasonal and permanent events to keep you engaged Additional Features:   Custom Endgame Content: Introduce unique dungeons, raids, or zones unavailable in other servers. Player-Driven Economy: Implement a strong market system and avoid overinflated drops or rewards. Epic Siege Battles: Announce special large-scale sieges and PvP events. Incentives for Streamers and Clans: Attract influencers and big clans to boost server publicity. Roadmap Transparency: Share a public roadmap of planned updates to build trust and excitemen   Here you can read all the features: https://l2soe.com/features   [youtube]https://youtu.be/3DI3Rf4lTVQ?si=EQJ34gK-GazOhC32[/youtube] Join the Revolution! This is your chance to be part of something legendary. L2 Saga of Eternia is not just a server; it’s a movement to redefine what Lineage 2 can be. Whether you’re a seasoned veteran or a newcomer to the world of Aden, we invite you to experience Lineage 2 at its finest.   Official Launch Date: December 6th 2024 Website: https://l2soe.com/ Facebook: https://www.facebook.com/l2soe Discord: https://discord.com/invite/l2eternia   Let’s build the ultimate Lineage 2 experience together. See you in-game! 🎮
    • That's like a tutorial on how to run l2 on MacOS Xd but good job for the investigation. 
    • small update: dc robe set sold   wts adena 1kk = 1.5$ 
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt
    • Why adena in this sever so expensive 🙂
  • Topics

×
×
  • Create New...