2
0

AdminInvul.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 java.util.logging.Logger;
  17. import net.sf.l2j.Config;
  18. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  19. import net.sf.l2j.gameserver.model.L2Object;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. /**
  22. * This class handles following admin commands:
  23. * - invul = turns invulnerability on/off
  24. *
  25. * @version $Revision: 1.2.4.4 $ $Date: 2007/07/31 10:06:02 $
  26. */
  27. public class AdminInvul implements IAdminCommandHandler
  28. {
  29. private static Logger _log = Logger.getLogger(AdminInvul.class.getName());
  30. private static final String[] ADMIN_COMMANDS =
  31. {
  32. "admin_invul",
  33. "admin_setinvul"
  34. };
  35. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  36. {
  37. if (command.equals("admin_invul"))
  38. handleInvul(activeChar);
  39. if (command.equals("admin_setinvul"))
  40. {
  41. L2Object target = activeChar.getTarget();
  42. if (target instanceof L2PcInstance)
  43. {
  44. handleInvul((L2PcInstance) target);
  45. }
  46. }
  47. return true;
  48. }
  49. public String[] getAdminCommandList()
  50. {
  51. return ADMIN_COMMANDS;
  52. }
  53. private void handleInvul(L2PcInstance activeChar)
  54. {
  55. String text;
  56. if (activeChar.isInvul())
  57. {
  58. activeChar.setIsInvul(false);
  59. text = activeChar.getName() + " is now mortal";
  60. if (Config.DEBUG)
  61. _log.fine("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
  62. }
  63. else
  64. {
  65. activeChar.setIsInvul(true);
  66. text = activeChar.getName() + " is now invulnerable";
  67. if (Config.DEBUG)
  68. _log.fine("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
  69. }
  70. activeChar.sendMessage(text);
  71. }
  72. }