Replaced recipe CSV data with aCis free version XML data.

This commit is contained in:
MobiusDevelopment
2020-01-26 21:24:19 +00:00
parent f1f8ccfc2b
commit a6a0c0fd06
27 changed files with 10786 additions and 1211 deletions

View File

@@ -50,7 +50,6 @@ import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.datatables.csv.ExtractableItemsData;
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRoutesTable;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.csv.SummonItemsData;
import org.l2jmobius.gameserver.datatables.sql.ArmorSetsTable;
import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
@@ -72,6 +71,7 @@ import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
import org.l2jmobius.gameserver.datatables.xml.FenceData;
import org.l2jmobius.gameserver.datatables.xml.FishData;
import org.l2jmobius.gameserver.datatables.xml.HennaData;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
import org.l2jmobius.gameserver.datatables.xml.StaticObjectData;
import org.l2jmobius.gameserver.datatables.xml.ZoneData;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
@@ -323,7 +323,7 @@ public class GameServer
DimensionalRiftManager.getInstance();
Util.printSection("Misc");
RecipeTable.getInstance();
RecipeData.getInstance();
RecipeController.getInstance();
EventDroplist.getInstance();
AugmentationData.getInstance();

View File

@@ -27,7 +27,7 @@ import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
import org.l2jmobius.gameserver.model.Inventory;
import org.l2jmobius.gameserver.model.ManufactureItem;
import org.l2jmobius.gameserver.model.RecipeList;
@@ -88,7 +88,6 @@ public class RecipeController
public synchronized void requestManufactureItem(PlayerInstance manufacturer, int recipeListId, PlayerInstance player)
{
final RecipeList recipeList = getValidRecipeList(player, recipeListId);
if (recipeList == null)
{
return;
@@ -471,7 +470,7 @@ public class RecipeController
}
else
{
_target.sendPacket(new RecipeShopItemInfo(_player.getObjectId(), _recipeList.getId()));
_target.sendPacket(new RecipeShopItemInfo(_player, _recipeList.getId()));
}
}
@@ -720,8 +719,7 @@ public class RecipeController
private RecipeList getValidRecipeList(PlayerInstance player, int id)
{
final RecipeList recipeList = RecipeTable.getInstance().getRecipeList(id - 1);
final RecipeList recipeList = RecipeData.getInstance().getRecipe(id);
if ((recipeList == null) || (recipeList.getRecipes().length == 0))
{
player.sendMessage("No recipe for: " + id);

View File

@@ -1,234 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.datatables.csv;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.RecipeController;
import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.model.actor.instance.RecipeInstance;
/**
* @author programmos
*/
public class RecipeTable extends RecipeController
{
private static final Logger LOGGER = Logger.getLogger(RecipeTable.class.getName());
private final Map<Integer, RecipeList> _lists;
private RecipeTable()
{
_lists = new HashMap<>();
String line = null;
FileReader reader = null;
BufferedReader buff = null;
LineNumberReader lnr = null;
try
{
final File recipesData = new File(Config.DATAPACK_ROOT, "data/csv/recipes.csv");
reader = new FileReader(recipesData);
buff = new BufferedReader(reader);
lnr = new LineNumberReader(buff);
while ((line = lnr.readLine()) != null)
{
if ((line.trim().length() == 0) || line.startsWith("#"))
{
continue;
}
parseList(line);
}
LOGGER.info("RecipeController: Loaded " + _lists.size() + " Recipes.");
}
catch (Exception e)
{
if (lnr != null)
{
LOGGER.warning("error while creating recipe controller in linenr: " + lnr.getLineNumber() + " " + e);
}
else
{
LOGGER.warning("No recipes were found in data folder");
}
}
finally
{
if (lnr != null)
{
try
{
lnr.close();
}
catch (Exception e1)
{
LOGGER.warning("Problem with RecipeTable: " + e1.getMessage());
}
}
if (buff != null)
{
try
{
buff.close();
}
catch (Exception e1)
{
LOGGER.warning("Problem with RecipeTable: " + e1.getMessage());
}
}
if (reader != null)
{
try
{
reader.close();
}
catch (Exception e1)
{
LOGGER.warning("Problem with RecipeTable: " + e1.getMessage());
}
}
}
}
private void parseList(String line)
{
try
{
final StringTokenizer st = new StringTokenizer(line, ";");
final List<RecipeInstance> recipePartList = new ArrayList<>();
// we use common/dwarf for easy reading of the recipes.csv file
final String recipeTypeString = st.nextToken();
// now parse the string into a boolean
boolean isDwarvenRecipe;
if (recipeTypeString.equalsIgnoreCase("dwarven"))
{
isDwarvenRecipe = true;
}
else if (recipeTypeString.equalsIgnoreCase("common"))
{
isDwarvenRecipe = false;
}
else
{ // prints a helpfull message
LOGGER.warning("Error parsing recipes.csv, unknown recipe type " + recipeTypeString);
return;
}
final String recipeName = st.nextToken();
final int id = Integer.parseInt(st.nextToken());
final int recipeId = Integer.parseInt(st.nextToken());
final int level = Integer.parseInt(st.nextToken());
// material
final StringTokenizer st2 = new StringTokenizer(st.nextToken(), "[],");
while (st2.hasMoreTokens())
{
final StringTokenizer st3 = new StringTokenizer(st2.nextToken(), "()");
final int rpItemId = Integer.parseInt(st3.nextToken());
final int quantity = Integer.parseInt(st3.nextToken());
final RecipeInstance rp = new RecipeInstance(rpItemId, quantity);
recipePartList.add(rp);
}
final int itemId = Integer.parseInt(st.nextToken());
final int count = Integer.parseInt(st.nextToken());
// npc fee
/* String notdoneyet = */st.nextToken();
final int mpCost = Integer.parseInt(st.nextToken());
final int successRate = Integer.parseInt(st.nextToken());
final RecipeList recipeList = new RecipeList(id, level, recipeId, recipeName, successRate, mpCost, itemId, count, isDwarvenRecipe);
for (RecipeInstance recipePart : recipePartList)
{
recipeList.addRecipe(recipePart);
}
_lists.put(_lists.size(), recipeList);
}
catch (Exception e)
{
LOGGER.warning("Exception in RecipeController.parseList() " + e);
}
}
public int getRecipesCount()
{
return _lists.size();
}
public RecipeList getRecipeList(int listId)
{
return _lists.get(listId);
}
public RecipeList getRecipeByItemId(int itemId)
{
for (int i = 0; i < _lists.size(); i++)
{
final RecipeList find = _lists.get(i);
if (find.getRecipeId() == itemId)
{
return find;
}
}
return null;
}
public RecipeList getRecipeById(int recId)
{
for (int i = 0; i < _lists.size(); i++)
{
final RecipeList find = _lists.get(i);
if (find.getId() == recId)
{
return find;
}
}
return null;
}
public static RecipeTable getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final RecipeTable INSTANCE = new RecipeTable();
}
}

View File

@@ -0,0 +1,171 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.datatables.xml;
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.logging.Level;
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.RecipeController;
import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.model.actor.instance.RecipeInstance;
public class RecipeData extends RecipeController implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(RecipeData.class.getName());
private final Map<Integer, RecipeList> _lists = new HashMap<>();
protected RecipeData()
{
load();
}
@Override
public void load()
{
_lists.clear();
parseDatapackFile("data/Recipes.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _lists.size() + " recipes.");
}
@Override
public void parseDocument(Document doc, File f)
{
try
{
List<RecipeInstance> recipePartList = new ArrayList<>();
Node n = doc.getFirstChild();
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("item".equalsIgnoreCase(d.getNodeName()))
{
recipePartList.clear();
NamedNodeMap attrs = d.getAttributes();
Node att = attrs.getNamedItem("id");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing id for recipe item, skipping.");
continue;
}
int id = Integer.parseInt(att.getNodeValue());
att = attrs.getNamedItem("name");
if (att == null)
{
LOGGER.severe(getClass().getSimpleName() + ": Missing name for recipe item id: " + id + ", skipping");
continue;
}
String recipeName = att.getNodeValue();
int recipeId = -1;
int level = -1;
boolean isDwarvenRecipe = true;
int mpCost = -1;
int successRate = -1;
int prodId = -1;
int count = -1;
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
{
if ("recipe".equalsIgnoreCase(c.getNodeName()))
{
recipeId = Integer.parseInt(c.getAttributes().getNamedItem("id").getNodeValue());
level = Integer.parseInt(c.getAttributes().getNamedItem("level").getNodeValue());
isDwarvenRecipe = c.getAttributes().getNamedItem("type").getNodeValue().equalsIgnoreCase("dwarven");
}
else if ("mpCost".equalsIgnoreCase(c.getNodeName()))
{
mpCost = Integer.parseInt(c.getTextContent());
}
else if ("successRate".equalsIgnoreCase(c.getNodeName()))
{
successRate = Integer.parseInt(c.getTextContent());
}
else if ("ingredient".equalsIgnoreCase(c.getNodeName()))
{
int ingId = Integer.parseInt(c.getAttributes().getNamedItem("id").getNodeValue());
int ingCount = Integer.parseInt(c.getAttributes().getNamedItem("count").getNodeValue());
recipePartList.add(new RecipeInstance(ingId, ingCount));
}
else if ("production".equalsIgnoreCase(c.getNodeName()))
{
prodId = Integer.parseInt(c.getAttributes().getNamedItem("id").getNodeValue());
count = Integer.parseInt(c.getAttributes().getNamedItem("count").getNodeValue());
}
}
final RecipeList recipeList = new RecipeList(id, level, recipeId, recipeName, successRate, mpCost, prodId, count, isDwarvenRecipe);
for (RecipeInstance recipePart : recipePartList)
{
recipeList.addRecipe(recipePart);
}
_lists.put(id, recipeList);
}
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, getClass().getSimpleName() + ": Failed loading recipe list", e);
}
}
public Collection<RecipeList> getAllRecipes()
{
return _lists.values();
}
public RecipeList getRecipeByItemId(int itemId)
{
for (RecipeList recipe : _lists.values())
{
if (recipe.getRecipeId() == itemId)
{
return recipe;
}
}
return null;
}
public RecipeList getRecipe(int recId)
{
return _lists.get(recId);
}
public static RecipeData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final RecipeData INSTANCE = new RecipeData();
}
}

View File

@@ -17,7 +17,7 @@
package org.l2jmobius.gameserver.handler.itemhandlers;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.model.actor.Playable;
@@ -32,11 +32,11 @@ public class Recipes implements IItemHandler
public Recipes()
{
final RecipeTable rc = RecipeTable.getInstance();
ITEM_IDS = new int[rc.getRecipesCount()];
for (int i = 0; i < rc.getRecipesCount(); i++)
int index = 0;
ITEM_IDS = new int[RecipeData.getInstance().getAllRecipes().size()];
for (RecipeList recipe : RecipeData.getInstance().getAllRecipes())
{
ITEM_IDS[i] = rc.getRecipeList(i).getRecipeId();
ITEM_IDS[index++] = recipe.getRecipeId();
}
}
@@ -55,7 +55,7 @@ public class Recipes implements IItemHandler
return;
}
final RecipeList recipe = RecipeTable.getInstance().getRecipeByItemId(item.getItemId());
final RecipeList recipe = RecipeData.getInstance().getRecipeByItemId(item.getItemId());
if (player.hasRecipeList(recipe.getId()))
{
player.sendPacket(new SystemMessage(SystemMessageId.RECIPE_ALREADY_REGISTERED));
@@ -66,7 +66,7 @@ public class Recipes implements IItemHandler
{
if (recipe.getLevel() > player.getDwarvenCraft())
{
// can't add recipe, becouse create item level too low
// Cannot add recipe, because create item level too low.
player.sendPacket(new SystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER));
}
else if (player.getDwarvenRecipeBook().length >= player.getDwarfRecipeLimit())
@@ -94,7 +94,7 @@ public class Recipes implements IItemHandler
{
if (recipe.getLevel() > player.getCommonCraft())
{
// can't add recipe, becouse create item level too low
// Cannot add recipe, because create item level too low.
player.sendPacket(new SystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER));
}
else if (player.getCommonRecipeBook().length >= player.getCommonRecipeLimit())

View File

@@ -16,7 +16,7 @@
*/
package org.l2jmobius.gameserver.model;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
/**
* @version $Revision: 1.1.2.2.2.1 $ $Date: 2005/03/27 15:29:32 $
@@ -31,7 +31,7 @@ public class ManufactureItem
{
_recipeId = recipeId;
_cost = cost;
_isDwarven = RecipeTable.getInstance().getRecipeById(_recipeId).isDwarvenRecipe();
_isDwarven = RecipeData.getInstance().getRecipe(_recipeId).isDwarvenRecipe();
}
public int getRecipeId()

View File

@@ -27,19 +27,19 @@ public class RecipeList
/** The table containing all RecipeInstance (1 line of the recipe : Item-Quantity needed) of the RecipeList */
private RecipeInstance[] _recipes;
/** The Identifier of the Instance */
/** The recipe id */
private final int _id;
/** The crafting level needed to use this RecipeList */
private final int _level;
/** The Identifier of the RecipeList */
/** The item id of the recipe. */
private final int _recipeId;
/** The name of the RecipeList */
private final String _recipeName;
/** The crafting succes rate when using the RecipeList */
/** The crafting success rate when using the RecipeList */
private final int _successRate;
/** The crafting MP cost of this RecipeList */
@@ -94,7 +94,7 @@ public class RecipeList
}
/**
* @return the Identifier of the Instance.
* @return the recipe id of the recipe.
*/
public int getId()
{
@@ -110,7 +110,7 @@ public class RecipeList
}
/**
* @return the Identifier of the RecipeList.
* @return the item id of the recipe.
*/
public int getRecipeId()
{

View File

@@ -57,7 +57,6 @@ import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.datatables.NobleSkillTable;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.sql.CharTemplateTable;
import org.l2jmobius.gameserver.datatables.sql.ClanTable;
import org.l2jmobius.gameserver.datatables.sql.NpcTable;
@@ -66,6 +65,7 @@ import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
import org.l2jmobius.gameserver.datatables.xml.FishData;
import org.l2jmobius.gameserver.datatables.xml.HennaData;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
import org.l2jmobius.gameserver.enums.Race;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IItemHandler;
@@ -7823,7 +7823,6 @@ public class PlayerInstance extends Playable
/**
* Return the _buyList object of the PlayerInstance.<BR>
* <BR>
* @return the buy list
*/
public TradeList getBuyList()
@@ -7838,14 +7837,13 @@ public class PlayerInstance extends Playable
/**
* Set the Private Store type of the PlayerInstance.<BR>
* <BR>
* <B><U> Values </U> :</B><BR>
* <BR>
* <B><U> Values </U> :</B>
* <li>0 : STORE_PRIVATE_NONE</li>
* <li>1 : STORE_PRIVATE_SELL</li>
* <li>2 : sellmanage</li><BR>
* <li>3 : STORE_PRIVATE_BUY</li><BR>
* <li>4 : buymanage</li><BR>
* <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR>
* <li>2 : sellmanage</li>
* <li>3 : STORE_PRIVATE_BUY</li>
* <li>4 : buymanage</li>
* <li>5 : STORE_PRIVATE_MANUFACTURE</li>
* @param type the new private store type
*/
public void setPrivateStoreType(int type)
@@ -7871,14 +7869,13 @@ public class PlayerInstance extends Playable
/**
* Return the Private Store type of the PlayerInstance.<BR>
* <BR>
* <B><U> Values </U> :</B><BR>
* <BR>
* <B><U> Values </U> :</B>
* <li>0 : STORE_PRIVATE_NONE</li>
* <li>1 : STORE_PRIVATE_SELL</li>
* <li>2 : sellmanage</li><BR>
* <li>3 : STORE_PRIVATE_BUY</li><BR>
* <li>4 : buymanage</li><BR>
* <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR>
* <li>2 : sellmanage</li>
* <li>3 : STORE_PRIVATE_BUY</li>
* <li>4 : buymanage</li>
* <li>5 : STORE_PRIVATE_MANUFACTURE</li>
* @return the private store type
*/
public int getPrivateStoreType()
@@ -9121,7 +9118,7 @@ public class PlayerInstance extends Playable
RecipeList recipe;
while (rset.next())
{
recipe = RecipeTable.getInstance().getRecipeList(rset.getInt("id") - 1);
recipe = RecipeData.getInstance().getRecipe(rset.getInt("id"));
if (rset.getInt("type") == 1)
{

View File

@@ -41,7 +41,7 @@ public abstract class GameClientPacket extends ReceivablePacket<GameClient>
}
catch (Exception e)
{
LOGGER.severe("Client: " + getClient() + " - Failed reading: " + getType() + " ; " + e.getMessage());
LOGGER.severe("Client: " + getClient() + " - Failed reading: " + getType() + " ; " + e.getMessage() + " " + e);
if (e instanceof BufferUnderflowException)
{

View File

@@ -16,7 +16,7 @@
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.RecipeBookItemList;
@@ -45,7 +45,7 @@ public class RequestRecipeBookDestroy extends GameClientPacket
return;
}
final RecipeList rp = RecipeTable.getInstance().getRecipeList(_recipeID - 1);
final RecipeList rp = RecipeData.getInstance().getRecipe(_recipeID);
if (rp == null)
{
return;

View File

@@ -38,7 +38,7 @@ public class RequestRecipeBookOpen extends GameClientPacket
if (getClient().getPlayer().getPrivateStoreType() != 0)
{
getClient().getPlayer().sendMessage("Cannot use recipe book while trading");
getClient().getPlayer().sendMessage("Cannot use recipe book while trading.");
return;
}

View File

@@ -22,19 +22,22 @@ import org.l2jmobius.gameserver.network.serverpackets.RecipeItemMakeInfo;
public class RequestRecipeItemMakeInfo extends GameClientPacket
{
private int _id;
private PlayerInstance _player;
@Override
protected void readImpl()
{
_id = readD();
_player = getClient().getPlayer();
}
@Override
protected void runImpl()
{
final RecipeItemMakeInfo response = new RecipeItemMakeInfo(_id, _player);
sendPacket(response);
final PlayerInstance player = getClient().getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new RecipeItemMakeInfo(_id, player));
}
}

View File

@@ -45,13 +45,13 @@ public class RequestRecipeItemMakeSelf extends GameClientPacket
if (player.getPrivateStoreType() != 0)
{
player.sendMessage("Cannot make items while trading");
// player.sendMessage("Cannot create items while trading.");
return;
}
if (player.isCrafting())
{
player.sendMessage("Currently in Craft Mode");
// player.sendMessage("Currently in Craft Mode.");
return;
}

View File

@@ -69,15 +69,14 @@ public class RequestRecipeShopListSet extends GameClientPacket
if (player.isTradeDisabled())
{
player.sendMessage("Private manufacture are disable here. Try in another place.");
player.sendMessage("Private manufacture is disabled here. Try in another place.");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (player.isInsideZone(ZoneId.NO_STORE))
{
// player.sendPacket(new RecipeShopManageList(player, player.isDwarven()));
player.sendMessage("Private manufacture are disable here. Try in another place.");
player.sendMessage("Private manufacture is disabled here. Try in another place.");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}

View File

@@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.RecipeShopItemInfo;
@@ -40,6 +41,12 @@ public class RequestRecipeShopMakeInfo extends GameClientPacket
return;
}
player.sendPacket(new RecipeShopItemInfo(_playerObjectId, _recipeId));
final PlayerInstance shop = World.getInstance().getPlayer(_playerObjectId);
if ((shop == null) || (shop.getPrivateStoreType() != 5))
{
return;
}
player.sendPacket(new RecipeShopItemInfo(shop, _recipeId));
}
}

View File

@@ -51,7 +51,7 @@ public class RequestRecipeShopMakeItem extends GameClientPacket
return;
}
final PlayerInstance manufacturer = (PlayerInstance) World.getInstance().findObject(_id);
final PlayerInstance manufacturer = World.getInstance().getPlayer(_id);
if (manufacturer == null)
{
return;
@@ -59,7 +59,7 @@ public class RequestRecipeShopMakeItem extends GameClientPacket
if (player.getPrivateStoreType() != 0)
{
player.sendMessage("Cannot make items while trading");
// player.sendMessage("Cannot create items while trading.");
return;
}
@@ -71,7 +71,7 @@ public class RequestRecipeShopMakeItem extends GameClientPacket
if (player.isCrafting() || manufacturer.isCrafting())
{
player.sendMessage("Currently in Craft Mode");
// player.sendMessage("Currently in Craft Mode.");
return;
}

View File

@@ -49,7 +49,6 @@ public class RequestRecipeShopManagePrev extends GameClientPacket
return;
}
final PlayerInstance target = (PlayerInstance) player.getTarget();
player.sendPacket(new RecipeShopSellList(player, target));
player.sendPacket(new RecipeShopSellList(player, (PlayerInstance) player.getTarget()));
}
}

