Guest User

Untitled

a guest
Jan 10th, 2022
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. public Inventory getAM(final FileConfiguration config, final String path, final Player player, final PlaceholderReplacer loreReplacer) {
  2. Menu menu = new Menu(player,Commons.getInstance().getColorUtil().color(config.getString(path+".Title")),Integer.parseInt(config.getString(path+".Size")));
  3. Inventory gui = menu.createMenu();
  4. final ConfigurationSection menuSection = config.getConfigurationSection(path);
  5. for (String keys : config.getConfigurationSection(path + ".Borders").getKeys(false)) {
  6. ItemStack border = Commons.getInstance().getUtils().getItemFromConfig(config, path + ".Borders." + keys).parse();
  7. Iterator iterator = config.getIntegerList(path + ".Borders." + keys + ".Slots").iterator();
  8. while (iterator.hasNext()) {
  9. int i = (Integer) iterator.next();
  10. gui.setItem(i, border);
  11. }
  12. }
  13. final ConfigurationSection configItems = config.getConfigurationSection(path+".Items");
  14. configItems.getKeys(false).forEach(key -> {
  15. ItemStack inventoryItem = getQItemFromConfig(config, path+".Items."+key, loreReplacer);
  16. gui.setItem(config.getInt(path+".Items."+key+".Slot"), inventoryItem);
  17. });
  18.  
  19. return gui;
  20. }
  21. public ItemStack getQItemFromConfig(final FileConfiguration config, final String path, final PlaceholderReplacer loreReplacer) {
  22. ItemStack item;
  23. final ItemBuilder itemBuilder = new ItemBuilder(config.getString(path + ".Material", "BARRIER"), 1).setDurability(config.get(path + ".Durability", 0)).setGlow(config.getBoolean(path + ".Glow", false)).setName(config.getString(path + ".Name", "Invalid Name")).setLore(config.getStringList(path + ".Lore")).setSkull(config.getString(path + ".Skull", "")).setAmount(config.getInt(path + ".Amount", 1)).setColor(config.getInt(path + ".Color", 5));
  24. item = itemBuilder.parse();
  25. ItemMeta meta = item.getItemMeta();
  26. List<String> lore = meta.getLore();
  27. for (String string : lore) {
  28. if (loreReplacer != null) {
  29. string = loreReplacer.parse(string);
  30. List<String> newLore= new ArrayList<>();
  31. newLore.add(string);
  32. meta.setLore(newLore);
  33. } else {
  34. meta.setLore(lore);
  35. }
  36. }
  37. item.setItemMeta(meta);
  38. return item;
  39. }
Add Comment
Please, Sign In to add comment