Banking.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * @author Ahmed
  22. */
  23. public class Banking implements IVoicedCommandHandler
  24. {
  25. private static final String[] _voicedCommands =
  26. {
  27. "bank",
  28. "withdraw",
  29. "deposit"
  30. };
  31. @Override
  32. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  33. {
  34. if (command.equals("bank"))
  35. {
  36. activeChar.sendMessage(".deposit (" + Config.BANKING_SYSTEM_ADENA + " Adena = " + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar) / .withdraw (" + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar = " + Config.BANKING_SYSTEM_ADENA + " Adena)");
  37. }
  38. else if (command.equals("deposit"))
  39. {
  40. if (activeChar.getInventory().getInventoryItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
  41. {
  42. if (!activeChar.reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, activeChar, false))
  43. {
  44. return false;
  45. }
  46. activeChar.getInventory().addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, null);
  47. activeChar.getInventory().updateDatabase();
  48. activeChar.sendMessage("Thank you, you now have " + Config.BANKING_SYSTEM_GOLDBARS + " Goldbar(s), and " + Config.BANKING_SYSTEM_ADENA + " less adena.");
  49. }
  50. else
  51. {
  52. activeChar.sendMessage("You do not have enough Adena to convert to Goldbar(s), you need " + Config.BANKING_SYSTEM_ADENA + " Adena.");
  53. }
  54. }
  55. else if (command.equals("withdraw"))
  56. {
  57. if (activeChar.getInventory().getInventoryItemCount(3470, 0) >= Config.BANKING_SYSTEM_GOLDBARS)
  58. {
  59. if (!activeChar.destroyItemByItemId("Adena", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, false))
  60. {
  61. return false;
  62. }
  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. @Override
  75. public String[] getVoicedCommandList()
  76. {
  77. return _voicedCommands;
  78. }
  79. }