Jump to content
  • 0

Don't know how to adapt this


Question

Posted

Hi to everyone. i'm making this thread to find any help

 

Im new on the world of l2 servers, im using free source of acis (rev 382) and cannot ad this code to my project 

 

/*
 * 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 net.sf.l2j.gameserver.data.xml;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import net.sf.l2j.gameserver.enums.items.CrystalType;
import net.sf.l2j.gameserver.model.L2EnchantScroll;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

/**
 * @author Thug
 *
 */
public class EnchantData
{
       private static Logger _log = Logger.getLogger(EnchantData.class.getName());
      
       private static final Map<Integer, L2EnchantScroll> _map = new HashMap<>();
      
       public static EnchantData getInstance()
       {
               return SingletonHolder._instance;
       }
      
       protected EnchantData()
       {
               try
               {
                       File f = new File("./data/xml/enchants.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 ("enchant".equalsIgnoreCase(d.getNodeName()))
                                               {
                                                       NamedNodeMap attrs = d.getAttributes();
                                                      
                                                       int id = Integer.valueOf(attrs.getNamedItem("id").getNodeValue());
                                                       byte grade = Byte.valueOf(attrs.getNamedItem("grade").getNodeValue());
                                                       boolean weapon = Boolean.valueOf(attrs.getNamedItem("weapon").getNodeValue());
                                                       boolean breaks = Boolean.valueOf(attrs.getNamedItem("break").getNodeValue());
                                                       boolean maintain = Boolean.valueOf(attrs.getNamedItem("maintain").getNodeValue());
                                                      
                                                       String[] list = attrs.getNamedItem("chance").getNodeValue().split(";");
                                                       byte[] chance = new byte[list.length];
                                                       for (int i = 0; i < list.length; i++)
                                                               chance[i] = Byte.valueOf(list[i]);
                                                      
                                                       CrystalType grade_test = CrystalType.NONE;
                                                       switch (grade)
                                                       {
                                                               case 1:
                                                                       grade_test = CrystalType.D;
                                                                       break;
                                                               case 2:
                                                                       grade_test = CrystalType.C;
                                                                       break;
                                                               case 3:
                                                                       grade_test = CrystalType.B;
                                                                       break;
                                                               case 4:
                                                                       grade_test = CrystalType.A;
                                                                       break;
                                                               case 5:
                                                                       grade_test = CrystalType.S;
                                                                       break;
                                                       }                                                      
                                                      
                                                       _map.put(id, new L2EnchantScroll(grade_test, weapon, breaks, maintain, chance));
                                               }
                                       }
                               }
                       }
                              
                       _log.info("EnchantTable: Loaded " + _map.size() + " enchants.");
               }
               catch (Exception e)
               {
                       _log.warning("EnchantTable: Error while loading enchant table: " + e);
               }
       }
      
       public L2EnchantScroll getEnchantScroll(ItemInstance item)
       {
               return _map.get(item.getItemId());
       }
      
       private static class SingletonHolder
       {
               protected static final EnchantData _instance = new EnchantData();
       }
}

 

i have errors in the lines:

// -> import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;


// -> Document doc = XMLDocumentFactory.getInstance().loadDocument(f);

 

i will be so grateful if someone could help me

6 answers to this question

Recommended Posts

  • 0
Posted

 

Hey thanks for your reply ... I try to copy the way what i found at class (MultisellData.java) and did this:

 

public class EnchantData implements IXmlReader
{
	private static Logger _log = Logger.getLogger(EnchantData.class.getName());
	private static final Map<Integer, L2EnchantScroll> _map = new HashMap<>();
	
	public EnchantData()
	{
		load();
	}

	@Override
	public void load()
	{
		parseFile("data/xml/enchants.xml");
	}

