Guest User

Untitled

a guest
Sep 15th, 2019
122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void revealEnchant(ItemStack i, Player p) {
  2. Random r = new Random();
  3. int success = r.nextInt(101);
  4. int destroy = r.nextInt(101);
  5. for (EnchantTier tier : TierHandler.allTiers()) {
  6. if (i.getItemMeta().equals(LostBookHandler.getLostBook(tier).getItemMeta())) {
  7. CustomEnchant ce = EnchantBookHandler.getRandomCeFromList(EnchantBookHandler.getEnchantsFromTier(tier));
  8. int level = NumberUtils.randInt(1, ce.getMaxLevel());
  9. EnchantBook enchb = new EnchantBook(ce, success, destroy, level);
  10. if (tier.equals(TierHandler.basic)) {
  11. WorldUtils.fanfare(p, Sound.ORB_PICKUP, 1, Color.GRAY);
  12. p.getInventory().addItem(ItemMetadata.setMetadata(enchb.getBookItem(), "Level", level));
  13. InventoryUtils.pop(p, i, 1);
  14. break;
  15. } else if (tier.equals(TierHandler.Super)) {
  16. WorldUtils.fanfare(p, Sound.ORB_PICKUP, 1, Color.AQUA);
  17. p.getInventory().addItem(ItemMetadata.setMetadata(enchb.getBookItem(), "Level", level));
  18. InventoryUtils.pop(p, i, 1);
  19. break;
  20. } else if (tier.equals(TierHandler.rare)) {
  21. WorldUtils.fanfare(p, Sound.ORB_PICKUP, 1, Color.YELLOW);
  22. p.getInventory().addItem(ItemMetadata.setMetadata(enchb.getBookItem(), "Level", level));
  23. InventoryUtils.pop(p, i, 1);
  24. break;
  25. } else if (tier.equals(TierHandler.dragon)) {
  26. WorldUtils.fanfare(p, Sound.ORB_PICKUP, 1, Color.PURPLE);
  27. p.getInventory().addItem(ItemMetadata.setMetadata(enchb.getBookItem(), "Level", level));
  28. InventoryUtils.pop(p, i, 1);
  29. break;
  30. } else if (tier.equals(TierHandler.legendary)) {
  31. WorldUtils.fanfare(p, Sound.ORB_PICKUP, 1, Color.GREEN);
  32. p.getInventory().addItem(ItemMetadata.setMetadata(enchb.getBookItem(), "Level", level));
  33. InventoryUtils.pop(p, i, 1);
  34. break;
  35. }
  36. }
  37. }
  38. }
RAW Paste Data