AdminInvul.java 2.5 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.admincommandhandlers;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.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. {
  39. handleInvul(activeChar);
  40. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  41. }
  42. if (command.equals("admin_setinvul"))
  43. {
  44. L2Object target = activeChar.getTarget();
  45. if (target instanceof L2PcInstance)
  46. {
  47. handleInvul((L2PcInstance) target);
  48. }
  49. }
  50. return true;
  51. }
  52. public String[] getAdminCommandList()
  53. {
  54. return ADMIN_COMMANDS;
  55. }
  56. private void handleInvul(L2PcInstance activeChar)
  57. {
  58. String text;
  59. if (activeChar.isInvul())
  60. {
  61. activeChar.setIsInvul(false);
  62. text = activeChar.getName() + " is now mortal";
  63. if (Config.DEBUG)
  64. _log.fine("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
  65. }
  66. else
  67. {
  68. activeChar.setIsInvul(true);
  69. text = activeChar.getName() + " is now invulnerable";
  70. if (Config.DEBUG)
  71. _log.fine("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
  72. }
  73. activeChar.sendMessage(text);
  74. }
  75. }