L2DoorInstanceActionShift.java 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.actionhandlers;
  16. import com.l2jserver.gameserver.handler.IActionHandler;
  17. import com.l2jserver.gameserver.model.L2Object;
  18. import com.l2jserver.gameserver.model.L2Object.InstanceType;
  19. import com.l2jserver.gameserver.model.actor.L2Character;
  20. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
  23. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  24. import com.l2jserver.gameserver.network.serverpackets.StaticObject;
  25. public class L2DoorInstanceActionShift implements IActionHandler
  26. {
  27. public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
  28. {
  29. if (activeChar.getAccessLevel().isGm())
  30. {
  31. activeChar.setTarget(target);
  32. activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel()));
  33. StaticObject su;
  34. // send HP amount if doors are inside castle/fortress zone
  35. // TODO: needed to be added here doors from conquerable clanhalls
  36. if ((((L2DoorInstance)target).getCastle() != null
  37. && ((L2DoorInstance)target).getCastle().getCastleId() > 0)
  38. || (((L2DoorInstance)target).getFort() != null
  39. && ((L2DoorInstance)target).getFort().getFortId() > 0
  40. && !((L2DoorInstance)target).getIsCommanderDoor()))
  41. su = new StaticObject((L2DoorInstance)target, true);
  42. else
  43. su = new StaticObject((L2DoorInstance)target, false);
  44. activeChar.sendPacket(su);
  45. NpcHtmlMessage html = new NpcHtmlMessage(0);
  46. html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/doorinfo.htm");
  47. html.replace("%class%", target.getClass().getSimpleName());
  48. html.replace("%hp%", String.valueOf((int)((L2Character)target).getCurrentHp()));
  49. html.replace("%hpmax%", String.valueOf(((L2Character)target).getMaxHp()));
  50. html.replace("%objid%", String.valueOf(target.getObjectId()));
  51. html.replace("%doorid%", String.valueOf(((L2DoorInstance)target).getDoorId()));
  52. html.replace("%minx%", String.valueOf(((L2DoorInstance)target).getXMin()));
  53. html.replace("%miny%", String.valueOf(((L2DoorInstance)target).getYMin()));
  54. html.replace("%minz%", String.valueOf(((L2DoorInstance)target).getZMin()));
  55. html.replace("%maxx%", String.valueOf(((L2DoorInstance)target).getXMax()));
  56. html.replace("%maxy%", String.valueOf(((L2DoorInstance)target).getYMax()));
  57. html.replace("%maxz%", String.valueOf(((L2DoorInstance)target).getZMax()));
  58. html.replace("%unlock%", ((L2DoorInstance)target).isUnlockable() ? "<font color=00FF00>YES<font>" : "<font color=FF0000>NO</font>");
  59. activeChar.sendPacket(html);
  60. }
  61. return true;
  62. }
  63. public InstanceType getInstanceType()
  64. {
  65. return InstanceType.L2DoorInstance;
  66. }
  67. }