How could I store all my items stacks in a seperate class to where I'm giving them. ItemStacks.Class (example) Code:java ItemStack dsword = new ItemStack(Material.DIAMOND_SWORD);ItemStack ihelm = new ItemStack(Material.IRON_HELMET);ItemStack ichest = new ItemStack(Material.IRON_CHESTPLATE);ItemStack ilegs = new ItemStack(Material.IRON_LEGGINGS); PvPKit.Class (example) Code:java player.getInventory().addItem(dsword);dsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);player.getInventory().setHelmet(ihelm);player.getInventory().setChestplate(ichest);player.getInventory().setLeggings(ilegs);
Jellydude In my opinion it's kinda stupid to keep your itemstacks in one class and use it in another. Unless you happen to be using it in more than 2 classes of course
Jellydude You don't really need to tahg me and quote at the same time tahging does the trick. And use TheGreenGamerHD 's method
xTrollxDudex It's because I've just been pressing reply. sorry TheGreenGamerHD I'm new to java how would I do that? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Jellydude Just tipping it's shorter to just tahg me and it doesn't spam up my alerts. And Code:php declare the itemstacks publicStatically access te ItemStack class
xTrollxDudex Alright, I made the item stacks public but I've got no idea how to access them in the Kit.class
You need a reference to the class. Either statically or via constructor. If you don't know what that means, try google
Jellydude In your items class have this: PHP: ItemStacks is = new ItemStacks();public static void getInstance(){return is;} This assumes that your items class is named ItemStacks. Change all the ItemStacks into your items class name. To access, use this: PHP: ItemStacks.getInstance().dsword To get the dsword ItemStack.
xTrollxDudex I fixed it now anyway using a different method. I put it in a class that all the other classes extend and it worked. I had to ask my friend though for the help.