Jump to content

Recommended Posts

Posted (edited)

Make a zone required party with minimum members for lucera.

 


package zones;

import java.util.Collection;
import java.util.Iterator;
import l2.gameserver.instancemanager.ReflectionManager;
import l2.gameserver.listener.zone.OnZoneEnterLeaveListener;
import l2.gameserver.model.Creature;
import l2.gameserver.model.Party;
import l2.gameserver.model.Player;
import l2.gameserver.model.Zone;
import l2.gameserver.network.l2.components.CustomMessage;
import l2.gameserver.network.l2.s2c.ExShowScreenMessage;
import l2.gameserver.scripts.ScriptFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PartyZone implements OnZoneEnterLeaveListener, ScriptFile {
	private static final Logger bEb = LoggerFactory.getLogger(PartyZone.class);
	private static final PartyZone bHe = new PartyZone();
	private static final String bHf = "PartyZone";
	private Object PartyInfo;

	public PartyZone() {
	}

	public void onLoad() {
		byte var1 = 0;
		Collection var2 = ReflectionManager.DEFAULT.getZones();
		Iterator var3 = var2.iterator();

		while(var3.hasNext()) {
			Zone var4 = (Zone)var3.next();
			if (var4.getParams().getBool("PartyZone", false)) {
				var4.addListener(bHe);
			}
		}

		if (var1 > 0) {
			bEb.info("PartyZone: added {} party zone(s).", Integer.valueOf(var1));
		}

	}

	public void onReload() {
		this.onShutdown();
		this.onLoad();
	}

	public void onShutdown() {
		Collection var1 = ReflectionManager.DEFAULT.getZones();
		Iterator var2 = var1.iterator();

		while(var2.hasNext()) {
			Zone var3 = (Zone)var2.next();
			if (var3.getParams().getBool("PartyZone", false)) {
				var3.removeListener(bHe);
			}
		}

	}

	public void onZoneEnter(Zone var1, Creature var2) {
		if (var2.isPlayer()) {
			Player var3 = var2.getPlayer();
			Party var4 = var3.getParty();
			if (var4 == null) {
				String var10 = (new CustomMessage("zone.services.PartyZone", var3, new Object[0])).toString();
				var3.sendPacket(new ExShowScreenMessage(var10, 10000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, false));
				var3.teleToClosestTown();
			}

			if (var3.getParty().getMemberCount() <= 4) {
				String var10 = (new CustomMessage("zone.services.PartyZone", var3, new Object[0])).toString();
				var3.sendPacket(new ExShowScreenMessage(var10, 10000, ExShowScreenMessage.ScreenMessageAlign.TOP_CENTER, false));
				var3.teleToClosestTown();
			}
		}

	}

	public void onZoneLeave(Zone var1, Creature var2) {
	}
}

 

Next you have to add this parameter in zone:         <set name="PartyZone" val="true" />

 

For example:

 

    <zone name="[primeval_peace1]" type="fun" >
            <coords loc="10408 -27395 -4290 -1290" />
            <coords loc="12065 -25334 -4290 -1290" />
            <coords loc="12223 -23159 -4290 -1290" />
            <coords loc="10424 -22340 -4290 -1290" />
            <coords loc="9566 -23131 -4290 -1290" />
            <coords loc="9290 -24261 -4290 -1290" />
        </polygon>
    </zone>

 

Make it like this:

 

    <zone name="[primeval_peace1]" type="fun" >

    <set name="PartyZone" val="true" />
            <coords loc="10408 -27395 -4290 -1290" />
            <coords loc="12065 -25334 -4290 -1290" />
            <coords loc="12223 -23159 -4290 -1290" />
            <coords loc="10424 -22340 -4290 -1290" />
            <coords loc="9566 -23131 -4290 -1290" />
            <coords loc="9290 -24261 -4290 -1290" />
        </polygon>
    </zone>

 

Then go to en string gameserver\data\string and add this line:

zone.services.PartyZone=You Are Not Currently In A Party With Minimum 5 Party Members So You Cannot Enter.

And this line to ru string gameserver\data\string:

zone.services.PartyZone=Вы не находитесь в партии с минимум 5 членами партии Так что вы не можете войти.

