Jump to content

Acis half of npc templates not found..


Recommended Posts

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
Link to comment
Share on other sites

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.. :/

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

/*
 * 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
Link to comment
Share on other sites

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();
	}
}

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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? 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • the refering npc is string lenght, so either u edited something badly in html or the size is too big to handle from the client, and propably yan made some customizations to accept bigger size? if also the path is wrong that should be a problem aswell
    • Adapted YanBuffer and everything work fine until i try to talk to the npc. (no errors when building) i get the following: \game\data\scripts\custom\Buffer\Buffer.java java.lang.NullPointerException: Cannot invoke "String.length()" because "html" is null at org.l2jmobius.gameserver.network.serverpackets.AbstractHtmlPacket.setHtml(AbstractHtmlPacket.java:77) at org.l2jmobius.gameserver.network.serverpackets.AbstractHtmlPacket.<init>(AbstractHtmlPacket.java:67) at org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage.<init>(NpcHtmlMessage.java:53) at custom.Buffer.Buffer.showAdvancedHtml(Buffer.java:279) at custom.Buffer.Buffer.htmlShowMain(Buffer.java:289) at custom.Buffer.Buffer.executeHtmlCommand(Buffer.java:366) at custom.Buffer.Buffer.executeCommand(Buffer.java:840) at custom.Buffer.Buffer.onFirstTalk(Buffer.java:126) at org.l2jmobius.gameserver.model.quest.Quest.notifyFirstTalk(Quest.java:720) at org.l2jmobius.gameserver.model.quest.Quest.lambda$addFirstTalkId$0(Quest.java:1826) at org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener.executeEvent(ConsumerEventListener.java:44) at org.l2jmobius.gameserver.model.events.EventDispatcher.notifyToListeners(EventDispatcher.java:289) at org.l2jmobius.gameserver.model.events.EventDispatcher.notifyEventToSingleContainer(EventDispatcher.java:182) at org.l2jmobius.gameserver.model.events.EventDispatcher.lambda$notifyEventAsync$0(EventDispatcher.java:144) at org.l2jmobius.commons.threads.RunnableWrapper.run(RunnableWrapper.java:35) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)   and here is the actual code: /* * This file is part of YANModPack: https://github.com/HorridoJoho/YANModPack * Copyright (C) 2015 Christian Buck * * 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 custom.Buffer; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; import org.l2jmobius.Config; import org.l2jmobius.gameserver.enums.HtmlActionScope; import org.l2jmobius.gameserver.handler.BypassHandler; import org.l2jmobius.gameserver.handler.ItemHandler; import org.l2jmobius.gameserver.handler.VoicedCommandHandler; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Playable; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.skill.BuffInfo; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import org.l2jmobius.gameserver.network.serverpackets.ShowBoard; import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager; import ai.AbstractNpcAI; import custom.Buffer.util.ItemRequirement; import custom.Buffer.util.htmltmpls.HTMLTemplateParser; import custom.Buffer.util.htmltmpls.HTMLTemplatePlaceholder; import custom.Buffer.util.htmltmpls.funcs.ChildsCountFunc; import custom.Buffer.util.htmltmpls.funcs.ExistsFunc; import custom.Buffer.util.htmltmpls.funcs.ForeachFunc; import custom.Buffer.util.htmltmpls.funcs.IfChildsFunc; import custom.Buffer.util.htmltmpls.funcs.IfFunc; import custom.Buffer.util.htmltmpls.funcs.IncludeFunc; /** * @author HorridoJoho */ public final class Buffer extends AbstractNpcAI { private static final class SingletonHolder { protected static final Buffer INSTANCE = new Buffer(); } private static final int MINUTE_IN_SECONDS = 60; private static final Logger _LOGGER = Logger.getLogger(Buffer.class.getName()); public static final Path SCRIPTS_SUBFOLDER = Paths.get("custom"); public static final Path SCRIPT_TOP_FOLDER = Paths.get("Buffer"); public static final Path SCRIPT_SUBFOLDER = Paths.get(SCRIPTS_SUBFOLDER.toString(), SCRIPT_TOP_FOLDER.toString()); static Buffer getInstance() { return SingletonHolder.INSTANCE; } public static void main(String[] args) { try { BufferData.initInstance(); } catch (Exception ex) { _LOGGER.log(Level.WARNING, "Buffer - Data: Exception while loading npc buffer data, not registering mod!", ex); return; } Buffer instance = getInstance(); for (Entry<Integer, BufferData.BufferNpc> npc : BufferData.getInstance().getBufferNpcs().entrySet()) { instance.addFirstTalkId(npc.getKey()); instance.addStartNpc(npc.getKey()); instance.addTalkId(npc.getKey()); } } private static final ConcurrentHashMap<Integer, Long> _LAST_PLAYABLES_HEAL_TIME = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<Integer, String> _LAST_PLAYER_HTMLS = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<Integer, String> _ACTIVE_PLAYER_BUFFLISTS = new ConcurrentHashMap<>(); Buffer() { // super(-1, SCRIPT_TOP_FOLDER.toString(), SCRIPTS_SUBFOLDER.toString()); super(); BypassHandler.getInstance().registerHandler(BufferNpcBypassHandler.getInstance()); if (BufferData.getInstance().getVoicedBuffer().enabled) { VoicedCommandHandler.getInstance().registerHandler(BufferVoicedCommandHandler.getInstance()); ItemHandler.getInstance().registerHandler(BufferItemHandler.getInstance()); } } // //////////////////////////////////// // AI METHOD OVERRIDES // //////////////////////////////////// @Override public String onFirstTalk(Npc npc, Player player) { executeCommand(player, npc, null); return null; } // /////////////////////////////////// // UTILITY METHODS // /////////////////////////////////// private BufferData.Buffer determineBuffer(Npc npc, Player player) { if (npc == null) { BufferData.VoicedBuffer buffer = BufferData.getInstance().getVoicedBuffer(); if (!buffer.enabled || ((buffer.requiredItem > 0) && (player.getInventory().getItemByItemId(buffer.requiredItem) == null))) { return null; } return buffer; } return BufferData.getInstance().getBufferNpc(npc.getId()); } private String generateAdvancedHtml(Player player, String path, Map<String, HTMLTemplatePlaceholder> placeholders, BufferData.HtmlType dialogType) { return HTMLTemplateParser.fromCache(Path.of("/data/scripts/" + SCRIPT_SUBFOLDER + "/data/html/" + dialogType.toString().toLowerCase(Locale.ENGLISH) + "/" + path).toString(), player, placeholders, IncludeFunc.INSTANCE, IfFunc.INSTANCE, ForeachFunc.INSTANCE, ExistsFunc.INSTANCE, IfChildsFunc.INSTANCE, ChildsCountFunc.INSTANCE); } /** * Copy from {@link NpcHtmlMessage} * @param activeChar the player * @param html the html to check */ private void buildBypassCache(Player activeChar, String html) { if (activeChar == null) { return; } activeChar.clearHtmlActions(HtmlActionScope.NPC_HTML); int len = html.length(); for (int i = 0; i < len; i++) { int start = html.indexOf("\"bypass ", i); int finish = html.indexOf("\"", start + 1); if ((start < 0) || (finish < 0)) { break; } if (html.substring(start + 8, start + 10).equals("-h")) { start += 11; } else { start += 8; } i = finish; int finish2 = html.indexOf("$", start); if ((finish2 < finish) && (finish2 > 0)) { activeChar.addHtmlAction(HtmlActionScope.NPC_HTML, html.substring(start, finish2).trim()); } else { activeChar.addHtmlAction(HtmlActionScope.NPC_HTML, html.substring(start, finish).trim()); } } } /** * Copy from {@link org.l2jmobius.gameserver.communitybbs.Manager.BaseBBSManager}. Modified to allow larger community board htmls. * @param player the player to send to * @param html the html text */ private void sendBBSHtml(Player player, String html) { buildBypassCache(player, html); if (html.length() < 16250) { player.sendPacket(new ShowBoard(html, "101")); player.sendPacket(new ShowBoard(null, "102")); player.sendPacket(new ShowBoard(null, "103")); } else if (html.length() < (16250 * 2)) { player.sendPacket(new ShowBoard(html.substring(0, 16250), "101")); player.sendPacket(new ShowBoard(html.substring(16250), "102")); player.sendPacket(new ShowBoard(null, "103")); } else if (html.length() < (16250 * 3)) { player.sendPacket(new ShowBoard(html.substring(0, 16250), "101")); player.sendPacket(new ShowBoard(html.substring(16250, 16250 * 2), "102")); player.sendPacket(new ShowBoard(html.substring(16250 * 2), "103")); } else { player.sendPacket(new ShowBoard("<html><body><br><center>Error: HTML was too long!</center></body></html>", "101")); player.sendPacket(new ShowBoard(null, "102")); player.sendPacket(new ShowBoard(null, "103")); } } private void fillItemAmountMap(Map<Integer, Long> items, BufferData.Buff buff) { for (Entry<String, ItemRequirement> item : buff.items.entrySet()) { Long amount = items.get(item.getValue().item.getId()); if (amount == null) { amount = 0L; } items.put(item.getValue().item.getId(), amount + item.getValue().amount); } } private void castBuff(Playable playable, BufferData.Buff buff) { buff.skill.applyEffects(playable, playable, true, Config.BUFFER_CUSTOM_BUFF_DURATION * MINUTE_IN_SECONDS); } // ////////////////////////////////// // HTML COMMANDS // ////////////////////////////////// private void showAdvancedHtml(Player player, BufferData.Buffer buffer, Npc npc, String htmlPath, Map<String, HTMLTemplatePlaceholder> placeholders) { placeholders.put(buffer.placeholder.getName(), buffer.placeholder); HTMLTemplatePlaceholder ulistsPlaceholder = BufferData.getInstance().getPlayersUListsPlaceholder(player.getObjectId()); if (ulistsPlaceholder != null) { placeholders.put(ulistsPlaceholder.getName(), ulistsPlaceholder); } String activeUniqueName = _ACTIVE_PLAYER_BUFFLISTS.get(player.getObjectId()); if (activeUniqueName != null) { HTMLTemplatePlaceholder ulistPlaceholder = BufferData.getInstance().getPlayersUListPlaceholder(player.getObjectId(), activeUniqueName); if (ulistPlaceholder != null) { placeholders.put("active_unique", ulistPlaceholder); } } BufferData.HtmlType dialogType = BufferData.getInstance().getHtmlType(); String html = generateAdvancedHtml(player, htmlPath, placeholders, dialogType); switch (dialogType) { case NPC: player.sendPacket(new NpcHtmlMessage(npc == null ? 0 : npc.getObjectId(), html)); break; case COMMUNITY: sendBBSHtml(player, html); break; } } private void htmlShowMain(Player player, BufferData.Buffer buffer, Npc npc) { showAdvancedHtml(player, buffer, npc, "main.html", new HashMap<String, HTMLTemplatePlaceholder>()); } private void htmlShowCategory(Player player, BufferData.Buffer buffer, Npc npc, String categoryIdent) { BufferData.BuffCategory buffCat = buffer.getBuffCat(categoryIdent); if (buffCat == null) { return; } HashMap<String, HTMLTemplatePlaceholder> placeholders = new HashMap<>(); placeholders.put("category", buffCat.placeholder); showAdvancedHtml(player, buffer, npc, "category.html", placeholders); } private void htmlShowBuff(Player player, BufferData.Buffer buffer, Npc npc, String categoryIdent, String buffIdent) { BufferData.BuffCategory buffCat = buffer.getBuffCat(categoryIdent); if (buffCat == null) { return; } BufferData.Buff buff = buffCat.getBuff(buffIdent); if (buff == null) { return; } HashMap<String, HTMLTemplatePlaceholder> placeholders = new HashMap<>(); placeholders.put("category", buffCat.placeholder); placeholders.put("buff", buff.placeholder); showAdvancedHtml(player, buffer, npc, "buff.html", placeholders); } private void htmlShowPreset(Player player, BufferData.Buffer buffer, Npc npc, String presetBufflistIdent) { BufferData.BuffCategory presetBufflist = buffer.getPresetBufflist(presetBufflistIdent); if (presetBufflist == null) { return; } HashMap<String, HTMLTemplatePlaceholder> placeholders = new HashMap<>(); placeholders.put("preset", presetBufflist.placeholder); showAdvancedHtml(player, buffer, npc, "preset.html", placeholders); } private void htmlShowUnique(Player player, BufferData.Buffer buffer, Npc npc, String uniqueName) { HTMLTemplatePlaceholder uniquePlaceholder = BufferData.getInstance().getPlayersUListPlaceholder(player.getObjectId(), uniqueName); if (uniquePlaceholder == null) { // redirect to main html if uniqueName is not valid, will most likely happen when the player deletes a unique bufflist he is currently viewing executeHtmlCommand(player, buffer, npc, "main"); return; } HashMap<String, HTMLTemplatePlaceholder> placeholders = new HashMap<>(); placeholders.put(uniquePlaceholder.getName(), uniquePlaceholder); showAdvancedHtml(player, buffer, npc, "unique.html", placeholders); } private void executeHtmlCommand(Player player, BufferData.Buffer buffer, Npc npc, String command) { _LAST_PLAYER_HTMLS.put(player.getObjectId(), command); if ("main".equals(command)) { htmlShowMain(player, buffer, npc); } else if (command.startsWith("category ")) { htmlShowCategory(player, buffer, npc, command.substring(9)); } else if (command.startsWith("preset ")) { htmlShowPreset(player, buffer, npc, command.substring(7)); } else if (command.startsWith("buff ")) { String[] argsSplit = command.substring(5).split(" ", 2); if (argsSplit.length != 2) { return; } htmlShowBuff(player, buffer, npc, argsSplit[0], argsSplit[1]); } else if (command.startsWith("unique ")) { htmlShowUnique(player, buffer, npc, command.substring(7)); } else { // all other malformed bypasses htmlShowMain(player, buffer, npc); } } // // //////////////////////////////// // ///////////////////////////////////////////// // TARGET COMMANDS // ///////////////////////////////////////////// private void targetBuffBuff(Player player, Playable target, BufferData.Buffer buffer, String categoryIdent, String buffIdent) { BufferData.BuffCategory bCat = buffer.getBuffCat(categoryIdent); if (bCat == null) { return; } BufferData.Buff buff = bCat.getBuff(buffIdent); if (buff == null) { return; } if (!buff.items.isEmpty()) { HashMap<Integer, Long> items = new HashMap<>(); fillItemAmountMap(items, buff); for (Entry<Integer, Long> item : items.entrySet()) { if (player.getInventory().getInventoryItemCount(item.getKey(), 0, true) < item.getValue()) { player.sendMessage("Not enough items!"); return; } } for (Entry<Integer, Long> item : items.entrySet()) { player.destroyItemByItemId("Buffer", item.getKey(), item.getValue(), player, true); } } castBuff(target, buff); } private void targetBuffUnique(Player player, Playable target, BufferData.Buffer buffer, String uniqueName) { List<BufferData.Buff> buffs = BufferData.getInstance().getUniqueBufflist(player.getObjectId(), uniqueName); if (buffs != null) { HashMap<Integer, Long> items = null; for (BufferData.Buff buff : buffs) { if (!buff.items.isEmpty()) { if (items == null) { items = new HashMap<>(); } fillItemAmountMap(items, buff); } } if (items != null) { for (Entry<Integer, Long> item : items.entrySet()) { if (player.getInventory().getInventoryItemCount(item.getKey(), 0, true) < item.getValue()) { player.sendMessage("Not enough items!"); return; } } for (Entry<Integer, Long> item : items.entrySet()) { player.destroyItemByItemId("Buffer", item.getKey(), item.getValue(), player, true); } } for (BufferData.Buff buff : buffs) { castBuff(target, buff); } } } private void targetBuffPreset(Player player, Playable target, BufferData.Buffer buffer, String presetBufflistIdent) { BufferData.BuffCategory presetBufflist = buffer.getPresetBufflist(presetBufflistIdent); if (presetBufflist == null) { return; } Collection<BufferData.Buff> buffs = presetBufflist.buffs.values(); if (buffs != null) { HashMap<Integer, Long> items = null; for (BufferData.Buff buff : buffs) { if (!buff.items.isEmpty()) { if (items == null) { items = new HashMap<>(); } fillItemAmountMap(items, buff); } } if (items != null) { for (Entry<Integer, Long> item : items.entrySet()) { if (player.getInventory().getInventoryItemCount(item.getKey(), 0, true) < item.getValue()) { player.sendMessage("Not enough items!"); return; } } for (Entry<Integer, Long> item : items.entrySet()) { player.destroyItemByItemId("Buffer", item.getKey(), item.getValue(), player, true); } } for (BufferData.Buff buff : buffs) { castBuff(target, buff); } } } private void targetHeal(Player player, Playable target, BufferData.Buffer buffer) { if (!buffer.canHeal) { return; } // prevent heal spamming, process cooldown on heal target Long lastPlayableHealTime = _LAST_PLAYABLES_HEAL_TIME.get(target.getObjectId()); if (lastPlayableHealTime != null) { Long elapsedTime = System.currentTimeMillis() - lastPlayableHealTime; Long healCooldown = BufferData.getInstance().getHealCooldown(); if (elapsedTime < healCooldown) { Long remainingTime = healCooldown - elapsedTime; if (target == player) { player.sendMessage("You can heal yourself again in " + (remainingTime / 1000) + " seconds."); } else { player.sendMessage("You can heal your pet again in " + (remainingTime / 1000) + " seconds."); } return; } } _LAST_PLAYABLES_HEAL_TIME.put(target.getObjectId(), System.currentTimeMillis()); if (player == target) { player.setCurrentCp(player.getMaxCp()); } target.setCurrentHp(target.getMaxHp()); target.setCurrentMp(target.getMaxMp()); target.broadcastStatusUpdate(); } private void targetCancel(Player player, Playable target, BufferData.Buffer buffer) { if (!buffer.canCancel) { return; } target.stopAllEffectsExceptThoseThatLastThroughDeath(); } private void executeTargetCommand(Player player, BufferData.Buffer buffer, String command) { // ///////////////////////////////// // first determine the target Playable target; if (command.startsWith("player ")) { target = player; command = command.substring(7); } else if (command.startsWith("summon ")) { target = player.getPet(); if (target == null) { return; } command = command.substring(7); } else { return; } // ////////////////////////////////////////// // run the choosen action on the target if (command.startsWith("buff ")) { String[] argsSplit = command.substring(5).split(" ", 2); if (argsSplit.length != 2) { return; } targetBuffBuff(player, target, buffer, argsSplit[0], argsSplit[1]); } else if (command.startsWith("unique ")) { targetBuffUnique(player, target, buffer, command.substring(7)); } else if (command.startsWith("preset ")) { targetBuffPreset(player, target, buffer, command.substring(7)); } else if ("heal".equals(command)) { targetHeal(player, target, buffer); } else if ("cancel".equals(command)) { targetCancel(player, target, buffer); } } // // //////////////////////////////// // //////////////////////////////// // UNIQUE COMMANDS // //////////////////////////////// private boolean uniqueCreate(Player player, String uniqueName) { if (!BufferData.getInstance().canHaveMoreBufflists(player)) { player.sendMessage("Maximum number of unique bufflists reached!"); return false; } // only allow alpha numeric names because we use this name on the htmls if (!uniqueName.matches("[A-Za-z0-9]+")) { return false; } return BufferData.getInstance().createUniqueBufflist(player.getObjectId(), uniqueName); } private void uniqueDelete(Player player, String uniqueName) { BufferData.getInstance().deleteUniqueBufflist(player.getObjectId(), uniqueName); // also remove from active bufflist when it's the deleted String activeUniqueName = _ACTIVE_PLAYER_BUFFLISTS.get(player.getObjectId()); if ((activeUniqueName != null) && activeUniqueName.equals(uniqueName)) { _ACTIVE_PLAYER_BUFFLISTS.remove(player.getObjectId()); } } private void uniqueAdd(Player player, BufferData.Buffer buffer, String uniqueName, String categoryIdent, String buffIdent) { BufferData.BuffCategory bCat = buffer.getBuffCat(categoryIdent); if (bCat == null) { return; } BufferData.Buff buff = bCat.getBuff(buffIdent); if (buff == null) { return; } BufferData.getInstance().addToUniqueBufflist(player.getObjectId(), uniqueName, buff); } private void uniqueRemove(Player player, String uniqueName, String buffIdent) { BufferData.Buff buff = BufferData.getInstance().getBuff(buffIdent); if (buff == null) { return; } BufferData.getInstance().removeFromUniqueBufflist(player.getObjectId(), uniqueName, buff); } private void uniqueSelect(Player player, String uniqueName) { if (BufferData.getInstance().hasUniqueBufflist(player.getObjectId(), uniqueName)) { _ACTIVE_PLAYER_BUFFLISTS.put(player.getObjectId(), uniqueName); } } private void uniqueDeselect(Player player) { _ACTIVE_PLAYER_BUFFLISTS.remove(player.getObjectId()); } private void executeUniqueCommand(Player player, BufferData.Buffer buffer, String command) { if (command.startsWith("create ")) { uniqueCreate(player, command.substring(7)); } else if (command.startsWith("create_from_effects ")) { String uniqueName = command.substring(20); if (!uniqueCreate(player, uniqueName)) { return; } final Collection<BuffInfo> buffs = player.getEffectList().getEffects(); for (final BuffInfo effect : buffs) { for (Entry<String, BufferData.BuffCategory> buffCatEntry : buffer.buffCats.entrySet()) { boolean added = false; for (Entry<String, BufferData.Buff> buffEntry : buffCatEntry.getValue().buffs.entrySet()) { final BufferData.Buff buff = buffEntry.getValue(); if (buff.skill.getId() == effect.getSkill().getId()) { uniqueAdd(player, buffer, uniqueName, buffCatEntry.getKey(), buff.ident); added = true; break; } } if (added) { break; } } } } else if (command.startsWith("delete ")) { uniqueDelete(player, command.substring(7)); } else if (command.startsWith("add ")) { String[] argsSplit = command.substring(4).split(" ", 3); if (argsSplit.length != 3) { return; } uniqueAdd(player, buffer, argsSplit[0], argsSplit[1], argsSplit[2]); } else if (command.startsWith("remove ")) { String[] argsSplit = command.substring(7).split(" ", 2); if (argsSplit.length != 2) { return; } uniqueRemove(player, argsSplit[0], argsSplit[1]); } else if (command.startsWith("select ")) { uniqueSelect(player, command.substring(7)); } else if (command.startsWith("deselect")) { uniqueDeselect(player); } } // // //////////////////////////////// private static boolean isInsideAnyZoneOf(Creature character, ZoneId first, ZoneId... more) { if (character.isInsideZone(first)) { return true; } if (more != null) { for (ZoneId zone : more) { if (character.isInsideZone(zone)) { return true; } } } return false; } void executeCommand(Player player, Npc npc, String command) { if (isInsideAnyZoneOf(player, ZoneId.PVP, ZoneId.SIEGE, ZoneId.WATER, ZoneId.JAIL, ZoneId.DANGER_AREA)) { player.sendMessage("The buffer cannot be used here."); return; } else if (player.isOnEvent() || player.isInOlympiadMode()) { player.sendMessage("The buffer cannot be used in events."); return; } else if (player.isInDuel() || (player.getPvpFlag() == 1)) { player.sendMessage("The buffer cannot be used in duells or pvp."); return; } else if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player)) { player.sendMessage("The buffer cannot be used while in combat."); return; } BufferData.Buffer buffer = determineBuffer(npc, player); if (buffer == null) { // not an authorized npc or npc is null and voiced buffer is disabled return; } if ((command == null) || command.isEmpty()) { command = "html main"; } if (command.startsWith("html ")) { executeHtmlCommand(player, buffer, npc, command.substring(5)); } else { if (command.startsWith("target ")) { executeTargetCommand(player, buffer, command.substring(7)); } else if (command.startsWith("unique ")) { executeUniqueCommand(player, buffer, command.substring(7)); } // display last html again // since somebody could use the chat as a command line(eg.: .buffer target player heal), we check if the player has opened a html before String lastHtmlCommand = _LAST_PLAYER_HTMLS.get(player.getObjectId()); if (lastHtmlCommand != null) { executeHtmlCommand(player, buffer, npc, _LAST_PLAYER_HTMLS.get(player.getObjectId())); } } } }   i searched and saw something about "Html length" that i can rl understand.    I also noticed that it doesnt follow the path correctly. It is:  \scripts\custom\Buffer\data\htmlpc\main.html  and it should be    \scripts\custom\Buffer\data\html\npc\main.html    Thanks.
    • Use L2Editor   Also, documentation: UDN - Two - UnrealEdInterface (unrealengine.com)    
    • hello maxcheaters..i need your help once more with .utx editor..i am trying to edit one .utx file (logo) for html , and i cant whatever i tried...is there anyone who could help me with this? thanks in advance.!
  • Topics

×
×
  • Create New...