BaseReadPacket.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.communityserver.network.netcon;
  16. import com.l2jserver.communityserver.util.buffer.AbstractBufferedByteReader;
  17. import com.l2jserver.communityserver.util.buffer.BufferedByteReader;
  18. public abstract class BaseReadPacket implements Runnable
  19. {
  20. private final AbstractBufferedByteReader _buf;
  21. protected BaseReadPacket(final byte[] data)
  22. {
  23. _buf = new BufferedByteReader(data);
  24. _buf.readH();
  25. }
  26. /** BYTE */
  27. protected final int readC()
  28. {
  29. return _buf.readC();
  30. }
  31. /** CHAR */
  32. protected final int readH()
  33. {
  34. return _buf.readH();
  35. }
  36. /** INTEGER */
  37. protected final int readD()
  38. {
  39. return _buf.readD();
  40. }
  41. /** DOUBLE */
  42. protected final double readF()
  43. {
  44. return _buf.readF();
  45. }
  46. /** LONG */
  47. protected final long readQ()
  48. {
  49. return _buf.readQ();
  50. }
  51. /** BYTE ARRAY */
  52. protected final byte[] readB(final int length)
  53. {
  54. return _buf.readB(length);
  55. }
  56. /** STRING */
  57. protected final String readS()
  58. {
  59. return _buf.readS();
  60. }
  61. }