Guest User

Untitled

a guest
Jul 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. package org.hyperion.rs2.content.skills;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. import org.hyperion.rs2.model.Animation;
  7. import org.hyperion.rs2.model.Item;
  8. import org.hyperion.rs2.model.Player;
  9. import org.hyperion.rs2.model.Skills;
  10.  
  11. /**
  12. * Handles all the crafting methods
  13. * @author Validation
  14. */
  15. public class Crafting
  16. {
  17. private Player player;
  18.  
  19. public Crafting(Player player)
  20. {
  21. this.player = player;
  22. }
  23.  
  24. private enum Gem
  25. {
  26. SAPPHIRE(1623, 1607, 20, 888, 50.0),
  27. EMERALD(1621, 1605, 27, 889, 67.0),
  28. RUBY(1619, 1603, 34, 887, 85.0),
  29. DIAMOND(1617, 1601, 43, 886, 107.5),
  30. DRAGONSTONE(1631, 1615, 55, 885, 137.5),
  31. ONYX(6571, 6573, 67, 885, 168);
  32.  
  33. private int unCut;
  34.  
  35. private int product;
  36.  
  37. private int level;
  38.  
  39. private int animation;
  40.  
  41. private double experience;
  42.  
  43. private static HashMap <Integer, Gem> gems = new HashMap<Integer, Gem>();
  44.  
  45. public static Gem forId(int id)
  46. {
  47. return gems.get(id);
  48. }
  49.  
  50. private Gem(int unCut, int product, int level, int animation, double experience)
  51. {
  52. this.unCut = unCut;
  53. this.product = product;
  54. this.level = level;
  55. this.animation = animation;
  56. this.experience = experience;
  57. }
  58.  
  59. static {
  60. for (Gem g : Gem.values()) {
  61. gems.put(g.getUnCut(), g);
  62. }
  63. }
  64.  
  65. public int getUnCut()
  66. {
  67. return unCut;
  68. }
  69.  
  70. public int getProduct()
  71. {
  72. return product;
  73. }
  74.  
  75. public int getLevel()
  76. {
  77. return level;
  78. }
  79.  
  80. public int getAnimation()
  81. {
  82. return animation;
  83. }
  84.  
  85. public double getExperience()
  86. {
  87. return experience;
  88. }
  89.  
  90. }
  91.  
  92. public void cutGem(int itemUsed, int usedWith)
  93. {
  94. int itemId = itemUsed != 1755 ? itemUsed : usedWith;
  95. final Item item = new Item(itemId, 1);
  96. if(Gem.forId(itemId) == null)
  97. {
  98. return;
  99. }
  100. if(player.getSkills().getLevelForExperience(Skills.CRAFTING) < Gem.forId(itemId).getLevel())
  101. {
  102. player.getActionSender().sendMessage("You need a Crafting level of " + Gem.forId(itemId).getLevel() + " to cut this gem.");
  103. return;
  104. }
  105. if(itemUsed == 1755 && usedWith == Gem.forId(itemId).getUnCut() || usedWith == 1755 && itemUsed == Gem.forId(itemId).getUnCut())
  106. {
  107. player.playAnimation(Animation.create(Gem.forId(itemId).getAnimation()));
  108. player.getInventory().remove(new Item(Gem.forId(itemId).getUnCut(), 1));
  109. player.getInventory().add(new Item(Gem.forId(itemId).getProduct(), 1));
  110. player.getSkills().addExperience(12, Gem.forId(itemId).getExperience());
  111. player.getActionSender().sendMessage("You cut the " + item.getDefinition().getName().toLowerCase() + ".");
  112. }
  113. }
  114.  
  115. }
Add Comment
Please, Sign In to add comment