L2GameServerPacket.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 com.l2jserver.gameserver.network.serverpackets;
  16. import java.util.logging.Logger;
  17. import org.mmocore.network.SendablePacket;
  18. import com.l2jserver.Config;
  19. import com.l2jserver.gameserver.network.L2GameClient;
  20. /**
  21. *
  22. * @author KenM
  23. */
  24. public abstract class L2GameServerPacket extends SendablePacket<L2GameClient>
  25. {
  26. private static final Logger _log = Logger.getLogger(L2GameServerPacket.class.getName());
  27. protected boolean _invisible = false;
  28. /**
  29. *
  30. * @return True if packet originated from invisible character.
  31. */
  32. public boolean isInvisible()
  33. {
  34. return _invisible;
  35. }
  36. /**
  37. * Set "invisible" boolean flag in the packet.
  38. * Packets from invisible characters will not be broadcasted to players.
  39. * @param b
  40. */
  41. public void setInvisible(boolean b)
  42. {
  43. _invisible = b;
  44. }
  45. /**
  46. * @see com.l2jserver.mmocore.network.SendablePacket#write()
  47. */
  48. @Override
  49. protected void write()
  50. {
  51. try
  52. {
  53. //_log.info(this.getType());
  54. writeImpl();
  55. }
  56. catch (Exception e)
  57. {
  58. _log.severe("Client: "+getClient().toString()+" - Failed writing: "+getType()+" - L2J Server Version: "+Config.SERVER_VERSION+" - DP Revision: "+Config.DATAPACK_VERSION);
  59. e.printStackTrace();
  60. }
  61. }
  62. public void runImpl()
  63. {
  64. }
  65. protected abstract void writeImpl();
  66. /**
  67. * @return A String with this packet name for debuging purposes
  68. */
  69. public abstract String getType();
  70. }