If you want to change the value of minimum players then you have to change the number 4 in this line in ext:

if (var3.getParty().getMemberCount() <= 4) {

 

DOWNLOAD EXT

 

This is a simple code i make it for my needs you can remake it as you want don't spam this topic.

Edited by • Punisher •
  • Thanks 3
Posted (edited)

I don't think deleting my reply is by any means the right thing to do here. I am not spamming, I am expressing my opinion and helping/warning admins that might want to use a party zone in their own server.

Your code works, I am just saying how to improve it, I did not force you to do it but someone might want my opinion.

 

Reposted:

 

 

Variable naming is terrible.

byte var1 = 0;

This will always be 0,

 

since you don't check if the players leave the party while within the zone, a simple check in the teleporter would be enough. This whole code can be replaced by 1 line of code.

 

In addition to that, the method onZoneEnter, can be made like so:

 

    public void onZoneEnter(Zone zone, Creature creature)
    {
        if (creature.isPlayer() && (creature.getPlayer().getParty() == null || creature.getParty().getMembers().size() < 5))
        {
            creature.getPlayer().sendMessage("You are not in a party that consists of 5 or more members, you cannot enter the party zone.");
            creature.getPlayer().teleToClosestTown();
        }
    }

 

 

Generally, the idea to teleport players back, the moment they teleport in the zone is very very bad and will result in a laggy, long teleport or even some critical errors.

Edited by An4rchy
Posted (edited)

First of all your code is not working and as i say in description i make it for my needs if you can make it better you can reshare it this maybe helps more than to judge my code when you dont give any solution here, a simple teleport is not better since you can walk into the zone!

Edited by • Punisher •
Posted (edited)

Why would someone walk all the way to the Party zone? :D

 

But even if he did, a party zone that needs 3 people to enter should have difficult to kill mobs, therefore someone going there solo (by walking) would achieve nothing for him other than wasting his time.

 

Anyway, I just pointed out how to improve your code, perhaps you should implement my improvements in your other codes too. The logic ‘if it works, it’s ok’ is not quite right and you should consider all possibilities when you code something.

Edited by An4rchy
Posted
16 hours ago, An4rchy said:

I don't think deleting my reply by any means the right thing to do here. I am not spamming, I am expressing my opinion and helping/warning admins that might want to use a party zone in their own server.

Your code works, I am just saying how to improve it, I did not force you to do it but someone might want my opinion.

 

Reposted:

Variable naming is terrible,.


byte var1 = 0;

This will always be 0,

 

You really point out var name to an amateur person who have no idea what java is? We are in 2020 and sharing 10 lines of code which is against rules while deleting other's comment or chat ban them if the post does not contain "Thanks ! Very useful code". 

 

So again don't bother.

Posted (edited)
10 minutes ago, Elfocrash said:

Tbh the code looks like it's been decompiled, there is no way he wrote this. Not because he is bad but because there is no way a human being actually writes code like this.

 

  • The static final field names look obfuscated
  • The Object PartyInfo makes it seem like there was a class named PartyInfo that he didn't have access to
  • This collection var and iterator is what the IL code will be converted to in a stream().foreach if I'm not wrong
  • var1, var2, var3, var4 are decompiling names
  • The empty public constructor 

Lucera doesnt give you source the only you can do is to create extensions with intelij or the IDEA program you are using in my subject (im not professional java coder) i just take some examples and i make it thats all nothing special ! 

Edited by Dragic
Posted
4 minutes ago, Elfocrash said:

I know it doesn't give you source but it doesn't force you to name the fields or write the implementations in some special way. I've written code for Lucera's plugin engine before and they look like normal code with some listeners

I would say the same thing if I were you but we are not all on the same level :laughing:

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

    • Looking for someone to setup a website for me with account panel and donate panel, I require to explain me how to setup the account panel to be working with player's emails and my lineage2 server and donate panel in order to be working with my paypal and my lineage2 server. Contact me here in forum, I will pick the best offert. Thank you.
    • TILL START - LEFT 3 DAYS ! GRAND OPENING FROM - 12/052025, FRIDAY, 20:00 +3 GMT !
    • SOCNET — BIRTHDAY! Thank you for staying with us! A week of maximum gifts, bonuses, and discounts! Today we celebrate the SOCNET project’s birthday — and YOU get the gifts! We’ve prepared powerful promotions across all our services: ⭐ SOCNET STORE — SHOP (website/telegram) 1. Promo code BIRTHDAY — 20% discount Use it for any product purchase! 2. Gift for a large purchase Spend $200 on any products and choose any item up to $10 — for free! 3. Gift balance for a comment in our store threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐ SOCNET SMM PANEL 1. Top-up = bonus Top up your balance by $100 and get +$5 to your balance. After topping up — create a ticket in the panel. 2. Gift balance for a comment in our SMM Panel threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET STARS — BOT FOR BUYING TELEGRAM STARS/PREMIUM 1. Large purchase = huge bonus Buy >1000 Stars in one transaction and get +100 Stars as a gift! After purchase, write to support. 2. Gift balance for a comment in our bot threads for star purchases "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. Leave a comment: ➡ 1 forum = +50 Stars to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET SMS SERVICE OF VIRTUAL NUMBERS 1. Top-up with bonus Top up your balance by $50 and get +$10 as a gift. After topping up — simply write to support. 2. Gift balance for a comment in our SMS service threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. Let’s celebrate together! Promotions are valid from 02.12.2025 to 07.12.2025 inclusive. Don’t miss it — these are the best conditions of the year! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • SOCNET — BIRTHDAY! Thank you for staying with us! A week of maximum gifts, bonuses, and discounts! Today we celebrate the SOCNET project’s birthday — and YOU get the gifts! We’ve prepared powerful promotions across all our services: ⭐ SOCNET STORE — SHOP (website/telegram) 1. Promo code BIRTHDAY — 20% discount Use it for any product purchase! 2. Gift for a large purchase Spend $200 on any products and choose any item up to $10 — for free! 3. Gift balance for a comment in our store threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐ SOCNET SMM PANEL 1. Top-up = bonus Top up your balance by $100 and get +$5 to your balance. After topping up — create a ticket in the panel. 2. Gift balance for a comment in our SMM Panel threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET STARS — BOT FOR BUYING TELEGRAM STARS/PREMIUM 1. Large purchase = huge bonus Buy >1000 Stars in one transaction and get +100 Stars as a gift! After purchase, write to support. 2. Gift balance for a comment in our bot threads for star purchases "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. Leave a comment: ➡ 1 forum = +50 Stars to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET SMS SERVICE OF VIRTUAL NUMBERS 1. Top-up with bonus Top up your balance by $50 and get +$10 as a gift. After topping up — simply write to support. 2. Gift balance for a comment in our SMS service threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. Let’s celebrate together! Promotions are valid from 02.12.2025 to 07.12.2025 inclusive. Don’t miss it — these are the best conditions of the year! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • SOCNET — BIRTHDAY! Thank you for staying with us! A week of maximum gifts, bonuses, and discounts! Today we celebrate the SOCNET project’s birthday — and YOU get the gifts! We’ve prepared powerful promotions across all our services: ⭐ SOCNET STORE — SHOP (website/telegram) 1. Promo code BIRTHDAY — 20% discount Use it for any product purchase! 2. Gift for a large purchase Spend $200 on any products and choose any item up to $10 — for free! 3. Gift balance for a comment in our store threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐ SOCNET SMM PANEL 1. Top-up = bonus Top up your balance by $100 and get +$5 to your balance. After topping up — create a ticket in the panel. 2. Gift balance for a comment in our SMM Panel threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET STARS — BOT FOR BUYING TELEGRAM STARS/PREMIUM 1. Large purchase = huge bonus Buy >1000 Stars in one transaction and get +100 Stars as a gift! After purchase, write to support. 2. Gift balance for a comment in our bot threads for star purchases "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. Leave a comment: ➡ 1 forum = +50 Stars to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET SMS SERVICE OF VIRTUAL NUMBERS 1. Top-up with bonus Top up your balance by $50 and get +$10 as a gift. After topping up — simply write to support. 2. Gift balance for a comment in our SMS service threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. Let’s celebrate together! Promotions are valid from 02.12.2025 to 07.12.2025 inclusive. Don’t miss it — these are the best conditions of the year! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • 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