Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- diff --git config/players.properties config/players.properties
- index e52d795..25e8695 100644
- --- config/players.properties
- +++ config/players.properties
- @@ -260,4 +260,10 @@
- MaxBuffsAmount = 20
- # Store buffs/debuffs on user logout. Default: True
- -StoreSkillCooltime = True
- \ No newline at end of file
- +StoreSkillCooltime = True
- +
- +#==========================================================================
- +# BLACK COUPON RECOVERY 1 ITEM ENCHANT FAILED
- +#==========================================================================
- +
- +BlackCouponId = 6392
- diff --git java/Base/Data/IconTable.java java/Base/Data/IconTable.java
- new file mode 100644
- index 0000000..fa75062
- --- /dev/null
- +++ java/Base/Data/IconTable.java
- @@ -0,0 +1,62 @@
- +package Base.Data;
- +
- +import java.io.File;
- +import java.util.HashMap;
- +import java.util.Map;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +public class IconTable extends XMLDocument
- +{
- + private static final Map<Integer, String> itemIcons = new HashMap<>();
- +
- + public IconTable()
- + {
- + load();
- + }
- +
- + @Override
- + protected void load()
- + {
- + loadDocument("./data/xml/icons.xml");
- + LOG.info("Loaded " + itemIcons.size() + " icons.");
- + }
- +
- + @Override
- + protected void parseDocument(Document doc, File f)
- + {
- +
- + final Node n = doc.getFirstChild();
- +
- + for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
- + {
- + if (!"icon".equalsIgnoreCase(o.getNodeName()))
- + {
- + continue;
- + }
- +
- + final NamedNodeMap attrs = o.getAttributes();
- + final int itemId = Integer.valueOf(attrs.getNamedItem("Id").getNodeValue());
- + final String value = String.valueOf(attrs.getNamedItem("value").getNodeValue());
- +
- + itemIcons.put(itemId, value);
- + }
- + }
- +
- + public String getIcon(int id)
- + {
- + return itemIcons.get(id) == null ? "icon.noimage" : itemIcons.get(id);
- + }
- +
- + public static IconTable getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final IconTable _instance = new IconTable();
- + }
- +}
- diff --git java/Base/Data/XMLDocument.java java/Base/Data/XMLDocument.java
- new file mode 100644
- index 0000000..6d491db
- --- /dev/null
- +++ java/Base/Data/XMLDocument.java
- @@ -0,0 +1,121 @@
- +package Base.Data;
- +
- +import java.io.File;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import javax.xml.parsers.DocumentBuilderFactory;
- +import javax.xml.transform.OutputKeys;
- +import javax.xml.transform.Transformer;
- +import javax.xml.transform.TransformerException;
- +import javax.xml.transform.TransformerFactory;
- +import javax.xml.transform.dom.DOMSource;
- +import javax.xml.transform.stream.StreamResult;
- +
- +import net.sf.l2j.gameserver.templates.StatsSet;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +
- +
- +/**
- + * An XML document, relying on a static and single DocumentBuilderFactory.
- + */
- +public abstract class XMLDocument
- +{
- + protected static final Logger LOG = Logger.getLogger(XMLDocument.class.getName());
- +
- + protected Document document;
- +
- + private static final DocumentBuilderFactory BUILDER;
- + static
- + {
- + BUILDER = DocumentBuilderFactory.newInstance();
- + BUILDER.setValidating(false);
- + BUILDER.setIgnoringComments(true);
- + }
- +
- + abstract protected void load();
- +
- + abstract protected void parseDocument(Document doc, File f);
- +
- + public void loadDocument(String filePath)
- + {
- + loadDocument(new File(filePath));
- + }
- +
- + public void writeDocument(Document doc, String fileName)
- + {
- + try
- + {
- + TransformerFactory transformerFactory = TransformerFactory.newInstance();
- + Transformer transformer = transformerFactory.newTransformer();
- + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- + transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- +
- + DOMSource source = new DOMSource(doc);
- + StreamResult result = new StreamResult(new File(fileName));
- +
- + transformer.transform(source, result);
- + LOG.info("XML file saved to " + fileName);
- + }
- + catch (TransformerException e)
- + {
- + LOG.warning("Error saving XML file: " + e.getMessage());
- + }
- + }
- +
- + /**
- + * Parse an entire directory or file if found.
- + * @param file
- + */
- + public void loadDocument(File file)
- + {
- + if (!file.exists())
- + {
- + LOG.severe("The following file or directory doesn't exist: " + file.getName());
- + return;
- + }
- +
- + if (file.isDirectory())
- + {
- + for (File f : file.listFiles())
- + {
- + loadDocument(f);
- + }
- + }
- + else if (file.isFile())
- + {
- + try
- + {
- + parseDocument(BUILDER.newDocumentBuilder().parse(file), file);
- + }
- + catch (Exception e)
- + {
- + LOG.log(Level.SEVERE, "Error loading XML file " + file.getName(), e);
- + }
- + }
- + }
- +
- + public Document getDocument()
- + {
- + return document;
- + }
- +
- + /**
- + * This method parses the content of a NamedNodeMap and feed the given StatsSet.
- + * @param attrs : The NamedNodeMap to parse.
- + * @param set : The StatsSet to feed.
- + */
- + public static void parseAndFeed(NamedNodeMap attrs, StatsSet set)
- + {
- + for (int i = 0; i < attrs.getLength(); i++)
- + {
- + final Node attr = attrs.item(i);
- + set.set(attr.getNodeName(), attr.getNodeValue());
- + }
- + }
- +}
- diff --git java/Base/RecoverySystem/ItemRecoveryManager.java java/Base/RecoverySystem/ItemRecoveryManager.java
- new file mode 100644
- index 0000000..050c6cc
- --- /dev/null
- +++ java/Base/RecoverySystem/ItemRecoveryManager.java
- @@ -0,0 +1,275 @@
- +package Base.RecoverySystem;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.sql.SQLException;
- +import java.util.HashMap;
- +import java.util.Map;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- +import net.sf.l2j.gameserver.network.serverpackets.ItemList;
- +
- +
- +
- +public class ItemRecoveryManager
- +{
- + private Map<Integer, Integer> validEnchantLevels;
- +
- + public ItemRecoveryManager()
- + {
- + validEnchantLevels = new HashMap<>();
- + loadValidEnchantLevels();
- + }
- +
- + public void recoverSelectedItem(Player player, int itemId, int enchantLevel)
- + {
- +
- + ItemInstance recoveryItem = player.getInventory().getItemByItemId(Config.BLACK_COUPON_ID);
- + if (recoveryItem == null || recoveryItem.getCount() < 1)
- + {
- + player.sendMessage("No tienes suficientes items para recuperar este item.");
- + return;
- + }
- +
- +
- + if (!isValidEnchantLevel(itemId, enchantLevel, player.getObjectId()))
- + {
- + player.sendMessage("No puedes recuperar este item con ese nivel de enchant.");
- + return;
- + }
- +
- +
- + if (!isValidRecoveryItem(itemId, player.getObjectId()))
- + {
- + player.sendMessage("No puedes recuperar este item.");
- + return;
- + }
- +
- +
- + ItemInstance recoveredItem = ItemTable.getInstance().createItem("RecoverItem", itemId, 1, player, null);
- + recoveredItem.setEnchantLevel(enchantLevel);
- +
- +
- + player.getInventory().addItem("RecoverItem", recoveredItem, player, player);
- +
- +
- + player.getInventory().destroyItemByItemId("RecoveryCost", Config.BLACK_COUPON_ID, 1, player, player);
- +
- +
- + removeRecoverableItem(itemId, player.getObjectId());
- +
- +
- + player.sendPacket(new ItemList(player, true));
- +
- +
- + String itemName = recoveredItem.getItemName();
- + String message = "Has recuperado el item " + itemName;
- + if (enchantLevel > 0)
- + {
- + message += " +" + enchantLevel;
- + }
- + player.sendMessage(message);
- + }
- +
- + @SuppressWarnings("resource")
- + public boolean isValidRecoveryItem(int itemId, int objectId)
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- + ResultSet resultSet = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "SELECT item_id FROM item_recover WHERE object_id = ? AND item_id = ?";
- + statement = con.prepareStatement(sql);
- + statement.setInt(1, objectId);
- + statement.setInt(2, itemId);
- + resultSet = statement.executeQuery();
- +
- + return resultSet.next();
- +
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + if (resultSet != null)
- + {
- + resultSet.close();
- + }
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- +
- + return false;
- + }
- +
- + @SuppressWarnings("resource")
- + public boolean isValidEnchantLevel(int itemId, int enchantLevel, int objectId)
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- + ResultSet resultSet = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "SELECT enchant_level FROM item_recover WHERE object_id = ? AND item_id = ?";
- + statement = con.prepareStatement(sql);
- + statement.setInt(1, objectId);
- + statement.setInt(2, itemId);
- + resultSet = statement.executeQuery();
- +
- + if (resultSet.next())
- + {
- + int validEnchantLevel = resultSet.getInt("enchant_level");
- + return enchantLevel == validEnchantLevel;
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + if (resultSet != null)
- + {
- + resultSet.close();
- + }
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- +
- + return false;
- + }
- +
- + public void removeRecoverableItem(int itemId, int objectId)
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "DELETE FROM item_recover WHERE item_id = ? AND object_id = ?";
- + statement = con.prepareStatement(sql);
- + statement.setInt(1, itemId);
- + statement.setInt(2, objectId);
- + statement.executeUpdate();
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- + }
- +
- + private void loadValidEnchantLevels()
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- + ResultSet resultSet = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "SELECT item_id, enchant_level FROM item_recover";
- + statement = con.prepareStatement(sql);
- + resultSet = statement.executeQuery();
- +
- + while (resultSet.next())
- + {
- + int itemId = resultSet.getInt("item_id");
- + int enchantLevel = resultSet.getInt("enchant_level");
- +
- + validEnchantLevels.put(itemId, enchantLevel);
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + if (resultSet != null)
- + {
- + resultSet.close();
- + }
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- + }
- +
- +}
- diff --git java/Base/RecoverySystem/RecoverableItem.java java/Base/RecoverySystem/RecoverableItem.java
- new file mode 100644
- index 0000000..a13f0e8
- --- /dev/null
- +++ java/Base/RecoverySystem/RecoverableItem.java
- @@ -0,0 +1,113 @@
- +package Base.RecoverySystem;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.SQLException;
- +
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.model.item.kind.Item;
- +
- +
- +
- +public class RecoverableItem
- +{
- + private int objectId;
- + private int itemId;
- + private String itemName;
- + private int enchantLevel;
- + private boolean selected;
- +
- + public RecoverableItem(int objectId, int itemId, String itemName, int enchantLevel)
- + {
- + this.objectId = objectId;
- + this.itemId = itemId;
- + this.itemName = itemName;
- + this.enchantLevel = enchantLevel;
- + this.selected = false;
- + }
- +
- + public int getObjectId()
- + {
- + return objectId;
- + }
- +
- + public int getItemId()
- + {
- + return itemId;
- + }
- +
- + public String getItemName()
- + {
- + return itemName;
- + }
- +
- + public int getEnchantLevel()
- + {
- + return enchantLevel;
- + }
- +
- + public void saveBrokenItemInfo()
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "INSERT INTO item_recover (object_id, item_id, item_name, enchant_level) VALUES (?, ?, ?, ?)";
- + statement = con.prepareStatement(sql);
- + statement.setInt(1, objectId);
- + statement.setInt(2, itemId);
- + statement.setString(3, itemName);
- + statement.setInt(4, enchantLevel);
- + statement.execute();
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- +
- + try
- + {
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- + }
- +
- + public boolean isSelected()
- + {
- + return selected;
- + }
- +
- + public void setSelected(boolean selected)
- + {
- + this.selected = selected;
- + }
- +
- + public String getIcon()
- + {
- + return getItem().getIcon();
- + }
- +
- + public Item getItem()
- + {
- + return ItemTable.getInstance().getTemplate(itemId);
- + }
- +
- +}
- diff --git java/net/sf/l2j/Config.java java/net/sf/l2j/Config.java
- index 91fc0f1..85901f5 100644
- --- java/net/sf/l2j/Config.java
- +++ java/net/sf/l2j/Config.java
- @@ -44,6 +44,12 @@
- // Clans settings
- // --------------------------------------------------
- +
- +
- +
- + public static int BLACK_COUPON_ID;
- +
- +
- /** Clans */
- public static int ALT_CLAN_JOIN_DAYS;
- public static int ALT_CLAN_CREATE_DAYS;
- @@ -1069,6 +1075,9 @@
- {
- final ExProperties players = initProperties(PLAYERS_FILE);
- EFFECT_CANCELING = players.getProperty("CancelLesserEffect", true);
- + BLACK_COUPON_ID = players.getProperty("BlackCouponId", 6392);
- +
- +
- HP_REGEN_MULTIPLIER = players.getProperty("HpRegenMultiplier", 1.);
- MP_REGEN_MULTIPLIER = players.getProperty("MpRegenMultiplier", 1.);
- CP_REGEN_MULTIPLIER = players.getProperty("CpRegenMultiplier", 1.);
- diff --git java/net/sf/l2j/gameserver/GameServer.java java/net/sf/l2j/gameserver/GameServer.java
- index 65bf5ef..2f1e305 100644
- --- java/net/sf/l2j/gameserver/GameServer.java
- +++ java/net/sf/l2j/gameserver/GameServer.java
- @@ -108,6 +108,8 @@
- import net.sf.l2j.util.DeadLockDetector;
- import net.sf.l2j.util.IPv4Filter;
- +import Base.Data.IconTable;
- +
- public class GameServer
- {
- private static final Logger _log = Logger.getLogger(GameServer.class.getName());
- @@ -285,6 +287,10 @@
- DerbyTrackManager.getInstance();
- LotteryManager.getInstance();
- +
- + IconTable.getInstance();
- +
- +
- if (Config.ALLOW_WEDDING)
- CoupleManager.getInstance();
- diff --git java/net/sf/l2j/gameserver/handler/ItemHandler.java java/net/sf/l2j/gameserver/handler/ItemHandler.java
- index 07bb3f7..0020d2a 100644
- --- java/net/sf/l2j/gameserver/handler/ItemHandler.java
- +++ java/net/sf/l2j/gameserver/handler/ItemHandler.java
- @@ -14,6 +14,7 @@
- import net.sf.l2j.gameserver.handler.itemhandlers.FishShots;
- import net.sf.l2j.gameserver.handler.itemhandlers.Harvester;
- import net.sf.l2j.gameserver.handler.itemhandlers.ItemSkills;
- +import net.sf.l2j.gameserver.handler.itemhandlers.Item_Recover;
- import net.sf.l2j.gameserver.handler.itemhandlers.Keys;
- import net.sf.l2j.gameserver.handler.itemhandlers.Maps;
- import net.sf.l2j.gameserver.handler.itemhandlers.MercTicket;
- @@ -62,6 +63,7 @@
- registerItemHandler(new PetFood());
- registerItemHandler(new Recipes());
- registerItemHandler(new RollingDice());
- + registerItemHandler(new Item_Recover());
- registerItemHandler(new ScrollOfResurrection());
- registerItemHandler(new SeedHandler());
- registerItemHandler(new SevenSignsRecord());
- diff --git java/net/sf/l2j/gameserver/handler/itemhandlers/Item_Recover.java java/net/sf/l2j/gameserver/handler/itemhandlers/Item_Recover.java
- new file mode 100644
- index 0000000..47f23fe
- --- /dev/null
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/Item_Recover.java
- @@ -0,0 +1,170 @@
- +package net.sf.l2j.gameserver.handler.itemhandlers;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.sql.SQLException;
- +import java.util.ArrayList;
- +import java.util.List;
- +
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.handler.IItemHandler;
- +import net.sf.l2j.gameserver.model.actor.Playable;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +import Base.RecoverySystem.RecoverableItem;
- +
- +
- +
- +/**
- + * @author Terius
- + */
- +public class Item_Recover implements IItemHandler
- +{
- +
- +
- + @Override
- + public void useItem(Playable playable, ItemInstance item, boolean forceUse)
- + {
- + if (!(playable instanceof Player))
- + {
- + return;
- + }
- +
- + Player activeChar = (Player) playable;
- +
- +
- + openRecoveryWindow(activeChar);
- + }
- +
- + private static void openRecoveryWindow(Player player)
- + {
- +
- + List<RecoverableItem> recoverableItems = getRecoverableItems(player.getObjectId());
- +
- +
- + if (recoverableItems.isEmpty())
- + {
- +
- + player.sendMessage("No hay items recuperables disponibles.");
- + return;
- + }
- +
- +
- + NpcHtmlMessage html = new NpcHtmlMessage(1);
- +
- +
- + String content = generateRecoveryList(recoverableItems);
- + html.setHtml(content);
- +
- +
- + player.sendPacket(html);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +
- +
- +
- + private static String generateRecoveryList(List<RecoverableItem> recoverableItems)
- + {
- +
- +
- + StringBuilder sb = new StringBuilder();
- + sb.append("<html><body><center><font color=\"LEVEL\">Items Recuperables</font><br><br>");
- +
- +
- + sb.append("<font color=\"FF0000\">Solo puedes recuperar 1 item a la vez.</font><br>");
- +
- +
- + for (RecoverableItem item : recoverableItems)
- + {
- + sb.append("<img src=\"L2UI.SquareGray\" width=295 height=1>");
- + sb.append("<table>");
- +
- + sb.append("<tr>");
- + sb.append("<td>");
- + sb.append("<img src=\"").append(item.getIcon()).append("\" width=32 height=32>");
- + sb.append("</td>");
- + sb.append("<td width=210><font color=\"FFFFFF\">").append(item.getItemName()).append("</font>");
- +
- + int enchantLevel = item.getEnchantLevel();
- + if (enchantLevel > 0)
- + {
- + sb.append(" <font color=\"00FF00\">+").append(enchantLevel).append("</font>");
- + }
- +
- + sb.append("</td>");
- +
- + int itemId = item.getItemId();
- + sb.append("<td><button value=\"Recuperar\" action=\"bypass -h recoverSelectedItem ").append(itemId).append(" ").append(enchantLevel).append("\" width=75 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"></td>");
- +
- + sb.append("</tr>");
- +
- + sb.append("</table>");
- + sb.append("<img src=\"L2UI.SquareGray\" width=295 height=1>");
- + sb.append("<br>");
- + }
- +
- + sb.append("</center></body></html>");
- + return sb.toString();
- + }
- +
- + private static List<RecoverableItem> getRecoverableItems(int objectId)
- + {
- + List<RecoverableItem> recoverableItems = new ArrayList<>();
- + Connection con = null;
- + PreparedStatement statement = null;
- + ResultSet resultSet = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "SELECT item_id, item_name, enchant_level FROM item_recover WHERE object_id = ? ORDER BY id DESC LIMIT 10";
- + statement = con.prepareStatement(sql);
- + statement.setInt(1, objectId);
- + resultSet = statement.executeQuery();
- +
- + while (resultSet.next())
- + {
- + int itemId = resultSet.getInt("item_id");
- + String itemName = resultSet.getString("item_name");
- + int enchantLevel = resultSet.getInt("enchant_level");
- +
- + RecoverableItem item = new RecoverableItem(objectId, itemId, itemName, enchantLevel);
- + recoverableItems.add(item);
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- + try
- + {
- + if (resultSet != null)
- + {
- + resultSet.close();
- + }
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- +
- + return recoverableItems;
- + }
- +}
- diff --git java/net/sf/l2j/gameserver/model/item/kind/Item.java java/net/sf/l2j/gameserver/model/item/kind/Item.java
- index f72530e..a7d1556 100644
- --- java/net/sf/l2j/gameserver/model/item/kind/Item.java
- +++ java/net/sf/l2j/gameserver/model/item/kind/Item.java
- @@ -28,6 +28,8 @@
- import net.sf.l2j.gameserver.skills.conditions.Condition;
- import net.sf.l2j.gameserver.templates.StatsSet;
- +import Base.Data.IconTable;
- +
- /**
- * This class contains all informations concerning the item (weapon, armor, etc). Mother class of :
- * <ul>
- @@ -577,4 +579,11 @@
- {
- return _questEvents;
- }
- +
- +
- + public String getIcon()
- + {
- + return IconTable.getInstance().getIcon(getItemId());
- + }
- +
- }
- \ No newline at end of file
- diff --git java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
- index 7e74c2b..634bace 100644
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
- @@ -24,6 +24,8 @@
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import Base.RecoverySystem.ItemRecoveryManager;
- +
- public final class RequestBypassToServer extends L2GameClientPacket
- {
- private static final Logger GMAUDIT_LOG = Logger.getLogger("gmaudit");
- @@ -85,6 +87,20 @@
- {
- playerHelp(activeChar, _command.substring(12));
- }
- +
- + else if (_command.startsWith("recoverSelectedItem"))
- + {
- + String[] bypassParts = _command.split(" ");
- + if (bypassParts.length >= 3)
- + {
- + int itemId = Integer.parseInt(bypassParts[1]);
- + int enchantLevel = Integer.parseInt(bypassParts[2]);
- +
- + ItemRecoveryManager itemRecoveryManager = new ItemRecoveryManager();
- + itemRecoveryManager.recoverSelectedItem(activeChar, itemId, enchantLevel);
- + }
- + }
- +
- else if (_command.startsWith("npc_"))
- {
- if (!activeChar.validateBypass(_command))
- diff --git java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java
- index 2a78f67..706b4f4 100644
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java
- @@ -1,7 +1,12 @@
- package net.sf.l2j.gameserver.network.clientpackets;
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.SQLException;
- +
- import net.sf.l2j.commons.random.Rnd;
- +import net.sf.l2j.L2DatabaseFactory;
- import net.sf.l2j.gameserver.data.SkillTable;
- import net.sf.l2j.gameserver.data.xml.ArmorSetData;
- import net.sf.l2j.gameserver.model.L2Skill;
- @@ -263,6 +268,13 @@
- su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
- activeChar.sendPacket(su);
- }
- +
- +
- +
- + saveBrokenItemInfo(activeChar.getObjectId(), item.getItemId(), item.getItemName(), item.getEnchantLevel());
- +
- +
- +
- }
- activeChar.sendPacket(new ItemList(activeChar, false));
- @@ -270,4 +282,55 @@
- activeChar.setActiveEnchantItem(null);
- }
- }
- +
- +
- + private static void saveBrokenItemInfo(int objectId, int itemId, String itemName, int enchantLevel)
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + String sql = "INSERT INTO item_recover (object_id, item_id, item_name, enchant_level) VALUES (?, ?, ?, ?)";
- + statement = con.prepareStatement(sql);
- + statement.setInt(1, objectId);
- + statement.setInt(2, itemId);
- + statement.setString(3, itemName);
- + statement.setInt(4, enchantLevel);
- + statement.execute();
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + finally
- + {
- +
- + try
- + {
- + if (statement != null)
- + {
- + statement.close();
- + }
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- +
- + e.printStackTrace();
- + }
- + }
- + }
- +
- +
- +
- +
- +
- +
- +
- }
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement