Jump to content

Recommended Posts

Posted (edited)

Hi all, i created server on windows, i wen to ubuntu server, i upload all files thru FTP..
It works with no problem on windows, but on linux half of npc are not spawned...

 

here is console:

---------------------------------------------------------------------=[ NPCs ]
BufferTable: Loaded 1 players schemes.
HerbDropTable: Loaded 2 herbs groups.
NpcTable: Error parsing NPC templates : 
File: /home/admin/Desktop/Arena/gs/./data/xml/npcs/custom doesn't exist and/or is not a file.
NpcTable: Loaded 4459 NPC templates.
WalkerRoutesTable: Loaded 12 NpcWalker routes.
DoorTable: Loaded 547 doors templates.
StaticObject: Loaded 29 templates.
L2Spawn: Random respawn delay for NPC id=21399 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21399 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21399 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21399 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21403 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21403 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21403 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21403 is higher than respawn delay.
L2Spawn: Random respawn delay for NPC id=21403 is higher than respawn delay.

i checked npc xml files, theese are in.. btw this list is very long i coppied only few lines.

 

WINDOWS SERVER CONSOLE :

---------------------------------------------------------------------=[ NPCs ]
BufferTable: Loaded 1 players schemes.
HerbDropTable: Loaded 2 herbs groups.
SevenSignsFestival: Reinitialized engine for next competition period.
SevenSigns: The Quest Event Initialization period has begun!
SevenSigns: Next period change set to Fri Jan 05 12:58:36 GMT 2018
NpcTable: Error parsing NPC templates :
File: C:\Users\Home\Desktop\Arena\gameserver\.\data\xml\npcs\custom doesn't exist and/or is not a file.
NpcTable: Loaded 6474 NPC templates.
WalkerRoutesTable: Loaded 12 NpcWalker routes.
DoorTable: Loaded 547 doors templates.
StaticObject: Loaded 29 templates.

 

 

P.S. I was not able install fresh database so i have EXPORT my sql database and then import into Ubuntu...

 

I have found topic like mine but there was no answer just "use fresh original acis pack from i-live.eu.... but the problem is that i use fresh.. i only created 1 npc, teleporter...

Anyway database spawntabe and spawntable_4s has same rows like in windows.. i tried everything, checkout svn again, build, upload into UBUNTU SERVER and same story... no npc like gk or shop, just mobs and ch managers etc.

 

Please any help.

Edited by Devolskis
Posted
1 minute ago, Reborn12 said:

.xml is missing

no is not have add read folders and can read only file like npc/123.xml can't read npc/folder/folder/123.xml

Posted
Just now, Reborn12 said:

.xml is missing

 

Well as i said xml files are same in both servers.. i updated it 10 times.. i changed mod 777 for all folders subfolders and files..

As well I checked first missing ID and there code in xml file, aswell i tried to check xml syntax error on ID above that missing but its good.. :/

Posted
1 minute ago, tazerman2 said:

no is not have add read folders and can read only file like npc/123.xml can't read npc/folder/folder/123.xml

 

As I wrote the post with both ubuntu and windows console, in both there is that error but on windows all good, ubuntu not..

