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