diff --git a/src/com/github/igotyou/FactoryMod/utility/MenuBuilder.java b/src/com/github/igotyou/FactoryMod/utility/MenuBuilder.java index e48a18cd..63095e74 100644 --- a/src/com/github/igotyou/FactoryMod/utility/MenuBuilder.java +++ b/src/com/github/igotyou/FactoryMod/utility/MenuBuilder.java @@ -109,8 +109,8 @@ public void openFactoryBrowser(Player p, String startingFac) { // creation option ItemStack creationStack = new ItemStack(Material.CHEST); ISUtils.setName(creationStack, "Setup"); - ISUtils.addLore(creationStack, ChatColor.LIGHT_PURPLE - + "Click to display more information", + ISUtils.addLore(creationStack, + ChatColor.LIGHT_PURPLE + "Click to display more information", ChatColor.LIGHT_PURPLE + "on how to setup this factory"); Clickable creationClickable = new Clickable(creationStack) { @Override @@ -139,10 +139,9 @@ public void clicked(Player arg0) { // upgrade option ItemStack upgradeStack = new ItemStack(Material.FURNACE); ISUtils.setName(upgradeStack, "Upgrades"); - ISUtils.addLore(upgradeStack, ChatColor.LIGHT_PURPLE - + "Click to display more information about", - ChatColor.LIGHT_PURPLE - + "the possible upgrades to this factory"); + ISUtils.addLore(upgradeStack, + ChatColor.LIGHT_PURPLE + "Click to display more information about", + ChatColor.LIGHT_PURPLE + "the possible upgrades to this factory"); Clickable upgradeClickable = new Clickable(upgradeStack) { @Override public void clicked(Player arg0) { @@ -159,12 +158,15 @@ public void clicked(Player arg0) { private void openRecipeBrowser(Player p, String facName) { ClickableInventory.forceCloseInventory(p); ClickableInventory recipeInventory = new ClickableInventory(36, - "All recipes for " + facName); + "Recipes for " + facName); // Bukkit has 32 char limit on inventory FurnCraftChestEgg egg = (FurnCraftChestEgg) manager.getEgg(facName); List recipes = egg.getRecipes(); // put recipes for (int i = 0; i < recipes.size(); i++) { + if (recipes.get(i) == null) { + continue; + } Clickable c = new Clickable( ((InputRecipe) recipes.get(i)).getRecipeRepresentation()) { @Override @@ -179,8 +181,8 @@ public void clicked(Player arg0) { // back option ItemStack backStack = new ItemStack(Material.ARROW); ISUtils.setName(backStack, "Back to factory overview"); - ISUtils.addLore(backStack, ChatColor.LIGHT_PURPLE - + "Click to go back"); + ISUtils.addLore(backStack, + ChatColor.LIGHT_PURPLE + "Click to go back"); Clickable backClickable = new Clickable(backStack) { @Override public void clicked(Player arg0) { @@ -197,21 +199,19 @@ private void openSetupBrowser(Player p, String facName) { FurnCraftChestEgg egg = (FurnCraftChestEgg) manager.getEgg(facName); FurnCraftChestEgg parEgg = (FurnCraftChestEgg) manager .getEgg(parentFactories.get(facName)); - ClickableInventory ci = new ClickableInventory(54, "How to get a " - + egg.getName()); + ClickableInventory ci = new ClickableInventory(54, "Create a " + + egg.getName()); // Bukkit has 32 char limit on inventory ItemStack cr = new ItemStack(Material.WORKBENCH); ItemStack fur = new ItemStack(Material.FURNACE); ItemStack che = new ItemStack(Material.CHEST); if (parEgg == null) {// creation factory - ISUtils.setLore(cr, ChatColor.LIGHT_PURPLE - + "This factory can be created with", - ChatColor.LIGHT_PURPLE - + "a normal crafting table, furnace and chest"); - ISUtils.setLore(che, ChatColor.LIGHT_PURPLE - + "Arrange the 3 blocks like this,", ChatColor.LIGHT_PURPLE - + "put the materials below in the chest", - ChatColor.LIGHT_PURPLE - + "and hit the craftingtable with a stick"); + ISUtils.setLore(cr, + ChatColor.LIGHT_PURPLE + "This factory can be created with", + ChatColor.LIGHT_PURPLE + "a normal crafting table, furnace and chest"); + ISUtils.setLore(che, + ChatColor.LIGHT_PURPLE + "Arrange the 3 blocks like this,", + ChatColor.LIGHT_PURPLE + "put the materials below in the chest", + ChatColor.LIGHT_PURPLE + "and hit the crafting table with a stick"); DecorationStack furnDec = new DecorationStack(fur); DecorationStack chestDec = new DecorationStack(che); DecorationStack craStack = new DecorationStack(cr); @@ -256,8 +256,9 @@ public void clicked(Player arg0) { } }; ci.setSlot(craCli, 4); - ISUtils.setLore(fur, ChatColor.LIGHT_PURPLE - + "Click to display information", ChatColor.LIGHT_PURPLE + "on this factory"); + ISUtils.setLore(fur, + ChatColor.LIGHT_PURPLE + "Click to display information", + ChatColor.LIGHT_PURPLE + "on this factory"); Clickable furCli = new Clickable(fur) { @Override public void clicked(Player arg0) { @@ -296,8 +297,7 @@ public void clicked(Player arg0) { ci.setSlot(input, 22); ItemStack backStack = new ItemStack(Material.ARROW); ISUtils.setName(backStack, "Back to factory overview"); - ISUtils.addLore(backStack, ChatColor.LIGHT_PURPLE - + "Click to go back"); + ISUtils.addLore(backStack, ChatColor.LIGHT_PURPLE + "Click to go back"); Clickable backClickable = new Clickable(backStack) { @Override public void clicked(Player arg0) { @@ -312,18 +312,18 @@ private void openUpgradeBrowser(Player p, String facName) { ClickableInventory.forceCloseInventory(p); FurnCraftChestEgg egg = (FurnCraftChestEgg) manager .getEgg(factoryViewed.get(p.getUniqueId())); - ClickableInventory ci = new ClickableInventory(18, "Possible upgrades"); List upgrades = new LinkedList(); for (IRecipe recipe : egg.getRecipes()) { if (recipe instanceof Upgraderecipe) { upgrades.add(recipe); } } + ClickableInventory ci = new ClickableInventory( + Math.max(18, (upgrades.size() / 9) * 9), "Possible upgrades"); if (upgrades.size() == 0) { ItemStack bar = new ItemStack(Material.BARRIER); ISUtils.setName(bar, "No upgrades available"); - ISUtils.addLore(bar, ChatColor.LIGHT_PURPLE - + "Click to go back"); + ISUtils.addLore(bar, ChatColor.LIGHT_PURPLE + "Click to go back"); Clickable noUpgrades = new Clickable(bar) { @Override public void clicked(Player p) { @@ -335,8 +335,8 @@ public void clicked(Player p) { for (IRecipe recipe : upgrades) { ItemStack recStack = ((InputRecipe) recipe) .getRecipeRepresentation(); - ISUtils.setLore(recStack, ChatColor.LIGHT_PURPLE - + "Click to display more information"); + ISUtils.setLore(recStack, + ChatColor.LIGHT_PURPLE + "Click to display more information"); Clickable c = new Clickable( ((InputRecipe) recipe).getRecipeRepresentation()) { @Override @@ -350,8 +350,7 @@ public void clicked(Player p) { } ItemStack backStack = new ItemStack(Material.ARROW); ISUtils.setName(backStack, "Back to factory overview"); - ISUtils.addLore(backStack, ChatColor.LIGHT_PURPLE - + "Click to go back"); + ISUtils.addLore(backStack, ChatColor.LIGHT_PURPLE + "Click to go back"); Clickable backClickable = new Clickable(backStack) { @Override public void clicked(Player arg0) {