Posted (edited)
/*
 * 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.datatables;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.MinionData;
import net.sf.l2j.gameserver.model.PetDataEntry;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.actor.template.PetTemplate;
import net.sf.l2j.gameserver.model.item.DropCategory;
import net.sf.l2j.gameserver.model.item.DropData;
import net.sf.l2j.gameserver.templates.StatsSet;
import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;

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

public class NpcTable
{
	private static final Logger _log = Logger.getLogger(NpcTable.class.getName());
	
	private final Map<Integer, NpcTemplate> _npcs = new HashMap<>();
	
	protected NpcTable()
	{
		load();
	}
	
	public void reloadAllNpc()
	{
		_npcs.clear();
		load();
	}
	
	private void load()
	{
		try
		{
			final File dir = new File("./data/xml/npcs");
			final StatsSet set = new StatsSet();
			final StatsSet petSet = new StatsSet();
			
			for (File file : dir.listFiles())
			{
				final Document doc = XMLDocumentFactory.getInstance().loadDocument(file);
				
				Node list = doc.getFirstChild();
				for (Node npc = list.getFirstChild(); npc != null; npc = npc.getNextSibling())
				{
					if ("npc".equalsIgnoreCase(npc.getNodeName()))
					{
						NamedNodeMap attrs = npc.getAttributes();
						
						boolean mustUsePetTemplate = false; // Used to define template type.
						
						final int npcId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
						final int templateId = attrs.getNamedItem("idTemplate") == null ? npcId : Integer.parseInt(attrs.getNamedItem("idTemplate").getNodeValue());
						
						set.set("id", npcId);
						set.set("idTemplate", templateId);
						set.set("name", attrs.getNamedItem("name").getNodeValue());
						set.set("title", attrs.getNamedItem("title").getNodeValue());
						
						for (Node cat = npc.getFirstChild(); cat != null; cat = cat.getNextSibling())
						{
							if ("ai".equalsIgnoreCase(cat.getNodeName()))
							{
								attrs = cat.getAttributes();
								
								set.set("aiType", attrs.getNamedItem("type").getNodeValue());
								set.set("ssCount", Integer.parseInt(attrs.getNamedItem("ssCount").getNodeValue()));
								set.set("ssRate", Integer.parseInt(attrs.getNamedItem("ssRate").getNodeValue()));
								set.set("spsCount", Integer.parseInt(attrs.getNamedItem("spsCount").getNodeValue()));
								set.set("spsRate", Integer.parseInt(attrs.getNamedItem("spsRate").getNodeValue()));
								set.set("aggro", Integer.parseInt(attrs.getNamedItem("aggro").getNodeValue()));
								
								// Verify if the parameter exists.
								if (attrs.getNamedItem("clan") != null)
								{
									set.set("clan", attrs.getNamedItem("clan").getNodeValue().split(";"));
									set.set("clanRange", Integer.parseInt(attrs.getNamedItem("clanRange").getNodeValue()));
									
									// Verify if the parameter exists.
									if (attrs.getNamedItem("ignoredIds") != null)
										set.set("ignoredIds", attrs.getNamedItem("ignoredIds").getNodeValue());
								}
								
								set.set("canMove", Boolean.parseBoolean(attrs.getNamedItem("canMove").getNodeValue()));
								set.set("seedable", Boolean.parseBoolean(attrs.getNamedItem("seedable").getNodeValue()));
							}
							else if ("drops".equalsIgnoreCase(cat.getNodeName()))
							{
								final String type = set.getString("type");
								final boolean isRaid = type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss");
								
								final List<DropCategory> drops = new ArrayList<>();
								
								for (Node dropCat = cat.getFirstChild(); dropCat != null; dropCat = dropCat.getNextSibling())
								{
									if ("category".equalsIgnoreCase(dropCat.getNodeName()))
									{
										attrs = dropCat.getAttributes();
										
										final DropCategory category = new DropCategory(Integer.parseInt(attrs.getNamedItem("id").getNodeValue()));
										
										for (Node item = dropCat.getFirstChild(); item != null; item = item.getNextSibling())
										{
											if ("drop".equalsIgnoreCase(item.getNodeName()))
											{
												attrs = item.getAttributes();
												
												final DropData data = new DropData();
												data.setItemId(Integer.parseInt(attrs.getNamedItem("itemid").getNodeValue()));
												data.setMinDrop(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
												data.setMaxDrop(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
												data.setChance(Integer.parseInt(attrs.getNamedItem("chance").getNodeValue()));
												
												if (ItemTable.getInstance().getTemplate(data.getItemId()) == null)
												{
													_log.warning("Droplist data for undefined itemId: " + data.getItemId());
													continue;
												}
												category.addDropData(data, isRaid);
											}
										}
										drops.add(category);
									}
								}
								set.set("drops", drops);
							}
							else if ("minions".equalsIgnoreCase(cat.getNodeName()))
							{
								final List<MinionData> minions = new ArrayList<>();
								
								for (Node minion = cat.getFirstChild(); minion != null; minion = minion.getNextSibling())
								{
									if ("minion".equalsIgnoreCase(minion.getNodeName()))
									{
										attrs = minion.getAttributes();
										
										final MinionData data = new MinionData();
										data.setMinionId(Integer.parseInt(attrs.getNamedItem("id").getNodeValue()));
										data.setAmountMin(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
										data.setAmountMax(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
										
										minions.add(data);
									}
								}
								set.set("minions", minions);
							}
							else if ("petdata".equalsIgnoreCase(cat.getNodeName()))
							{
								mustUsePetTemplate = true;
								
								attrs = cat.getAttributes();
								
								set.set("food1", Integer.parseInt(attrs.getNamedItem("food1").getNodeValue()));
								set.set("food2", Integer.parseInt(attrs.getNamedItem("food2").getNodeValue()));
								
								set.set("autoFeedLimit", Double.parseDouble(attrs.getNamedItem("autoFeedLimit").getNodeValue()));
								set.set("hungryLimit", Double.parseDouble(attrs.getNamedItem("hungryLimit").getNodeValue()));
								set.set("unsummonLimit", Double.parseDouble(attrs.getNamedItem("unsummonLimit").getNodeValue()));
								
								final Map<Integer, PetDataEntry> entries = new HashMap<>();
								
								for (Node petCat = cat.getFirstChild(); petCat != null; petCat = petCat.getNextSibling())
								{
									if ("stat".equalsIgnoreCase(petCat.getNodeName()))
									{
										attrs = petCat.getAttributes();
										
										// Get all nodes.
										for (int i = 0; i < attrs.getLength(); i++)
										{
											// Add them to stats by node name and node value.
											Node node = attrs.item(i);
											petSet.set(node.getNodeName(), node.getNodeValue());
										}
										
										entries.put(petSet.getInteger("level"), new PetDataEntry(petSet));
										petSet.clear();
									}
								}
								set.set("petData", entries);
							}
							else if ("set".equalsIgnoreCase(cat.getNodeName()))
							{
								attrs = cat.getAttributes();
								
								set.set(attrs.getNamedItem("name").getNodeValue(), attrs.getNamedItem("val").getNodeValue());
							}
							else if ("skills".equalsIgnoreCase(cat.getNodeName()))
							{
								final List<L2Skill> skills = new ArrayList<>();
								
								for (Node skillCat = cat.getFirstChild(); skillCat != null; skillCat = skillCat.getNextSibling())
								{
									if ("skill".equalsIgnoreCase(skillCat.getNodeName()))
									{
										attrs = skillCat.getAttributes();
										
										final int skillId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
										final int level = Integer.parseInt(attrs.getNamedItem("level").getNodeValue());
										
										// Setup the npc's race. Don't register the skill.
										if (skillId == L2Skill.SKILL_NPC_RACE)
										{
											set.set("raceId", level);
											continue;
										}
										
										final L2Skill data = SkillTable.getInstance().getInfo(skillId, level);
										if (data == null)
											continue;
										
										skills.add(data);
									}
								}
								set.set("skills", skills);
							}
							else if ("teachTo".equalsIgnoreCase(cat.getNodeName()))
								set.set("teachTo", cat.getAttributes().getNamedItem("classes").getNodeValue());
						}
						
						_npcs.put(npcId, (mustUsePetTemplate) ? new PetTemplate(set) : new NpcTemplate(set));
					}
					set.clear();
				}
			}
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "NpcTable: Error parsing NPC templates : ", e);
		}
		_log.info("NpcTable: Loaded " + _npcs.size() + " NPC templates.");
	}
	
	public NpcTemplate getTemplate(int id)
	{
		return _npcs.get(id);
	}
	
	/**
	 * @param name to search.
	 * @return the template list of NPCs for a given name.
	 */
	public NpcTemplate getTemplateByName(String name)
	{
		for (NpcTemplate npcTemplate : _npcs.values())
		{
			if (npcTemplate.getName().equalsIgnoreCase(name))
				return npcTemplate;
		}
		return null;
	}
	
	/**
	 * Gets all templates matching the filter.
	 * @param filter
	 * @return the template list for the given filter
	 */
	public List<NpcTemplate> getTemplates(Predicate<NpcTemplate> filter)
	{
		return _npcs.values().stream().filter(filter).collect(Collectors.toList());
	}
	
	public Collection<NpcTemplate> getAllNpcs()
	{
		return _npcs.values();
	}
	
	public static NpcTable getInstance()
	{
		return SingletonHolder._instance;
	}
	
	private static class SingletonHolder
	{
		protected static final NpcTable _instance = new NpcTable();
	}
}

