Java Code Examples for org.bukkit.configuration.file.FileConfiguration#getItemStack()

The following examples show how to use org.bukkit.configuration.file.FileConfiguration#getItemStack() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUI.java    From Crazy-Auctions with MIT License 5 votes vote down vote up
public static ItemStack getBiddingItem(Player player, String ID) {
    FileConfiguration config = Files.CONFIG.getFile();
    FileConfiguration data = Files.DATA.getFile();
    String seller = data.getString("Items." + ID + ".Seller");
    String topbidder = data.getString("Items." + ID + ".TopBidder");
    ItemStack item = data.getItemStack("Items." + ID + ".Item");
    List<String> lore = new ArrayList<>();
    for (String l : config.getStringList("Settings.GUISettings.Bidding")) {
        lore.add(l.replace("%TopBid%", Methods.getPrice(ID, false)).replace("%topbid%", Methods.getPrice(ID, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"))));
    }
    return Methods.addLore(item.clone(), lore);
}
 
Example 2
Source File: GameKit.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public GameKit(File kitFile) {
       FileConfiguration storage = YamlConfiguration.loadConfiguration(kitFile);

       List<ItemStack> inventoryItems = (List<ItemStack>) storage.getList("inventory");
       if (inventoryItems != null) {
		inventory = inventoryItems.toArray(new ItemStack[0]);
	}

       List<ItemStack> armorItems = (List<ItemStack>) storage.getList("armor");

       if (armorItems != null) {
		armor = armorItems.toArray(new ItemStack[0]);
	}

       icon = storage.getItemStack("icon");
       
       lIcon = storage.getItemStack("lockedIcon");
       
       name = storage.getString("name");
       
       position = storage.getInt("position");
       
       page = storage.getInt("page");
       
       if (page == 0) {
       	page = 1;
       	storage.set("page", page);
       }
       
       for (int x = 1; x < 17; x++) {
       	lores.put(x, storage.getString("lores.line" + x, " "));
       } 
       
       lockedLore = storage.getString("lores.locked", "");
       
       enabled = storage.getBoolean("enabled");
       
       requirePermission = storage.getBoolean("requirePermission");
       
       filename = storage.getString("filename");
               
       try {
       	storage.save(kitFile);
	} catch (IOException e) {
       	SkyWarsReloaded.get().getLogger().info("Failed to save kit file!");
	}
}