NpcHtmlMessage.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server 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 Server 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 com.l2jserver.gameserver.network.serverpackets;
  20. import com.l2jserver.gameserver.enums.HtmlActionScope;
  21. /**
  22. * NpcHtmlMessage server packet implementation.
  23. * @author HorridoJoho
  24. */
  25. public final class NpcHtmlMessage extends AbstractHtmlPacket
  26. {
  27. private final int _itemId;
  28. public NpcHtmlMessage()
  29. {
  30. _itemId = 0;
  31. }
  32. public NpcHtmlMessage(int npcObjId)
  33. {
  34. super(npcObjId);
  35. _itemId = 0;
  36. }
  37. public NpcHtmlMessage(String html)
  38. {
  39. super(html);
  40. _itemId = 0;
  41. }
  42. public NpcHtmlMessage(int npcObjId, String html)
  43. {
  44. super(npcObjId, html);
  45. _itemId = 0;
  46. }
  47. public NpcHtmlMessage(int npcObjId, int itemId)
  48. {
  49. super(npcObjId);
  50. if (itemId < 0)
  51. {
  52. throw new IllegalArgumentException();
  53. }
  54. _itemId = itemId;
  55. }
  56. public NpcHtmlMessage(int npcObjId, int itemId, String html)
  57. {
  58. super(npcObjId, html);
  59. if (itemId < 0)
  60. {
  61. throw new IllegalArgumentException();
  62. }
  63. _itemId = itemId;
  64. }
  65. @Override
  66. protected final void writeImpl()
  67. {
  68. writeC(0x19);
  69. writeD(getNpcObjId());
  70. writeS(getHtml());
  71. writeD(_itemId);
  72. }
  73. @Override
  74. public HtmlActionScope getScope()
  75. {
  76. return _itemId == 0 ? HtmlActionScope.NPC_HTML : HtmlActionScope.NPC_ITEM_HTML;
  77. }
  78. }