This is going to be a bit hard to explain so bare with me. I'm trying to make a plugin that takes two numbers and makes a ratio out of them. I have the ratio method working great with text however I'm wondering how to show it as items. Here is my ratio method. Code: public static String ratio(int yays, int nays, int symbolAmount, ChatColor leftColor, ChatColor rightColor, String symbol) { StringBuilder mratio = new StringBuilder(""); double dYes = yays; double dNo = nays; double yesv = (dYes / (dYes + dNo) * symbolAmount); if (dYes == 0 && dNo == 0) { return ChatColor.RED + "Limited Data"; } for (int i = 0; i < yesv; i++) { mratio.append(ChatColor.GREEN); mratio.append(symbol); } for (; yesv < symbolAmount; yesv++) { mratio.append(ChatColor.RED); mratio.append(symbol); } return mratio.toString(); } What I'm trying to do is to make it show like this instead of this If you need more clarification, please feel free to ask. Any help is very much appreciated. Thanks, plisov
Create a List of ItemStacks. In the same way you're appending symbols to a String builder, just add an itemstack to the list. Set the inventory's contents to your list. Profit.
This seems like it would work however it won't know when to go to the next row. I can add an itemstack until it gets to the top but how would I make it go back down to the bottom and start a new row?
Okay I definitely did this incorrectly. Whenever I try to do inv.setContents(list); it turn setContents to red. Code: public static ArrayList<ItemStack> list = new ArrayList<ItemStack>(); public static void createInv(Player player) { FileConfiguration config = null; File file = new File("plugins" + File.separator + "Vote" + File.separator + "vote-results.yml"); config = YamlConfiguration.loadConfiguration(file); if (!config.contains("Voted." + player.getName())) { config.set("Voted." + player.getName(), false); } Inventory inv = Bukkit.getServer().createInventory(player, 54, config.getString("Config.Question").replaceAll("&", "ยง")); y = yes(DyeColor.LIME, ChatColor.GREEN + "Yes"); n = no(DyeColor.PINK, ChatColor.RED + "No"); // Admin Panel Starts inv.setItem(53, ap); // Admin Panel Ends double dyes = config.getInt("Results.Yes"); double dno = config.getInt("Results.No"); int yes = config.getInt("Results.Yes"); int no = config.getInt("Results.No"); double yesv = (dyes / (dyes + dno) * 10); for (int i = 0; i < yesv; i++) { // mratio.append(ChatColor.GREEN); // mratio.append("|"); inv.setItem(0, new ItemStack(yes(DyeColor.GREEN, ""))); } for (; yesv < 10; yesv++) { // mratio.append(ChatColor.RED); // mratio.append("|"); inv.setItem(1, new ItemStack(no(DyeColor.RED, ""))); } player.openInventory(inv); } I'm also unsure how to make the itemstack move to a new slot after appending it.