AdminInvul.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. private static Logger _log = Logger.getLogger(AdminInvul.class.getName());
  29. private static final String[] ADMIN_COMMANDS = {"admin_invul", "admin_setinvul"};
  30. public boolean useAdminCommand(String command, L2PcInstance activeChar) {
  31. if (command.equals("admin_invul")) handleInvul(activeChar);
  32. if (command.equals("admin_setinvul")){
  33. L2Object target = activeChar.getTarget();
  34. if (target instanceof L2PcInstance){
  35. handleInvul((L2PcInstance)target);
  36. }
  37. }
  38. return true;
  39. }
  40. public String[] getAdminCommandList() {
  41. return ADMIN_COMMANDS;
  42. }
  43. private void handleInvul(L2PcInstance activeChar) {
  44. String text;
  45. if (activeChar.isInvul())
  46. {
  47. activeChar.setIsInvul(false);
  48. text = activeChar.getName() + " is now mortal";
  49. if (Config.DEBUG)
  50. _log.fine("GM: Gm removed invul mode from character "+activeChar.getName()+"("+activeChar.getObjectId()+")");
  51. } else
  52. {
  53. activeChar.setIsInvul(true);
  54. text = activeChar.getName() + " is now invulnerable";
  55. if (Config.DEBUG)
  56. _log.fine("GM: Gm activated invul mode for character "+activeChar.getName()+"("+activeChar.getObjectId()+")");
  57. }
  58. activeChar.sendMessage(text);
  59. }
  60. }