diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TeleportListData.xml b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TeleportListData.xml new file mode 100644 index 0000000000..7923afa3d4 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TeleportListData.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TeleportListData.xsd b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TeleportListData.xsd new file mode 100644 index 0000000000..e046c59a40 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TeleportListData.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java index c23204e4fe..7938927e07 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java @@ -96,6 +96,7 @@ import org.l2jmobius.gameserver.data.xml.impl.SkillData; import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData; import org.l2jmobius.gameserver.data.xml.impl.SpawnsData; import org.l2jmobius.gameserver.data.xml.impl.StaticObjectData; +import org.l2jmobius.gameserver.data.xml.impl.TeleportListData; import org.l2jmobius.gameserver.data.xml.impl.TeleportersData; import org.l2jmobius.gameserver.data.xml.impl.TransformData; import org.l2jmobius.gameserver.data.xml.impl.VariationData; @@ -339,6 +340,7 @@ public class GameServer printSection("Cache"); HtmCache.getInstance(); CrestTable.getInstance(); + TeleportListData.getInstance(); TeleportersData.getInstance(); MatchingRoomManager.getInstance(); PetitionManager.getInstance(); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/TeleportListData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/TeleportListData.java new file mode 100644 index 0000000000..32367722fd --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/TeleportListData.java @@ -0,0 +1,87 @@ +/* + * This file is part of the L2J Mobius project. + * + * 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 . + */ +package org.l2jmobius.gameserver.data.xml.impl; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.w3c.dom.Document; + +import org.l2jmobius.commons.util.IXmlReader; +import org.l2jmobius.gameserver.model.StatsSet; +import org.l2jmobius.gameserver.model.holders.TeleportListHolder; + +/** + * @author NviX + */ +public class TeleportListData implements IXmlReader +{ + private static Logger LOGGER = Logger.getLogger(TeleportListData.class.getName()); + private final List _teleports = new ArrayList<>(); + private int _teleportsCount = 0; + + protected TeleportListData() + { + load(); + } + + @Override + public void load() + { + _teleports.clear(); + parseDatapackFile("data/TeleportListData.xml"); + _teleportsCount = _teleports.size(); + LOGGER.info(getClass().getSimpleName() + ": Loaded " + _teleportsCount + " teleports."); + } + + @Override + public void parseDocument(Document doc, File f) + { + forEach(doc, "list", listNode -> forEach(listNode, "teleport", teleportNode -> + { + final StatsSet set = new StatsSet(parseAttributes(teleportNode)); + final int tpId = set.getInt("id"); + final int x = set.getInt("x"); + final int y = set.getInt("y"); + final int z = set.getInt("z"); + final int tpPrice = set.getInt("price"); + _teleports.add(new TeleportListHolder(tpId, x, y, z, tpPrice)); + })); + } + + public List getTeleports() + { + return _teleports; + } + + public int getTeleportsCount() + { + return _teleportsCount; + } + + public static TeleportListData getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final TeleportListData INSTANCE = new TeleportListData(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TeleportListHolder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TeleportListHolder.java new file mode 100644 index 0000000000..5dd6197d13 --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TeleportListHolder.java @@ -0,0 +1,63 @@ +/* + * This file is part of the L2J Mobius project. + * + * 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 . + */ +package org.l2jmobius.gameserver.model.holders; + +/** + * @author NviX + */ +public class TeleportListHolder +{ + private final int _locId; + private final int _x; + private final int _y; + private final int _z; + private final int _price; + + public TeleportListHolder(int locId, int x, int y, int z, int price) + { + _locId = locId; + _x = x; + _y = y; + _z = z; + _price = price; + } + + public int getLocId() + { + return _locId; + } + + public int getX() + { + return _x; + } + + public int getY() + { + return _y; + } + + public int getZ() + { + return _z; + } + + public int getPrice() + { + return _price; + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index fab9aa3a73..21838d0e0e 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -456,7 +456,7 @@ public enum ExIncomingPackets implements IIncomingPackets EX_OPEN_HTML(0x164, null, ConnectionState.IN_GAME), // 228 EX_REQUEST_CLASS_CHANGE(0x165, null, ConnectionState.IN_GAME), // 228 EX_REQUEST_CLASS_CHANGE_VERIFYING(0x166, null, ConnectionState.IN_GAME), // 228 - EX_REQUEST_TELEPORT(0x167, null, ConnectionState.IN_GAME), // 228 + EX_REQUEST_TELEPORT(0x167, ExRequestTeleport::new, ConnectionState.IN_GAME), // 228 EX_COSTUME_COLLECTION_SKILL_ACTIVE(0x16B, null, ConnectionState.IN_GAME), // 228 REQUEST_AUTO_USE_POTION(0x171, null, ConnectionState.IN_GAME), // 228 REQUEST_AUTO_USE(0x177, null, ConnectionState.IN_GAME), // 228 diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ExRequestTeleport.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ExRequestTeleport.java new file mode 100644 index 0000000000..599560064c --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/ExRequestTeleport.java @@ -0,0 +1,74 @@ +/* + * This file is part of the L2J Mobius project. + * + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.xml.impl.TeleportListData; +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.holders.TeleportListHolder; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; + +/** + * @author NviX + */ +public class ExRequestTeleport implements IClientIncomingPacket +{ + private int _locId; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _locId = packet.readD(); + return true; + } + + @Override + public void run(GameClient client) + { + final PlayerInstance player = client.getPlayer(); + if (player == null) + { + return; + } + + boolean success = false; + + for (TeleportListHolder teleport : TeleportListData.getInstance().getTeleports()) + { + if (teleport.getLocId() == _locId) + { + if (player.getAdena() < teleport.getPrice()) + { + player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA); + return; + } + + player.reduceAdena("teleport", teleport.getPrice(), player, true); + player.teleToLocation(teleport.getX(), teleport.getY(), teleport.getZ()); + success = true; + break; + } + } + + if (!success) + { + LOGGER.info("No registered teleport location for id: " + _locId); + return; + } + } +} \ No newline at end of file