AdminInvul.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. @Override
  36. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  37. {
  38. if (command.equals("admin_invul"))
  39. {
  40. handleInvul(activeChar);
  41. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  42. }
  43. if (command.equals("admin_setinvul"))
  44. {
  45. L2Object target = activeChar.getTarget();
  46. if (target instanceof L2PcInstance)
  47. {
  48. handleInvul((L2PcInstance) target);
  49. }
  50. }
  51. return true;
  52. }
  53. @Override
  54. public String[] getAdminCommandList()
  55. {
  56. return ADMIN_COMMANDS;
  57. }
  58. private void handleInvul(L2PcInstance activeChar)
  59. {
  60. String text;
  61. if (activeChar.isInvul())
  62. {
  63. activeChar.setIsInvul(false);
  64. text = activeChar.getName() + " is now mortal";
  65. if (Config.DEBUG)
  66. _log.fine("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
  67. }
  68. else
  69. {
  70. activeChar.setIsInvul(true);
  71. text = activeChar.getName() + " is now invulnerable";
  72. if (Config.DEBUG)
  73. _log.fine("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
  74. }
  75. activeChar.sendMessage(text);
  76. }
  77. }