ItemMeta item help

Discussion in 'Plugin Development' started by terturlcraft, Feb 9, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    terturlcraft

    So I am making a plugin but I can't seem to see if a players inventory contains an itemstack. Here is the code
    Code:java
    1. if(p.getInventory().contains(Main.im)) {
    2. p.getInventory().removeItem(Main.im);
    3. p.launchProjectile(Egg.class);
    4. p.updateInventory();
    5. }


    and the main

    Code:
    public class Main extends JavaPlugin {
     
        public static ItemStack im = new ItemStack(Material.FLINT, 1);
     
        public List<String> SkillList = Arrays.asList(new String[] { "EXP", "Master", "Barter", "BigGuns", "EnergyWeapons", "Explosives", "LockPick", "Medicine", "MeleeWeapons", "Repair", "Science", "SmallGuns", "Sneak", "Speech", "Unarmed" });
     
        public void onEnable() {
            setupPistolAmmo();
         
         
            ShapedRecipe PistalAmmo = new ShapedRecipe(im);
            PistalAmmo.shape(new String[] {
                    "FFF",
                    "FBF",
                    "GGG"
            });
            PistalAmmo.setIngredient('F', Material.FLINT);
            PistalAmmo.setIngredient('G', Material.SULPHUR);
            PistalAmmo.setIngredient('B', Material.STONE_BUTTON);
            Bukkit.addRecipe(PistalAmmo);
         
            PluginManager pm = Bukkit.getServer().getPluginManager();
         
            pm.registerEvents(new Util(), this);
            pm.registerEvents(new GunHandler(), this);
        }
     
        public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
         
            Player p = (Player)cs;
         
            if(label.equalsIgnoreCase("test")) {
                p.openInventory(ItemIcon.openInv(p));
            }
         
            return false;
         
        }
     
        public void setupPistolAmmo() {
            ItemMeta im = Main.im.getItemMeta();
            im.setDisplayName(ChatColor.AQUA + "Pistol Ammo");
            Main.im.setItemMeta(im);
        }
     
    }
    I want it to basically see if it contains the PistolAmmo and remove 1 from their inventory. Can anyone help?
     
Thread Status:
Not open for further replies.

Share This Page