	@Override
	public void parseDocument(Document doc, Path path)
	{
		try
		{
			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 ("enchant".equalsIgnoreCase(d.getNodeName()))
	                                {
	                                        NamedNodeMap attrs = d.getAttributes();
	                                       
	                                        int id = Integer.valueOf(attrs.getNamedItem("id").getNodeValue());
	                                        byte grade = Byte.valueOf(attrs.getNamedItem("grade").getNodeValue());
	                                        boolean weapon = Boolean.valueOf(attrs.getNamedItem("weapon").getNodeValue());
	                                        boolean breaks = Boolean.valueOf(attrs.getNamedItem("break").getNodeValue());
	                                        boolean maintain = Boolean.valueOf(attrs.getNamedItem("maintain").getNodeValue());
	                                       
	                                        String[] list = attrs.getNamedItem("chance").getNodeValue().split(";");
	                                        byte[] chance = new byte[list.length];
	                                        for (int i = 0; i < list.length; i++)
	                                                chance[i] = Byte.valueOf(list[i]);

 

well it's work fine to me because don't get erros and on live works good each enchant config...

Obviously if someone know Java more than me could say: "dude u are so wrong.." 

So if someone could say if this it's ok or i must do anything more will be so grateful

btw thanks again @Zake

  • 0
Posted

Well i did it if u check my second reply whit new code using the implements of IXmlReader and don't get any problem so i can say i did right...

Thanks to all, can close the topic !

  • 0
Posted
3 hours ago, lyrien said:

Well i did it if u check my second reply whit new code using the implements of IXmlReader and don't get any problem so i can say i did right...

Thanks to all, can close the topic !

locked

Guest
This topic is now closed to further replies.


  • Posts

    • UPDATE M63 Introduced the first major Party Logic system: Bots can join and operate under a real-player party leader. Party members: follow the real player, assist the leader in combat, coordinate around the party leader, support party combat instead of behaving purely as independent farmers. Added initial party formation/follow behavior. Added party-aware PvP assisting.   Expanded Party Support / Party Combat behavior: Improved party coordination across different bot classes. Added broader healer/support participation. Expanded combat equipment/ammunition support, including all six arrow grades. Party members became more coordinated in PvP and group combat. Added improved bot reaction to resurrection situations. Added compatible resurrection-answer handling. Refined party formation behavior. Party combat became more persistent when members were attacked. Party members maintain combat participation more reliably instead of immediately dropping engagement.     Major Party Logic expansion:   Changed party travel formation Added temporary main assister leadership: if the real-player leader dies, a random living damage dealer becomes combat leader, other bots assist that damage dealer, if the assister dies, another DD can take over. Added special Bishop/Cardinal real-player leader logic: bots continue following the real player, a damage-dealer bot becomes the party’s combat assister. Added 5-second idle Party Logic: if the real-player leader stops moving/actively controlling combat for 5 seconds, bots can resume autonomous farming around the leader. Temporary main assisters use the bot’s already configured PvP mode instead of a separate Party Logic PvP system. Existing modes remain authoritative: Idle AttackFlagged AttackEveryone Temporary main assister can independently acquire PvP targets according to its configured mode. Other party bots assist that selected combat leader. Made Party Logic target acquisition party-location aware. While operating in a party, autonomous PvE/PvP searches can be centered around the real player’s current location rather than only the bot’s original farming position. Existing bot farmRadius remains the effective acquisition radius. This allows parties to travel away from their original farming areas while continuing to operate dynamically.     Expanded Bishop/Cardinal Party Logic behavior:   Bishop/Cardinal parties now use the same 5-second activity/idle model as normal real-player-led parties. While the Bishop/Cardinal leader is moving or active: bots prioritize staying with the real player, maintain the ~70–100 unit random formation. After the Bishop/Cardinal remains idle for 5 seconds: party bots may return to autonomous farming around the leader. When the Bishop/Cardinal starts moving again: party members transition back to following the leader. PvP remains independent of the PvE idle condition: valid PvP targets can still trigger combat according to each bot’s configured PvP mode.     Optional Hero System: Added a new hero_enabled option for Autobots. Bot creation gained Hero appearance: No / Yes. Existing bots default to hero_enabled = 0. Bots with hero_enabled = 1 spawn with native Lucera Hero status/aura/appearance through Player.setHero(true). Hero weapons configured through the existing Autobots item system can be equipped normally. This is intentionally visual/status Hero only: no Hero skill injection, no automatic native Hero skills, no changes to combat AI or targeting. Hero state can also be changed directly in the database and takes effect after respawning the bot.     DOWNLOAD
    • Throw a free cloudflare SSL cert in there. 😄
    • Nextarget was a LT international clan in Dawn and  Evoke and other servers, playing most in Interlude, so dunno if you try use this name to atrack the players or smth.
    • Server Specs ChapterInterlude Classic EXP / SP Ratex50 Adena Ratex30 Drop Ratex20 Spoil Ratex15 Max Level78 Website https://l2nextarget.com/ Start On Today At 22:00
    • Since last forums fail, I decided to introduce a little website over PTS server holder - just to make basic informations more reachable. You can discover it over http://anothercrappyinterludeserver.com/   Discord channels ACCESS TO SOURCES and SERVER INSTALLATION were also reworked to be easier to handle.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..