Jump to content

Recommended Posts

Posted (edited)

Hello guys! I adapted the code about "Cannot Enchant near Warehouse"

I found the code by Prince*

I adapted this code for Frozen...

Try it and tell me if it's working good because i didn't check it.

Thank you :)

 

"I know it wasn't hard to adapt it but i wanted to share it for frozen because some guys don't know how to do it... Peace :)"

 

--- head-src/com/l2jfrozen/gameserver/clientpackets/RequestEnchantItem.java
+++ head-src/com/l2jfrozen/gameserver/clientpackets/RequestEnchantItem.java

@@ 20,1 @@

import com.l2jfrozen.Collection;
import com.l2jfrozen.Logger;

import com.l2jfrozen.gameserver.model.Inventory;
+import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2ItemInstance;


import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2WarehouseInstance;
import com.l2jfrozen.gameserver.network.SystemMessageId;


import com.l2jfrozen.gameserver.model.L2ItemInstance;
+import com.l2jfrozen.gameserver.model.L2Object;
import com.l2jfrozen.gameserver.model.L2World;


@@ -61,7 +61,15 @@
     {
         L2PcInstance activeChar = getClient().getActiveChar();
+               Collection<L2Character> knowns  = activeChar.getKnownList().getKnownCharactersInRadius(400);
         if (activeChar == null || _objectId == 0)
                        return;
+              
+               for (L2Object wh : knowns)
+               {
+                       if (wh instanceof L2WarehouseInstance)
+                       {
+                               activeChar.sendMessage("You cannot enchant near warehouse.");
+                               return;
+                       }
+               }
         L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
         L2ItemInstance scroll = activeChar.getActiveEnchantItem();

 

 

Edited by Kounto
Posted

Put that

activeChar.getKnownList().getKnownCharactersInRadius(400)

directly in the for loop . First because it's a good writting style to write things in the shortest range possible (faster ready for garbage collection), second because you put it before a activeChar == null check, so it will throw a NPE if activeChar is null.

Posted
7 hours ago, L2DragonWind said:

Why need this?

You cannot enchant near warehouse... Before some years it was a bug. Now i don't know if you can use this bug but i think this code is useful about your safety.

Posted

About the coding style you can just add after the null activechar check the following:

 

if (activeChar.getKnownList().getKnownCharactersInRadius(400).stream().filter(obj -> obj instanceof L2WarehouseInstance).findFirst())
{
	activeChar.sendMessage("You cannot enchant near warehouse.");
	return;
}

About the results.. In order someone to use this code must have old sources that missing important fixes

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...