Images count in the tooltips of the category selection GUI.

* NEW: Added images count per category in the main selection GUI.
* OPT: Removed the “Choose a category” part of the selection GUI's title.
This commit is contained in:
Amaury Carrade 2015-07-10 15:55:08 +02:00
parent 07bc9cf4a5
commit a1fa5b1f00

View File

@ -25,6 +25,8 @@ import org.bukkit.entity.*;
import org.bukkit.inventory.*; import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.*; import org.bukkit.inventory.meta.*;
import java.util.*;
public class CategorySelectionGui extends AbstractGui { public class CategorySelectionGui extends AbstractGui {
@ -32,12 +34,29 @@ public class CategorySelectionGui extends AbstractGui {
public void display(Player player) public void display(Player player)
{ {
inventory = Bukkit.createInventory(player, 3 * 9, ChatColor.BLACK + "Maps » Choose a category"); inventory = Bukkit.createInventory(player, 3 * 9, ChatColor.BLACK + "Maps");
/* ****** Data gathering ***** */
List<ImageMap> maps = MapManager.getMapList(player.getUniqueId());
Integer singleCount = 0;
Integer posterCount = 0;
for(ImageMap map : maps)
{
if(map.getType() == ImageMap.Type.POSTER)
posterCount++;
else
singleCount++;
}
/* ****** Access to the sub-categories ***** */
ItemStack singleMaps = new ItemStack(Material.MAP); ItemStack singleMaps = new ItemStack(Material.MAP);
ItemMeta meta = singleMaps.getItemMeta(); ItemMeta meta = singleMaps.getItemMeta();
meta.setDisplayName(ChatColor.GREEN + "Single maps"); meta.setDisplayName(ChatColor.GREEN + "Single maps");
meta.setLore(Collections.singletonList(ChatColor.WHITE + "" + singleCount + " image" + (singleCount != 1 ? "s" : "")));
GuiUtils.removeVanillaInfos(meta); GuiUtils.removeVanillaInfos(meta);
singleMaps.setItemMeta(meta); singleMaps.setItemMeta(meta);
@ -45,9 +64,13 @@ public class CategorySelectionGui extends AbstractGui {
ItemStack postersMaps = new ItemStack(Material.PAINTING); ItemStack postersMaps = new ItemStack(Material.PAINTING);
meta = postersMaps.getItemMeta(); meta = postersMaps.getItemMeta();
meta.setDisplayName(ChatColor.GREEN + "Posters"); meta.setDisplayName(ChatColor.GREEN + "Posters");
meta.setLore(Collections.singletonList(ChatColor.WHITE + "" + posterCount + " image" + (posterCount != 1 ? "s" : "")));
postersMaps.setItemMeta(meta); postersMaps.setItemMeta(meta);
/* ****** Registration ***** */
setSlotData(singleMaps, 11, "single"); setSlotData(singleMaps, 11, "single");
setSlotData(postersMaps, 15, "poster"); setSlotData(postersMaps, 15, "poster");