Hello , ive found on forum this code and added it to my project , i am using it for shift + click and lucky chest feature , so that when you open a chest an htm window appears and tells you what item you obtained , count and adds the icon of the item.
Problem is that everytime shift + click is requested or opening chest , all 10k icons loads and i get this message on gs log:
IconsTable: Succesfully loaded 9209 icons, in 17.0 Milliseconds.
the code im using is this:
package net.sf.l2j.gameserver.datatables;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import net.sf.l2j.gameserver.GameServer;
import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
public class IconsTable
{
public static final Map<Integer, String> Icons = new HashMap<>();
private static int count;
private static long t0;
private static double t;
private static final Logger _log = Logger.getLogger(GameServer.class.getName());
public void reload()
{
Icons.clear();
parseData();
}
public static void parseData()
{
count=0;
t0 = System.currentTimeMillis();
try
{
File f = new File("./data/xml/icons.xml");
Document doc = XMLDocumentFactory.getInstance().loadDocument(f);
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if (d.getNodeName().equalsIgnoreCase("icon"))
{
count++;
NamedNodeMap attrs = d.getAttributes();
Node att = attrs.getNamedItem("Id");
Node att2 = attrs.getNamedItem("value");
Icons.put(Integer.valueOf(att.getNodeValue()), String.valueOf(att2.getNodeValue()));
}
}
}
}
t = System.currentTimeMillis() - t0;
_log.config("IconsTable: Succesfully loaded "+count+" icons, in "+t+" Milliseconds.");
}
catch (Exception e)
{
_log.config("IconsTable: Failed loading IconsTable. Possible error: "+e.getMessage());
}
}
public static String getIcon(int id)
{
if (Icons.get(id)==null)
{
_log.config("IconsTable: Invalid Icon request: "+id+", or it doesn't exist, Ignoring ...");
return "null";
}
return Icons.get(id);
}
public static final IconsTable getInstance()
{
parseData();
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final IconsTable _instance = new IconsTable();
}
}
and when i want to get the icon i use this
IconsTable.getInstance().getIcon(ITEMID)) , what i need to know is that if there isn't any way to store all this 10k icons , and load them only once , not for every request to get icon..
EDIT: PROBLEM SOLVED , HERE IS THE FIX
public static String getIcon(int id)
{
if (Icons.get(id)==null)
{
parseData();
_log.config("IconsTable: Invalid Icon request: "+id+", or it doesn't exist, Ignoring ...");
return "null";
}
return Icons.get(id);
}
public static final IconsTable getInstance()
{
return SingletonHolder._instance;
}
i had to remove parsedata(); from the getInstance() and add it after if(icons.get(id)==null) , hope that this won't slowdown server much
just with this extender that I have shared it is not possible to start with c4 client, you have to make some changes to the extender and it works with c4 client perfectly.
regarding the updates in this last revision
🔹dll is not packaged with vmprotect
New custom zone types have been added:
🔹 NO_NOBLESS
begin MinX=84638 MaxX=92616 MinY=-87170 MaxY=-82018 MinZ=-6000 MaxZ=0 Type=NO_NOBLESS KickOutPos=83007/148057/-3464 end
▶️ This zone checks if the character is noble.
If it does not meet the condition, it will be automatically kicked to the indicated position (KickOutPos).
🔹 CUSTOM_SPAWN_ZONE
begin MinX=77275 MaxX=85704 MinY=10122 MaxY=18066 MinZ=-8000 MaxZ=5000 Type=CUSTOM_SPAWN_ZONE OutPos=83007/148057/-3464 Spawns={{82984/18066/-5256}};{{79275/15147/-5248}};{{82922/14263/-5256}};{{83704/10122/-5288}} end
▶️ This zone allows characters, upon death, to respawn with full buff, CP, HP and MP if they press “Fixed”.
They will only be able to revive in one of the positions defined in Spawns.
🔧 Both zones are fully configurable from territorydata.txt
🔧 Development Repository (SVN)
GX-EXT supports open, collaborative, and professional development. That’s why we provide access to our public SVN repository where you can:
✅ Compile your own version of the project
✅ Optimize and extend its features
✅ Learn from real production-quality source code
🔒 Delayed access: The repository is always 2 months behind the latest commercial release to prevent unauthorized reselling.
🔗 SVN URL: https://svn.l2servers.com.ar/!/#GX-EXT_INTERLUDE
Username: gx
Password: gx
You can use tools like TortoiseSVN to download and work with the code.
Could you tell me what changed in this update?
more one question:
Is it possible to log in through the c4 client instead of interlude? That would be great
Question
arm4729
Hello , ive found on forum this code and added it to my project , i am using it for shift + click and lucky chest feature , so that when you open a chest an htm window appears and tells you what item you obtained , count and adds the icon of the item.
Problem is that everytime shift + click is requested or opening chest , all 10k icons loads and i get this message on gs log:
IconsTable: Succesfully loaded 9209 icons, in 17.0 Milliseconds.
the code im using is this:
and when i want to get the icon i use this
IconsTable.getInstance().getIcon(ITEMID)) , what i need to know is that if there isn't any way to store all this 10k icons , and load them only once , not for every request to get icon..
EDIT: PROBLEM SOLVED , HERE IS THE FIX
public static String getIcon(int id) { if (Icons.get(id)==null) { parseData(); _log.config("IconsTable: Invalid Icon request: "+id+", or it doesn't exist, Ignoring ..."); return "null"; } return Icons.get(id); } public static final IconsTable getInstance() { return SingletonHolder._instance; }
i had to remove parsedata(); from the getInstance() and add it after if(icons.get(id)==null) , hope that this won't slowdown server much
Edited by arm47292 answers to this question
Recommended Posts