Guest User

Gui Class

a guest
Oct 9th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. public class Gui {
  2.    
  3.     public void shopGui (Player sender) {
  4.         String mainShop = getConfig().getString("Settings.Main Shop");
  5.         Logger log = Bukkit.getLogger();
  6.         log.info("Started the function");
  7.         log.info(mainShop);
  8.         Inventory open = Bukkit.createInventory(sender, 9, getConfig().getString("Shop." + mainShop + ".Name Of Shop"));
  9.        
  10.         log.info("Created the inventory");
  11.         //Set<String> cmdList = getConfig().getConfigurationSection("Shop." + mainShop + ".Items").getKeys(false);
  12.         for (String key : getConfig().getConfigurationSection("Shop." + mainShop + ".Items").getKeys(false)) {
  13.             log.info("For Looped Around");
  14.             String itemIcon = (String) getConfig().get("Shop." + mainShop + ".Items." + key + ".Icon");
  15.             log.info("got icon name from config");
  16.             ItemStack item = new ItemStack(Material.getMaterial(itemIcon.toUpperCase()), 1);
  17.             log.info("Got the item correctly");
  18.             String itemName = (String) getConfig().get("Shop." + mainShop + ".Items." + key + ".Name Of Item");
  19.             log.info("got the item name from config");
  20.             List<String> itemLore = getConfig().getStringList("Shop." + mainShop + ".Items." + key + ".Lore");
  21.             log.info("Got The Lore");
  22.             open.setItem(getConfig().getInt("Shop." + mainShop + ".Items." + key + ".Slot") - 1, setValues(item, itemName, itemLore));;
  23.             log.info("Put Item In the inventory");
  24.         }
  25.         log.info("Looped through the things");
  26.         sender.openInventory(open);
  27.        
  28.     }
  29.    
  30.     public ItemStack setValues(ItemStack item, String name, List<String> lore) {
  31.        
  32.         for (String string : lore) {
  33.             lore.add(ChatColor.translateAlternateColorCodes('~', string));
  34.         }
  35.  
  36.         ItemMeta itemMeta = item.getItemMeta();
  37.         Bukkit.getLogger().info("Started the rename process");
  38.         itemMeta.setDisplayName(name);
  39.         Bukkit.getLogger().info("Set The Name Of The Item");
  40.         itemMeta.setLore(lore);
  41.         Bukkit.getLogger().info("Should return item");
  42.         item.setItemMeta(itemMeta);
  43.         return item;
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment