Jump to content
  • 0

mass create per ip


Question

Posted (edited)

hello ..i have a problem . I tried to add the code when admin create mass item only 1window per ip can receive. 
i add this: 

Spoiler

         Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
        for (L2PcInstance p: pls)
        {
               final String ip = p.getClient().getConnection().getInetAddress().getHostAddress();

                if (ips.contains(ip))
                 continue;

blablabla

but it doesnt work :/  any help ? 
code hasnt errors, just in game doesnt work :/ 

edit: i use arraylist not hash

Edited by Irrelevant

Recommended Posts

  • 0
Posted
3 minutes ago, Irrelevant said:

you said about bots ,and i had an offline shop in server ,i disconnect it and now it work.BUT i have a question, does that mean that if someone use offline shop noone else will awarded?

That was it.

No, create the next method

private boolean isClientOk(L2PcInstance player)
{
	try
	{
		player.getClient().getConnection().getInetAddress().getHostAddress();
	}
	catch (Exception e)
	{
		return false;
	}
	return true;
}

 

and then, change this line

final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();

 

to

final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers().stream().filter(p -> isClientOk(p)).collect(Collectors.toList());

 

  • Thanks 1
  • 0
Posted
4 minutes ago, melron said:

Show us the whole code

Spoiler

         List<String> ips = new ArrayList<>();
         Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
         for (L2PcInstance p: pls)
         {
               final String ip = p.getClient().getConnection().getInetAddress().getHostAddress();
                if (ips.contains(ip))
                   continue;
           p.sendMessage("Admin is rewarding all online players.");

            item = p.getInventory().addItem("Admin", id, num, null, null);
            final InventoryUpdate iu = new InventoryUpdate();
            iu.addItem(item);
            p.sendPacket(iu);
            final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
            sm.addItemName(item.getItemId());
            sm.addNumber(num);
            p.sendPacket(sm);
            i++;
            ips.add(ip);
        }
        activeChar.sendMessage("Mass-created items in the inventory of " + i + " player(s).");
        LOGGER.info("GM " + activeChar.getName() + " mass_created item Id: " + id + " (" + num + ")");
    }

 

  • 0
Posted (edited)
18 minutes ago, Irrelevant said:
  Reveal hidden contents

         List<String> ips = new ArrayList<>();
         Collection <L2PcInstance> pls = L2World.getInstance (). getAllPlayers ();
         for (L2PcInstance p: pls)
         {
               final String ip = p.getClient().getConnection().getInetAddress().getHostAddress();
                if (ips.contains(ip))
                   continue;
           p.sendMessage("Admin is rewarding all online players.");

            item = p.getInventory().addItem("Admin", id, num, null, null);
            final InventoryUpdate iu = new InventoryUpdate();
            iu.addItem(item);
            p.sendPacket(iu);
            final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
            sm.addItemName(item.getItemId());
            sm.addNumber(num);
            p.sendPacket(sm);
            i++;
            ips.add(ip);
        }
        activeChar.sendMessage("Mass-created items in the inventory of " + i + " player(s).");
        LOGGER.info("GM " + activeChar.getName() + " mass_created item Id: " + id + " (" + num + ")");
    }

 

final int id = 57;
final int num = 5000000;
final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();
final HashSet<Object> seen = new HashSet<>();
players.removeIf(e -> !seen.add(e.getClient().getConnection().getInetAddress().getHostAddress()));

players.forEach(player -> player.addItem("Admin-Reward", id, num, null, true));

activeChar.sendMessage(String.format("Mass-created items in the inventory of %s player(s)",players.size()));
LOGGER.info(String.format("GM %s mass_created item Id: %s ( %s )",activeChar.getName(),id, num));

 

If you need the number of the players who did not get the reward, you can get them by "seen.getSize()"

Edited by melron
  • 0
Posted
22 minutes ago, melron said:

final int id = 57;
final int num = 5000000;
final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();
final HashSet<Object> seen = new HashSet<>();
players.removeIf(e -> !seen.add(e.getClient().getConnection().getInetAddress().getHostAddress()));

players.forEach(player -> player.addItem("Admin-Reward", id, num, null, true));

activeChar.sendMessage(String.format("Mass-created items in the inventory of %s player(s)",players.size()));
LOGGER.info(String.format("GM %s mass_created item Id: %s ( %s )",activeChar.getName(),id, num));

 

If you need the number of the players who did not get the reward, you can get them by "seen.getSize()"

 

ja.JPG

  • 0
Posted
10 minutes ago, Irrelevant said:

i dont know what do you exactly mean ,i use dualbox to check it :/

Strange, debug it .... before the current code, add this one.

System.out.println("Players online " + L2World.getAllPlayersCount());
L2World.getInstance().getAllPlayers().forEach(p -> System.out.println(String.format("Player %s , ip %s",
		p.getName(), p.getClient().getConnection().getInetAddress().getHostAddress())));

 

and when you click mass create, check the console i need the output

  • 0
Posted
5 minutes ago, melron said:

Strange, debug it .... before the current code, add this one.


System.out.println("Players online " + L2World.getAllPlayersCount());
L2World.getInstance().getAllPlayers().forEach(p -> System.out.println(String.format("Player %s , ip %s",
		p.getName(), p.getClient().getConnection().getInetAddress().getHostAddress())));

 

and when you click mass create, check the console i need the output

you said about bots ,and i had an offline shop in server ,i disconnect it and now it work.BUT i have a question, does that mean that if someone use offline shop noone else will awarded?

  • 0
Posted (edited)
34 minutes ago, melron said:

That was it.

No, create the next method





private boolean isClientOk(L2PcInstance player)
{
	try
	{
		player.getClient().getConnection().getInetAddress().getHostAddress();
	}
	catch (Exception e)
	{
		return false;
	}
	return true;
}

 

and then, change this line





final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers();

 

to





final Collection<L2PcInstance> players = L2World.getInstance().getAllPlayers().stream().filter(p -> isClientOk(p)).collect(Collectors.toList());

 

It works PERFECTLY , i add again the offline shop and test it,its working properly(no errors and reward 1char per ip)!!
Thanks dude!
P.S my code was worked too after i disconnect offline shop . but i kept yours, its better :)

Edited by Irrelevant
  • 0
Posted

I wrote you a more organized and 1 line code. (Consider i just giving you a different perspective of java). The code the other guy gave you it's good and java proof for sure but it's very messy.

 

L2World.getInstance().getPlayers().stream().filter(s -> Objects.nonNull(s.getClient().getConnection())).collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(s -> s.getClient().getConnection().getInetAddress().getHostAddress())))).forEach(s -> s.addItem(getClass().getSimpleName(), 57, 100, s, true));

 

It check for offline shops (since offline player has null connection while assigned a client)

and remove duplicate base on their host name, you can change that to IP or whatever you want.

 

I would also advice you to make a public method which retrieve the IP and the Host Name for a player

and it's safe. 

  • 0
Posted
3 minutes ago, Kara said:

I wrote you a more organized and 1 line code. (Consider i just giving you a different perspective of java). The code the other guy gave you it's good and java proof for sure but it's very messy.

 


L2World.getInstance().getPlayers().stream().filter(s -> Objects.nonNull(s.getClient().getConnection())).collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(s -> s.getClient().getConnection().getInetAddress().getHostAddress())))).forEach(s -> s.addItem(getClass().getSimpleName(), 57, 100, s, true));

 

It check for offline shops (since offline player has null connection while assigned a client)

and remove duplicate base on their host name, you can change that to IP or whatever you want.

 

I would also advice you to make a public method which retrieve the IP and the Host Name for a player

and it's safe. 

i will give a try on that .thanks :D

  • 0
