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.


×
×
  • Create New...