mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-10 20:40:16 +01:00
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:
parent
07bc9cf4a5
commit
a1fa5b1f00
@ -25,6 +25,8 @@ import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class CategorySelectionGui extends AbstractGui {
|
||||
|
||||
@ -32,12 +34,29 @@ public class CategorySelectionGui extends AbstractGui {
|
||||
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);
|
||||
ItemMeta meta = singleMaps.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.GREEN + "Single maps");
|
||||
meta.setLore(Collections.singletonList(ChatColor.WHITE + "" + singleCount + " image" + (singleCount != 1 ? "s" : "")));
|
||||
GuiUtils.removeVanillaInfos(meta);
|
||||
singleMaps.setItemMeta(meta);
|
||||
|
||||
@ -45,9 +64,13 @@ public class CategorySelectionGui extends AbstractGui {
|
||||
ItemStack postersMaps = new ItemStack(Material.PAINTING);
|
||||
meta = postersMaps.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.GREEN + "Posters");
|
||||
meta.setLore(Collections.singletonList(ChatColor.WHITE + "" + posterCount + " image" + (posterCount != 1 ? "s" : "")));
|
||||
postersMaps.setItemMeta(meta);
|
||||
|
||||
|
||||
|
||||
/* ****** Registration ***** */
|
||||
|
||||
setSlotData(singleMaps, 11, "single");
|
||||
setSlotData(postersMaps, 15, "poster");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user