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

    • Hello Everyone  I hope you missed Old nostalgia BNB , is time to come back and be ready for the new journey  L2 BnB C3 Website: https://l2bnb.eu/ Discord: https://discord.gg/jaCJKYXgYZ Max Level 75 Max Grade (A) Safe:3 , Max:16 Anti-Botting. Auto learning skills , Auto Loot , Auto Create Account Subclass (NO) quest. Retail Buffs/DS Time ,Need Buffer Char (NO NPC Buffer) OfflineShop,OfflineCraft,ChangePass No GM Shop,No Global Gk,No Donate,Free Teleport only LVL 1 commands: .offline , .changepassword 99+% Retail 1+1 Window Per Pc BASIC FEATURES: Exp/SP: x 3 Adena: x3 Drop: х3 Spoil: x3 Support 24/7 GLOBAL COMMUNITY
    • 亲爱的朋友们,我们很高兴向您介绍我们的全新服务 —— KYC 实名认证,适用于任何平台!️ 我们为加密货币交易所、在线市场、社交网络、主机服务商、赌场及其他合法网站提供实名认证服务。认证可通过护照或驾驶证完成。不支持任何涉及非法活动的网站。 可用国家: 东欧:俄罗斯、乌克兰、白俄罗斯、乌兹别克斯坦、亚美尼亚、吉尔吉斯斯坦、哈萨克斯坦 — $30–33 欧盟(西欧,通常为拉脱维亚和爱沙尼亚) — $80–88 非洲:尼日利亚、肯尼亚 — $30–33 如果您需要注册并验证您的账户,总金额将额外收取 10% 手续费。 如需申请 KYC 认证或咨询其他问题,请通过以下方式联系我们: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store SOCNET 商店有效链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 消息应用便捷访问商店。 Telegram 星星购买机器人:进入 – 快速且优惠地购买 Telegram 星星。 SMM 面板:进入 – 推广您的社交媒体账户。 我们为您准备了最新的促销与特别优惠,用于购买我们的产品与服务: 1. 使用优惠码 OCTOBER2025(8% 折扣)即可在 9 月于我们的商店(网站或机器人)购物享受优惠!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获得 $1 商店余额或 10–20% 折扣 —— 只需在网站注册后按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..." – 在我们的论坛帖中发布即可! 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道及星星购买机器人中举行 Telegram 星星赠送活动! 新闻资讯: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh
    • 亲爱的朋友们,我们很高兴向您介绍我们的全新服务 —— KYC 实名认证,适用于任何平台!️ 我们为加密货币交易所、在线市场、社交网络、主机服务商、赌场及其他合法网站提供实名认证服务。认证可通过护照或驾驶证完成。不支持任何涉及非法活动的网站。 可用国家: 东欧:俄罗斯、乌克兰、白俄罗斯、乌兹别克斯坦、亚美尼亚、吉尔吉斯斯坦、哈萨克斯坦 — $30–33 欧盟(西欧,通常为拉脱维亚和爱沙尼亚) — $80–88 非洲:尼日利亚、肯尼亚 — $30–33 如果您需要注册并验证您的账户,总金额将额外收取 10% 手续费。 如需申请 KYC 认证或咨询其他问题,请通过以下方式联系我们: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store SOCNET 商店有效链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 消息应用便捷访问商店。 Telegram 星星购买机器人:进入 – 快速且优惠地购买 Telegram 星星。 SMM 面板:进入 – 推广您的社交媒体账户。 我们为您准备了最新的促销与特别优惠,用于购买我们的产品与服务: 1. 使用优惠码 OCTOBER2025(8% 折扣)即可在 9 月于我们的商店(网站或机器人)购物享受优惠!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获得 $1 商店余额或 10–20% 折扣 —— 只需在网站注册后按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..." – 在我们的论坛帖中发布即可! 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道及星星购买机器人中举行 Telegram 星星赠送活动! 新闻资讯: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh
    • 亲爱的朋友们,我们很高兴向您介绍我们的全新服务 —— KYC 实名认证,适用于任何平台!️ 我们为加密货币交易所、在线市场、社交网络、主机服务商、赌场及其他合法网站提供实名认证服务。认证可通过护照或驾驶证完成。不支持任何涉及非法活动的网站。 可用国家: 东欧:俄罗斯、乌克兰、白俄罗斯、乌兹别克斯坦、亚美尼亚、吉尔吉斯斯坦、哈萨克斯坦 — $30–33 欧盟(西欧,通常为拉脱维亚和爱沙尼亚) — $80–88 非洲:尼日利亚、肯尼亚 — $30–33 如果您需要注册并验证您的账户,总金额将额外收取 10% 手续费。 如需申请 KYC 认证或咨询其他问题,请通过以下方式联系我们: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store SOCNET 商店有效链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 消息应用便捷访问商店。 Telegram 星星购买机器人:进入 – 快速且优惠地购买 Telegram 星星。 SMM 面板:进入 – 推广您的社交媒体账户。 我们为您准备了最新的促销与特别优惠,用于购买我们的产品与服务: 1. 使用优惠码 OCTOBER2025(8% 折扣)即可在 9 月于我们的商店(网站或机器人)购物享受优惠!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获得 $1 商店余额或 10–20% 折扣 —— 只需在网站注册后按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..." – 在我们的论坛帖中发布即可! 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道及星星购买机器人中举行 Telegram 星星赠送活动! 新闻资讯: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh
  • 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