Guest User

ClanRepsItem

a guest
Oct 15th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2, or (at your option)
  5. * any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. * 02111-1307, USA.
  16. *
  17. * http://www.gnu.org/copyleft/gpl.html
  18. */
  19. package net.sf.l2j.gameserver.handler.itemhandlers;
  20.  
  21. /**
  22. *
  23. *
  24. * @author Coyote
  25. * Adapted by Strike
  26. */
  27.  
  28.  
  29. import net.sf.l2j.Config;
  30. import net.sf.l2j.gameserver.handler.IItemHandler;
  31. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  32. import net.sf.l2j.gameserver.model.actor.Playable;
  33. import net.sf.l2j.gameserver.model.actor.Player;
  34. import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  35.  
  36. public class ClanRepsItem implements IItemHandler
  37. {
  38. private static final int ITEM_IDS[] =
  39. {
  40. Config.CR_ITEM_REPS_ITEM_ID
  41. };
  42.  
  43. public void useItem(Playable playable, ItemInstance item)
  44. {
  45. if (!(playable instanceof Player))
  46. {
  47. return;
  48. }
  49.  
  50. Player activeChar = (Player)playable;
  51.  
  52. if (!activeChar.isClanLeader())
  53. {
  54. activeChar.sendMessage("This can be used only by Clan Leaders!");
  55. return;
  56. }
  57.  
  58. else if (!(activeChar.getClan().getLevel() >= Config.CR_ITEM_MIN_CLAN_LVL))
  59. {
  60. activeChar.sendMessage("Your Clan Level is not big enough to use this item!");
  61. return;
  62. }
  63. else
  64. {
  65. activeChar.getClan().setReputationScore(activeChar.getClan().getReputationScore()+Config.CR_ITEM_REPS_TO_BE_AWARDED, true);
  66. activeChar.sendMessage("Your clan has earned "+ Config.CR_ITEM_REPS_TO_BE_AWARDED +" rep points!");
  67. MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
  68. activeChar.broadcastPacket(MSU);
  69. playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
  70. }
  71. }
  72.  
  73. public int[] getItemIds()
  74. {
  75. return ITEM_IDS;
  76. }
  77.  
  78. /* (non-Javadoc)
  79. * @see net.sf.l2j.gameserver.handler.IItemHandler#useItem(net.sf.l2j.gameserver.model.actor.Playable, net.sf.l2j.gameserver.model.item.instance.ItemInstance, boolean)
  80. */
  81. @Override
  82. public void useItem(Playable playable, ItemInstance item, boolean forceUse)
  83. {
  84. // TODO Auto-generated method stub
  85.  
  86. }
  87. }
Add Comment
Please, Sign In to add comment