Guest User

ClanRepsItem

a guest
Oct 15th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 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. +* Re-Adapted by Hann1bal
  27. +*/
  28. +
  29. +
  30. +import net.sf.l2j.Config;
  31. +import net.sf.l2j.gameserver.handler.IItemHandler;
  32. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  33. +import net.sf.l2j.gameserver.model.actor.Playable;
  34. +import net.sf.l2j.gameserver.model.actor.Player;
  35. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  36. +
  37. +public class ClanRepsItem implements IItemHandler
  38. +{
  39. + private static final int ITEM_IDS[] =
  40. + {
  41. + Config.CR_ITEM_REPS_ITEM_ID
  42. + };
  43. + @Override
  44. + public void useItem(Playable playable, ItemInstance item, boolean forceUse)
  45. + {
  46. + if (!(playable instanceof Player))
  47. + {
  48. + return;
  49. + }
  50. +
  51. + Player activeChar = (Player)playable;
  52. +
  53. + if (!activeChar.isClanLeader())
  54. + {
  55. + activeChar.sendMessage("This can be used only by Clan Leaders!");
  56. + return;
  57. + }
  58. +
  59. + else if (!(activeChar.getClan().getLevel() >= Config.CR_ITEM_MIN_CLAN_LVL))
  60. + {
  61. + activeChar.sendMessage("Your Clan Level is not big enough to use this item!");
  62. + return;
  63. + }
  64. + else
  65. + {
  66. + activeChar.getClan().addReputationScore(Config.CR_ITEM_REPS_TO_BE_AWARDED);
  67. + activeChar.sendMessage("Your clan has earned "+ Config.CR_ITEM_REPS_TO_BE_AWARDED +" rep points!");
  68. + MagicSkillUse MSU = new MagicSkillUse(activeChar, activeChar, 2024, 1, 1, 0);
  69. + activeChar.broadcastPacket(MSU);
  70. + playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
  71. + }
  72. + }
  73. +
  74. + public int[] getItemIds()
  75. + {
  76. + return ITEM_IDS;
  77. + }
  78. +}
Add Comment
Please, Sign In to add comment