Kounto Posted February 12, 2018 Posted February 12, 2018 (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 February 12, 2018 by Kounto
Tryskell Posted February 13, 2018 Posted February 13, 2018 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.
Kounto Posted February 13, 2018 Author Posted February 13, 2018 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.
Kounto Posted February 13, 2018 Author Posted February 13, 2018 Thank you Tryskell for your reply. Good notice.
Kounto Posted February 13, 2018 Author Posted February 13, 2018 1 hour ago, SweeTs said: Ofc it's not working. The reason?
melron Posted February 13, 2018 Posted February 13, 2018 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
SweeTs Posted February 13, 2018 Posted February 13, 2018 5 hours ago, Kounto said: The reason? I was referring to the bug.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now