P.S. I didint touch this file. i update original acis libs to my server.. still not working

Edited by Devolskis
Posted

with this you can't read folders try add this

 

package net.sf.l2j.gameserver.data;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import net.sf.l2j.commons.data.xml.XMLDocument;

import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.MinionData;
import net.sf.l2j.gameserver.model.PetDataEntry;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.actor.template.PetTemplate;
import net.sf.l2j.gameserver.model.item.DropCategory;
import net.sf.l2j.gameserver.model.item.DropData;
import net.sf.l2j.gameserver.templates.StatsSet;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class NpcTable extends XMLDocument
{
	private static final Logger _log = Logger.getLogger(NpcTable.class.getName());
	
	private final Map<Integer, NpcTemplate> _npcs = new HashMap<>();
	
	protected NpcTable()
	{
		load();
	}
	
	public void reloadAllNpc()
	{
		_npcs.clear();
		load();
	}
	
	@Override
	protected void load()
	{
		loadDocument("./data/xml/npcs/");

		_log.info("NpcTable: Loaded " + _npcs.size() + " NPC templates.");
	}
	
	@Override
	protected void parseDocument(Document doc, File file)
	{
		final StatsSet set = new StatsSet();
		final StatsSet petSet = new StatsSet();
		
		final Node d = doc.getFirstChild();
		
		for (Node npc = d.getFirstChild(); npc != null; npc = npc.getNextSibling())
		{
			if ("npc".equalsIgnoreCase(npc.getNodeName()))
			{
				NamedNodeMap attrs = npc.getAttributes();
				
				boolean mustUsePetTemplate = false; // Used to define template type.
				
				final int npcId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
				final int templateId = attrs.getNamedItem("idTemplate") == null ? npcId : Integer.parseInt(attrs.getNamedItem("idTemplate").getNodeValue());
				
				set.set("id", npcId);
				set.set("idTemplate", templateId);
				set.set("name", attrs.getNamedItem("name").getNodeValue());
				set.set("title", attrs.getNamedItem("title").getNodeValue());
				
				for (Node cat = npc.getFirstChild(); cat != null; cat = cat.getNextSibling())
				{
					if ("ai".equalsIgnoreCase(cat.getNodeName()))
					{
						attrs = cat.getAttributes();
						
						set.set("aiType", attrs.getNamedItem("type").getNodeValue());
						set.set("ssCount", Integer.parseInt(attrs.getNamedItem("ssCount").getNodeValue()));
						set.set("ssRate", Integer.parseInt(attrs.getNamedItem("ssRate").getNodeValue()));
						set.set("spsCount", Integer.parseInt(attrs.getNamedItem("spsCount").getNodeValue()));
						set.set("spsRate", Integer.parseInt(attrs.getNamedItem("spsRate").getNodeValue()));
						set.set("aggro", Integer.parseInt(attrs.getNamedItem("aggro").getNodeValue()));
						
						// Verify if the parameter exists.
						if (attrs.getNamedItem("clan") != null)
						{
							set.set("clan", attrs.getNamedItem("clan").getNodeValue().split(";"));
							set.set("clanRange", Integer.parseInt(attrs.getNamedItem("clanRange").getNodeValue()));
							
							// Verify if the parameter exists.
							if (attrs.getNamedItem("ignoredIds") != null)
								set.set("ignoredIds", attrs.getNamedItem("ignoredIds").getNodeValue());
						}
						
						set.set("canMove", Boolean.parseBoolean(attrs.getNamedItem("canMove").getNodeValue()));
						set.set("seedable", Boolean.parseBoolean(attrs.getNamedItem("seedable").getNodeValue()));
					}
					else if ("drops".equalsIgnoreCase(cat.getNodeName()))
					{
						final String type = set.getString("type");
						final boolean isRaid = type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss");
						
						final List<DropCategory> drops = new ArrayList<>();
						
						for (Node dropCat = cat.getFirstChild(); dropCat != null; dropCat = dropCat.getNextSibling())
						{
							if ("category".equalsIgnoreCase(dropCat.getNodeName()))
							{
								attrs = dropCat.getAttributes();
								
								final DropCategory category = new DropCategory(Integer.parseInt(attrs.getNamedItem("id").getNodeValue()));
								
								for (Node item = dropCat.getFirstChild(); item != null; item = item.getNextSibling())
								{
									if ("drop".equalsIgnoreCase(item.getNodeName()))
									{
										attrs = item.getAttributes();
										
										final DropData data = new DropData();
										data.setItemId(Integer.parseInt(attrs.getNamedItem("itemid").getNodeValue()));
										data.setMinDrop(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
										data.setMaxDrop(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
										data.setChance(Integer.parseInt(attrs.getNamedItem("chance").getNodeValue()));
										
										if (ItemTable.getInstance().getTemplate(data.getItemId()) == null)
										{
											_log.warning("Droplist data for undefined itemId: " + data.getItemId());
											continue;
										}
										category.addDropData(data, isRaid);
									}
								}
								drops.add(category);
							}
						}
						set.set("drops", drops);
					}
					else if ("minions".equalsIgnoreCase(cat.getNodeName()))
					{
						final List<MinionData> minions = new ArrayList<>();
						
						for (Node minion = cat.getFirstChild(); minion != null; minion = minion.getNextSibling())
						{
							if ("minion".equalsIgnoreCase(minion.getNodeName()))
							{
								attrs = minion.getAttributes();
								
								final MinionData data = new MinionData();
								data.setMinionId(Integer.parseInt(attrs.getNamedItem("id").getNodeValue()));
								data.setAmountMin(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
								data.setAmountMax(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
								
								minions.add(data);
							}
						}
						set.set("minions", minions);
					}
					else if ("petdata".equalsIgnoreCase(cat.getNodeName()))
					{
						mustUsePetTemplate = true;
						
						attrs = cat.getAttributes();
						
						set.set("food1", Integer.parseInt(attrs.getNamedItem("food1").getNodeValue()));
						set.set("food2", Integer.parseInt(attrs.getNamedItem("food2").getNodeValue()));
						
						set.set("autoFeedLimit", Double.parseDouble(attrs.getNamedItem("autoFeedLimit").getNodeValue()));
						set.set("hungryLimit", Double.parseDouble(attrs.getNamedItem("hungryLimit").getNodeValue()));
						set.set("unsummonLimit", Double.parseDouble(attrs.getNamedItem("unsummonLimit").getNodeValue()));
						
						final Map<Integer, PetDataEntry> entries = new HashMap<>();
						
						for (Node petCat = cat.getFirstChild(); petCat != null; petCat = petCat.getNextSibling())
						{
							if ("stat".equalsIgnoreCase(petCat.getNodeName()))
							{
								attrs = petCat.getAttributes();
								
								// Get all nodes.
								for (int i = 0; i < attrs.getLength(); i++)
								{
									// Add them to stats by node name and node value.
									Node node = attrs.item(i);
									petSet.set(node.getNodeName(), node.getNodeValue());
								}
								
								entries.put(petSet.getInteger("level"), new PetDataEntry(petSet));
								petSet.clear();
							}
						}
						set.set("petData", entries);
					}
					else if ("set".equalsIgnoreCase(cat.getNodeName()))
					{
						attrs = cat.getAttributes();
						
						set.set(attrs.getNamedItem("name").getNodeValue(), attrs.getNamedItem("val").getNodeValue());
					}
					else if ("skills".equalsIgnoreCase(cat.getNodeName()))
					{
						final List<L2Skill> skills = new ArrayList<>();
						
						for (Node skillCat = cat.getFirstChild(); skillCat != null; skillCat = skillCat.getNextSibling())
						{
							if ("skill".equalsIgnoreCase(skillCat.getNodeName()))
							{
								attrs = skillCat.getAttributes();
								
								final int skillId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
								final int level = Integer.parseInt(attrs.getNamedItem("level").getNodeValue());
								
								// Setup the npc's race. Don't register the skill.
								if (skillId == L2Skill.SKILL_NPC_RACE)
								{
									set.set("raceId", level);
									continue;
								}
								
								final L2Skill data = SkillTable.getInstance().getInfo(skillId, level);
								if (data == null)
									continue;
								
								skills.add(data);
							}
						}
						set.set("skills", skills);
					}
					else if ("teachTo".equalsIgnoreCase(cat.getNodeName()))
						set.set("teachTo", cat.getAttributes().getNamedItem("classes").getNodeValue());
				}
				
				_npcs.put(npcId, (mustUsePetTemplate) ? new PetTemplate(set) : new NpcTemplate(set));
			}
			set.clear();
		}
	}
	
	public NpcTemplate getTemplate(int id)
	{
		return _npcs.get(id);
	}
	
	/**
	 * @param name to search.
	 * @return the template list of NPCs for a given name.
	 */
	public NpcTemplate getTemplateByName(String name)
	{
		for (NpcTemplate npcTemplate : _npcs.values())
		{
			if (npcTemplate.getName().equalsIgnoreCase(name))
				return npcTemplate;
		}
		return null;
	}
	
	/**
	 * Gets all templates matching the filter.
	 * @param filter
	 * @return the template list for the given filter
	 */
	public List<NpcTemplate> getTemplates(Predicate<NpcTemplate> filter)
	{
		return _npcs.values().stream().filter(filter).collect(Collectors.toList());
	}
	
	public Collection<NpcTemplate> getAllNpcs()
	{
		return _npcs.values();
	}
	
	public static NpcTable getInstance()
	{
		return SingletonHolder._instance;
	}
	
	private static class SingletonHolder
	{
		protected static final NpcTable _instance = new NpcTable();
	}
}

 

Posted
11 minutes ago, tazerman2 said:

with this you can't read folders try add this

 


package net.sf.l2j.gameserver.data;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import net.sf.l2j.commons.data.xml.XMLDocument;

import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.MinionData;
import net.sf.l2j.gameserver.model.PetDataEntry;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.actor.template.PetTemplate;
import net.sf.l2j.gameserver.model.item.DropCategory;
import net.sf.l2j.gameserver.model.item.DropData;
import net.sf.l2j.gameserver.templates.StatsSet;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class NpcTable extends XMLDocument
{
	private static final Logger _log = Logger.getLogger(NpcTable.class.getName());
	
	private final Map<Integer, NpcTemplate> _npcs = new HashMap<>();
	
	protected NpcTable()
	{
		load();
	}
	
	public void reloadAllNpc()
	{
		_npcs.clear();
		load();
	}
	
	@Override
	protected void load()
	{
		loadDocument("./data/xml/npcs/");

		_log.info("NpcTable: Loaded " + _npcs.size() + " NPC templates.");
	}
	
	@Override
	protected void parseDocument(Document doc, File file)
	{
		final StatsSet set = new StatsSet();
		final StatsSet petSet = new StatsSet();
		
		final Node d = doc.getFirstChild();
		
		for (Node npc = d.getFirstChild(); npc != null; npc = npc.getNextSibling())
		{
			if ("npc".equalsIgnoreCase(npc.getNodeName()))
			{
				NamedNodeMap attrs = npc.getAttributes();
				
				boolean mustUsePetTemplate = false; // Used to define template type.
				
				final int npcId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
				final int templateId = attrs.getNamedItem("idTemplate") == null ? npcId : Integer.parseInt(attrs.getNamedItem("idTemplate").getNodeValue());
				
				set.set("id", npcId);
				set.set("idTemplate", templateId);
				set.set("name", attrs.getNamedItem("name").getNodeValue());
				set.set("title", attrs.getNamedItem("title").getNodeValue());
				
				for (Node cat = npc.getFirstChild(); cat != null; cat = cat.getNextSibling())
				{
					if ("ai".equalsIgnoreCase(cat.getNodeName()))
					{
						attrs = cat.getAttributes();
						
						set.set("aiType", attrs.getNamedItem("type").getNodeValue());
						set.set("ssCount", Integer.parseInt(attrs.getNamedItem("ssCount").getNodeValue()));
						set.set("ssRate", Integer.parseInt(attrs.getNamedItem("ssRate").getNodeValue()));
						set.set("spsCount", Integer.parseInt(attrs.getNamedItem("spsCount").getNodeValue()));
						set.set("spsRate", Integer.parseInt(attrs.getNamedItem("spsRate").getNodeValue()));
						set.set("aggro", Integer.parseInt(attrs.getNamedItem("aggro").getNodeValue()));
						
						// Verify if the parameter exists.
						if (attrs.getNamedItem("clan") != null)
						{
							set.set("clan", attrs.getNamedItem("clan").getNodeValue().split(";"));
							set.set("clanRange", Integer.parseInt(attrs.getNamedItem("clanRange").getNodeValue()));
							
							// Verify if the parameter exists.
							if (attrs.getNamedItem("ignoredIds") != null)
								set.set("ignoredIds", attrs.getNamedItem("ignoredIds").getNodeValue());
						}
						
						set.set("canMove", Boolean.parseBoolean(attrs.getNamedItem("canMove").getNodeValue()));
						set.set("seedable", Boolean.parseBoolean(attrs.getNamedItem("seedable").getNodeValue()));
					}
					else if ("drops".equalsIgnoreCase(cat.getNodeName()))
					{
						final String type = set.getString("type");
						final boolean isRaid = type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss");
						
						final List<DropCategory> drops = new ArrayList<>();
						
						for (Node dropCat = cat.getFirstChild(); dropCat != null; dropCat = dropCat.getNextSibling())
						{
							if ("category".equalsIgnoreCase(dropCat.getNodeName()))
							{
								attrs = dropCat.getAttributes();
								
								final DropCategory category = new DropCategory(Integer.parseInt(attrs.getNamedItem("id").getNodeValue()));
								
								for (Node item = dropCat.getFirstChild(); item != null; item = item.getNextSibling())
								{
									if ("drop".equalsIgnoreCase(item.getNodeName()))
									{
										attrs = item.getAttributes();
										
										final DropData data = new DropData();
										data.setItemId(Integer.parseInt(attrs.getNamedItem("itemid").getNodeValue()));
										data.setMinDrop(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
										data.setMaxDrop(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
										data.setChance(Integer.parseInt(attrs.getNamedItem("chance").getNodeValue()));
										
										if (ItemTable.getInstance().getTemplate(data.getItemId()) == null)
										{
											_log.warning("Droplist data for undefined itemId: " + data.getItemId());
											continue;
										}
										category.addDropData(data, isRaid);
									}
								}
								drops.add(category);
							}
						}
						set.set("drops", drops);
					}
					else if ("minions".equalsIgnoreCase(cat.getNodeName()))
					{
						final List<MinionData> minions = new ArrayList<>();
						
						for (Node minion = cat.getFirstChild(); minion != null; minion = minion.getNextSibling())
						{
							if ("minion".equalsIgnoreCase(minion.getNodeName()))
							{
								attrs = minion.getAttributes();
								
								final MinionData data = new MinionData();
								data.setMinionId(Integer.parseInt(attrs.getNamedItem("id").getNodeValue()));
								data.setAmountMin(Integer.parseInt(attrs.getNamedItem("min").getNodeValue()));
								data.setAmountMax(Integer.parseInt(attrs.getNamedItem("max").getNodeValue()));
								
								minions.add(data);
							}
						}
						set.set("minions", minions);
					}
					else if ("petdata".equalsIgnoreCase(cat.getNodeName()))
					{
						mustUsePetTemplate = true;
						
						attrs = cat.getAttributes();
						
						set.set("food1", Integer.parseInt(attrs.getNamedItem("food1").getNodeValue()));
						set.set("food2", Integer.parseInt(attrs.getNamedItem("food2").getNodeValue()));
						
						set.set("autoFeedLimit", Double.parseDouble(attrs.getNamedItem("autoFeedLimit").getNodeValue()));
						set.set("hungryLimit", Double.parseDouble(attrs.getNamedItem("hungryLimit").getNodeValue()));
						set.set("unsummonLimit", Double.parseDouble(attrs.getNamedItem("unsummonLimit").getNodeValue()));
						
						final Map<Integer, PetDataEntry> entries = new HashMap<>();
						
						for (Node petCat = cat.getFirstChild(); petCat != null; petCat = petCat.getNextSibling())
						{
							if ("stat".equalsIgnoreCase(petCat.getNodeName()))
							{
								attrs = petCat.getAttributes();
								
								// Get all nodes.
								for (int i = 0; i < attrs.getLength(); i++)
								{
									// Add them to stats by node name and node value.
									Node node = attrs.item(i);
									petSet.set(node.getNodeName(), node.getNodeValue());
								}
								
								entries.put(petSet.getInteger("level"), new PetDataEntry(petSet));
								petSet.clear();
							}
						}
						set.set("petData", entries);
					}
					else if ("set".equalsIgnoreCase(cat.getNodeName()))
					{
						attrs = cat.getAttributes();
						
						set.set(attrs.getNamedItem("name").getNodeValue(), attrs.getNamedItem("val").getNodeValue());
					}
					else if ("skills".equalsIgnoreCase(cat.getNodeName()))
					{
						final List<L2Skill> skills = new ArrayList<>();
						
						for (Node skillCat = cat.getFirstChild(); skillCat != null; skillCat = skillCat.getNextSibling())
						{
							if ("skill".equalsIgnoreCase(skillCat.getNodeName()))
							{
								attrs = skillCat.getAttributes();
								
								final int skillId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
								final int level = Integer.parseInt(attrs.getNamedItem("level").getNodeValue());
								
								// Setup the npc's race. Don't register the skill.
								if (skillId == L2Skill.SKILL_NPC_RACE)
								{
									set.set("raceId", level);
									continue;
								}
								
								final L2Skill data = SkillTable.getInstance().getInfo(skillId, level);
								if (data == null)
									continue;
								
								skills.add(data);
							}
						}
						set.set("skills", skills);
					}
					else if ("teachTo".equalsIgnoreCase(cat.getNodeName()))
						set.set("teachTo", cat.getAttributes().getNamedItem("classes").getNodeValue());
				}
				
				_npcs.put(npcId, (mustUsePetTemplate) ? new PetTemplate(set) : new NpcTemplate(set));
			}
			set.clear();
		}
	}
	
	public NpcTemplate getTemplate(int id)
	{
		return _npcs.get(id);
	}
	
	/**
	 * @param name to search.
	 * @return the template list of NPCs for a given name.
	 */
	public NpcTemplate getTemplateByName(String name)
	{
		for (NpcTemplate npcTemplate : _npcs.values())
		{
			if (npcTemplate.getName().equalsIgnoreCase(name))
				return npcTemplate;
		}
		return null;
	}
	
	/**
	 * Gets all templates matching the filter.
	 * @param filter
	 * @return the template list for the given filter
	 */
	public List<NpcTemplate> getTemplates(Predicate<NpcTemplate> filter)
	{
		return _npcs.values().stream().filter(filter).collect(Collectors.toList());
	}
	
	public Collection<NpcTemplate> getAllNpcs()
	{
		return _npcs.values();
	}
	
	public static NpcTable getInstance()
	{
		return SingletonHolder._instance;
	}
	
	private static class SingletonHolder
	{
		protected static final NpcTable _instance = new NpcTable();
	}
}

import net.sf.l2j.commons.data.xml.XMLDocument;

 

this doesnt exist in my files.

 

Posted (edited)

If you can find which files are blocked, that could give you a begin of answer (maybe encoding or they aren't considered XML ?).

 

I suppose you speak about "vanilla" templates and not custom ones. There is clearly no reason 1/3 templates aren't load, and the leftover is ok. About your custom folder, put all XMLs from this directory on the root level of data/xml/npcs folder in order they're loaded.

 

XMLDocument has been added recently, the previous layer was XmlDocumentFactory. Until I missed a point, it probably won't solve your problem.

 

You should track which file is correctly loaded, and which isn't. And try to figure why those files aren't loaded (if you edited them, if they got a special encoding, etc).

Edited by Tryskell
Posted
1 hour ago, Reborn12 said:

npcs\custom

make a file like customnpcs.xml in you data/xml/npcs folded and all will be fine no reason to change any java or create a new folder

http://prntscr.com/hwg3oy

There is file with 2 npc wedding manager and buffer. Original by ACIS

Posted
1 hour ago, Tryskell said:

If you can find which files are blocked, that could give you a begin of answer (maybe encoding or they aren't considered XML ?).

 

 

How? in gs/log?

I think first corrupted file should be 27000-27999 because first missing template is 27002.

 

p.s. i dont know what vanilla is or what it means.

 

1 hour ago, Tryskell said:

You should track which file is correctly loaded, and which isn't. And try to figure why those files aren't loaded (if you edited them, if they got a special encoding, etc).

 

What if i will re-save all files with special xml editor? 

 

Posted

Vanilla != custom. Vanilla is the sources as shared by project owner, custom is sources either edited by you or another dude you downloaded from.

 

About which file or id is loaded, you can put a log on the loading process see which file is loaded.

 

			for (File file : dir.listFiles())
			{

just here, put a log using "file" to identify which xml is loaded.

 

A "special XML editor" is nothing more than a notepad++ specialized at reading xml. It won't change anything, until you edited those files yourself or they are, somehow, corrupted.

Guest
This topic is now closed to further replies.


  • Posts

    • in conclusion when somebody who has a project for 10+ years still on development writes an e-say to try until you succeed and then advertises his project, one of the reasons is he needs money, so l2j has once more become pure expensive hobby, you wont make money out of it.   You can still use L2jFrozen and get better results for this, i know some people that done it    keep in mind that C in aCis stands for Crappy, and after all these years its not a cool wordplay anymore, its a fact, prove me wrong.
    • First, don't really follow the "main voice", moreover if you consider it an hobby. Simply do what you want, you got only one life so use it as you want. If you make it an hobby, it's exactly like piano, or velo - only practice makes you better.   Secondly, how do you learn things ? It's actually a really important question, since some can simply be scholar, read books (theory) then practice ; and some simply can't read books. I'm the second type, I hated school, I find it boring - my knowledge in Java comes from try-and-fail. You improve your coding style every year or so, I can myself rewrite my own code (which I already considered top-notched) after a while. You always learn something new - even if Java barely evolves. L2J is a fun way to learn programming, it's a giant sandbox where you can edit anything, and I believe it should be taken as it.   My own way of learning was as follow : Add existing customs, no matter what they are : the point is to know main classes used by L2J / customs. L2J is barely Java knowledge ; the true knowledge is to know WHAT to search in WHICH location (what I call, organization). You have to understand than EVERYTHING you think already exists, in a form on another, in the source code. A custom is only the association of the different mechanisms you found "here and there", glued together in a proper goal. Once you know main classes to edit, and the customs you added are compiling fine, the main point is to know WHAT exactly you DID. Try to understand WHY and WHERE you actually copied the code. Third point would be to MANIPULATE the customs you added in order to fit your wish. First edit little values, then logic conditions ; eventually add a new Config, or a new functionality to the custom. Fourth point would be to begin to craft your own ideas. Once again, EVERYTHING already exists, in a form or another. You want a cycled event ? You got Seven Signs main task as exemple. Npc ? Search any type of Npc and figure out what it does. Fifth point would be to understand Java - mostly containers (WHAT and WHERE to use them), variables types and main Java mechanisms (inheritance, static modifier, etc). You should also begin to cut your code into maintainable classes or methods. Java can actually run without optimization, but bigger your ideas, more optimized and well-thought it should be. It's direct saved time in the future, and you would thank yourself doing so. Main tips : ALWAYS use any type of versioning system - GIT or SVN. It allows to save your work, step by step and eventually revert back anytime you want if you terribly messed up. L2J is 80% organization knowledge, and 20% Java knowledge. Basically, if you know WHAT and WHERE to search, if you aren't dumb, it's easy to replicate and re-use things. Cherry on top is to use a already good coded pack to avoid copy-paste crap and get bad habits. Avoid any type of russian or brazilian packs, for exemple - their best ability is to leak someone's else code. Obviously you need some default sense of logic, but Java and programming in general help you to improve it.   Finally, most of your questions could be solved joining related Discord (at least for aCis, I can't speak for others) - from the moment your question was correctly asked (and you seemed to search for the answer). My community (and myself) welcomes newbies, but got some issues with noobies.   The simpliest is to try, fail and repeat until you succeed - it sounds stupid, but that's basically how life works.   PS : about Java ressources, before ChatGPT, it was mostly about stackoverflow website, and site like Baeldung's one. With ChatGPT and alike, you generally double-cross AI output to avoid fucked up answers. Also, care about AI, they are often hallucinating really hard, even today. They can give you complete wrong answer, you tell them they are wrong, and they say "indeed, I suck, sorry - here's a new fucked up answer". You shouldn't 100% rely over AI answer, even if that can give sometimes legit answers, full code or just skeletons of ideas.   PPS : I don't think there are reliable ressources regarding L2J itself, also most of the proposed code decays pretty fast if the source code is actually maintained (at least for aCis). Still, old coded customs for old aCis sources are actually a good beginner challenge to apply on latest source.
    • WTS: - AQ - Baium - Zaken  - Frintezza - Vesper Fighter Focus Fire Element   pm for detalis
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock