diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShop.xml b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShop.xml index e71d1f048c..66423ba4d7 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShop.xml +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShop.xml @@ -224,6 +224,10 @@ + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShopSpecialCraft.xml b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShopSpecialCraft.xml new file mode 100644 index 0000000000..23a418c9fc --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/data/LCoinShopSpecialCraft.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/LCoinShopSpecialCraftData.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/LCoinShopSpecialCraftData.java new file mode 100644 index 0000000000..225ef5f031 --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/LCoinShopSpecialCraftData.java @@ -0,0 +1,195 @@ +/* + * 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; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.logging.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +import org.l2jmobius.commons.util.IXmlReader; +import org.l2jmobius.gameserver.data.ItemTable; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder; +import org.l2jmobius.gameserver.model.items.Item; + +/** + * @author GustavoFonseca + */ +public class LCoinShopSpecialCraftData implements IXmlReader +{ + private static final Logger LOGGER = Logger.getLogger(LCoinShopData.class.getName()); + + private final List _products = new ArrayList<>(); + + protected LCoinShopSpecialCraftData() + { + load(); + } + + @Override + public void load() + { + _products.clear(); + parseDatapackFile("data/LCoinShopSpecialCraft.xml"); + + if (!_products.isEmpty()) + { + LOGGER.info(getClass().getSimpleName() + ": Loaded " + _products.size() + " items."); + } + else + { + LOGGER.info(getClass().getSimpleName() + ": System is disabled."); + } + } + + @Override + public void parseDocument(Document doc, File f) + { + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) + { + if ("list".equalsIgnoreCase(n.getNodeName())) + { + final NamedNodeMap at = n.getAttributes(); + final Node attribute = at.getNamedItem("enabled"); + if ((attribute != null) && Boolean.parseBoolean(attribute.getNodeValue())) + { + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) + { + if ("product".equalsIgnoreCase(d.getNodeName())) + { + NamedNodeMap attrs = d.getAttributes(); + Node att; + final StatSet set = new StatSet(); + for (int i = 0; i < attrs.getLength(); i++) + { + att = attrs.item(i); + set.set(att.getNodeName(), att.getNodeValue()); + } + + final int id = parseInteger(attrs, "id"); + final int category = parseInteger(attrs, "category"); + final int minLevel = parseInteger(attrs, "minLevel", 1); + final int maxLevel = parseInteger(attrs, "maxLevel", 999); + final int[] ingredientIds = new int[3]; + ingredientIds[0] = 0; + ingredientIds[1] = 0; + ingredientIds[2] = 0; + final long[] ingredientQuantities = new long[3]; + ingredientQuantities[0] = 0; + ingredientQuantities[1] = 0; + ingredientQuantities[2] = 0; + int productionId = 0; + int accountDailyLimit = 0; + int accountBuyLimit = 0; + for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling()) + { + attrs = b.getAttributes(); + + if ("ingredient".equalsIgnoreCase(b.getNodeName())) + { + final int ingredientId = parseInteger(attrs, "id"); + final long ingredientQuantity = parseLong(attrs, "count", 1L); + + final Item item = ItemTable.getInstance().getTemplate(ingredientId); + if (item == null) + { + LOGGER.severe(getClass().getSimpleName() + ": Item template null for itemId: " + productionId + " productId: " + id); + continue; + } + + if (ingredientIds[0] == 0) + { + ingredientIds[0] = ingredientId; + } + else if (ingredientIds[1] == 0) + { + ingredientIds[1] = ingredientId; + } + else + { + ingredientIds[2] = ingredientId; + } + + if (ingredientQuantities[0] == 0) + { + ingredientQuantities[0] = ingredientQuantity; + } + else if (ingredientQuantities[1] == 0) + { + ingredientQuantities[1] = ingredientQuantity; + } + else + { + ingredientQuantities[2] = ingredientQuantity; + } + } + else if ("production".equalsIgnoreCase(b.getNodeName())) + { + productionId = parseInteger(attrs, "id"); + accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0); + accountBuyLimit = parseInteger(attrs, "accountBuyLimit", 0); + + final Item item = ItemTable.getInstance().getTemplate(productionId); + if (item == null) + { + LOGGER.severe(getClass().getSimpleName() + ": Item template null for itemId: " + productionId + " productId: " + id); + continue; + } + } + } + + _products.add(new LCoinShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, accountDailyLimit, accountBuyLimit)); + } + } + } + } + } + } + + public LCoinShopProductHolder getProduct(int id) + { + for (LCoinShopProductHolder product : _products) + { + if (product.getId() == id) + { + return product; + } + } + return null; + } + + public Collection getProducts() + { + return _products; + } + + public static LCoinShopSpecialCraftData getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final LCoinShopSpecialCraftData INSTANCE = new LCoinShopSpecialCraftData(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java index 4918ba77d4..2fe19a9269 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java @@ -35,15 +35,13 @@ import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.E */ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket { - @SuppressWarnings("unused") - private int _category; private int _productId; private int _amount; @Override public boolean read(GameClient client, PacketReader packet) { - _category = packet.readC(); + packet.readC(); // category? _productId = packet.readD(); _amount = packet.readD(); return true; diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java index 5e31da4c70..869c89283d 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java @@ -21,6 +21,7 @@ import java.util.Collection; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.data.xml.LCoinShopData; +import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder; import org.l2jmobius.gameserver.model.variables.AccountVariables; @@ -32,13 +33,15 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; */ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket { - private final int _category; + private final int _shopType; // 3 = Lcoin Shop - 4 = Special Craft private final PlayerInstance _player; + private Collection _products; - public ExPurchaseLimitShopItemListNew(int category, PlayerInstance player) + public ExPurchaseLimitShopItemListNew(int shopType, PlayerInstance player) { - _category = category; + _shopType = shopType; _player = player; + _products = null; } @Override @@ -46,12 +49,28 @@ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket { OutgoingPackets.EX_PURCHASE_LIMIT_SHOP_ITEM_LIST_NEW.writeId(packet); - final Collection products = LCoinShopData.getInstance().getProducts(); + switch (_shopType) + { + case 3: // Normal Lcoin Shop + { + _products = LCoinShopData.getInstance().getProducts(); + break; + } + case 4: // Lcoin Special Craft + { + _products = LCoinShopSpecialCraftData.getInstance().getProducts(); + break; + } + default: + { + _products = LCoinShopData.getInstance().getProducts(); + } + } - packet.writeC(_category); // _category? Main shop? - packet.writeD(products.size()); + packet.writeC(_shopType); // + packet.writeD(_products.size()); - for (LCoinShopProductHolder product : products) + for (LCoinShopProductHolder product : _products) { packet.writeD(product.getId()); packet.writeD(product.getProductionId()); diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/LCoinShopSpecialCraft.xml b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/LCoinShopSpecialCraft.xml new file mode 100644 index 0000000000..23a418c9fc --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/data/LCoinShopSpecialCraft.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/data/xml/LCoinShopSpecialCraftData.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/data/xml/LCoinShopSpecialCraftData.java new file mode 100644 index 0000000000..225ef5f031 --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/data/xml/LCoinShopSpecialCraftData.java @@ -0,0 +1,195 @@ +/* + * 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; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.logging.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +import org.l2jmobius.commons.util.IXmlReader; +import org.l2jmobius.gameserver.data.ItemTable; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder; +import org.l2jmobius.gameserver.model.items.Item; + +/** + * @author GustavoFonseca + */ +public class LCoinShopSpecialCraftData implements IXmlReader +{ + private static final Logger LOGGER = Logger.getLogger(LCoinShopData.class.getName()); + + private final List _products = new ArrayList<>(); + + protected LCoinShopSpecialCraftData() + { + load(); + } + + @Override + public void load() + { + _products.clear(); + parseDatapackFile("data/LCoinShopSpecialCraft.xml"); + + if (!_products.isEmpty()) + { + LOGGER.info(getClass().getSimpleName() + ": Loaded " + _products.size() + " items."); + } + else + { + LOGGER.info(getClass().getSimpleName() + ": System is disabled."); + } + } + + @Override + public void parseDocument(Document doc, File f) + { + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) + { + if ("list".equalsIgnoreCase(n.getNodeName())) + { + final NamedNodeMap at = n.getAttributes(); + final Node attribute = at.getNamedItem("enabled"); + if ((attribute != null) && Boolean.parseBoolean(attribute.getNodeValue())) + { + for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) + { + if ("product".equalsIgnoreCase(d.getNodeName())) + { + NamedNodeMap attrs = d.getAttributes(); + Node att; + final StatSet set = new StatSet(); + for (int i = 0; i < attrs.getLength(); i++) + { + att = attrs.item(i); + set.set(att.getNodeName(), att.getNodeValue()); + } + + final int id = parseInteger(attrs, "id"); + final int category = parseInteger(attrs, "category"); + final int minLevel = parseInteger(attrs, "minLevel", 1); + final int maxLevel = parseInteger(attrs, "maxLevel", 999); + final int[] ingredientIds = new int[3]; + ingredientIds[0] = 0; + ingredientIds[1] = 0; + ingredientIds[2] = 0; + final long[] ingredientQuantities = new long[3]; + ingredientQuantities[0] = 0; + ingredientQuantities[1] = 0; + ingredientQuantities[2] = 0; + int productionId = 0; + int accountDailyLimit = 0; + int accountBuyLimit = 0; + for (Node b = d.getFirstChild(); b != null; b = b.getNextSibling()) + { + attrs = b.getAttributes(); + + if ("ingredient".equalsIgnoreCase(b.getNodeName())) + { + final int ingredientId = parseInteger(attrs, "id"); + final long ingredientQuantity = parseLong(attrs, "count", 1L); + + final Item item = ItemTable.getInstance().getTemplate(ingredientId); + if (item == null) + { + LOGGER.severe(getClass().getSimpleName() + ": Item template null for itemId: " + productionId + " productId: " + id); + continue; + } + + if (ingredientIds[0] == 0) + { + ingredientIds[0] = ingredientId; + } + else if (ingredientIds[1] == 0) + { + ingredientIds[1] = ingredientId; + } + else + { + ingredientIds[2] = ingredientId; + } + + if (ingredientQuantities[0] == 0) + { + ingredientQuantities[0] = ingredientQuantity; + } + else if (ingredientQuantities[1] == 0) + { + ingredientQuantities[1] = ingredientQuantity; + } + else + { + ingredientQuantities[2] = ingredientQuantity; + } + } + else if ("production".equalsIgnoreCase(b.getNodeName())) + { + productionId = parseInteger(attrs, "id"); + accountDailyLimit = parseInteger(attrs, "accountDailyLimit", 0); + accountBuyLimit = parseInteger(attrs, "accountBuyLimit", 0); + + final Item item = ItemTable.getInstance().getTemplate(productionId); + if (item == null) + { + LOGGER.severe(getClass().getSimpleName() + ": Item template null for itemId: " + productionId + " productId: " + id); + continue; + } + } + } + + _products.add(new LCoinShopProductHolder(id, category, minLevel, maxLevel, ingredientIds, ingredientQuantities, productionId, accountDailyLimit, accountBuyLimit)); + } + } + } + } + } + } + + public LCoinShopProductHolder getProduct(int id) + { + for (LCoinShopProductHolder product : _products) + { + if (product.getId() == id) + { + return product; + } + } + return null; + } + + public Collection getProducts() + { + return _products; + } + + public static LCoinShopSpecialCraftData getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final LCoinShopSpecialCraftData INSTANCE = new LCoinShopSpecialCraftData(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java index 4918ba77d4..2fe19a9269 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/clientpackets/limitshop/RequestPurchaseLimitShopItemBuy.java @@ -35,15 +35,13 @@ import org.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.E */ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket { - @SuppressWarnings("unused") - private int _category; private int _productId; private int _amount; @Override public boolean read(GameClient client, PacketReader packet) { - _category = packet.readC(); + packet.readC(); // category? _productId = packet.readD(); _amount = packet.readD(); return true; diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java index b9d2ef7bf9..528a9aac60 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/limitshop/ExPurchaseLimitShopItemListNew.java @@ -21,6 +21,7 @@ import java.util.Collection; import org.l2jmobius.commons.network.PacketWriter; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.gameserver.data.xml.LCoinShopData; +import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder; import org.l2jmobius.gameserver.model.variables.AccountVariables; @@ -32,13 +33,15 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; */ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket { - private final int _category; + private final int _shopType; // 3 = Lcoin Shop - 4 = Special Craft private final PlayerInstance _player; + private Collection _products; - public ExPurchaseLimitShopItemListNew(int category, PlayerInstance player) + public ExPurchaseLimitShopItemListNew(int shopType, PlayerInstance player) { - _category = category; + _shopType = shopType; _player = player; + _products = null; } @Override @@ -46,12 +49,28 @@ public class ExPurchaseLimitShopItemListNew implements IClientOutgoingPacket { OutgoingPackets.EX_PURCHASE_LIMIT_SHOP_ITEM_LIST_NEW.writeId(packet); - final Collection products = LCoinShopData.getInstance().getProducts(); + switch (_shopType) + { + case 3: // Normal Lcoin Shop + { + _products = LCoinShopData.getInstance().getProducts(); + break; + } + case 4: // Lcoin Special Craft + { + _products = LCoinShopSpecialCraftData.getInstance().getProducts(); + break; + } + default: + { + _products = LCoinShopData.getInstance().getProducts(); + } + } - packet.writeC(_category); // _category? Main shop? - packet.writeD(products.size()); + packet.writeC(_shopType); // + packet.writeD(_products.size()); - for (LCoinShopProductHolder product : products) + for (LCoinShopProductHolder product : _products) { packet.writeD(product.getId()); packet.writeD(product.getProductionId());