Getting a player

Discussion in 'Spigot Help' started by LazerShadow, May 27, 2015.

  1. I know that this is an easy answer, and I am going to feel dumb for not knowing it but how do I get the player here?
    Code (Text):
        public static Inventory getStarInventory() {
           
           
            Inventory inv = Bukkit.createInventory(null, 27, "§lSelect your Kit!");
           
            {
                ItemStack item = new ItemStack(Material.EMERALD_BLOCK, 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(ChatColor.GREEN + "§lPlayer Kits");
                List<String> lore = new ArrayList<String>();
                lore.add("§7These are all the player kits that you get from");
                lore.add("§7joining the server!");
                meta.setLore(lore);
                item.setItemMeta(meta);
                inv.addItem(item);
                   
            }
           
           
            {
                ItemStack item = new ItemStack(Material.IRON_CHESTPLATE, 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(ChatColor.GREEN + "§lKnight");
                List<String> lore = new ArrayList<String>();
                lore.add("§7The Knight is the classic Minecraft warrior. He doesn't");
                lore.add("§7have any special abilities, although he has generally");
                lore.add("§7better armour then other players and more health!");
                lore.add("");
                lore.add(ChatColor.RED + "Left Click" + ChatColor.GRAY + " to select.");
                meta.setLore(lore);
                item.setItemMeta(meta);
                inv.setItem(2, item);
                   
            }
           
           
            {
                ItemStack item = new ItemStack(Material.DIAMOND_SWORD, 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(ChatColor.GREEN + "§lAssassin");
                List<String> lore = new ArrayList<String>();
                lore.add("§7The assassin is a very strong in strength, although he");
                lore.add("§7has one weakness: He has bad armor! Fortunately for him");
                lore.add("§7his strength makes up for it");
                lore.add("");
                lore.add(ChatColor.RED + "Left Click" + ChatColor.GRAY + " to select.");
                meta.setLore(lore);
                item.setItemMeta(meta);
                inv.setItem(4, item);
                   
            }
           
            {
                ItemStack item = new ItemStack(Material.BOW, 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(ChatColor.GREEN + "§lArcher");
                List<String> lore = new ArrayList<String>();
                lore.add("§7The archer is most skilled with the bow, rumor has it");
                lore.add("§7he once shot and killed someone from over 300 blocks");
                lore.add("§7away! His one weakness is close quarters combat.");
                lore.add("");
                lore.add(ChatColor.RED + "Left Click" + ChatColor.GRAY + " to select.");
                meta.setLore(lore);
                item.setItemMeta(meta);
                inv.setItem(6, item);
                   
            }
           
            {
                ItemStack item = new ItemStack(Material.GOLD_BLOCK, 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(ChatColor.YELLOW + "§lCurrency Kits");
                List<String> lore = new ArrayList<String>();
                lore.add("§7When you kill a player you get X currency, you");
                lore.add("§7save these to rent or buy a kit!");
                lore.add("§7");
                lore.add("§cRent §7- Buys a kit, you have it till you die.");
                lore.add("§cBuy §7- Buys a kit, you keep it forever.");
                item.setItemMeta(meta);
                inv.setItem(9, item);
                   
            }

           
            return inv;
        }
     
  2. * the question is which player are you referring to and what do you want to use the object for?

    * the curling brackets you used to separate the items should be removed as they don't fit official conventions, use comments instead

    * I suggest to rename the method to create* as get* refers to a getter, however you always create a new instance when you call the method.