/*
* Copyright (C) 2016 eccentric_nz
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.eccentric_nz.TARDIS.howto;
import java.util.ArrayList;
import java.util.List;
import me.eccentric_nz.TARDIS.enumeration.CONSOLES;
import me.eccentric_nz.TARDIS.enumeration.SCHEMATIC;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* By the time of his eleventh incarnation, the Doctor's console room had gone
* through at least twelve redesigns, though the TARDIS revealed that she had
* archived 30 versions. Once a control room was reconfigured, the TARDIS
* archived the old design "for neatness". The TARDIS effectively "curated" a
* museum of control rooms — both those in the Doctor's personal past and future
*
* @author eccentric_nz
*/
public class TARDISSeedsInventory {
private final ItemStack[] menu;
private final Player player;
public TARDISSeedsInventory(Player player) {
this.player = player;
this.menu = getItemStack();
}
/**
* Constructs an inventory for the Player Preferences Menu GUI.
*
* @return an Array of itemStacks (an inventory)
*/
private ItemStack[] getItemStack() {
ItemStack[] stack = new ItemStack[18];
int i = 0;
// get consoles
for (SCHEMATIC a : CONSOLES.getBY_NAMES().values()) {
if (player.hasPermission("tardis." + a.getPermission())) {
Material m = Material.getMaterial(a.getSeed());
ItemStack is = new ItemStack(m, 1);
ItemMeta im = is.getItemMeta();
im.setDisplayName(a.getDescription());
List<String> lore = new ArrayList<String>();
lore.add("Click to see recipe...");
im.setLore(lore);
is.setItemMeta(im);
stack[i] = is;
i++;
}
}
// close
ItemStack close = new ItemStack(Material.BOWL, 1);
ItemMeta close_im = close.getItemMeta();
close_im.setDisplayName("Close");
close.setItemMeta(close_im);
stack[17] = close;
return stack;
}
public ItemStack[] getMenu() {
return menu;
}
}