Banking.java 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package handlers.voicedcommandhandlers;
  16. import com.l2jserver.Config;
  17. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. /**
  20. * This class trades Gold Bars for Adena and vice versa.
  21. *
  22. * @author Ahmed
  23. */
  24. public class Banking implements IVoicedCommandHandler
  25. {
  26. private static final String[] _voicedCommands =
  27. {
  28. "bank",
  29. "withdraw",
  30. "deposit"
  31. };
  32. /**
  33. *
  34. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  35. */
  36. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  37. {
  38. if (command.equalsIgnoreCase("bank"))
  39. {
  40. activeChar.sendMessage(".deposit (" + Config.BANKING_SYSTEM_ADENA + " Adena = " + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar) / .withdraw (" + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar = " + Config.BANKING_SYSTEM_ADENA + " Adena)");
  41. }
  42. else if (command.equalsIgnoreCase("deposit"))
  43. {
  44. if (activeChar.getInventory().getInventoryItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
  45. {
  46. if (!activeChar.reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, activeChar, false))
  47. return false;
  48. activeChar.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, null);
  49. activeChar.getInventory().updateDatabase();
  50. activeChar.sendMessage("Thank you, you now have " + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar(s), and " + Config.BANKING_SYSTEM_ADENA + " less adena.");
  51. }
  52. else
  53. {
  54. activeChar.sendMessage("You do not have enough Adena to convert to Goldbar(s), you need " + Config.BANKING_SYSTEM_ADENA + " Adena.");
  55. }
  56. }
  57. else if (command.equalsIgnoreCase("withdraw"))
  58. {
  59. if (activeChar.getInventory().getInventoryItemCount(3470, 0) >= Config.BANKING_SYSTEM_GOLDBARS)
  60. {
  61. if (!activeChar.destroyItemByItemId("Adena", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, false))
  62. return false;
  63. activeChar.getInventory().addAdena("Adena", Config.BANKING_SYSTEM_ADENA, activeChar, null);
  64. activeChar.getInventory().updateDatabase();
  65. activeChar.sendMessage("Thank you, you now have " + Config.BANKING_SYSTEM_ADENA + " Adena, and " + Config.BANKING_SYSTEM_GOLDBARS + " less Goldbar(s).");
  66. }
  67. else
  68. {
  69. activeChar.sendMessage("You do not have any Goldbars to turn into " + Config.BANKING_SYSTEM_ADENA + " Adena.");
  70. }
  71. }
  72. return true;
  73. }
  74. /**
  75. *
  76. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
  77. */
  78. public String[] getVoicedCommandList()
  79. {
  80. return _voicedCommands;
  81. }
  82. }