Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onAnvilCombined(PrepareAnvilEvent e){
- ItemStack[] contents = e.getInventory().getContents();
- ItemStack firstSlot = contents[0];
- ItemStack secondSlot = contents[1];
- if (firstSlot == null || secondSlot == null){
- return;
- }
- for (String key : getConfig().getConfigurationSection("Recipes").getKeys(false)){
- ConfigurationSection keySection = getConfig().getConfigurationSection("Recipes").getConfigurationSection(key);
- if (firstSlot.getType().equals(Material.matchMaterial(keySection.getString("firstItem")))){
- if (secondSlot.getType().equals(Material.matchMaterial(keySection.getString("secondItem")))){
- ItemStack item = new ItemStack(Material.matchMaterial(keySection.getString("itemResult")));
- ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', keySection.getString("name")));
- ArrayList<String> lore = new ArrayList<>();
- for (String s : keySection.getStringList("lore")) {
- lore.add(ChatColor.translateAlternateColorCodes('&', s));
- }
- meta.setLore(lore);
- item.setItemMeta(meta);
- e.getInventory().setRepairCost(Integer.parseInt(keySection.getString("levelCost")));
- e.setResult(item);
- }else{
- return;
- }
- }else{
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment