L2JMobius

C6 (Black Cupon Essence) in interlude - Item Recovery l2jmobius

Reanimation · 7 · 1400

Offline Reanimation

  • Knight
  • ***
    • Posts: 62
hello everyone.


I come here to share the work of this person, he has made this mod adapted to l2jmobius c6 interlude 100% working.



https://pastebin.com/EMTnPwNC


(SQL) https://www.mediafire.com/file/o3izrvuqazjlbxy/item_recover.sql/file


Credit: tensador


Preview





Offline jasker

  • Vassal
  • *
    • Posts: 3
Sorry I do not speak English .
I use a translator.
After installing the patch I get an error

https://ibb.co/t2b4CP0


Offline Reanimation

  • Knight
  • ***
    • Posts: 62
Sorry I do not speak English .
I use a translator.
After installing the patch I get an error

https://ibb.co/t2b4CP0

Hello, good afternoon, my English is also bad. forget to add the following lines, because this mod is completed based on another. add this and let me know.

Code: [Select]

diff --git java/Base/Data/IconTable.java java/Base/Data/IconTable.java
new file mode 100644
index 0000000..03b2c05
--- /dev/null
+++ java/Base/Data/IconTable.java
@@ -0,0 +1,97 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package Base.Data;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import Base.XML.XMLDocumentFactory;
+
+/**
+ * @author Tayran.JavaDev
+ */
+public class IconTable
+{
+   private static final Logger _log = Logger.getLogger(IconTable.class.getName());
+   
+   public static Map<Integer, String> _icons = new ConcurrentHashMap<>();
+   
+   public static final IconTable getInstance()
+   {
+       return SingletonHolder._instance;
+   }
+   
+   protected IconTable()
+   {
+       
+       load();
+   }
+   
+   private static void load()
+   {
+       try
+       {
+           File f = new File("./data/icons.xml");
+           Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
+           
+           Node n = doc.getFirstChild();
+           for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+           {
+               if (d.getNodeName().equalsIgnoreCase("icon"))
+               {
+                   NamedNodeMap attrs = d.getAttributes();
+                   
+                   int itemId = Integer.valueOf(attrs.getNamedItem("itemId").getNodeValue());
+                   String iconName = attrs.getNamedItem("iconName").getNodeValue();
+                   
+                   if ((itemId == 0) && (itemId < 0))
+                   {
+                       _log.log(Level.WARNING, "Icon Table: itemId=\"" + itemId + "\" is not item ID, Ignoring it!");
+                       continue;
+                   }
+                   _icons.put(itemId, iconName);
+               }
+           }
+       }
+       catch (Exception e)
+       {
+           _log.log(Level.WARNING, "Icon Table: Error loading from database: " + e.getMessage(), e);
+       }
+       
+       _log.info("Icon Table: Loaded " + _icons.size() + " icons.");
+   }
+   
+   public static String getIcon(int id)
+   {
+       if (_icons.get(id) == null)
+       {
+           return "icon.NOIMAGE";
+       }
+       
+       return _icons.get(id);
+   }
+   
+   private static class SingletonHolder
+   {
+       protected static final IconTable _instance = new IconTable();
+   }
+}
\ No newline at end of file


Code: [Select]

diff --git java/Base/XML/XMLDocument.java java/Base/XML/XMLDocument.java
new file mode 100644
index 0000000..756a5ee
--- /dev/null
+++ java/Base/XML/XMLDocument.java
@@ -0,0 +1,119 @@
+package Base.XML;
+
+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 org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import org.l2jmobius.gameserver.model.StatSet;
+
+/**
+ * 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, StatSet set)
+   {
+       for (int i = 0; i < attrs.getLength(); i++)
+       {
+           final Node attr = attrs.item(i);
+           set.set(attr.getNodeName(), attr.getNodeValue());
+       }
+   }
+}



Offline jasker

  • Vassal
  • *
    • Posts: 3
Hello, good afternoon, my English is also bad. forget to add the following lines, because this mod is completed based on another. add this and let me know.

Code: [Select]

diff --git java/Base/Data/IconTable.java java/Base/Data/IconTable.java
new file mode 100644
index 0000000..03b2c05
--- /dev/null
+++ java/Base/Data/IconTable.java
@@ -0,0 +1,97 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package Base.Data;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import Base.XML.XMLDocumentFactory;
+
+/**
+ * @author Tayran.JavaDev
+ */
+public class IconTable
+{
+   private static final Logger _log = Logger.getLogger(IconTable.class.getName());
+   
+   public static Map<Integer, String> _icons = new ConcurrentHashMap<>();
+   
+   public static final IconTable getInstance()
+   {
+       return SingletonHolder._instance;
+   }
+   
+   protected IconTable()
+   {
+       
+       load();
+   }
+   
+   private static void load()
+   {
+       try
+       {
+           File f = new File("./data/icons.xml");
+           Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
+           
+           Node n = doc.getFirstChild();
+           for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+           {
+               if (d.getNodeName().equalsIgnoreCase("icon"))
+               {
+                   NamedNodeMap attrs = d.getAttributes();
+                   
+                   int itemId = Integer.valueOf(attrs.getNamedItem("itemId").getNodeValue());
+                   String iconName = attrs.getNamedItem("iconName").getNodeValue();
+                   
+                   if ((itemId == 0) && (itemId < 0))
+                   {
+                       _log.log(Level.WARNING, "Icon Table: itemId=\"" + itemId + "\" is not item ID, Ignoring it!");
+                       continue;
+                   }
+                   _icons.put(itemId, iconName);
+               }
+           }
+       }
+       catch (Exception e)
+       {
+           _log.log(Level.WARNING, "Icon Table: Error loading from database: " + e.getMessage(), e);
+       }
+       
+       _log.info("Icon Table: Loaded " + _icons.size() + " icons.");
+   }
+   
+   public static String getIcon(int id)
+   {
+       if (_icons.get(id) == null)
+       {
+           return "icon.NOIMAGE";
+       }
+       
+       return _icons.get(id);
+   }
+   
+   private static class SingletonHolder
+   {
+       protected static final IconTable _instance = new IconTable();
+   }
+}
\ No newline at end of file


Code: [Select]

diff --git java/Base/XML/XMLDocument.java java/Base/XML/XMLDocument.java
new file mode 100644
index 0000000..756a5ee
--- /dev/null
+++ java/Base/XML/XMLDocument.java
@@ -0,0 +1,119 @@
+package Base.XML;
+
+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 org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import org.l2jmobius.gameserver.model.StatSet;
+
+/**
+ * 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, StatSet set)
+   {
+       for (int i = 0; i < attrs.getLength(); i++)
+       {
+           final Node attr = attrs.item(i);
+           set.set(attr.getNodeName(), attr.getNodeValue());
+       }
+   }
+}


Added more bugs. The old error has not disappeared.

https://ibb.co/fCpdhg2

I would like to install your mod.



Offline Reanimation

  • Knight
  • ***
    • Posts: 62
Added more bugs. The old error has not disappeared.

https://ibb.co/fCpdhg2

I would like to install your mod.

Hello friend, good afternoon, sorry for the delay in answering you.

To be very honest, this system works perfectly for me. This mod is not believed by me, the creator is a tensador.

Before adding this mod that I shared here, add this other one:

https://pastebin.com/4GA43bgz

xml:https://www.mediafire.com/file/pv9yd448wtf34y5/icons.xml/file

sql:https://www.mediafire.com/file/s2srbscllf2kee9/randomcraftitem.sql/file

This other mod is an npc random craft, you can see it in the post that the author made here in the forum:

https://l2jmobius.org/forum/index.php?topic=10442.0

Later, once this randomcraft mod was added, just then, I added the back coupon mod, and everything worked correctly, without errors.

Credit: tensador

Even so, if you have any problems or doubts, you can tell me or try to talk to the author tensador. I hope everything works for you.



Offline Reanimation

  • Knight
  • ***
    • Posts: 62
It's good that it worked for you. as I said the system is not mine, and when I added it I did it together with that other system haha ​​the 2 systems are incredible so I hope you can get a lot of use out of it and all the credits to its creator: tensador