71 lines
2.4 KiB
Java
71 lines
2.4 KiB
Java
package me.unurled.raxen.components.gui;
|
|
|
|
import me.unurled.raxen.utils.Items;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.Inventory;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.inventory.meta.SkullMeta;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import static me.unurled.raxen.utils.Utils.colorComp;
|
|
import static me.unurled.raxen.utils.Utils.fillGreyPane;
|
|
|
|
public class MainGui {
|
|
|
|
public static Inventory build(Player p) {
|
|
Inventory inv = Bukkit.createInventory(null, 54, colorComp("<dark_grey>Raxen</dark_grey>"));
|
|
String gui = "0,7,0,0,0,8,9,0,10," +
|
|
"0,0,0,0,0,0,0,0,0," +
|
|
"0,0,0,0,0,0,0,0,0," +
|
|
"0,2,3,0,0,0,0,4,0," +
|
|
"0,0,0,0,1,0,0,0,0," +
|
|
"0,0,0,0,0,0,0,0,0";
|
|
// 1 player Head
|
|
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
|
SkullMeta headm = (SkullMeta) head.getItemMeta();
|
|
headm.setOwningPlayer(p.getPlayer());
|
|
headm.displayName(colorComp("<green></green>"));
|
|
// 2 bank
|
|
ItemStack bank = new ItemStack(Material.GOLD_INGOT);
|
|
// 3 ah
|
|
ItemStack ah = new ItemStack(Material.GOLD_INGOT);
|
|
// 4 skill tree
|
|
ItemStack sk_tree = new ItemStack(Material.OAK_SAPLING);
|
|
// 7 teleport
|
|
ItemStack tp = new ItemStack(Material.ENDER_PEARL);
|
|
// 8 select character
|
|
ItemStack sel_char = new ItemStack(Material.SNOWBALL);
|
|
// 9 Settings
|
|
ItemStack sett = new ItemStack(Material.MAGMA_CREAM);
|
|
// 10 barrier block close
|
|
|
|
HashMap<String, ItemStack> list = new HashMap<>();
|
|
list.put("1", head);
|
|
list.put("2", bank);
|
|
list.put("3",ah);
|
|
list.put("4", sk_tree);
|
|
list.put("7", tp);
|
|
list.put("8", sel_char);
|
|
list.put("9", sett);
|
|
list.put("10", Items.closeItem());
|
|
Inventory inventory = stringToGui(inv, gui,list);
|
|
inventory = fillGreyPane(inventory);
|
|
return inventory;
|
|
}
|
|
|
|
public static Inventory stringToGui(Inventory inv, String stt, HashMap<String, ItemStack> it) {
|
|
String[] s = stt.split(",");
|
|
if (s.length != inv.getContents().length) {
|
|
return inv;
|
|
}
|
|
Integer i = 0;
|
|
for (String st : s) {
|
|
inv.setItem(i, it.get(st));
|
|
i++;
|
|
}
|
|
return inv;
|
|
}
|
|
}
|