Guest User

onItemCraftedByPlayer - PlayerEvents

a guest
Jun 19th, 2016
21
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @SubscribeEvent
  2. public void onItemCraftedByPlayer(ItemCraftedEvent event)
  3. {
  4.     CraftingRequirement requirement = CraftingRequirement.getCraftingRequirement(event.crafting);
  5.     if(requirement != null)
  6.     {
  7.         ItemStack stack = event.crafting;
  8.        
  9.         //ExperienceReward is acquired from the amount made and the experience reward multiplied
  10.         int experienceReward = stack.stackSize * requirement.getExperienceReward();
  11.        
  12.         //Gives experience to the player
  13.         SuperSkill.get(event.player, SkillDB.SKILL_NAMES.Crafting.toString()).giveXp(experienceReward);
  14.         if(requirement.isCollectable())
  15.         {
  16.             //Get the index of the stack being created
  17.             int indexOfCollection = CollectionWrapper.getIndexOfCollection(Item.getIdFromItem(stack.getItem()), stack.getMetadata());
  18.             if(indexOfCollection != -1)
  19.             {
  20.                 //Increase the collection stat by the stack size
  21.                 ((Collection)SuperSkill.get(event.player, SkillDB.SKILL_NAMES.Collection.toString())).incrementCollectionStatByAmount(indexOfCollection, stack.stackSize);
  22.             }
  23.         }
  24.     }
  25. }
RAW Paste Data