Code: Select all
1. ERROR in \YANModPack\YANTeleporter\YANTeleporter.java (at line 135)
if (!member.isInsideRadius(npc.getX(), npc.getY(), teleLoc.maxMemberDistance, true))
^^^^^^^^^^^^^^
The method isInsideRadius(ILocational, int, boolean, boolean) in the type L2Character is not applicable for the arguments (int, int, int, boolean)
----------
2. ERROR in \YANModPack\YANTeleporter\YANTeleporter.java (at line 158)
member.teleToLocation(teleLoc.pos.x, teleLoc.pos.y, teleLoc.pos.z);
^^^^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
3. ERROR in \YANModPack\YANTeleporter\YANTeleporter.java (at line 158)
member.teleToLocation(teleLoc.pos.x, teleLoc.pos.y, teleLoc.pos.z);
^^^^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
4. ERROR in \YANModPack\YANTeleporter\YANTeleporter.java (at line 158)
member.teleToLocation(teleLoc.pos.x, teleLoc.pos.y, teleLoc.pos.z);
^^^^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
----------
5. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 33)
import com.l2jserver.gameserver.datatables.NpcTable;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import com.l2jserver.gameserver.datatables.NpcTable cannot be resolved
----------
6. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 34)
import com.l2jserver.gameserver.model.L2CharPosition;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import com.l2jserver.gameserver.model.L2CharPosition cannot be resolved
----------
7. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 53)
protected final L2CharPosition pos;
^^^^^^^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
8. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 58)
protected TeleportLocation(String ident, String name, int minMembers, int maxMemberDistance, L2CharPosition pos, Element elem)
^^^^^^^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
9. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 64)
this.pos = pos;
^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
10. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 237)
_teleLocs.put(ident, new TeleportLocation(ident, name, minMembers, maxMemberDistance, new L2CharPosition(x, y, z, 0), curElem));
^^^^^^^^^^^^^^
L2CharPosition cannot be resolved to a type
----------
11. ERROR in C:\Users\Avtom\Downloads\Fun\Backup\L2JServer\game\data\scripts\YANModPack\YANTeleporter\YANTeleporterData.java (at line 255)
L2NpcTemplate npc = NpcTable.getInstance().getTemplate(id);
^^^^^^^^
NpcTable cannot be resolved
Code: Select all
/*
* 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 YANModPack.YANTeleporter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import YANModPack.util.ItemRequirement;
import YANModPack.util.htmltmpls.HTMLTemplateParser;
import YANModPack.util.htmltmpls.HTMLTemplatePlaceholder;
import YANModPack.util.htmltmpls.funcs.ExistsFunc;
import YANModPack.util.htmltmpls.funcs.ForeachFunc;
import YANModPack.util.htmltmpls.funcs.IfFunc;
import YANModPack.util.htmltmpls.funcs.IncludeFunc;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import ai.npc.AbstractNpcAI;
import YANModPack.YANTeleporter.YANTeleporterData.TeleportLocation;
import YANModPack.YANTeleporter.YANTeleporterData.TeleportNpc;
/**
* @author HorridoJoho
*/
public final class YANTeleporter extends AbstractNpcAI
{
private static final Logger _LOGGER = Logger.getLogger(YANTeleporter.class.getName());
public static final Path SCRIPTS_SUBFOLDER = Paths.get("YANModPack");
public static final Path SCRIPT_TOP_FOLDER = Paths.get("YANTeleporter");
public static final Path SCRIPT_SUBFOLDER = Paths.get(SCRIPTS_SUBFOLDER.toString(), SCRIPT_TOP_FOLDER.toString());
public static void main(String[] args)
{
try
{
YANTeleporterData.INIT_INSTANCE();
new YANTeleporter();
}
catch (Exception ex)
{
_LOGGER.log(Level.WARNING, "YANTeleporter - Data: Exception while loading npc teleporter data, not registering mod!", ex);
}
}
private static TeleportNpc _getTeleNpc(L2Npc npc)
{
return YANTeleporterData.GET_INSTANCE().getTeleportNpc(npc.getId());
}
private static TeleportLocation _getTeleLoc(TeleportNpc teleNpc, String locIdent)
{
return teleNpc.locations.get(locIdent);
}
private static String _generateHtml(String path, L2PcInstance player, HashMap<String, HTMLTemplatePlaceholder> placeholders)
{
return HTMLTemplateParser.fromCache(Paths.get("data", "scripts", SCRIPT_SUBFOLDER.toString(), path).toString(), player, placeholders, IncludeFunc.INSTANCE, IfFunc.INSTANCE, ForeachFunc.INSTANCE, ExistsFunc.INSTANCE);
}
private static String _getMainHtml(L2Npc npc, L2PcInstance player)
{
TeleportNpc teleNpc = _getTeleNpc(npc);
if (teleNpc == null)
return null;
HashMap<String, HTMLTemplatePlaceholder> placeholders = new HashMap<>();
placeholders.put(teleNpc.placeholder.getName(), teleNpc.placeholder);
return _generateHtml("main.html", player, placeholders);
}
private static String _getLocationHtml(L2Npc npc, L2PcInstance player, String locIdent)
{
TeleportNpc teleNpc = _getTeleNpc(npc);
if (teleNpc == null)
return null;
TeleportLocation teleLoc = _getTeleLoc(teleNpc, locIdent);
if (teleLoc == null)
return null;
HashMap<String, HTMLTemplatePlaceholder> placeholders = new HashMap<>();
placeholders.put(teleNpc.placeholder.getName(), teleNpc.placeholder);
placeholders.put(teleLoc.placeholder.getName(), teleLoc.placeholder);
return _generateHtml("location.html", player, placeholders);
}
private static String _makeTeleport(L2Npc npc, L2PcInstance player, String locIdent)
{
TeleportNpc teleNpc = _getTeleNpc(npc);
if (teleNpc == null)
return null;
TeleportLocation teleLoc = _getTeleLoc(teleNpc, locIdent);
if (teleLoc == null)
return null;
L2Party party = player.getParty();
if (party == null || party.getLeader() != player)
{
player.sendMessage("You have to be the leader of a party!");
return null;
}
if (party.getMemberCount() < teleLoc.minMembers)
{
player.sendMessage("For this teleport you need at least " + teleLoc.minMembers + " players in your party!");
return null;
}
List<L2PcInstance> members = party.getMembers();
for (L2PcInstance member : members)
{
if (!member.isInsideRadius(npc.getX(), npc.getY(), npc.getZ(), teleLoc.maxMemberDistance, true, false))
{
player.sendMessage("Not all party members in range!");
return null;
}
}
for (Entry<String, ItemRequirement> item : teleLoc.items.entrySet())
{
if (player.getInventory().getInventoryItemCount(item.getValue().item.getId(), 0) < item.getValue().amount)
{
player.sendMessage("Not enough items!");
return null;
}
}
for (Entry<String, ItemRequirement> item : teleLoc.items.entrySet())
{
player.destroyItemByItemId("YANTeleporter-teleport", item.getValue().item.getId(), item.getValue().amount, player, true);
}
for (L2PcInstance member : members)
{
member.teleToLocation(teleLoc.pos.x, teleLoc.pos.y, teleLoc.pos.z);
}
return "Your party has been teleported.";
}
private YANTeleporter()
{
super(SCRIPT_TOP_FOLDER.toString(), SCRIPTS_SUBFOLDER.toString());
for (Entry<Integer, TeleportNpc> npc : YANTeleporterData.GET_INSTANCE().getTeleportNpcs().entrySet())
{
addFirstTalkId(npc.getKey());
addStartNpc(npc.getKey());
addTalkId(npc.getKey());
}
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
return "first_talk.html";
}
@Override
public String onTalk(L2Npc npc, L2PcInstance talker)
{
return _getMainHtml(npc, talker);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if ("list".equals(event))
{
return _getMainHtml(npc, player);
}
else if (event.startsWith("show_"))
{
return _getLocationHtml(npc, player, event.substring(5));
}
else if (event.startsWith("use_"))
{
return _makeTeleport(npc, player, event.substring(4));
}
return null;
}
}
Code: Select all
/*
* 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 YANModPack.YANTeleporter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Logger;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.model.L2CharPosition;
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jserver.gameserver.model.items.L2Item;
import YANModPack.util.ItemRequirement;
import YANModPack.util.XMLUtils;
import YANModPack.util.htmltmpls.HTMLTemplatePlaceholder;
/**
* @author HorridoJoho
*/
final class YANTeleporterData
{
public final class TeleportLocation
{
protected final String ident;
protected final String name;
protected final int minMembers;
protected final int maxMemberDistance;
protected final L2CharPosition pos;
protected final Map<String, ItemRequirement> items;
/** HTMLTemplatePlaceholder */
protected final HTMLTemplatePlaceholder placeholder;
protected TeleportLocation(String ident, String name, int minMembers, int maxMemberDistance, L2CharPosition pos, Element elem)
{
this.ident = ident;
this.name = name;
this.minMembers = minMembers;
this.maxMemberDistance = maxMemberDistance;
this.pos = pos;
this.items = _parseItems(elem);
this.placeholder = new HTMLTemplatePlaceholder("tele_loc", null);
this.placeholder.addChild("ident", ident).addChild("name", name).addChild("min_members", String.valueOf(minMembers));
if (!this.items.isEmpty())
{
HTMLTemplatePlaceholder itemsPlaceholder = this.placeholder.addChild("items", null).getChild("items");
for (Entry<String, ItemRequirement> item : this.items.entrySet())
{
itemsPlaceholder.addAliasChild(String.valueOf(itemsPlaceholder.getChildsSize()), item.getValue().placeholder);
}
}
}
private Map<String, ItemRequirement> _parseItems(Element elem)
{
Map<String, ItemRequirement> items = new HashMap<>();
Node curNode = elem.getFirstChild();
while (curNode != null)
{
switch (curNode.getNodeType())
{
case Node.ELEMENT_NODE:
Element curElem = (Element)curNode;
String ident = curElem.getAttribute("ident");
ItemRequirement req = _itemRequirements.get(ident);
if (req == null)
{
_LOGGER.warning("YANTeleporter - teleport_locations.xml: Item requirement with ident " + ident + " does not exists!");
}
else
{
items.put(ident, req);
}
break;
}
curNode = curNode.getNextSibling();
}
return Collections.unmodifiableMap(items);
}
}
public final class TeleportNpc
{
public final L2NpcTemplate npc;
public final Map<String, TeleportLocation> locations;
/** HTMLTemplatePlaceholder */
protected final HTMLTemplatePlaceholder placeholder;
protected TeleportNpc(L2NpcTemplate npc, Element elem)
{
this.npc = npc;
this.locations = _parseLocations(elem);
this.placeholder = new HTMLTemplatePlaceholder("teleporter", null);
this.placeholder.addChild("name", npc.getName());
if (!this.locations.isEmpty())
{
HTMLTemplatePlaceholder locsPlaceholder = this.placeholder.addChild("locs", null).getChild("locs");
for (Entry<String, TeleportLocation> location : this.locations.entrySet())
{
locsPlaceholder.addAliasChild(String.valueOf(locsPlaceholder.getChildsSize()), location.getValue().placeholder);
}
}
}
private Map<String, TeleportLocation> _parseLocations(Element elem)
{
Map<String, TeleportLocation> locations = new HashMap<>();
Node curNode = elem.getFirstChild();
while (curNode != null)
{
switch (curNode.getNodeType())
{
case Node.ELEMENT_NODE:
Element curElem = (Element)curNode;
String ident = curElem.getAttribute("ident");
TeleportLocation location = _teleLocs.get(ident);
if (location == null)
{
_LOGGER.warning("YANTeleporter - teleport_npcs.xml: Teleport location with ident " + ident + " does not exists!");
}
else
{
locations.put(ident, location);
}
break;
}
curNode = curNode.getNextSibling();
}
return Collections.unmodifiableMap(locations);
}
}
protected static final Logger _LOGGER = Logger.getLogger(YANTeleporterData.class.getName());
private static YANTeleporterData _INSTANCE = null;
public synchronized static void INIT_INSTANCE() throws Exception
{
_INSTANCE = new YANTeleporterData();
}
public synchronized static YANTeleporterData GET_INSTANCE()
{
return _INSTANCE;
}
protected final Map<String, ItemRequirement> _itemRequirements = new HashMap<>();
protected final Map<String, TeleportLocation> _teleLocs = new HashMap<>();
protected final Map<Integer, TeleportNpc> _teleNpcs = new HashMap<>();
private YANTeleporterData() throws Exception
{
Path dataPath = Paths.get(Config.DATAPACK_ROOT.getAbsolutePath(), "data", "scripts", YANTeleporter.SCRIPT_SUBFOLDER.toString(), "data");
Path xsdPath = Paths.get(dataPath.toString(), "xsd");
Element elem = XMLUtils.CreateDocument(dataPath.resolve("item_requirements.xml"), xsdPath.resolve("item_requirements.xsd")).getDocumentElement();
_parseItemRequirements(elem);
elem = XMLUtils.CreateDocument(dataPath.resolve("teleport_locations.xml"), xsdPath.resolve("teleport_locations.xsd")).getDocumentElement();
_parseTeleLocs(elem);
elem = XMLUtils.CreateDocument(dataPath.resolve("teleport_npcs.xml"), xsdPath.resolve("teleport_npcs.xsd")).getDocumentElement();
_parseTeleNpcs(elem);
}
private void _parseItemRequirements(Element elem)
{
Node curNode = elem.getFirstChild();
while (curNode != null)
{
switch (curNode.getNodeType())
{
case Node.ELEMENT_NODE:
Element curElem = (Element)curNode;
String ident = curElem.getAttribute("ident");
int itemId = Integer.parseInt(curElem.getAttribute("id"));
long itemAmount = Long.parseLong(curElem.getAttribute("amount"));
L2Item item = ItemTable.getInstance().getTemplate(itemId);
if (item == null)
{
_LOGGER.warning("YANTeleporter - item_requirements.xml: Item with id " + itemId + " does not exists!");
}
else
{
_itemRequirements.put(ident, new ItemRequirement(item, itemAmount));
}
break;
}
curNode = curNode.getNextSibling();
}
}
private void _parseTeleLocs(Element elem)
{
Node curNode = elem.getFirstChild();
while (curNode != null)
{
switch (curNode.getNodeType())
{
case Node.ELEMENT_NODE:
Element curElem = (Element)curNode;
String ident = curElem.getAttribute("ident");
String name = curElem.getAttribute("name");
int minMembers = Integer.parseInt(curElem.getAttribute("min_members"));
int maxMemberDistance = Integer.parseInt(curElem.getAttribute("max_member_distance"));
int x = Integer.parseInt(curElem.getAttribute("x"));
int y = Integer.parseInt(curElem.getAttribute("y"));
int z = Integer.parseInt(curElem.getAttribute("z"));
_teleLocs.put(ident, new TeleportLocation(ident, name, minMembers, maxMemberDistance, new L2CharPosition(x, y, z, 0), curElem));
break;
}
curNode = curNode.getNextSibling();
}
}
private void _parseTeleNpcs(Element elem)
{
Node curNode = elem.getFirstChild();
while (curNode != null)
{
switch (curNode.getNodeType())
{
case Node.ELEMENT_NODE:
Element curElem = (Element)curNode;
int id = Integer.parseInt(curElem.getAttribute("id"));
L2NpcTemplate npc = NpcTable.getInstance().getTemplate(id);
if (npc == null)
{
_LOGGER.warning("YANTeleporter - teleport_npcs.xml: Npc with id " + id + " does not exists!");
}
else
{
_teleNpcs.put(id, new TeleportNpc(npc, curElem));
}
break;
}
curNode = curNode.getNextSibling();
}
}
public TeleportLocation getLocation(String ident)
{
return _teleLocs.get(ident);
}
public Map<Integer, TeleportNpc> getTeleportNpcs()
{
return _teleNpcs;
}
public TeleportNpc getTeleportNpc(int npcId)
{
return _teleNpcs.get(npcId);
}
}