Guest User

code help

a guest
Oct 27th, 2022
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. @EventHandler
  2. public void onAnvilCombined(PrepareAnvilEvent e){
  3. ItemStack[] contents = e.getInventory().getContents();
  4. ItemStack firstSlot = contents[0];
  5. ItemStack secondSlot = contents[1];
  6. if (firstSlot == null || secondSlot == null){
  7. return;
  8. }
  9. for (String key : getConfig().getConfigurationSection("Recipes").getKeys(false)){
  10. ConfigurationSection keySection = getConfig().getConfigurationSection("Recipes").getConfigurationSection(key);
  11. if (firstSlot.getType().equals(Material.matchMaterial(keySection.getString("firstItem")))){
  12. if (secondSlot.getType().equals(Material.matchMaterial(keySection.getString("secondItem")))){
  13. ItemStack item = new ItemStack(Material.matchMaterial(keySection.getString("itemResult")));
  14. ItemMeta meta = item.getItemMeta();
  15. meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', keySection.getString("name")));
  16. ArrayList<String> lore = new ArrayList<>();
  17. for (String s : keySection.getStringList("lore")) {
  18. lore.add(ChatColor.translateAlternateColorCodes('&', s));
  19. }
  20. meta.setLore(lore);
  21. item.setItemMeta(meta);
  22. e.getInventory().setRepairCost(Integer.parseInt(keySection.getString("levelCost")));
  23. e.setResult(item);
  24. }else{
  25. return;
  26. }
  27. }else{
  28. return;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment