Jump to content
  • 0

need help with npc buffer.


Question

Posted (edited)

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.

Edited by Drazeal

6 answers to this question

Recommended Posts

  • 0
Posted

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

  • 0
Posted
2 hours ago, Cressendia said:

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

I think the post is pretty clear by itself coming together with a {HELP} prefix, didnt rl need someone to summarize...

I'd have added a TL;DR myself if it was needed.

  • 0
Posted (edited)

You are not parsing the HTML, or at least that's what the error states.

I assume the issue might lie here:

 

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)
Edited by Salty Mike
  • 0
Posted
9 hours ago, Drazeal said:

I think the post is pretty clear by itself coming together with a {HELP} prefix, didnt rl need someone to summarize...

I'd have added a TL;DR myself if it was needed.

its pretty obvious that you already say whats wrong and it is indeed the wrong but , you do not see it.. when the error is super clear! 

as the friend above said, you are not parsing the html so it gives you "empty" or "faulty" html as main 🙂 cause it doesnt even exist!

  • 0
Posted
50 minutes ago, Drazeal said:

its not the html.   its the "calling" of it (like Salty said) and i cant figure it out...

 

50 minutes ago, Drazeal said:

its not the html.   its the "calling" of it (like Salty said) and i cant figure it out...

i can help u later this night thehunter2435 , and no i wont ask money

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • so u need to create them and then use the icon name in the prefered ones
    • Please is anyone who can share the compiled version of the l2editor source for interlude? Because i run the !GenerateLibs.bat with the corrected code by CriticalError and then i try to build with the vs 2013 but i get errors again and again and when i try anyway to open or create something with the UnrealEd.exe then it closes automatically.
    • General Trackers :   IPTorrents invite IPTorrents account 1 tb TorrentLeech invite Torrentleech account 1 tb buffer  InTheShaDow ( ITS ) account Acid-lounge invite Torrentday invite Crnaberza account Abn.Lol account Limit-of-eden account Norbits account Xspeeds account Xspeeds invite Bemaniso invite Wigornot account Bithumen invite Filelist account Funfile invite AvistaZ invite Potuk.net invite ResurrectThe.Net invite GrabThe.Info invite Greek-Team invite LinkoManija invite Fano.in account tracker.czech-server.com Speed.cd invite Arab-torrents.net account Arabscene.me account Scenetime account 4thd.xyz invite Btarg.com.ar account Dedbit invite Estone.cc account Speedapp invite Finvip invite Fluxzone account GigaTorrents account Gimmepeers account Haidan.video invite Mojblink account Mycarpathians invite Newinsane.info account Oscarworld.xyz account Peers.FM invite Pt.msg.vg account Ransackedcrew account Redemption invite Scene-rush account Seedfile.io invite Teracod invite Torrent.ai account Torrentmasters invite Ttsweb invite X-files invite X-ite invite Ncore account TorrentHR account Rptorrents account BwTorrents account Superbits invite Krazyzone account Immortalseed account Tntracker invite Pt.eastgame.org account Bitturk account Rstorrent account Tracker.btnext invite Torrent-turk.de account BeiTai.PT account Pt.keepfrds account 52pt.site account Pthome account Torrentseeds account Aystorrent account Blues-brothers.biz invite Divteam account Thesceneplace invite CinemaMovies.pl account Brasiltracker account Patiodebutacas account Newheaven.nl account  Swarmazon.club invite Bc-reloaded account Crazyspirits account Silentground invite Omg.wtftrackr invite Milkie.cc invite Breathetheword invite Madsrevolution account Chilebt account Yubraca account Uniongang.tv account Frboard account Exvagos account Diablotorrent account Microbit account Carp-hunter.hu account Majomparade.eu account Theshinning.me account Youiv.info account Dragonworld-reloaded account Sharewood.tv account Partis.si account Digitalcore.club invite Fuzer.me account R3vuk.wtf invite Ztracker account 1 tb buffer 3changtrai account Best-core.info account Bitsite.us account Eliteunitedcrew invite Exitorrent.org account Tophos invite Torrent.lt account Sktorrent.eu account Oshen account Pirata.digital account Esharenet account Ohmenarikgi.la Pirate-share account Immortuos account Kiesbits account Cliente.amigos-share.club account Broadcity invite Ilovetorzz account Torrentbytes account Polishsource account Portugas invite Shareisland account ArabaFenice account Hudbt.hust.edu.cn account Audiences account Nanyangpt account Pt.sjtu.edu.cn account Pt.zhixing.bjtu.edu.cn account Byr.pt invite Ptfiles invite Red-bits account Pt.hdpost.top account Irrenhaus.dyndns.dk (NewPropaganda) account Mnvv2.info (MaxNewVision V2) account 1ptba.com account Spidertk.top account Film-paleis account Generation-free account Aftershock-tracker account Twilightsdreams account Back-ups.me invite Sor-next.tk ( Spirit Of Revolution ) account Tfa.tf ( The Falling Angels ) account Hdmayi account S-f-p.dyndns.dk ( Share Friends Projekt ) account Unlimitz.biz account Pttime account St-tracker.eu account New-retro.eu account Zbbit account Tigers-dl.net account Jptvts.us account Lat-team account Club.hares.top account Falkonvision-team account Concen account Drugari account T.ceskeforum account Peeratiko.org account Zamunda.se account Central-torrent.eu account h-o-d.org account Torrentleech.pl account Demonoid invite Lst.gg account Fakedoor.store account LaidBackManor account Vrbsharezone.co.uk invite Torrenteros account Arenaelite account Datascene account Tracker.0day.community Tapochek.net invite Ptchina invite Lesaloon account Exyusubs account Therebels.tv account Ubits.club invite Zmpt.cc account Turktorrent.us account Dasunerwarte account Hawke.uno account Monikadesign account Fearnopeer account Alpharatio account Wukongwendao.top account Chinapyg account Azusa.wiki account Yggtorrent.top account Torrentdd account Cyanbug.net invite Hhanclub.top account Wintersakura.net account Xthor account Tctg.pm account Finelite invite Agsvpt.com account Pt.0ff.cc invite Qingwapt.com account Xingtan.one account Ptcafe.club invite W-o-t.pro account Coastal-crew.bounceme.net account Darkpeers.org account Pianyuan.org account Seedpool.org  account Tempelbox account Pt.itzmx.com account Itatorrents.xyz  account Letseed.org account The-new-fun.com  account Malayabits.cc account Trellas.me account Yu-scene.net account Futuretorrent.org account Bitpt.cn account Tocashare.biz  account Videoteka.org  account White-angel.hu account Xbytesv2.li account Torr9  account Desitorrents account Okpt.net account Samaritano.cc account Polishtorrent.top  account C411.org account Bigcore.eu account BJ-Share.info account Infinitylibrary.net account Beload.org account Emuwarez.com account Yhpp.cc account Funsharing ( FSC ) account Rastastugan account Tlzdigital account account Upscalevault account Bluraytracker.cz account Torrenting.com account Infire.si account Dasunerwartete.biz invite The-torrent-trader account New-asgard.xyz account Pandapt account Deildu account Tmpt.top invite Pt.gtk.pw account Media.slo-bitcloud.eu account Pte.nu account P.t-baozi.cc account   Movies Trackers :   Secret-cinema account Anthelion account Pixelhd account Cinemageddon account Cinemaz account Retroflix account Classix-unlimited - invite Movie-Torrentz (m2g.link) invite Punck-tracker.net account Tmghub account Cathode-ray.tube account Greatposterwall account Arabicsource.net account Upload.cx account Crabpt.vip invite Onlyencodes.cc account Exyusubs account Hellashut.net invite Nordichd.sytes.net invite Locadora.cc account HD Trackers :   Blutopia buffered account Hd-olimpo buffered account Hdf.world account Torrentland.li account HdSky account Hdchina account Chdbits account Totheglory account Hdroute account Hdhome account TorrentCCF aka et8.org account 3DTorrents invite HD-Torrents account Bit-HDTV account HDME.eu invite Hdarea.co account Asiancinema.me account JoyHD invite HDSpace invite CrazyHD invite Bluebird-hd invite Htpt.cc account Hdtime invite Ourbits.club account Hd4fans account Siambit account Privatehd account Springsunday account Tjupt account Hdcity.leniter invite Ccfbits account Discfan account Pt.btschool.club account Ptsbao.club invite Hdzone.me invite Danishbytes account Zonaq.pw account Tracker.tekno3d account Arabp2p account Hd-united account Reelflix.xyz account Hdatmos.club account Anasch.cc invite Tigris-t account Nethd.org account Hd.ai invite Hitpt.com account Hdmonkey account Dragonhd.xyz account Hdclub.eu account Forum.bluraycd.com account Carpt account Hdfun.me invite Pt.hdupt invite Puntotorrent account Ultrahd account Rousi.zip account Bearbit account Hdturk.club account Asiandvdclub account Star-space.net account Nordicq.org account Hdkyl.in account Utp.to account Hdzero account Novahd account Hdtorrents.eu account   Music Trackers :   Dicmusic account Music-Vid account Open.cd account LzTr account ProAudioTorrents invite Jpopsuki invite TranceTraffic invite Audionews invite Kraytracker invite Libble.me invite Losslessclub invite Indietorrents.com invite Dimeadozen account Funkytorrents invite Karaokedl account zombtracker.the-zomb account Concertos account Sugoimusic account Satclubbing.club invite Metal.iplay invite Psyreactor invite Panda.cd account Adamsfile account Freehardmusic account Tracker.hqmusic.vn accouunt Twilightzoom account 3 tb buffer Hiresmusic account Metalguru account Musictorrents.org account Musebootlegs.com invite Zappateers.com account Jungleland.dnsalias.com account Naftamusic account Bemusic account   E-Learning Trackers :   Theplace account Thevault account Myanonamouse account Libranet account 420Project account Learnflakes account Pt.soulvoice.club account P2pelite account Aaaaarg.fail invite Ebooks-shares.org account Abtorrents account Pt.tu88.men invite Docspedia.world invite   TV-Trackers :   Skipthecommericals Cryptichaven account TV-Vault invite Shazbat.TV account Myspleen account Tasmanit.es invite Tvstore.me account Tvchaosuk account Jptv.club account   XXX - Porn Trackers :   FemdomCult account Pussytorrents account Adult-cinema-network account Bootytape account 1 Tb buffer Exoticaz account Bitporn account Kufirc account Gaytorrent.ru invite Nicept account Gay-torrents.org invite Ourgtn account Pt.hdbd.us account BitSexy account Happyfappy.org account Kamept.com account Lesbians4u.org account   Gaming Trackers :   Mteam.fr account BitGamer invite Retrowithin invite Gamegamept account   Cartoon/Anime/Comic Trackers :   Animeworld account Oldtoons.world account U2.dmhy account CartoonChaos invite Mononoke account Totallykids.tv account Bakabt.me invite Revanime account Ansktracker account Tracker.shakaw.com.br invite Bt.mdan.org account Skyey2.com account Animetracker.cc Adbt.it.cx invite Tracker.uniotaku.com account Mousebits.com account   Sports Trackers :   MMA-Tracker invite T3nnis.tv invite AcrossTheTasman account RacingForMe invite Sportscult invite Ultimatewrestlingtorrents account Worldboxingvideoarchive invite CyclingTorrents account Xtremewrestlingtorrents account Tc-boxing invite Mma-torrents account Aussierul invite Xwt-classics account Racing4everyone account Talk.tenyardtracker account Stalker.societyglitch invite Extremebits invite Rgfootball.net account F1carreras.xyz account   Software/Apps Trackers :   Brokenstones account Appzuniverse invite Teamos.xyz account Macbb.org account Phoenixproject.app account   Graphics Trackers:   Forum.Cgpersia account Cgfxw account   Others   Hduse.net account Fora.snahp.eu account Board4all.biz account Makingoff.org/forum account Xrel.to account Undergunz.su account Corebay account Endoftheinter.net ( EOTI ) account Thismight.be invite Skull.facefromouter.space account Avxhm.se (AvaxHome) account Ssdforum account Notfake.vip account Intotheinter.net account Tildes.net invite Thetoonz account Usinavirtual account Hdclasico invite HispaShare account Valentine.wtf account Adit-hd account Forum-andr.net account Warezforums account Justanothermusic.site account Forbiddenlibrary.moe account Senturion.to account Movieparadise account Dcdnet.ru account Sftdevils.net account Heavy-r.com account New-team.org account Ddl.tv account Filewarez.club account Hispamula.org account Hubwarez.tv account Ultim-zone.in account Leprosorium.ru account Planet-ultima.org account The-dark-warez.com account Koyi.pub account Tehparadox.net account Forumophilia account Torrentinvite.fr account Gmgard.com account   NZB :   Ninjacentral.co.za account Tabula-rasa.pw account Drunkenslug account Drunkenslug invite Usenet-4all account Dognzb.cr invite Kleverig account Nzb.cat account Nzbplanet.net invite Ng4you.com account NZB.to account Samuraiplace account Abhdtv.net account Abook.link account Comix.pw account House-of-usenet Secretbinaries.net account Vnext.to account Stockboxx.top account Sky-of-use.net account   Prices start from 3 $ to 100 $   Payment methods: Crypto, Neteller, Revolut   If you want to buy something send me a pm or contact me on:   Email: morrison2102@gmail.com   Discord: LFC4LIFE#4173   Telegram: https://t.me/LFC4LIFE4173   Skype: morrison2102@hotmail.com
    • I need two new one for the existing ones. 
    • Actioname dat Just change icons from there
  • Topics

×
×
  • Create New...

Important Information

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