Extractable item data moved from CSV to XML.
This commit is contained in:
@@ -47,7 +47,6 @@ import org.l2jmobius.gameserver.datatables.NobleSkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.OfflineTradeTable;
|
||||
import org.l2jmobius.gameserver.datatables.SchemeBufferTable;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.ExtractableItemData;
|
||||
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRouteTable;
|
||||
import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
|
||||
@@ -67,6 +66,7 @@ import org.l2jmobius.gameserver.datatables.xml.AugmentationData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.BoatData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.DoorData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.ExtractableItemData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.FenceData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.FishData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.HennaData;
|
||||
|
@@ -1,175 +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.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.model.ExtractableItem;
|
||||
import org.l2jmobius.gameserver.model.ExtractableProductItem;
|
||||
|
||||
/**
|
||||
* @author FBIagent
|
||||
*/
|
||||
public class ExtractableItemData
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(ExtractableItemData.class.getName());
|
||||
|
||||
// Map<itemid, ExtractableItem>
|
||||
private Map<Integer, ExtractableItem> _items;
|
||||
|
||||
public ExtractableItemData()
|
||||
{
|
||||
_items = new HashMap<>();
|
||||
|
||||
Scanner s = null;
|
||||
try
|
||||
{
|
||||
s = new Scanner(new File(Config.DATAPACK_ROOT + "/data/csv/extractable_items.csv"));
|
||||
|
||||
int lineCount = 0;
|
||||
while (s.hasNextLine())
|
||||
{
|
||||
lineCount++;
|
||||
|
||||
final String line = s.nextLine();
|
||||
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (line.equals(""))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] lineSplit = line.split(";");
|
||||
int itemID = 0;
|
||||
try
|
||||
{
|
||||
itemID = Integer.parseInt(lineSplit[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.info("Extractable items data: Error in line " + lineCount + " -> invalid item id or wrong seperator after item id!");
|
||||
LOGGER.info(" " + line);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<ExtractableProductItem> productTemp = new ArrayList<>(lineSplit.length);
|
||||
for (int i = 0; i < (lineSplit.length - 1); i++)
|
||||
{
|
||||
final String[] lineSplit2 = lineSplit[i + 1].split(",");
|
||||
if (lineSplit2.length != 3)
|
||||
{
|
||||
LOGGER.info("Extractable items data: Error in line " + lineCount + " -> wrong seperator!");
|
||||
LOGGER.info(" " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
int production = 0;
|
||||
int amount = 0;
|
||||
int chance = 0;
|
||||
|
||||
try
|
||||
{
|
||||
production = Integer.parseInt(lineSplit2[0]);
|
||||
amount = Integer.parseInt(lineSplit2[1]);
|
||||
chance = Integer.parseInt(lineSplit2[2]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.info("Extractable items data: Error in line " + lineCount + " -> incomplete/invalid production data or wrong seperator!");
|
||||
LOGGER.info(" " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
productTemp.add(new ExtractableProductItem(production, amount, chance));
|
||||
}
|
||||
|
||||
int fullChances = 0;
|
||||
for (ExtractableProductItem Pi : productTemp)
|
||||
{
|
||||
fullChances += Pi.getChance();
|
||||
}
|
||||
|
||||
if (fullChances > 100)
|
||||
{
|
||||
LOGGER.info("Extractable items data: Error in line " + lineCount + " -> all chances together are more then 100!");
|
||||
LOGGER.info(" " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
_items.put(itemID, new ExtractableItem(itemID, productTemp));
|
||||
}
|
||||
|
||||
LOGGER.info("Extractable items data: Loaded " + _items.size() + " extractable items!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.info("Extractable items data: Can not find './data/csv/extractable_items.csv'");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (s != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
s.close();
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
LOGGER.warning("Problem with ExtractableItemsData: " + e1.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ExtractableItem getExtractableItem(int itemID)
|
||||
{
|
||||
return _items.get(itemID);
|
||||
}
|
||||
|
||||
public int[] itemIDs()
|
||||
{
|
||||
final int size = _items.size();
|
||||
final int[] result = new int[size];
|
||||
int i = 0;
|
||||
for (ExtractableItem ei : _items.values())
|
||||
{
|
||||
result[i] = ei.getItemId();
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ExtractableItemData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final ExtractableItemData INSTANCE = new ExtractableItemData();
|
||||
}
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.model.ExtractableItem;
|
||||
import org.l2jmobius.gameserver.model.ExtractableProductItem;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ExtractableItemData implements IXmlReader
|
||||
{
|
||||
private final Map<Integer, ExtractableItem> _items = new HashMap<>();
|
||||
|
||||
protected ExtractableItemData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_items.clear();
|
||||
parseDatapackFile("data/ExtractableItems.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id;
|
||||
int amount;
|
||||
int production;
|
||||
float totalChance;
|
||||
float chance;
|
||||
final StatSet set = new StatSet();
|
||||
|
||||
final Node n = doc.getFirstChild();
|
||||
for (Node node = n.getFirstChild(); node != null; node = node.getNextSibling())
|
||||
{
|
||||
if ("item".equalsIgnoreCase(node.getNodeName()))
|
||||
{
|
||||
id = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue());
|
||||
final List<ExtractableProductItem> extractables = new ArrayList<>();
|
||||
for (Node b = node.getFirstChild(); b != null; b = b.getNextSibling())
|
||||
{
|
||||
if ("extract".equalsIgnoreCase(b.getNodeName()))
|
||||
{
|
||||
final NamedNodeMap attrs = b.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node attr = attrs.item(i);
|
||||
set.set(attr.getNodeName(), attr.getNodeValue());
|
||||
}
|
||||
|
||||
production = set.getInt("id");
|
||||
amount = set.getInt("quantity");
|
||||
chance = set.getFloat("chance");
|
||||
extractables.add(new ExtractableProductItem(production, amount, chance));
|
||||
|
||||
totalChance = 0;
|
||||
for (ExtractableProductItem extractable : extractables)
|
||||
{
|
||||
totalChance += extractable.getChance();
|
||||
}
|
||||
if (totalChance > 100)
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Extractable with id " + id + " has was more than 100% total chance!");
|
||||
}
|
||||
}
|
||||
}
|
||||
_items.put(id, new ExtractableItem(id, extractables));
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _items.size() + " extractable items.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while loading extractable items! " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public ExtractableItem getExtractableItem(int itemId)
|
||||
{
|
||||
return _items.get(itemId);
|
||||
}
|
||||
|
||||
public int[] getAllItemIds()
|
||||
{
|
||||
int index = 0;
|
||||
final int[] ids = new int[_items.size()];
|
||||
for (ExtractableItem recipe : _items.values())
|
||||
{
|
||||
ids[index++] = recipe.getItemId();
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static ExtractableItemData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final ExtractableItemData INSTANCE = new ExtractableItemData();
|
||||
}
|
||||
}
|
@@ -1,106 +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.handler.custom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.handler.ICustomByPassHandler;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.entity.Rebirth;
|
||||
|
||||
/**
|
||||
* This 'Bypass Handler' is a handy tool indeed!<br>
|
||||
* Basically, you can send any custom bypass commmands to it from ANY npc and it will call the appropriate function.<br>
|
||||
* <strong>Example:</strong><br>
|
||||
* <button value=" Request Rebirth " action="bypass -h custom_rebirth_confirmrequest" width=110 height=36 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
|
||||
* @author JStar
|
||||
*/
|
||||
public class CustomBypassHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(CustomBypassHandler.class.getName());
|
||||
|
||||
private final Map<String, ICustomByPassHandler> _handlers;
|
||||
|
||||
private CustomBypassHandler()
|
||||
{
|
||||
_handlers = new HashMap<>();
|
||||
registerCustomBypassHandler(new ExtractableByPassHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param handler as ICustomByPassHandler
|
||||
*/
|
||||
private void registerCustomBypassHandler(ICustomByPassHandler handler)
|
||||
{
|
||||
for (String s : handler.getByPassCommands())
|
||||
{
|
||||
_handlers.put(s, handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles player's Bypass request to the Custom Content.
|
||||
* @param player
|
||||
* @param command
|
||||
*/
|
||||
public void handleBypass(PlayerInstance player, String command)
|
||||
{
|
||||
// Rebirth Manager and Engine Caller
|
||||
|
||||
String cmd = "";
|
||||
String params = "";
|
||||
final int iPos = command.indexOf(' ');
|
||||
if (iPos != -1)
|
||||
{
|
||||
cmd = command.substring(7, iPos);
|
||||
params = command.substring(iPos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = command.substring(7);
|
||||
}
|
||||
final ICustomByPassHandler ch = _handlers.get(cmd);
|
||||
if (ch != null)
|
||||
{
|
||||
ch.handleCommand(cmd, player, params);
|
||||
}
|
||||
else if (command.startsWith("custom_rebirth"))
|
||||
{
|
||||
// Check to see if Rebirth is enabled to avoid hacks
|
||||
if (!Config.REBIRTH_ENABLE)
|
||||
{
|
||||
LOGGER.warning("[WARNING] Player " + player.getName() + " is trying to use rebirth system when it's disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
Rebirth.getInstance().handleCommand(player, command);
|
||||
}
|
||||
}
|
||||
|
||||
public static CustomBypassHandler getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final CustomBypassHandler INSTANCE = new CustomBypassHandler();
|
||||
}
|
||||
}
|
@@ -1,65 +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.handler.custom;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.entity.Rebirth;
|
||||
|
||||
/**
|
||||
* This will simply manage any custom 'Enter World callers' needed.<br>
|
||||
* Rather then having to add them to the core's. (yuck!)
|
||||
* @author JStar
|
||||
*/
|
||||
public class CustomWorldHandler
|
||||
{
|
||||
private CustomWorldHandler()
|
||||
{
|
||||
// Do Nothing ^_-
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests entry into the world - manages appropriately.
|
||||
* @param player
|
||||
*/
|
||||
public void enterWorld(PlayerInstance player)
|
||||
{
|
||||
// Rebirth's skills must be actived only on main class
|
||||
if (!player.isSubClassActive())
|
||||
{
|
||||
Rebirth.getInstance().grantRebirthSkills(player); // Rebirth Caller - if player has any skills, they will be granted them.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests removal from the world - manages appropriately.
|
||||
* @param player
|
||||
*/
|
||||
public void exitWorld(PlayerInstance player)
|
||||
{
|
||||
// TODO: Remove the rebirth engine's bonus skills from player?
|
||||
}
|
||||
|
||||
public static CustomWorldHandler getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final CustomWorldHandler INSTANCE = new CustomWorldHandler();
|
||||
}
|
||||
}
|
@@ -1,76 +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.handler.custom;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.handler.ICustomByPassHandler;
|
||||
import org.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import org.l2jmobius.gameserver.handler.ItemHandler;
|
||||
import org.l2jmobius.gameserver.handler.itemhandlers.ExtractableItems;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
|
||||
/**
|
||||
* @author Nick
|
||||
*/
|
||||
public class ExtractableByPassHandler implements ICustomByPassHandler
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(ExtractableByPassHandler.class.getName());
|
||||
private static String[] _IDS =
|
||||
{
|
||||
"extractOne",
|
||||
"extractAll"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getByPassCommands()
|
||||
{
|
||||
return _IDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(String command, PlayerInstance player, String parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
final int objId = Integer.parseInt(parameters);
|
||||
final ItemInstance item = player.getInventory().getItemByObjectId(objId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IItemHandler ih = ItemHandler.getInstance().getItemHandler(item.getItemId());
|
||||
if (!(ih instanceof ExtractableItems))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (command.compareTo(_IDS[0]) == 0)
|
||||
{
|
||||
((ExtractableItems) ih).doExtract(player, item, 1);
|
||||
}
|
||||
else if (command.compareTo(_IDS[1]) == 0)
|
||||
{
|
||||
((ExtractableItems) ih).doExtract(player, item, item.getCount());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("ExtractableByPassHandler: Error while running " + e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,9 +19,8 @@ package org.l2jmobius.gameserver.handler.itemhandlers;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.ExtractableItemData;
|
||||
import org.l2jmobius.gameserver.datatables.xml.ExtractableItemData;
|
||||
import org.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import org.l2jmobius.gameserver.model.ExtractableItem;
|
||||
import org.l2jmobius.gameserver.model.ExtractableProductItem;
|
||||
@@ -29,7 +28,6 @@ import org.l2jmobius.gameserver.model.actor.Playable;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -39,93 +37,7 @@ public class ExtractableItems implements IItemHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(ExtractableItems.class.getName());
|
||||
|
||||
public void doExtract(Playable playable, ItemInstance item, int count)
|
||||
{
|
||||
if (!(playable instanceof PlayerInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final PlayerInstance player = (PlayerInstance) playable;
|
||||
final int itemID = item.getItemId();
|
||||
|
||||
if (count > item.getCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
while (count-- > 0)
|
||||
{
|
||||
final ExtractableItem exitem = ExtractableItemData.getInstance().getExtractableItem(itemID);
|
||||
if (exitem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int createItemID = 0;
|
||||
int createAmount = 0;
|
||||
final int rndNum = Rnd.get(100);
|
||||
int chanceFrom = 0;
|
||||
for (ExtractableProductItem expi : exitem.getProductItems())
|
||||
{
|
||||
final int chance = expi.getChance();
|
||||
|
||||
if ((rndNum >= chanceFrom) && (rndNum <= (chance + chanceFrom)))
|
||||
{
|
||||
createItemID = expi.getId();
|
||||
createAmount = expi.getAmmount();
|
||||
break;
|
||||
}
|
||||
|
||||
chanceFrom += chance;
|
||||
}
|
||||
|
||||
if (createItemID == 0)
|
||||
{
|
||||
player.sendMessage("Nothing happened.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (createItemID > 0)
|
||||
{
|
||||
if (ItemTable.getInstance().createDummyItem(createItemID) == null)
|
||||
{
|
||||
LOGGER.warning("createItemID " + createItemID + " doesn't have template!");
|
||||
player.sendMessage("Nothing happened.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemTable.getInstance().createDummyItem(createItemID).isStackable())
|
||||
{
|
||||
player.addItem("Extract", createItemID, createAmount, item, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < createAmount; i++)
|
||||
{
|
||||
player.addItem("Extract", createItemID, 1, item, false);
|
||||
}
|
||||
}
|
||||
SystemMessage sm;
|
||||
|
||||
if (createAmount > 1)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
|
||||
sm.addItemName(createItemID);
|
||||
sm.addNumber(createAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
|
||||
sm.addItemName(createItemID);
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Item failed to open"); // TODO: Put a more proper message here.
|
||||
}
|
||||
|
||||
player.destroyItemByItemId("Extract", itemID, 1, player.getTarget(), true);
|
||||
}
|
||||
}
|
||||
private static final int[] ITEM_IDS = ExtractableItemData.getInstance().getAllItemIds();
|
||||
|
||||
@Override
|
||||
public void useItem(Playable playable, ItemInstance item)
|
||||
@@ -134,30 +46,78 @@ public class ExtractableItems implements IItemHandler
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (item.getCount() > 1)
|
||||
final PlayerInstance player = (PlayerInstance) playable;
|
||||
final int itemId = item.getItemId();
|
||||
|
||||
final ExtractableItem extractable = ExtractableItemData.getInstance().getExtractableItem(itemId);
|
||||
if (extractable == null)
|
||||
{
|
||||
String message = HtmCache.getInstance().getHtm("data/html/others/extractable.htm");
|
||||
if (message == null)
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy item first.
|
||||
player.destroyItemByItemId("Extract", itemId, 1, player.getTarget(), true);
|
||||
|
||||
int createItemId = 0;
|
||||
int createAmount = 0;
|
||||
float chanceFrom = 0;
|
||||
final float random = Rnd.get(100);
|
||||
for (ExtractableProductItem expi : extractable.getProductItems())
|
||||
{
|
||||
final float chance = expi.getChance();
|
||||
if ((random >= chanceFrom) && (random <= (chance + chanceFrom)))
|
||||
{
|
||||
doExtract(playable, item, 1);
|
||||
createItemId = expi.getId();
|
||||
createAmount = expi.getAmmount();
|
||||
break;
|
||||
}
|
||||
chanceFrom += chance;
|
||||
}
|
||||
|
||||
if (createItemId > 0)
|
||||
{
|
||||
if (ItemTable.getInstance().createDummyItem(createItemId) == null)
|
||||
{
|
||||
LOGGER.warning("Extractable item with id " + createItemId + " does not have a template!");
|
||||
player.sendMessage("Nothing happened.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemTable.getInstance().createDummyItem(createItemId).isStackable())
|
||||
{
|
||||
player.addItem("Extract", createItemId, createAmount, item, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = message.replace("%objectId%", String.valueOf(item.getObjectId()));
|
||||
message = message.replace("%itemname%", item.getItemName());
|
||||
message = message.replace("%count%", String.valueOf(item.getCount()));
|
||||
playable.sendPacket(new NpcHtmlMessage(5, message));
|
||||
for (int i = 0; i < createAmount; i++)
|
||||
{
|
||||
player.addItem("Extract", createItemId, 1, item, false);
|
||||
}
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
if (createAmount > 1)
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
|
||||
sm.addItemName(createItemId);
|
||||
sm.addNumber(createAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
|
||||
sm.addItemName(createItemId);
|
||||
}
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
doExtract(playable, item, 1);
|
||||
player.sendMessage("Nothing happened.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getItemIds()
|
||||
{
|
||||
return ExtractableItemData.getInstance().itemIDs();
|
||||
return ITEM_IDS;
|
||||
}
|
||||
}
|
@@ -23,9 +23,9 @@ public class ExtractableProductItem
|
||||
{
|
||||
private final int _id;
|
||||
private final int _ammount;
|
||||
private final int _chance;
|
||||
private final float _chance;
|
||||
|
||||
public ExtractableProductItem(int id, int ammount, int chance)
|
||||
public ExtractableProductItem(int id, int ammount, float chance)
|
||||
{
|
||||
_id = id;
|
||||
_ammount = ammount;
|
||||
@@ -42,7 +42,7 @@ public class ExtractableProductItem
|
||||
return _ammount;
|
||||
}
|
||||
|
||||
public int getChance()
|
||||
public float getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
@@ -34,7 +34,6 @@ import org.l2jmobius.gameserver.communitybbs.Manager.MailBBSManager;
|
||||
import org.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
|
||||
import org.l2jmobius.gameserver.datatables.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.handler.custom.CustomWorldHandler;
|
||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.CoupleManager;
|
||||
@@ -53,6 +52,7 @@ import org.l2jmobius.gameserver.model.clan.Clan;
|
||||
import org.l2jmobius.gameserver.model.entity.Announcements;
|
||||
import org.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import org.l2jmobius.gameserver.model.entity.Hero;
|
||||
import org.l2jmobius.gameserver.model.entity.Rebirth;
|
||||
import org.l2jmobius.gameserver.model.entity.Wedding;
|
||||
import org.l2jmobius.gameserver.model.entity.event.CTF;
|
||||
import org.l2jmobius.gameserver.model.entity.event.DM;
|
||||
@@ -431,7 +431,11 @@ public class EnterWorld extends GameClientPacket
|
||||
player.sendMessage("You have been teleported to the nearest town due to you being in siege zone");
|
||||
}
|
||||
|
||||
CustomWorldHandler.getInstance().enterWorld(player);
|
||||
// Rebirth's skills must be actived only on main class
|
||||
if (Config.REBIRTH_ENABLE && !player.isSubClassActive())
|
||||
{
|
||||
Rebirth.getInstance().grantRebirthSkills(player);
|
||||
}
|
||||
|
||||
if (TvT._savePlayers.contains(player.getName()))
|
||||
{
|
||||
|
@@ -24,7 +24,6 @@ import org.l2jmobius.gameserver.communitybbs.CommunityBoard;
|
||||
import org.l2jmobius.gameserver.datatables.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import org.l2jmobius.gameserver.handler.custom.CustomBypassHandler;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@@ -293,7 +292,6 @@ public class RequestBypassToServer extends GameClientPacket
|
||||
|
||||
final String p = _command.substring(6).trim();
|
||||
final int idx = p.indexOf(' ');
|
||||
|
||||
if (idx < 0)
|
||||
{
|
||||
player.processQuestEvent(p, "");
|
||||
@@ -304,12 +302,7 @@ public class RequestBypassToServer extends GameClientPacket
|
||||
}
|
||||
}
|
||||
|
||||
// Jstar's Custom Bypass Caller!
|
||||
else if (_command.startsWith("custom_"))
|
||||
{
|
||||
CustomBypassHandler.getInstance().handleBypass(player, _command);
|
||||
}
|
||||
else if (_command.startsWith("OlympiadArenaChange"))
|
||||
if (_command.startsWith("OlympiadArenaChange"))
|
||||
{
|
||||
Olympiad.bypassChangeArena(_command, player);
|
||||
}
|
||||
|
Reference in New Issue
Block a user