AdminDelete.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 net.sf.l2j.gameserver.handler.admincommandhandlers;
  16. import net.sf.l2j.gameserver.datatables.SpawnTable;
  17. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  18. import net.sf.l2j.gameserver.instancemanager.RaidBossSpawnManager;
  19. import net.sf.l2j.gameserver.model.L2Object;
  20. import net.sf.l2j.gameserver.model.L2Spawn;
  21. import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  23. /**
  24. * This class handles following admin commands: - delete = deletes target
  25. *
  26. * @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
  27. */
  28. public class AdminDelete implements IAdminCommandHandler
  29. {
  30. //private static Logger _log = Logger.getLogger(AdminDelete.class.getName());
  31. private static final String[] ADMIN_COMMANDS = {"admin_delete"};
  32. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  33. {
  34. if (command.equals("admin_delete")) handleDelete(activeChar);
  35. return true;
  36. }
  37. public String[] getAdminCommandList()
  38. {
  39. return ADMIN_COMMANDS;
  40. }
  41. // TODO: add possibility to delete any L2Object (except L2PcInstance)
  42. private void handleDelete(L2PcInstance activeChar)
  43. {
  44. L2Object obj = activeChar.getTarget();
  45. if (obj instanceof L2NpcInstance)
  46. {
  47. L2NpcInstance target = (L2NpcInstance) obj;
  48. target.deleteMe();
  49. L2Spawn spawn = target.getSpawn();
  50. if (spawn != null)
  51. {
  52. spawn.stopRespawn();
  53. if (RaidBossSpawnManager.getInstance().isDefined(spawn.getNpcid())) RaidBossSpawnManager.getInstance().deleteSpawn(
  54. spawn,
  55. true);
  56. else SpawnTable.getInstance().deleteSpawn(spawn, true);
  57. }
  58. activeChar.sendMessage("Deleted " + target.getName() + " from " + target.getObjectId() + ".");
  59. }
  60. else
  61. activeChar.sendMessage("Incorrect target.");
  62. }
  63. }