L2GameServerPacket.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 java.util.logging.Level;
  21. import java.util.logging.Logger;
  22. import com.l2jserver.gameserver.model.interfaces.IPositionable;
  23. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  24. import com.l2jserver.gameserver.network.L2GameClient;
  25. import com.l2jserver.mmocore.SendablePacket;
  26. /**
  27. * @author KenM
  28. */
  29. public abstract class L2GameServerPacket extends SendablePacket<L2GameClient>
  30. {
  31. protected static final Logger _log = Logger.getLogger(L2GameServerPacket.class.getName());
  32. private boolean _invisible = false;
  33. private static final int[] PAPERDOLL_ORDER = new int[]
  34. {
  35. Inventory.PAPERDOLL_UNDER,
  36. Inventory.PAPERDOLL_REAR,
  37. Inventory.PAPERDOLL_LEAR,
  38. Inventory.PAPERDOLL_NECK,
  39. Inventory.PAPERDOLL_RFINGER,
  40. Inventory.PAPERDOLL_LFINGER,
  41. Inventory.PAPERDOLL_HEAD,
  42. Inventory.PAPERDOLL_RHAND,
  43. Inventory.PAPERDOLL_LHAND,
  44. Inventory.PAPERDOLL_GLOVES,
  45. Inventory.PAPERDOLL_CHEST,
  46. Inventory.PAPERDOLL_LEGS,
  47. Inventory.PAPERDOLL_FEET,
  48. Inventory.PAPERDOLL_CLOAK,
  49. Inventory.PAPERDOLL_RHAND,
  50. Inventory.PAPERDOLL_HAIR,
  51. Inventory.PAPERDOLL_HAIR2,
  52. Inventory.PAPERDOLL_RBRACELET,
  53. Inventory.PAPERDOLL_LBRACELET,
  54. Inventory.PAPERDOLL_DECO1,
  55. Inventory.PAPERDOLL_DECO2,
  56. Inventory.PAPERDOLL_DECO3,
  57. Inventory.PAPERDOLL_DECO4,
  58. Inventory.PAPERDOLL_DECO5,
  59. Inventory.PAPERDOLL_DECO6,
  60. Inventory.PAPERDOLL_BELT
  61. };
  62. /**
  63. * @return True if packet originated from invisible character.
  64. */
  65. public boolean isInvisible()
  66. {
  67. return _invisible;
  68. }
  69. /**
  70. * Set "invisible" boolean flag in the packet.<br>
  71. * Packets from invisible characters will not be broadcasted to players.
  72. * @param b
  73. */
  74. public void setInvisible(boolean b)
  75. {
  76. _invisible = b;
  77. }
  78. /**
  79. * Writes 3 D (int32) with current location x, y, z
  80. * @param loc
  81. */
  82. protected void writeLoc(IPositionable loc)
  83. {
  84. writeD(loc.getX());
  85. writeD(loc.getY());
  86. writeD(loc.getZ());
  87. }
  88. protected int[] getPaperdollOrder()
  89. {
  90. return PAPERDOLL_ORDER;
  91. }
  92. @Override
  93. protected void write()
  94. {
  95. try
  96. {
  97. writeImpl();
  98. }
  99. catch (Exception e)
  100. {
  101. _log.log(Level.SEVERE, "Client: " + getClient().toString() + " - Failed writing: " + getClass().getSimpleName() + " ; " + e.getMessage(), e);
  102. }
  103. }
  104. public void runImpl()
  105. {
  106. }
  107. protected abstract void writeImpl();
  108. }