Posted
1 minute ago, Irrelevant said:

i will give a try on that .thanks 😄

 

Consider this is just the way i write java. Clear and short. It doesn't mean you have to use it. 

But for sure you can experiment. (Also i believe it require java 10+)

  • 0
Posted (edited)
10 minutes ago, Kara said:

 

Consider this is just the way i write java. Clear and short. It doesn't mean you have to use it. 

But for sure you can experiment. (Also i believe it require java 10+)

if it requires above java 8 ,i will not try xd (borring to update java again,l2jfrozen uses java 6-7 XDXDXD)

Edited by Irrelevant
  • 0
Posted (edited)
6 minutes ago, Irrelevant said:

if it requires above java 8 ,i will not try xd (borring to update java again,l2jfrozen uses java 6-7 XDXDXD)

 

Ah alright then, i didn't know. For sure you should upgrade to java 8 since scripting engine is still supported and java 8 has some future proof features and it's the current stable java version.

 

I don't see the reason why you stick with Java 7 in 2021. Saying you're lazy and you spend 10 minutes writing in this topic while updating java only take 5.

 

So vouch for java 8 !

 

1X4XFqx.gif

Edited by Kara
Guest
This topic is now closed to further replies.


  • Posts

    • Faltan demasiados archivos,  y lógicas en clases claves como L2pcInstance, entre otras. si bien muchas cosas están y el flujo es valorable.  Gracias por tu esfuerzo es bastante... pero realmente no esta completo el código, falta que subas todas las modificaciones en clases colaterales... podrías intentar subir un diff de todo el mod  completo de tu pack y bueno ahí si que cada uno adapte... pero faltan muchas cosas, dudo que haya gente que lo haya echo funcionar con esto... 
    • I know people who have fully bypassed and reversed AAC. One day, they might even release the full source code, but for now, they’re still making money off it. I won’t name anyone, but it’s clear that there aren’t any truly solid anticheats for Lineage2. As I’ve said before, kernel level anticheats are the only real solution. Anything that runs as Internal and injects gets flagged, and your account ends up getting kicked or banned. That’s just how most games handle it nowadays. To TL;DR the whole thing cheating will always exist because there are people out there smart enough to bypass any protection and run private cheats. Public cheats are always detected eventually, so I don’t see any point in buying AAC, especially when they claim it blocks adr, which simply isn’t true.
    • 🌐 Website: https://l2adonis.com 📅 GRAND OPENING: July 18, 2025 – 20:00 (UTC+2) 💬 Discord: https://discord.com/invite/tZBj8JxAwx 🚫 No auto-farm • No auto-macro • No pay-to-win • No custom   Some Basic Info's (More detalied info's on website)  EXP/SP: x25  Adena: x15  Drop: x15  Spoil: x15  Seal Stones: x15  Raid Boss Drop: x10  Epic Boss Drop: x1  Manor: x10  Safe Enchant: +4  Max Enchant: +16  Normal Scroll Chance: 50%  Blessed Scroll Chance: 66% (If enchant fail item remain +4)  Buff Slots (30+4 extra with Divine Inspiration)  Dances/Songs Slots 14  Auto-learn skills  ⚔️ Real PvP • Real Progression • Retail-like experience JOIN NOW and relive the real L2 experience!
    • Discord         :  utchiha_market Telegram        : https://t.me/utchiha_market Auto Buy Store  : https://utchihamkt.mysellauth.com/ Not sure if we’re legit? Check Our server — real reviews, real buyers https://discord.gg/uthciha-servicess  | https://campsite.bio/utchihaamkt
    • Looking for a Developer – Lineage II Interlude (Vanganth Files)   I’m seeking a developer to collaborate on a project based on Vanganth Interlude files.   Important: Applicants with a bad attitude, lack of respect, or unwillingness to work will be immediately rejected. Payment: Hourly rate, not per task. Contact: Please reach out to me via PM.
  • 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