RequestExRqItemLink.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.clientpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.model.L2ItemInstance;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. import com.l2jserver.gameserver.model.L2World;
  21. import com.l2jserver.gameserver.network.L2GameClient;
  22. import com.l2jserver.gameserver.network.serverpackets.ExRpItemLink;
  23. /**
  24. *
  25. * @author KenM
  26. */
  27. public class RequestExRqItemLink extends L2GameClientPacket
  28. {
  29. private static String name = "[C] DO:1E RequestExRqItemLink";
  30. private int _objectId;
  31. private Logger _log = Logger.getLogger(RequestExRqItemLink.class.getName());
  32. /**
  33. * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#getType()
  34. */
  35. @Override
  36. public String getType()
  37. {
  38. return name;
  39. }
  40. /**
  41. * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#readImpl()
  42. */
  43. @Override
  44. protected void readImpl()
  45. {
  46. _objectId = readD();
  47. }
  48. /**
  49. * @see com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket#runImpl()
  50. */
  51. @Override
  52. protected void runImpl()
  53. {
  54. L2GameClient client = this.getClient();
  55. if (client != null)
  56. {
  57. L2Object object = L2World.getInstance().findObject(_objectId);
  58. if (object instanceof L2ItemInstance)
  59. {
  60. L2ItemInstance item = (L2ItemInstance)object;
  61. if (item.isPublished())
  62. {
  63. client.sendPacket(new ExRpItemLink(item));
  64. }
  65. else
  66. {
  67. if (Config.DEBUG)
  68. _log.info(getClient()+" requested "+name+" for item which wasnt published! ID:"+_objectId);
  69. }
  70. }
  71. }
  72. }
  73. }