Hi guys. I am sharing an older code for Interlude with what i have a small issue. This is the Craft Manager what i recently managed to make it work. The code works fine, except for a little detail. This code loads up the items that are eligible for crystallization from D grade up to A grade. Problem is it loads up the items that are equipped aswell. How can i bypass it so it will ignore those items on the character so the user wont accidentally crystallize the equipped gear. My knowledge for this is mediocre at best, and i tried multiple aproches and have come up with nothing. Any help is appreciated. Thanks!
Here is the updated code for the Craft Manager for anyone who wants to use it. The only known issue so far, is the one on my 2nd post with the item selection crash after a certain amount.
package com.l2jmobius.gameserver.model.actor.instance;
import java.util.ArrayList;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.datatables.csv.RecipeTable;
import com.l2jmobius.gameserver.datatables.sql.IconTable;
import com.l2jmobius.gameserver.datatables.xml.ItemTable;
import com.l2jmobius.gameserver.model.Inventory;
import com.l2jmobius.gameserver.model.L2RecipeList;
import com.l2jmobius.gameserver.model.multisell.L2Multisell;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.templates.chars.L2NpcTemplate;
import com.l2jmobius.gameserver.templates.item.L2EtcItemType;
import com.l2jmobius.gameserver.templates.item.L2Item;
public class L2CraftManagerInstance extends L2MerchantInstance
{
public static final int ADENA_ID = 57;
public static final int ITEMS_PER_PAGE = 6; // items list size in craft and crystallize pages
public L2CraftManagerInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
}
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
if (command.startsWith("multisell"))
{
L2Multisell.getInstance().generateMultiSell(Integer.parseInt(command.substring(9).trim()), player, false, this);
}
else if (command.startsWith("Crystallize")) // List player inventory items for crystallization
{
int _pageId;
ArrayList<Integer> _itemsSelected = new ArrayList<>();
Inventory _inventory = player.getInventory();
StringTokenizer st = new StringTokenizer(command.substring(11).trim());
try
{
if (st.countTokens() > 1)
{
_pageId = Integer.parseInt(st.nextToken());
while (st.hasMoreTokens())
{
int _itemObjId = Integer.parseInt(st.nextToken());
if ((_inventory.getItemByObjectId(_itemObjId) != null) && (!_itemsSelected.contains(_itemObjId)))
{
_itemsSelected.add(_itemObjId);
}
}
}
else
{
_pageId = Integer.parseInt(command.substring(11).trim());
}
}
catch (NumberFormatException e)
{
_pageId = 0;
}
ArrayList<Integer> _items = new ArrayList<>();
int _priceTotal = 0;
ArrayList<Integer> _crystals = new ArrayList<>();
_crystals.add(0, 0);
_crystals.add(1, 0);
_crystals.add(2, 0);
_crystals.add(3, 0);
_crystals.add(4, 0);
_crystals.add(5, 0);
for (L2ItemInstance _item : _inventory.getItems())
{
if (!_item.isStackable() && (_item.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL) && (_item.getItem().getCrystalType() != L2Item.CRYSTAL_NONE) && (_item.getItem().getCrystalCount() > 0))
{
_items.add(_item.getObjectId());
if (_itemsSelected.contains(_item.getObjectId()))
{
int _count = _crystals.get(_item.getItem().getCrystalType()) + _item.getCrystalCount();
_crystals.set(_item.getItem().getCrystalType(), _count);
int _crystalId = 1457 + _item.getItem().getCrystalType();
int _price = (int) ((Config.ALT_CRAFT_PRICE * _count * ItemTable.getInstance().getTemplate(_crystalId).getReferencePrice()) / 55);
if (_price == 0)
{
_price = Config.ALT_CRAFT_DEFAULT_PRICE;
}
_priceTotal += _price;
}
}
}
if (_items.size() == 0)
{
sendOutOfItems(player, "at least one", "breakable item");
return;
}
int _itemsOnPage = ITEMS_PER_PAGE;
int _pages = _items.size() / _itemsOnPage;
if (_items.size() > (_pages * _itemsOnPage))
{
_pages++;
}
if (_pageId > _pages)
{
_pageId = _pages;
}
int _itemStart = _pageId * _itemsOnPage;
int _itemEnd = _items.size();
if ((_itemEnd - _itemStart) > _itemsOnPage)
{
_itemEnd = _itemStart + _itemsOnPage;
}
String _elementsSelected = "";
for (int i = 0; i < _itemsSelected.size(); i++)
{
_elementsSelected += " " + _itemsSelected.get(i);
}
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append("<center>Items to Crystallize</center>");
replyMSG.append("<imgsrc=\"L2UI.SquareWhite\"width=300height=1><imgsrc=\"L2UI.SquareBlank\"width=1height=3>");
replyMSG.append("<tablewidth=270><tr>");
replyMSG.append("<tdwidth=66><buttonvalue=\"Back\"action=\"bypass -h npc_" + getObjectId() + ((_pageId== 0) ? "_Chat 0" : "_Crystallize ") + (_pageId - 1) + _elementsSelected + "\"width=65height=19back=\"L2UI_ch3.smallbutton2_over\"fore=\"L2UI_ch3.smallbutton2\"></td>");
replyMSG.append("<tdwidth=138></td>");
replyMSG.append("<tdwidth=66>" + (((_pageId + 1) < _pages) ? "<buttonvalue=\"Next\"action=\"bypass -h npc_" + getObjectId() + "_Crystallize " + (_pageId + 1) + _elementsSelected + "\"width=65height=19back=\"L2UI_ch3.smallbutton2_over\"fore=\"L2UI_ch3.smallbutton2\">" : "") + "</td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br>");
replyMSG.append("<tablewidth=270><tr>");
if (Config.ALT_CRAFT_ALLOW_CRYSTALLIZE)
{
replyMSG.append("<tdwidth=35><buttonvalue=\"\"action=\"bypass -h npc_" + getObjectId() + "_BreakItem" + _elementsSelected + "\"width=32height=32back=\"icon.skill0248\"fore=\"icon.skill0248\"></td>");
replyMSG.append("<tdwidth=135>");
replyMSG.append("<tableborder=0width=100%>");
replyMSG.append("<tr><td><fontcolor=\"B09878\">Crystallize</font></td></tr>");
replyMSG.append("<tr><td><fontcolor=\"B09878\">selected items " + (_itemsSelected.size() == 0 ? "" : "(" + _itemsSelected.size() + ")") + "</font></td></tr></table></td>");
replyMSG.append("<tdwidth=100>");
replyMSG.append("<tableborder=0width=100%>");
replyMSG.append("<tr><td><fontcolor=\"A2A0A2\">Total price:</font></td></tr>");
replyMSG.append("<tr><td><fontcolor=\"B09878\">" + _priceTotal + " Adena</font></td></tr></table></td>");
}
replyMSG.append("</tr></table><br>");
for (int i = _itemStart; i < _itemEnd; i++)
{
L2ItemInstance _item = _inventory.getItemByObjectId(_items.get(i));
if (_item == null)
{
continue;
}
int _crystalId = 1457 + _item.getItem().getCrystalType();
String _crystal = _item.getItem().getCrystalType() == 1 ? "D" : _item.getItem().getCrystalType() == 2 ? "C" : _item.getItem().getCrystalType() == 3 ? "B" : _item.getItem().getCrystalType() == 4 ? "A" : _item.getItem().getCrystalType() == 5 ? "S" : "S";
int _count = _item.getCrystalCount();
int _price = (int) ((Config.ALT_CRAFT_PRICE * _count * ItemTable.getInstance().getTemplate(_crystalId).getReferencePrice()) / 55);
if (_price == 0)
{
_price = Config.ALT_CRAFT_DEFAULT_PRICE;
}
replyMSG.append("<imgsrc=\"L2UI.SquareWhite\"width=300height=1><imgsrc=\"L2UI.SquareBlank\"width=1height=1>");
replyMSG.append("<tablewidth=300bgcolor=000000><tr>");
replyMSG.append("<tdwidth=44height=41align=center><tablebgcolor=FFFFFFcellpadding=6cellspacing=\"-5\"><tr><td><buttonwidth=32height=32back=" + IconTable.getIcon(_item.getItemId()) + "fore=" + IconTable.getIcon(_item.getItemId()) + "></td></tr></table></td>");
replyMSG.append("<tdwidth=240height=20>");
replyMSG.append("<tableborder=0width=100%>");
replyMSG.append("<tr><td><fontcolor=\"A2A0A2\">" + ItemTable.getInstance().getTemplate(_item.getItemId()).getName() + (_item.getEnchantLevel() == 0 ? "" : " +" + _item.getEnchantLevel()) + "</font></td></tr>");
replyMSG.append("<tr><td><fontcolor=\"A2A0A2\">" + _crystal + " Crystals:</font><fontcolor=\"B09878\">" + _count + "</font></td></tr></table></td>");
if (Config.ALT_CRAFT_ALLOW_CRYSTALLIZE)
{
if (_itemsSelected.contains(_items.get(i)))
{
replyMSG.append("<tdvalign=centerwidth=20><buttonvalue=\"\"action=\"bypass -h npc_" + getObjectId() + "_Crystallize " + _pageId + _elementsSelected.replace(" " + _items.get(i).toString(), "") + "\"width=16height=16back=\"L2UI.CheckBox_checked\"fore=\"L2UI.CheckBox_checked\"></td>");
}
else
{
replyMSG.append("<tdvalign=centerwidth=20><buttonvalue=\"\"action=\"bypass -h npc_" + getObjectId() + "_Crystallize " + _pageId + " " + _items.get(i).toString() + _elementsSelected + "\"width=16height=16back=\"L2UI.CheckBox\"fore=\"L2UI.CheckBox\"></td>");
}
}
else
{
replyMSG.append("<tdvalign=centerwidth=20></td>");
}
replyMSG.append("</tr></table>");
}
replyMSG.append("</body></html>");
npcReply.setHtml(replyMSG.toString());
player.sendPacket(npcReply);
}
else if (command.startsWith("BreakItem") && Config.ALT_CRAFT_ALLOW_CRYSTALLIZE)
// Crystallize selected items
{
ArrayList<Integer> _itemsSelected = new ArrayList<>();
Inventory _inventory = player.getInventory();
StringTokenizer st = new StringTokenizer(command.substring(9).trim());
try
{
while (st.hasMoreTokens())
{
int _itemObjId = Integer.parseInt(st.nextToken());
if ((_inventory.getItemByObjectId(_itemObjId) != null) && (!_itemsSelected.contains(_itemObjId)))
{
_itemsSelected.add(_itemObjId);
}
}
}
catch (NumberFormatException e)
{
}
if (_itemsSelected.size() == 0)
{
sendOutOfItems(player, "at least one", "breakable items");
return;
}
int _priceTotal = 0;
ArrayList<Integer> _crystals = new ArrayList<>();
_crystals.add(0, 0);
_crystals.add(1, 0);
_crystals.add(2, 0);
_crystals.add(3, 0);
_crystals.add(4, 0);
_crystals.add(5, 0);
for (int i = 0; i < _itemsSelected.size(); i++)
{
L2ItemInstance _item = _inventory.getItemByObjectId(_itemsSelected.get(i));
if ((_item != null) && (_item.getOwnerId() == player.getObjectId()) && !_item.isStackable() && (_item.getItem().getCrystalType() != L2Item.CRYSTAL_NONE) && (_item.getItem().getCrystalCount() > 0) && (i < _itemsSelected.size()))
{
int _count = _crystals.get(_item.getItem().getCrystalType()) + _item.getCrystalCount();
_crystals.set(_item.getItem().getCrystalType(), _count);
int _crystalId = 1457 + _item.getItem().getCrystalType();
int _price = (int) ((Config.ALT_CRAFT_PRICE * _count * ItemTable.getInstance().getTemplate(_crystalId).getReferencePrice()) / 55);
if (_price == 0)
{
_price = Config.ALT_CRAFT_DEFAULT_PRICE;
}
_priceTotal += _price;
}
else
{
_itemsSelected.remove(i);
}
}
if (_inventory.getInventoryItemCount(ADENA_ID, 0) < _priceTotal)
{
sendOutOfItems(player, Integer.toString(_priceTotal), "Adena");
return;
}
InventoryUpdate iu = new InventoryUpdate();
player.destroyItemByItemId("CraftManager", ADENA_ID, _priceTotal, player, true);
iu.addModifiedItem(player.getInventory().getItemByItemId(ADENA_ID));
for (int i = 0; i < _itemsSelected.size(); i++)
{
L2ItemInstance _item = _inventory.getItemByObjectId(_itemsSelected.get(i));
if ((_item != null) && (_item.getOwnerId() == player.getObjectId()) && !_item.isStackable() && (_item.getItem().getCrystalType() != L2Item.CRYSTAL_NONE) && (_item.getItem().getCrystalCount() > 0))
{
if (_item.isEquipped())
{
L2ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(_item.getEquipSlot());
if (_item.isEquipped())
{
for (L2ItemInstance element : unequiped)
{
iu.addModifiedItem(element);
}
}
}
player.destroyItem("CraftManager", _itemsSelected.get(i), 1, player, true);
iu.addModifiedItem(player.getInventory().getItemByObjectId(_itemsSelected.get(i)));
}
}
for (int i = 0; i < _crystals.size(); i++)
{
if (_crystals.get(i) > 0)
{
int _crystalId = 1457 + i;
SystemMessage sm = null;
sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(_crystalId);
sm.addNumber(_crystals.get(i));
player.sendPacket(sm);
_inventory.addItem("CraftManager", _crystalId, _crystals.get(i), player, player.getTarget());
iu.addModifiedItem(player.getInventory().getItemByItemId(_crystalId));
}
}
player.sendPacket(iu);
player.broadcastUserInfo();
}
else if (command.startsWith("Manufacture"))
// List recipes from player inventory
{
int _pageId;
try
{
_pageId = Integer.parseInt(command.substring(11).trim());
}
catch (NumberFormatException e)
{
_pageId = 0;
}
Inventory _inventory = player.getInventory();
ArrayList<Integer> _recipes = new ArrayList<>();
for (L2ItemInstance _item : _inventory.getItems())
{
if (_item.getItemType() == L2EtcItemType.RECEIPE)
{
L2RecipeList _recipe = RecipeTable.getInstance().getRecipeByItemId(_item.getItemId());
if (_recipe != null)
{
_recipes.add(_item.getObjectId());
}
}
}
if (_recipes.size() == 0)
{
sendOutOfItems(player, "at least one", "recipe");
return;
}
int _itemsOnPage = ITEMS_PER_PAGE;
int _pages = _recipes.size() / _itemsOnPage;
if (_recipes.size() > (_pages * _itemsOnPage))
{
_pages++;
}
if (_pageId > _pages)
{
_pageId = _pages;
}
int _itemStart = _pageId * _itemsOnPage;
int _itemEnd = _recipes.size();
if ((_itemEnd - _itemStart) > _itemsOnPage)
{
_itemEnd = _itemStart + _itemsOnPage;
}
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append("<center>List of Recipes</center>");
replyMSG.append("<imgsrc=\"L2UI.SquareWhite\"width=300height=1><imgsrc=\"L2UI.SquareBlank\"width=1height=3>");
replyMSG.append("<br1>");
replyMSG.append("<center><fontcolor=\"FFFF00\">To craft multiple items first press </center></font>");
replyMSG.append("<br1>");
replyMSG.append("<center><fontcolor=\"FFFF00\">CALCULATE to see if you have the required amount!</center></font>");
replyMSG.append("<tablewidth=270><tr>");
replyMSG.append("<tdwidth=66><buttonvalue=\"Back\"action=\"bypass -h npc_" + getObjectId() + ((_pageId== 0) ? "_Chat 0" : "_Manufacture ") + (_pageId - 1) + "\"width=65height=19back=\"L2UI_ch3.smallbutton2_over\"fore=\"L2UI_ch3.smallbutton2\"></td>");
replyMSG.append("<tdwidth=138></td>");
replyMSG.append("<tdwidth=66>" + (((_pageId + 1) < _pages) ? "<buttonvalue=\"Next\"action=\"bypass -h npc_" + getObjectId() + "_Manufacture " + (_pageId + 1) + "\"width=65height=19back=\"L2UI_ch3.smallbutton2_over\"fore=\"L2UI_ch3.smallbutton2\">" : "") + "</td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br>");
replyMSG.append("<imgsrc=\"L2UI.SquareWhite\"width=300height=1><imgsrc=\"L2UI.SquareBlank\"width=1height=1>");
for (int i = _itemStart; i < _itemEnd; i++)
{
L2ItemInstance _recipe = _inventory.getItemByObjectId(_recipes.get(i));
if (_recipe == null)
{
continue;
}
L2RecipeList _recipeList = RecipeTable.getInstance().getRecipeByItemId(_recipe.getItemId());
if (_recipeList == null)
{
continue;
}
boolean _isConsumable = ItemTable.getInstance().getTemplate(_recipeList.getItemId()).isConsumable();
int _price = (int) ((((Config.RATE_CRAFT_COST * _recipeList.getSuccessRate()) / 100) * ItemTable.getInstance().getTemplate(_recipeList.getItemId()).getReferencePrice()) / 55);
if (_price == 0)
{
_price = Config.ALT_CRAFT_DEFAULT_PRICE;
}
L2Item item = ItemTable.getInstance().getTemplate(_recipe.getItemId());
String name = item.getName();
if (name.startsWith("Recipe: "))
{
name = "R: " + name.substring(8);
}
String _recipeIcon = IconTable.getIcon(item.getItemId());
replyMSG.append("<tablewidth=300bgcolor=000000><tr>");
replyMSG.append("<tdvalign=topwidth=35><buttonvalue=\"\"action=\"bypass -h npc_" + getObjectId() + "_CraftInfo " + _recipes.get(i) + " 1 " + _pageId + "\"width=32height=32back=\"" + _recipeIcon + "\"fore=\"" + _recipeIcon + "\"></td>");
replyMSG.append("<tdvalign=topwidth=235>");
replyMSG.append("<tdvalign=centerwidth=320height=20>");
replyMSG.append("<tableborder=0width=100%>");
replyMSG.append("<tr><td><fontcolor=\"FFFF00\">" + name + "</font></td></tr>");
replyMSG.append("<tr><td><fontcolor=\"A2A0A2\">Product:</font><fontcolor=\"B09878\">" + (_isConsumable ? _recipeList.getCount() + " " : "") + ItemTable.getInstance().getTemplate(_recipeList.getItemId()).getName() + "</font></td></tr></table></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<imgsrc=\"L2UI.SquareWhite\"width=300height=1><imgsrc=\"L2UI.SquareBlank\"width=1height=1>");
replyMSG.append("<br1>");
}
replyMSG.append("</body></html>");
npcReply.setHtml(replyMSG.toString());
player.sendPacket(npcReply);
}
else if (command.startsWith("CraftInfo"))
// Show information about choosen recipe
{
int _recipeObjId = 0;
int _pageId = 0;
int _quantity = 1;
StringTokenizer st = new StringTokenizer(command.substring(9).trim());
try
{
if (st.countTokens() > 2)
{
_recipeObjId = Integer.parseInt(st.nextToken());
_quantity = Integer.parseInt(st.nextToken());
}
else
{
_recipeObjId = Integer.parseInt(st.nextToken());
}
_pageId = Integer.parseInt(st.nextToken());
}
catch (NumberFormatException e)
{
}
Inventory _inventory = player.getInventory();
L2ItemInstance _recipe = _inventory.getItemByObjectId(_recipeObjId);
L2RecipeList _recipeList = RecipeTable.getInstance().getRecipeByItemId(_recipe.getItemId());
boolean _isConsumable = ItemTable.getInstance().getTemplate(_recipeList.getItemId()).isConsumable();
if ((_recipe.getOwnerId() == player.getObjectId()) && (_recipe.getItemType() == L2EtcItemType.RECEIPE))
{
int _price = (int) ((((Config.RATE_CRAFT_COST * _recipeList.getSuccessRate()) / 100) * _quantity * (_isConsumable ? _recipeList.getCount() : 1) * ItemTable.getInstance().getTemplate(_recipeList.getItemId()).getReferencePrice()) / 55);
if (_price == 0)
{
_price = Config.ALT_CRAFT_DEFAULT_PRICE;
}
L2Item item = ItemTable.getInstance().getTemplate(_recipe.getItemId());
String name = item.getName();
if (name.startsWith("Recipe: "))
{
name = "R: " + name.substring(8);
}
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append("<center>Craft Info</center>");
replyMSG.append("<imgsrc=\"L2UI.SquareWhite\"width=300height=1><imgsrc=\"L2UI.SquareBlank\"width=1height=3>");
replyMSG.append("<tablewidth=270><tr>");
replyMSG.append("<tdwidth=66><buttonvalue=\"Back\"action=\"bypass -h npc_" + getObjectId() + "_Manufacture " + _pageId + "\"width=65height=19back=\"L2UI_ch3.smallbutton2_over\"fore=\"L2UI_ch3.smallbutton2\"></td>");
replyMSG.append("<tdwidth=138></td>");
replyMSG.append("<tdwidth=66></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<br>");
replyMSG.append("<tablewidth=270><tr>");
if ((_recipeList.isDwarvenRecipe() && Config.ALT_CRAFT_ALLOW_CRAFT) || (!_recipeList.isDwarvenRecipe() && Config.ALT_CRAFT_ALLOW_COMMON))
{
replyMSG.append("<tdvalign=topwidth=35><buttonvalue=\"\"action=\"bypass -h npc_" + getObjectId() + "_CraftItem " + _recipeObjId + " " + _quantity + "\"width=32height=32back=\"icon.skill0172\"fore=\"icon.skill0172\"></td>");
}
else
{
replyMSG.append("<tdvalign=topwidth=35><imgsrc=icon.skill0172width=32height=32align=left></td>");
}
replyMSG.append("<tdvalign=topwidth=235>");
replyMSG.append("<tableborder=0width=100%>");
replyMSG.append("<tr><td><fontcolor=\"FFFF00\">" + name + "</font></td></tr>");
replyMSG.append("<tr><td><fontcolor=\"A2A0A2\">Product:</font><fontcolor=\"B09878\">" + (_isConsumable ? (_recipeList.getCount() * _quantity) + " * " : _quantity > 1 ? _quantity : "") + " " + ItemTable.getInstance().getTemplate(_recipeList.getItemId()).getName() + "</font></td></tr>");
if ((_recipeList.isDwarvenRecipe() && Config.ALT_CRAFT_ALLOW_CRAFT) || (!_recipeList.isDwarvenRecipe() && Config.ALT_CRAFT_ALLOW_COMMON))
{
replyMSG.append("<tr><td><fontcolor=\"A2A0A2\">Price:</font><fontcolor=\"B09878\">" + _price + " Adena</font></td></tr></table></td>");
}
else
{
replyMSG.append("<tr><td></td></tr></table></td>");
}
replyMSG.append("</tr></table>");
replyMSG.append("<br>");
replyMSG.append("<center>");
replyMSG.append("<tablewidth=210>");
replyMSG.append("<tr><tdvalign=topwidth=70><fontcolor=\"B09878\">Enter quantity:</font></td><td></td></tr>");
replyMSG.append("<tr><tdvalign=topwidth=70><editvar=\"quantity\"width=70></td>");
replyMSG.append("<tdvalign=topwidth=70><buttonvalue=\"Calculate\"action=\"bypass -h npc_" + getObjectId() + "_CraftInfo " + _recipeObjId + " $quantity " + _pageId + "\"width=65height=19back=\"L2UI_ch3.smallbutton2_over\"fore=\"L2UI_ch3.smallbutton2\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("</center>");
replyMSG.append("<br>");
replyMSG.append("<br>");
replyMSG.append("<tablewidth=270><tr>");
replyMSG.append("<tdwidth=220><button value=\"Ingredients\" width=60 height=21 back=\"botaoes1.s04_over\" fore=\"botaoes1.s04_over\"</td>"); // width=120 height=21 back=\"botaoes1.s03_over\" fore=\"botaoes1.s03\">"
replyMSG.append("<tdwidth=50><button value=\"Quantity\" width=60 height=21 back=\"botaoes1.s04_over\" fore=\"botaoes1.s04_over\"</td></tr>");
L2RecipeInstance[] _recipeItems = _recipeList.getRecipes();
for (L2RecipeInstance _recipeItem : _recipeItems)
{
L2ItemInstance _item = _inventory.getItemByItemId(_recipeItem.getItemId());
String _quantityState = "<fontcolor=\"55FF55\">" + (_quantity * _recipeItem.getQuantity()) + "</font>";
if ((_item == null) || (_item.getCount() < (_quantity * _recipeItem.getQuantity())))
{
_quantityState = "<fontcolor=\"FF5555\">" + (int) (_quantity * _recipeItem.getQuantity() * Config.ALT_RATE_CRAFT_COST) + "</font>";
}
replyMSG.append("<tr><tdwidth=220>" + ItemTable.getInstance().getTemplate(_recipeItem.getItemId()).getName() + "</td>");
replyMSG.append("<tdwidth=50>" + _quantityState + "</td></tr>");
}
replyMSG.append("</table>");
replyMSG.append("</body></html>");
npcReply.setHtml(replyMSG.toString());
player.sendPacket(npcReply);
}
}
else if (command.startsWith("CraftItem") && (Config.ALT_CRAFT_ALLOW_CRAFT || Config.ALT_CRAFT_ALLOW_COMMON))
// Craft amount of items using selected recipe
{
int _recipeObjId = 0;
int _quantity = 1;
StringTokenizer st = new StringTokenizer(command.substring(9).trim());
if (st.countTokens() != 2)
{
return;
}
try
{
_recipeObjId = Integer.parseInt(st.nextToken());
_quantity = Integer.parseInt(st.nextToken());
}
catch (NumberFormatException e)
{
}
Inventory _inventory = player.getInventory();
L2ItemInstance _recipe = _inventory.getItemByObjectId(_recipeObjId);
L2RecipeList _recipeList = RecipeTable.getInstance().getRecipeByItemId(_recipe.getItemId());
boolean _isConsumable = ItemTable.getInstance().getTemplate(_recipeList.getItemId()).isConsumable();
if ((_recipe.getOwnerId() == player.getObjectId()) && (_recipe.getItemType() == L2EtcItemType.RECEIPE) && ((_recipeList.isDwarvenRecipe() && Config.ALT_CRAFT_ALLOW_CRAFT) || (!_recipeList.isDwarvenRecipe() && Config.ALT_CRAFT_ALLOW_COMMON)))
{
L2RecipeInstance[] _recipeItems = _recipeList.getRecipes();
boolean _enoughtMaterials = true;
for (L2RecipeInstance _recipeItem : _recipeItems)
{
L2ItemInstance _item = _inventory.getItemByItemId(_recipeItem.getItemId());
if ((_item == null) || (_item.getCount() < (int) (_quantity * _recipeItem.getQuantity() * Config.ALT_RATE_CRAFT_COST)))
{
_enoughtMaterials = false;
}
}
int _price = (int) ((((Config.RATE_CRAFT_COST * _recipeList.getSuccessRate()) / 100) * _quantity * _recipeList.getCount() * ItemTable.getInstance().getTemplate(_recipeList.getItemId()).getReferencePrice()) / 55);
if (_price == 0)
{
_price = Config.ALT_CRAFT_DEFAULT_PRICE;
}
if (_inventory.getInventoryItemCount(ADENA_ID, 0) < _price)
{
sendOutOfItems(player, Integer.toString(_price), "Adena");
return;
}
if (!_enoughtMaterials)
{
sendOutOfItems(player, "proper amount", "materials");
return;
}
int _quantitySuccess = 0;
for (int i = 0; i < _quantity; i++)
{
if (Rnd.get(100) < _recipeList.getSuccessRate())
{
_quantitySuccess++;
}
}
InventoryUpdate iu = new InventoryUpdate();
for (L2RecipeInstance _recipeItem : _recipeItems)
{
player.destroyItemByItemId("CraftManager", _recipeItem.getItemId(), (int) (_quantity * _recipeItem.getQuantity() * Config.ALT_RATE_CRAFT_COST), player, true);
iu.addModifiedItem(player.getInventory().getItemByItemId(_recipeItem.getItemId()));
}
player.destroyItemByItemId("CraftManager", ADENA_ID, _price, player, true);
iu.addModifiedItem(player.getInventory().getItemByItemId(ADENA_ID));
if (_quantitySuccess > 0)
{
SystemMessage sm = null;
sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(_recipeList.getItemId());
sm.addNumber(_quantitySuccess * _recipeList.getCount());
player.sendPacket(sm);
sm = null;
iu.addModifiedItem(player.getInventory().getItemByItemId(_recipeList.getItemId()));
_inventory.addItem("CraftManager", _recipeList.getItemId(), _quantitySuccess * (_isConsumable ? _recipeList.getCount() : 1), player, player.getTarget());
}
player.sendPacket(iu);
iu = null;
player.broadcastUserInfo();
sendCraftedItems(player, _quantitySuccess * (_isConsumable ? _recipeList.getCount() : 1), (_quantity - _quantitySuccess) * (_isConsumable ? _recipeList.getCount() : 1), ItemTable.getInstance().getTemplate(_recipeList.getItemId()).getName());
}
}
else
{
super.onBypassFeedback(player, command);
}
}
public String getRecipeIcon(int grade)
{
return "icon.etc_recipe_" + (grade == 1 ? "blue" : grade == 2 ? "yellow" : grade == 3 ? "red" : grade == 4 ? "violet" : grade == 5 ? "black" : "white") + "_i00";
}
public String getCrystalIcon(int grade)
{
return "icon.etc_crystal_" + (grade == 1 ? "blue" : grade == 2 ? "green" : grade == 3 ? "red" : grade == 4 ? "silver" : grade == 5 ? "gold" : "white") + "_i00";
}
public void sendOutOfItems(L2PcInstance player, String count, String itemname)
{
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append(getName() + ":<br>");
replyMSG.append("Come back later, when you will have <fontcolor=\"LEVEL\">" + count + "</font> of " + itemname + ".");
replyMSG.append("</body></html>");
npcReply.setHtml(replyMSG.toString());
player.sendPacket(npcReply);
}
public void sendCraftedItems(L2PcInstance player, int success, int failed, String itemname)
{
NpcHtmlMessage npcReply = new NpcHtmlMessage(1);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append(getName() + ":<br>");
if (success == 0)
{
replyMSG.append("I am sorry, " + player.getName() + ", but all attempts to create <fontcolor=\"LEVEL\">" + itemname + "</font> failed. All your materials have been lost.");
}
else if (failed == 0)
{
replyMSG.append("Congratulations, " + player.getName() + ", I created " + success + " <fontcolor=\"LEVEL\">" + itemname + "</font> for you!");
}
else
{
replyMSG.append("Here you go, " + player.getName() + ", " + success + " <fontcolor=\"LEVEL\">" + itemname + "</font> successfully created, but " + failed + " broken while craft.");
}
replyMSG.append("</body></html>");
npcReply.setHtml(replyMSG.toString());
player.sendPacket(npcReply);
}
@Override
public String getHtmlPath(int npcId, int val)
{
String pom = "";
if (val == 0)
{
pom = "" + npcId;
}
else
{
pom = npcId + "-" + val;
}
return "data/html/default/" + pom + ".htm";
}
}
Tell a Škoda 1.4 driver that a Škoda 1.8 is faster — and suddenly, you’re riding a mini race car.
On the way, they might share random stories — gas prices, the perfect BBQ recipe, or how passengers once called them “just for a minute.”
Maybe even how someone left a suitcase full of money in their car once.
The important part? You’ll get there on time, no delays.
Vibe SMS works just as fast — messages fly like that driver who just heard their 1.8 isn’t the fastest.
🌐 https://vibe-sms.net/
📲 https://t.me/vibe_sms
⚔️ The Grand Opening Has Arrived! ⚔️
In just a few hours the gate to the eternal battlefield will be open and the war between Order and Chaos will be set once again !
Its time to claim your destiny 🔥
👉 Register now and join the fight today!
🌐 https://l2ovc.com
register now : https://l2ovc.com
The gates are open the war between Order and Chaos has officially started!
🔥 Join the battlefield NOW and claim your destiny in Order vs Chaos!
💥 Don’t fall behind your faction needs you.
➡️ https://l2ovc.com
Don’t miss the new Telegram gifts with our Telegram Stars purchasing bot!
A great opportunity to invest in a stable digital asset at an early stage while the market is still forming.
Buy other existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium subscriptions, and react to messages in channels!
Low prices, multiple payment options, and other cool unique features!
⚡ Try it today — SOCNET STARS BOT ⚡
Active links to SOCNET stores:
Digital Goods Store (Website): Go
Store Telegram Bot: Go – convenient access to the store via Telegram messenger.
⭐ Telegram Stars Purchase Bot: Go – fast and profitable way to buy stars in Telegram.
SMM Panel: Go – promote your social media accounts.
We present to you the current list of promotions and special offers for purchasing our products and services:
1️⃣ Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in October! You can also use the promo code SOCNET (15% discount) for your first purchase.
2️⃣ Get $1 on your store balance or a 10–20% discount — just write your username after registration on our website using the template:
"SEND ME BONUS, MY USERNAME IS..." — post it in our forum thread!
3️⃣ Get $1 for your first SMM Panel trial — simply open a ticket titled “Get Trial Bonus” on our website (Support).
4️⃣ Weekly ⭐ Telegram Stars giveaways in our Telegram channel and in our Telegram Stars bot!
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 and Support:
➡ Telegram: https://t.me/socnet_support
➡ WhatsApp: https://wa.me/79051904467
➡ Discord: socnet_support
➡ ✉ Email: solomonbog@socnet.store
Question
stalker66
Hi guys. I am sharing an older code for Interlude with what i have a small issue. This is the Craft Manager what i recently managed to make it work. The code works fine, except for a little detail. This code loads up the items that are eligible for crystallization from D grade up to A grade. Problem is it loads up the items that are equipped aswell. How can i bypass it so it will ignore those items on the character so the user wont accidentally crystallize the equipped gear. My knowledge for this is mediocre at best, and i tried multiple aproches and have come up with nothing. Any help is appreciated. Thanks!Here is the updated code for the Craft Manager for anyone who wants to use it. The only known issue so far, is the one on my 2nd post with the item selection crash after a certain amount.
Updated code
9 answers to this question
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