L2DoorInstanceActionShift.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.actionshifthandlers;
  20. import com.l2jserver.gameserver.enums.InstanceType;
  21. import com.l2jserver.gameserver.handler.IActionShiftHandler;
  22. import com.l2jserver.gameserver.model.L2Object;
  23. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  26. import com.l2jserver.gameserver.network.serverpackets.StaticObject;
  27. public class L2DoorInstanceActionShift implements IActionShiftHandler
  28. {
  29. @Override
  30. public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
  31. {
  32. if (activeChar.getAccessLevel().isGm())
  33. {
  34. activeChar.setTarget(target);
  35. L2DoorInstance door = (L2DoorInstance) target;
  36. activeChar.sendPacket(new StaticObject(door, activeChar.isGM()));
  37. final NpcHtmlMessage html = new NpcHtmlMessage();
  38. html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/doorinfo.htm");
  39. html.replace("%class%", target.getClass().getSimpleName());
  40. html.replace("%hp%", String.valueOf((int) door.getCurrentHp()));
  41. html.replace("%hpmax%", String.valueOf(door.getMaxHp()));
  42. html.replace("%objid%", String.valueOf(target.getObjectId()));
  43. html.replace("%doorid%", String.valueOf(door.getId()));
  44. html.replace("%minx%", String.valueOf(door.getX(0)));
  45. html.replace("%miny%", String.valueOf(door.getY(0)));
  46. html.replace("%minz%", String.valueOf(door.getZMin()));
  47. html.replace("%maxx%", String.valueOf(door.getX(2)));
  48. html.replace("%maxy%", String.valueOf(door.getY(2)));
  49. html.replace("%maxz%", String.valueOf(door.getZMax()));
  50. html.replace("%unlock%", door.isOpenableBySkill() ? "<font color=00FF00>YES<font>" : "<font color=FF0000>NO</font>");
  51. activeChar.sendPacket(html);
  52. }
  53. return true;
  54. }
  55. @Override
  56. public InstanceType getInstanceType()
  57. {
  58. return InstanceType.L2DoorInstance;
  59. }
  60. }