Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.hyperion.rs2.content.skills;
- import java.util.HashMap;
- import java.util.Map;
- import org.hyperion.rs2.model.Animation;
- import org.hyperion.rs2.model.Item;
- import org.hyperion.rs2.model.Player;
- import org.hyperion.rs2.model.Skills;
- /**
- * Handles all the crafting methods
- * @author Validation
- */
- public class Crafting
- {
- private Player player;
- public Crafting(Player player)
- {
- this.player = player;
- }
- private enum Gem
- {
- SAPPHIRE(1623, 1607, 20, 888, 50.0),
- EMERALD(1621, 1605, 27, 889, 67.0),
- RUBY(1619, 1603, 34, 887, 85.0),
- DIAMOND(1617, 1601, 43, 886, 107.5),
- DRAGONSTONE(1631, 1615, 55, 885, 137.5),
- ONYX(6571, 6573, 67, 885, 168);
- private int unCut;
- private int product;
- private int level;
- private int animation;
- private double experience;
- private static HashMap <Integer, Gem> gems = new HashMap<Integer, Gem>();
- public static Gem forId(int id)
- {
- return gems.get(id);
- }
- private Gem(int unCut, int product, int level, int animation, double experience)
- {
- this.unCut = unCut;
- this.product = product;
- this.level = level;
- this.animation = animation;
- this.experience = experience;
- }
- static {
- for (Gem g : Gem.values()) {
- gems.put(g.getUnCut(), g);
- }
- }
- public int getUnCut()
- {
- return unCut;
- }
- public int getProduct()
- {
- return product;
- }
- public int getLevel()
- {
- return level;
- }
- public int getAnimation()
- {
- return animation;
- }
- public double getExperience()
- {
- return experience;
- }
- }
- public void cutGem(int itemUsed, int usedWith)
- {
- int itemId = itemUsed != 1755 ? itemUsed : usedWith;
- final Item item = new Item(itemId, 1);
- if(Gem.forId(itemId) == null)
- {
- return;
- }
- if(player.getSkills().getLevelForExperience(Skills.CRAFTING) < Gem.forId(itemId).getLevel())
- {
- player.getActionSender().sendMessage("You need a Crafting level of " + Gem.forId(itemId).getLevel() + " to cut this gem.");
- return;
- }
- if(itemUsed == 1755 && usedWith == Gem.forId(itemId).getUnCut() || usedWith == 1755 && itemUsed == Gem.forId(itemId).getUnCut())
- {
- player.playAnimation(Animation.create(Gem.forId(itemId).getAnimation()));
- player.getInventory().remove(new Item(Gem.forId(itemId).getUnCut(), 1));
- player.getInventory().add(new Item(Gem.forId(itemId).getProduct(), 1));
- player.getSkills().addExperience(12, Gem.forId(itemId).getExperience());
- player.getActionSender().sendMessage("You cut the " + item.getDefinition().getName().toLowerCase() + ".");
- }
- }
- }
Add Comment
Please, Sign In to add comment