View File

@@ -20,6 +20,7 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
public class RequestRecipeShopMessageSet extends GameClientPacket
{
private static final int MAX_MSG_LENGTH = 29;
private String _name;
@Override
@@ -37,11 +38,12 @@ public class RequestRecipeShopMessageSet extends GameClientPacket
return;
}
/*
* if (player.getCreateList() == null) { player.setCreateList(new ManufactureList()); }
*/
if ((_name != null) && (_name.length() > MAX_MSG_LENGTH))
{
return;
}
if ((player.getCreateList() != null) && (_name.length() < 30))
if (player.getCreateList() != null)
{
player.getCreateList().setStoreName(_name);
}

View File

@@ -57,8 +57,7 @@ public class RecipeBookItemList extends GameServerPacket
for (int i = 0; i < _recipes.length; i++)
{
final RecipeList temp = _recipes[i];
writeD(temp.getId());
writeD(_recipes[i].getId());
writeD(i + 1);
}
}

View File

@@ -16,13 +16,12 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
import org.l2jmobius.gameserver.datatables.xml.RecipeData;
import org.l2jmobius.gameserver.model.RecipeList;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* format dddd
* @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:29:57 $
*/
public class RecipeItemMakeInfo extends GameServerPacket
{
@@ -47,7 +46,7 @@ public class RecipeItemMakeInfo extends GameServerPacket
@Override
protected final void writeImpl()
{
final RecipeList recipe = RecipeTable.getInstance().getRecipeById(_id);
final RecipeList recipe = RecipeData.getInstance().getRecipe(_id);
if (recipe != null)
{
writeC(0xD7);

View File

@@ -16,38 +16,30 @@
*/
package org.l2jmobius.gameserver.network.serverpackets;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* ddddd
* @version $Revision: 1.1.2.3.2.3 $ $Date: 2005/03/27 15:29:39 $
*/
public class RecipeShopItemInfo extends GameServerPacket
{
private final int _shopId;
private final PlayerInstance _player;
private final int _recipeId;
public RecipeShopItemInfo(int shopId, int recipeId)
public RecipeShopItemInfo(PlayerInstance player, int recipeId)
{
_shopId = shopId;
_player = player;
_recipeId = recipeId;
}
@Override
protected final void writeImpl()
{
if (!(World.getInstance().findObject(_shopId) instanceof PlayerInstance))
{
return;
}
final PlayerInstance manufacturer = (PlayerInstance) World.getInstance().findObject(_shopId);
writeC(0xda);
writeD(_shopId);
writeD(_player.getObjectId());
writeD(_recipeId);
writeD(manufacturer != null ? (int) manufacturer.getCurrentMp() : 0);
writeD(manufacturer != null ? manufacturer.getMaxMp() : 0);
writeD((int) _player.getCurrentMp());
writeD(_player.getMaxMp());
writeD(0xffffffff);
}
}

View File

@@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* dd d(dd) d(ddd)
* @version $Revision: 1.1.2.2.2.3 $ $Date: 2005/03/27 15:29:57 $
*/
public class RecipeShopManageList extends GameServerPacket
{
@@ -77,8 +76,7 @@ public class RecipeShopManageList extends GameServerPacket
for (int i = 0; i < _recipes.length; i++)
{
final RecipeList temp = _recipes[i];
writeD(temp.getId());
writeD(_recipes[i].getId());
writeD(i + 1);
}
}

View File

@@ -18,9 +18,6 @@ package org.l2jmobius.gameserver.network.serverpackets;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:29:57 $
*/
public class RecipeShopMsg extends GameServerPacket
{
private final PlayerInstance _player;
@@ -35,6 +32,6 @@ public class RecipeShopMsg extends GameServerPacket
{
writeC(0xdb);
writeD(_player.getObjectId());
writeS(_player.getCreateList().getStoreName()); // _activeChar.getTradeList().getSellStoreName());
writeS(_player.getCreateList().getStoreName());
}
}

View File

@@ -20,44 +20,35 @@ import org.l2jmobius.gameserver.model.ManufactureItem;
import org.l2jmobius.gameserver.model.ManufactureList;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:29:39 $
*/
public class RecipeShopSellList extends GameServerPacket
{
private final PlayerInstance _buyer;
private final PlayerInstance _manufacturer;
private final PlayerInstance _player;
public RecipeShopSellList(PlayerInstance buyer, PlayerInstance manufacturer)
public RecipeShopSellList(PlayerInstance buyer, PlayerInstance player)
{
_buyer = buyer;
_manufacturer = manufacturer;
_player = player;
}
@Override
protected final void writeImpl()
{
final ManufactureList createList = _manufacturer.getCreateList();
final ManufactureList createList = _player.getCreateList();
if (createList != null)
{
// dddd d(ddd)
writeC(0xd9);
writeD(_manufacturer.getObjectId());
writeD((int) _manufacturer.getCurrentMp()); // Creator's MP
writeD(_manufacturer.getMaxMp()); // Creator's MP
writeD(_player.getObjectId());
writeD((int) _player.getCurrentMp()); // Creator's MP
writeD(_player.getMaxMp()); // Creator's MP
writeD(_buyer.getAdena()); // Buyer Adena
writeD(createList.size());
final int count = createList.size();
writeD(count);
ManufactureItem temp;
for (int i = 0; i < count; i++)
for (ManufactureItem item : createList.getList())
{
temp = createList.getList().get(i);
writeD(temp.getRecipeId());
writeD(item.getRecipeId());
writeD(0x00); // unknown
writeD(temp.getCost());
writeD(item.getCost());
}
}
}