RequestCursedWeaponLocation.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.List;
  17. import javolution.util.FastList;
  18. import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
  19. import com.l2jserver.gameserver.model.CursedWeapon;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponLocation;
  22. import com.l2jserver.gameserver.network.serverpackets.ExCursedWeaponLocation.CursedWeaponInfo;
  23. import com.l2jserver.util.Point3D;
  24. /**
  25. * Format: (ch)
  26. * @author -Wooden-
  27. */
  28. public final class RequestCursedWeaponLocation extends L2GameClientPacket
  29. {
  30. private static final String _C__D0_23_REQUESTCURSEDWEAPONLOCATION = "[C] D0:23 RequestCursedWeaponLocation";
  31. @Override
  32. protected void readImpl()
  33. {
  34. //nothing to read it's just a trigger
  35. }
  36. /**
  37. * @see com.l2jserver.util.network.BaseRecievePacket.ClientBasePacket#runImpl()
  38. */
  39. @Override
  40. protected void runImpl()
  41. {
  42. L2Character activeChar = getClient().getActiveChar();
  43. if (activeChar == null)
  44. return;
  45. List<CursedWeaponInfo> list = new FastList<CursedWeaponInfo>();
  46. for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
  47. {
  48. if (!cw.isActive())
  49. continue;
  50. Point3D pos = cw.getWorldPosition();
  51. if (pos != null)
  52. list.add(new CursedWeaponInfo(pos, cw.getItemId(), cw.isActivated() ? 1 : 0));
  53. }
  54. //send the ExCursedWeaponLocation
  55. if (!list.isEmpty())
  56. activeChar.sendPacket(new ExCursedWeaponLocation(list));
  57. }
  58. /**
  59. * @see com.l2jserver.gameserver.BasePacket#getType()
  60. */
  61. @Override
  62. public String getType()
  63. {
  64. return _C__D0_23_REQUESTCURSEDWEAPONLOCATION;
  65. }
  66. @Override
  67. protected boolean triggersOnActionRequest()
  68. {
  69. return false;
  70. }
  71. }