Advertisement
Reanimation06

l2jmobius c6 interlude combo Item extractable

Feb 25th, 2024
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.31 KB | Gaming | 0 0
  1. diff --git a/L2J_Mobius_C6_Interlude/.gitignore b/L2J_Mobius_C6_Interlude/.gitignore
  2. new file mode 100644
  3. index 0000000..ae3c172
  4. --- /dev/null
  5. +++ b/L2J_Mobius_C6_Interlude/.gitignore
  6. @@ -0,0 +1 @@
  7. +/bin/
  8. diff --git a/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBox.java b/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBox.java
  9. new file mode 100644
  10. index 0000000..21709b6
  11. --- /dev/null
  12. +++ b/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBox.java
  13. @@ -0,0 +1,79 @@
  14. +/*
  15. + * This program is free software: you can redistribute it and/or modify it under
  16. + * the terms of the GNU General Public License as published by the Free Software
  17. + * Foundation, either version 3 of the License, or (at your option) any later
  18. + * version.
  19. + *
  20. + * This program is distributed in the hope that it will be useful, but WITHOUT
  21. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  22. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  23. + * details.
  24. + *
  25. + * You should have received a copy of the GNU General Public License along with
  26. + * this program. If not, see <http://www.gnu.org/licenses/>.
  27. + */
  28. +package Base.ComboBox;
  29. +
  30. +import java.util.ArrayList;
  31. +import java.util.List;
  32. +
  33. +import org.l2jmobius.gameserver.model.StatSet;
  34. +
  35. +/**
  36. + * @author Rouxy
  37. + */
  38. +public class ComboBox
  39. +{
  40. +   private int id;
  41. +   private List<StatSet> items = new ArrayList<>();
  42. +  
  43. +   public ComboBox(int id, List<StatSet> items)
  44. +   {
  45. +       this.id = id;
  46. +       this.setItems(items);
  47. +   }
  48. +  
  49. +   public List<ComboBoxItem> getComboBoxItems()
  50. +   {
  51. +      
  52. +       List<ComboBoxItem> comboItems = new ArrayList<>();
  53. +       for (StatSet item : items)
  54. +       {
  55. +           comboItems.add(new ComboBoxItem(item.getInt("itemId"), item.getInt("amount"), item.getInt("enchantLevel"), item.getDouble("chance")));
  56. +       }
  57. +       return comboItems;
  58. +   }
  59. +  
  60. +   /**
  61. +    * @return the id
  62. +    */
  63. +   public int getId()
  64. +   {
  65. +       return id;
  66. +   }
  67. +  
  68. +   /**
  69. +    * @param id the id to set
  70. +    */
  71. +   public void setId(int id)
  72. +   {
  73. +       this.id = id;
  74. +   }
  75. +  
  76. +   /**
  77. +    * @return the items
  78. +    */
  79. +   public List<StatSet> getItems()
  80. +   {
  81. +       return items;
  82. +   }
  83. +  
  84. +   /**
  85. +    * @param items the items to set
  86. +    */
  87. +   public void setItems(List<StatSet> items)
  88. +   {
  89. +       this.items = items;
  90. +   }
  91. +  
  92. +}
  93. \ No newline at end of file
  94. diff --git a/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBoxData.java b/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBoxData.java
  95. new file mode 100644
  96. index 0000000..0a8969c
  97. --- /dev/null
  98. +++ b/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBoxData.java
  99. @@ -0,0 +1,135 @@
  100. +/*
  101. + * This program is free software: you can redistribute it and/or modify it under
  102. + * the terms of the GNU General Public License as published by the Free Software
  103. + * Foundation, either version 3 of the License, or (at your option) any later
  104. + * version.
  105. + *
  106. + * This program is distributed in the hope that it will be useful, but WITHOUT
  107. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  108. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  109. + * details.
  110. + *
  111. + * You should have received a copy of the GNU General Public License along with
  112. + * this program. If not, see <http://www.gnu.org/licenses/>.
  113. + */
  114. +package Base.ComboBox;
  115. +
  116. +import java.io.File;
  117. +import java.util.ArrayList;
  118. +import java.util.HashMap;
  119. +import java.util.List;
  120. +import java.util.Map;
  121. +
  122. +import org.w3c.dom.Document;
  123. +import org.w3c.dom.NamedNodeMap;
  124. +import org.w3c.dom.Node;
  125. +
  126. +import org.l2jmobius.gameserver.data.ItemTable;
  127. +import org.l2jmobius.gameserver.model.StatSet;
  128. +
  129. +import Base.XML.XMLDocument;
  130. +
  131. +/**
  132. + * @author Rouxy
  133. + */
  134. +public class ComboBoxData extends XMLDocument
  135. +{
  136. +   private Map<Integer, ComboBox> comboBoxes = new HashMap<>();
  137. +  
  138. +   public ComboBoxData()
  139. +   {
  140. +       load();
  141. +   }
  142. +  
  143. +   public static ComboBoxData getInstance()
  144. +   {
  145. +       return SingleTonHolder._instance;
  146. +   }
  147. +  
  148. +   private static class SingleTonHolder
  149. +   {
  150. +       protected static final ComboBoxData _instance = new ComboBoxData();
  151. +   }
  152. +  
  153. +   @Override
  154. +   protected void load()
  155. +   {
  156. +       loadDocument("./data/xml/ComboBoxes.xml");
  157. +       LOG.info("ComboBoxData: Loaded " + comboBoxes.size() + " Comboboxes.");
  158. +   }
  159. +  
  160. +   @Override
  161. +   protected void parseDocument(Document doc, File f)
  162. +   {
  163. +       try
  164. +       {
  165. +          
  166. +           // First element is never read.
  167. +           final Node n = doc.getFirstChild();
  168. +          
  169. +           for (Node o = n.getFirstChild(); o != null; o = o.getNextSibling())
  170. +           {
  171. +               if (!"ComboBox".equalsIgnoreCase(o.getNodeName()))
  172. +               {
  173. +                   continue;
  174. +               }
  175. +              
  176. +               NamedNodeMap attrs = o.getAttributes();
  177. +               ComboBox comboBox = null;
  178. +               List<StatSet> items = new ArrayList<>();
  179. +              
  180. +               final int id = Integer.parseInt(attrs.getNamedItem("ID").getNodeValue());
  181. +              
  182. +               for (Node d = o.getFirstChild(); d != null; d = d.getNextSibling())
  183. +               {
  184. +                   if (!"item".equalsIgnoreCase(d.getNodeName()))
  185. +                   {
  186. +                       continue;
  187. +                   }
  188. +                  
  189. +                   attrs = d.getAttributes();
  190. +                   StatSet item = new StatSet();
  191. +                  
  192. +                   item.set("itemId", Integer.parseInt(attrs.getNamedItem("itemId").getNodeValue()));
  193. +                   item.set("amount", Integer.parseInt(attrs.getNamedItem("amount").getNodeValue()));
  194. +                   item.set("enchantLevel", Integer.parseInt(attrs.getNamedItem("enchantLevel").getNodeValue()));
  195. +                   item.set("chance", Integer.parseInt(attrs.getNamedItem("chance").getNodeValue()));
  196. +                   if (ItemTable.getInstance().getTemplate(item.getInt("itemId")) != null)
  197. +                   {
  198. +                       items.add(item);
  199. +                   }
  200. +                   else
  201. +                   {
  202. +                       LOG.warning("Item Id: " + item.getInt("itemId") + " is an invalid item for combo box ID: " + id + ".");
  203. +                   }
  204. +                   comboBox = new ComboBox(id, items);
  205. +                  
  206. +               }
  207. +               comboBoxes.put(id, comboBox);
  208. +           }
  209. +       }
  210. +       catch (Exception e)
  211. +       {
  212. +           LOG.warning("ComboBox Data: Error while creating table: " + e);
  213. +           e.printStackTrace();
  214. +       }
  215. +   }
  216. +  
  217. +   public void clear()
  218. +   {
  219. +       comboBoxes.clear();
  220. +       comboBoxes = new HashMap<>();
  221. +   }
  222. +  
  223. +   public void reload()
  224. +   {
  225. +       clear();
  226. +       load();
  227. +   }
  228. +  
  229. +   public ComboBox getComboBoxById(int id)
  230. +   {
  231. +       return comboBoxes.get(id);
  232. +   }
  233. +  
  234. +}
  235. \ No newline at end of file
  236. diff --git a/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBoxItem.java b/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBoxItem.java
  237. new file mode 100644
  238. index 0000000..d3edbc1
  239. --- /dev/null
  240. +++ b/L2J_Mobius_C6_Interlude/java/Base/ComboBox/ComboBoxItem.java
  241. @@ -0,0 +1,93 @@
  242. +/*
  243. + * This program is free software: you can redistribute it and/or modify it under
  244. + * the terms of the GNU General Public License as published by the Free Software
  245. + * Foundation, either version 3 of the License, or (at your option) any later
  246. + * version.
  247. + *
  248. + * This program is distributed in the hope that it will be useful, but WITHOUT
  249. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  250. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  251. + * details.
  252. + *
  253. + * You should have received a copy of the GNU General Public License along with
  254. + * this program. If not, see <http://www.gnu.org/licenses/>.
  255. + */
  256. +package Base.ComboBox;
  257. +
  258. +/**
  259. + * @author Rouxy
  260. + */
  261. +public class ComboBoxItem
  262. +{
  263. +   private int enchantLevel;
  264. +   private int amount;
  265. +   private int id;
  266. +   private double chance;
  267. +  
  268. +   public ComboBoxItem(int id, int amount, int enchantLevel, double chance)
  269. +   {
  270. +       this.id = id;
  271. +       this.enchantLevel = enchantLevel;
  272. +       this.amount = amount;
  273. +       this.chance = chance;
  274. +   }
  275. +  
  276. +   /**
  277. +    * @return the enchantLevel
  278. +    */
  279. +   public int getEnchantLevel()
  280. +   {
  281. +       return enchantLevel;
  282. +   }
  283. +  
  284. +   /**
  285. +    * @param enchantLevel the enchantLevel to set
  286. +    */
  287. +   public void setEnchantLevel(int enchantLevel)
  288. +   {
  289. +       this.enchantLevel = enchantLevel;
  290. +   }
  291. +  
  292. +   /**
  293. +    * @return the amount
  294. +    */
  295. +   public int getAmount()
  296. +   {
  297. +       return amount;
  298. +   }
  299. +  
  300. +   /**
  301. +    * @param amount the amount to set
  302. +    */
  303. +   public void setAmount(int amount)
  304. +   {
  305. +       this.amount = amount;
  306. +   }
  307. +  
  308. +   /**
  309. +    * @return the id
  310. +    */
  311. +   public int getId()
  312. +   {
  313. +       return id;
  314. +   }
  315. +  
  316. +   /**
  317. +    * @param id the id to set
  318. +    */
  319. +   public void setId(int id)
  320. +   {
  321. +       this.id = id;
  322. +   }
  323. +  
  324. +   public double getChance()
  325. +   {
  326. +       return chance;
  327. +   }
  328. +  
  329. +   public void setChance(double chance)
  330. +   {
  331. +       this.chance = chance;
  332. +   }
  333. +  
  334. +}
  335. \ No newline at end of file
  336. diff --git a/L2J_Mobius_C6_Interlude/java/Base/XML/XMLDocument.java b/L2J_Mobius_C6_Interlude/java/Base/XML/XMLDocument.java
  337. new file mode 100644
  338. index 0000000..756a5ee
  339. --- /dev/null
  340. +++ b/L2J_Mobius_C6_Interlude/java/Base/XML/XMLDocument.java
  341. @@ -0,0 +1,119 @@
  342. +package Base.XML;
  343. +
  344. +import java.io.File;
  345. +import java.util.logging.Level;
  346. +import java.util.logging.Logger;
  347. +
  348. +import javax.xml.parsers.DocumentBuilderFactory;
  349. +import javax.xml.transform.OutputKeys;
  350. +import javax.xml.transform.Transformer;
  351. +import javax.xml.transform.TransformerException;
  352. +import javax.xml.transform.TransformerFactory;
  353. +import javax.xml.transform.dom.DOMSource;
  354. +import javax.xml.transform.stream.StreamResult;
  355. +
  356. +import org.w3c.dom.Document;
  357. +import org.w3c.dom.NamedNodeMap;
  358. +import org.w3c.dom.Node;
  359. +
  360. +import org.l2jmobius.gameserver.model.StatSet;
  361. +
  362. +/**
  363. + * An XML document, relying on a static and single DocumentBuilderFactory.
  364. + */
  365. +public abstract class XMLDocument
  366. +{
  367. +   protected static final Logger LOG = Logger.getLogger(XMLDocument.class.getName());
  368. +  
  369. +   protected Document document;
  370. +  
  371. +   private static final DocumentBuilderFactory BUILDER;
  372. +   static
  373. +   {
  374. +       BUILDER = DocumentBuilderFactory.newInstance();
  375. +       BUILDER.setValidating(false);
  376. +       BUILDER.setIgnoringComments(true);
  377. +   }
  378. +  
  379. +   abstract protected void load();
  380. +  
  381. +   abstract protected void parseDocument(Document doc, File f);
  382. +  
  383. +   public void loadDocument(String filePath)
  384. +   {
  385. +       loadDocument(new File(filePath));
  386. +   }
  387. +  
  388. +   public void writeDocument(Document doc, String fileName)
  389. +   {
  390. +       try
  391. +       {
  392. +           TransformerFactory transformerFactory = TransformerFactory.newInstance();
  393. +           Transformer transformer = transformerFactory.newTransformer();
  394. +           transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
  395. +           transformer.setOutputProperty(OutputKeys.INDENT, "yes");
  396. +           transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
  397. +          
  398. +           DOMSource source = new DOMSource(doc);
  399. +           StreamResult result = new StreamResult(new File(fileName));
  400. +          
  401. +           transformer.transform(source, result);
  402. +           LOG.info("XML file saved to " + fileName);
  403. +       }
  404. +       catch (TransformerException e)
  405. +       {
  406. +           LOG.warning("Error saving XML file: " + e.getMessage());
  407. +       }
  408. +   }
  409. +  
  410. +   /**
  411. +    * Parse an entire directory or file if found.
  412. +    * @param file
  413. +    */
  414. +   public void loadDocument(File file)
  415. +   {
  416. +       if (!file.exists())
  417. +       {
  418. +           LOG.severe("The following file or directory doesn't exist: " + file.getName());
  419. +           return;
  420. +       }
  421. +      
  422. +       if (file.isDirectory())
  423. +       {
  424. +           for (File f : file.listFiles())
  425. +           {
  426. +               loadDocument(f);
  427. +           }
  428. +       }
  429. +       else if (file.isFile())
  430. +       {
  431. +           try
  432. +           {
  433. +               parseDocument(BUILDER.newDocumentBuilder().parse(file), file);
  434. +           }
  435. +           catch (Exception e)
  436. +           {
  437. +               LOG.log(Level.SEVERE, "Error loading XML file " + file.getName(), e);
  438. +           }
  439. +       }
  440. +   }
  441. +  
  442. +   public Document getDocument()
  443. +   {
  444. +       return document;
  445. +   }
  446. +  
  447. +   /**
  448. +    * This method parses the content of a NamedNodeMap and feed the given StatsSet.
  449. +    * @param attrs : The NamedNodeMap to parse.
  450. +    * @param set : The StatsSet to feed.
  451. +    */
  452. +   public static void parseAndFeed(NamedNodeMap attrs, StatSet set)
  453. +   {
  454. +       for (int i = 0; i < attrs.getLength(); i++)
  455. +       {
  456. +           final Node attr = attrs.item(i);
  457. +           set.set(attr.getNodeName(), attr.getNodeValue());
  458. +       }
  459. +   }
  460. +}
  461. diff --git a/L2J_Mobius_C6_Interlude/java/Base/XML/XMLDocumentFactory.java b/L2J_Mobius_C6_Interlude/java/Base/XML/XMLDocumentFactory.java
  462. new file mode 100644
  463. index 0000000..9594e19
  464. --- /dev/null
  465. +++ b/L2J_Mobius_C6_Interlude/java/Base/XML/XMLDocumentFactory.java
  466. @@ -0,0 +1,74 @@
  467. +package Base.XML;
  468. +
  469. +import java.io.File;
  470. +
  471. +import javax.xml.parsers.DocumentBuilder;
  472. +import javax.xml.parsers.DocumentBuilderFactory;
  473. +
  474. +import org.w3c.dom.Document;
  475. +
  476. +/**
  477. + * @author Forsaiken
  478. + */
  479. +public final class XMLDocumentFactory
  480. +{
  481. +   public static final XMLDocumentFactory getInstance()
  482. +   {
  483. +       return SingletonHolder._instance;
  484. +   }
  485. +  
  486. +   private final DocumentBuilder _builder;
  487. +  
  488. +   protected XMLDocumentFactory() throws Exception
  489. +   {
  490. +       try
  491. +       {
  492. +           final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  493. +           factory.setValidating(false);
  494. +           factory.setIgnoringComments(true);
  495. +          
  496. +           _builder = factory.newDocumentBuilder();
  497. +       }
  498. +       catch (Exception e)
  499. +       {
  500. +           throw new Exception("Failed initializing", e);
  501. +       }
  502. +   }
  503. +  
  504. +   public final Document loadDocument(final String filePath) throws Exception
  505. +   {
  506. +       return loadDocument(new File(filePath));
  507. +   }
  508. +  
  509. +   public final Document loadDocument(final File file) throws Exception
  510. +   {
  511. +       if (!file.exists() || !file.isFile())
  512. +       {
  513. +           throw new Exception("File: " + file.getAbsolutePath() + " doesn't exist and/or is not a file.");
  514. +       }
  515. +      
  516. +       return _builder.parse(file);
  517. +   }
  518. +  
  519. +   public final Document newDocument()
  520. +   {
  521. +       return _builder.newDocument();
  522. +   }
  523. +  
  524. +   private static class SingletonHolder
  525. +   {
  526. +       protected static final XMLDocumentFactory _instance;
  527. +      
  528. +       static
  529. +       {
  530. +           try
  531. +           {
  532. +               _instance = new XMLDocumentFactory();
  533. +           }
  534. +           catch (Exception e)
  535. +           {
  536. +               throw new ExceptionInInitializerError(e);
  537. +           }
  538. +       }
  539. +   }
  540. +}
  541. \ No newline at end of file
  542. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
  543. index 0aff7d1..67ff047 100644
  544. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
  545. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
  546. @@ -128,6 +130,8 @@
  547.  import org.l2jmobius.gameserver.taskmanager.TaskManager;
  548.  import org.l2jmobius.gameserver.ui.Gui;
  549.  
  550. +import Base.ComboBox.ComboBoxData;
  551. +
  552.  public class GameServer
  553.  {
  554.     private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
  555. @@ -339,6 +343,9 @@
  556.         printSection("Access Levels");
  557.         AdminData.getInstance();
  558.        
  559. +       printSection("ComboBox Data");
  560. +       ComboBoxData.getInstance();
  561. +      
  562.         printSection("Handlers");
  563.         ItemHandler.getInstance();
  564.         SkillHandler.getInstance();
  565.  
  566. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/ItemHandler.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/ItemHandler.java
  567. index 6af36f0..b86f23f 100644
  568. --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/ItemHandler.java
  569. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/ItemHandler.java
  570. @@ -30,6 +30,7 @@
  571.  import org.l2jmobius.gameserver.handler.itemhandlers.CharChangePotions;
  572.  import org.l2jmobius.gameserver.handler.itemhandlers.ChestKey;
  573.  import org.l2jmobius.gameserver.handler.itemhandlers.ChristmasTree;
  574. +import org.l2jmobius.gameserver.handler.itemhandlers.ComboBoxHandler;
  575.  import org.l2jmobius.gameserver.handler.itemhandlers.CrystalCarol;
  576.  import org.l2jmobius.gameserver.handler.itemhandlers.Crystals;
  577.  import org.l2jmobius.gameserver.handler.itemhandlers.CustomPotions;
  578. @@ -106,6 +107,7 @@
  579.         registerItemHandler(new Maps());
  580.         registerItemHandler(new MercTicket());
  581.         registerItemHandler(new MOSKey());
  582. +       registerItemHandler(new ComboBoxHandler());
  583.         registerItemHandler(new MysteryPotion());
  584.         registerItemHandler(new Nectar());
  585.         registerItemHandler(new NobleCustomItem());
  586. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/ComboBoxHandler.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/ComboBoxHandler.java
  587. new file mode 100644
  588. index 0000000..9f88f55
  589. --- /dev/null
  590. +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/itemhandlers/ComboBoxHandler.java
  591. @@ -0,0 +1,241 @@
  592. +/*
  593. + * This file is part of the L2J Mobius project.
  594. + *
  595. + * This program is free software: you can redistribute it and/or modify
  596. + * it under the terms of the GNU General Public License as published by
  597. + * the Free Software Foundation, either version 3 of the License, or
  598. + * (at your option) any later version.
  599. + *
  600. + * This program is distributed in the hope that it will be useful,
  601. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  602. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  603. + * General Public License for more details.
  604. + *
  605. + * You should have received a copy of the GNU General Public License
  606. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  607. + */
  608. +package org.l2jmobius.gameserver.handler.itemhandlers;
  609. +
  610. +import org.l2jmobius.commons.util.Rnd;
  611. +import org.l2jmobius.gameserver.handler.IItemHandler;
  612. +import org.l2jmobius.gameserver.instancemanager.IdManager;
  613. +import org.l2jmobius.gameserver.model.actor.Playable;
  614. +import org.l2jmobius.gameserver.model.actor.Player;
  615. +import org.l2jmobius.gameserver.model.item.instance.Item;
  616. +
  617. +import Base.ComboBox.ComboBox;
  618. +import Base.ComboBox.ComboBoxData;
  619. +import Base.ComboBox.ComboBoxItem;
  620. +
  621. +/**
  622. + * @author Rouxy
  623. + */
  624. +public class ComboBoxHandler implements IItemHandler
  625. +{
  626. +  
  627. +   private static final int ITEM_IDS[] =
  628. +   {
  629. +       19000,
  630. +       19001,
  631. +       19002,
  632. +       19003,
  633. +       19004,
  634. +       19005,
  635. +       19006,
  636. +       19007,
  637. +       19008,
  638. +       19009,
  639. +       19010,
  640. +       19011,
  641. +       19012,
  642. +       19013,
  643. +       19014,
  644. +       19015,
  645. +       19016,
  646. +       19017,
  647. +       19018,
  648. +       19019,
  649. +       19020,
  650. +       19021,
  651. +       19022,
  652. +       19023,
  653. +       19024,
  654. +       19025,
  655. +       19026,
  656. +       19027,
  657. +       19028,
  658. +       19029,
  659. +       19030,
  660. +       19031,
  661. +       19033,
  662. +       19034,
  663. +       19035,
  664. +       19036,
  665. +       19037,
  666. +       19038,
  667. +       19039,
  668. +       19040,
  669. +       19041,
  670. +       19042,
  671. +       19043,
  672. +       19044,
  673. +       19045,
  674. +       19046,
  675. +       19047,
  676. +       19048,
  677. +       19049,
  678. +       19050,
  679. +       19051,
  680. +       19052,
  681. +       19053,
  682. +       19054,
  683. +       19055,
  684. +       19056,
  685. +       19057,
  686. +       19058,
  687. +       19059,
  688. +       19060,
  689. +       19061,
  690. +       19062,
  691. +       19063,
  692. +       19064,
  693. +       19065,
  694. +       19066,
  695. +       19067,
  696. +       19068,
  697. +       19069,
  698. +       19070,
  699. +       19071,
  700. +       19072,
  701. +       19073,
  702. +       19074,
  703. +       19075,
  704. +       19076,
  705. +       19077,
  706. +       19078,
  707. +       19079,
  708. +       19080,
  709. +       19081,
  710. +       19082,
  711. +       19083,
  712. +       19084,
  713. +       19085,
  714. +       19086,
  715. +       19087,
  716. +       19088,
  717. +       19089,
  718. +       19090,
  719. +       19091,
  720. +       19092,
  721. +       19093,
  722. +       19094,
  723. +       19095,
  724. +       19096,
  725. +       19097,
  726. +       19098,
  727. +       19099,
  728. +       19100,
  729. +       19101,
  730. +       19102,
  731. +       19103,
  732. +       19104,
  733. +       19105,
  734. +       19106,
  735. +       19107,
  736. +       19108,
  737. +       19109,
  738. +       19110,
  739. +       19111,
  740. +       19112,
  741. +       19113,
  742. +       19114,
  743. +       19115,
  744. +       19116,
  745. +       19117,
  746. +       19118,
  747. +       19119,
  748. +       19120,
  749. +       19121,
  750. +       19122,
  751. +       19123,
  752. +       19124,
  753. +       19125,
  754. +       19126,
  755. +       19127,
  756. +       19128,
  757. +       19129,
  758. +       19130,
  759. +       19131,
  760. +       19132,
  761. +       19133,
  762. +       19134,
  763. +       19135,
  764. +       19136,
  765. +       19137,
  766. +       19138,
  767. +       19139,
  768. +       19140,
  769. +       19141,
  770. +       15020,
  771. +       29142
  772. +  
  773. +   };
  774. +  
  775. +   @Override
  776. +   public void useItem(Playable playable, Item item)
  777. +   {
  778. +       if (!(playable instanceof Player))
  779. +       {
  780. +           return;
  781. +       }
  782. +      
  783. +       final Player activeChar = (Player) playable;
  784. +       final int itemId = item.getItemId();
  785. +      
  786. +       ComboBox comboBox = ComboBoxData.getInstance().getComboBoxById(itemId);
  787. +       if (comboBox != null)
  788. +       {
  789. +           Item toGive = null;
  790. +           for (ComboBoxItem boxItem : comboBox.getComboBoxItems())
  791. +           {
  792. +               toGive = new Item(IdManager.getInstance().getNextId(), boxItem.getId());
  793. +               int random = Rnd.get(100);
  794. +               if (random < boxItem.getChance())
  795. +               {
  796. +                   if (!toGive.isStackable())
  797. +                   {
  798. +                       toGive.setEnchantLevel(boxItem.getEnchantLevel());
  799. +                       activeChar.addItem("ComboBox", toGive, activeChar, true);
  800. +                      
  801. +                   }
  802. +                   else
  803. +                   {
  804. +                       activeChar.addItem("ComboBox", boxItem.getId(), boxItem.getAmount(), activeChar, true);
  805. +                   }
  806. +                  
  807. +               }
  808. +               else
  809. +               {
  810. +                   activeChar.sendMessage("You were out of luck opening the item " + toGive.getName());
  811. +               }
  812. +               activeChar.sendMessage(toGive.getName() + " chance: " + boxItem.getChance());
  813. +              
  814. +           }
  815. +          
  816. +           activeChar.sendMessage("You used a combo box type item!");
  817. +       }
  818. +       else
  819. +       {
  820. +           activeChar.sendMessage("This Combo box expired or is invalid!");
  821. +       }
  822. +      
  823. +       playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
  824. +   }
  825. +  
  826. +   @Override
  827. +   public int[] getItemIds()
  828. +   {
  829. +       return ITEM_IDS;
  830. +   }
  831. +  
  832. +}
  833. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement