AdminSummon.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.admincommandhandlers;
  20. import java.util.logging.Logger;
  21. import com.l2jserver.gameserver.data.xml.impl.AdminData;
  22. import com.l2jserver.gameserver.handler.AdminCommandHandler;
  23. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. /**
  26. * @author poltomb
  27. */
  28. public class AdminSummon implements IAdminCommandHandler
  29. {
  30. private static final Logger _log = Logger.getLogger(AdminSummon.class.getName());
  31. public static final String[] ADMIN_COMMANDS =
  32. {
  33. "admin_summon"
  34. };
  35. @Override
  36. public String[] getAdminCommandList()
  37. {
  38. return ADMIN_COMMANDS;
  39. }
  40. @Override
  41. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  42. {
  43. int id;
  44. int count = 1;
  45. String[] data = command.split(" ");
  46. try
  47. {
  48. id = Integer.parseInt(data[1]);
  49. if (data.length > 2)
  50. {
  51. count = Integer.parseInt(data[2]);
  52. }
  53. }
  54. catch (NumberFormatException nfe)
  55. {
  56. activeChar.sendMessage("Incorrect format for command 'summon'");
  57. return false;
  58. }
  59. String subCommand;
  60. if (id < 1000000)
  61. {
  62. subCommand = "admin_create_item";
  63. if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
  64. {
  65. activeChar.sendMessage("You don't have the access right to use this command!");
  66. _log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
  67. return false;
  68. }
  69. IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
  70. ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
  71. }
  72. else
  73. {
  74. subCommand = "admin_spawn_once";
  75. if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
  76. {
  77. activeChar.sendMessage("You don't have the access right to use this command!");
  78. _log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
  79. return false;
  80. }
  81. IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
  82. activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
  83. id -= 1000000;
  84. ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
  85. }
  86. return true;
  87. }
  88. }