Solved Help

Discussion in 'Plugin Development' started by Iervolino, Jul 16, 2013.

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

    Iervolino

    I'm trying to add a Sharpness 1 Diamond Sword, but it's not working..

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args){
    2. Player p = (Player)sender;
    3. ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP);
    4. if((cmd.getName().equalsIgnoreCase("pvp")) && (!kit.contains(p.getName())) && (p.hasPermission("ikits.pvp"))){
    5. kit.add(p.getName());
    6. ItemStack dsword = new ItemStack(Material.DIAMOND_SWORD, 1);
    7. p.getInventory().clear();
    8. p.sendMessage(ChatColor.GREEN + "VocĂȘ recebeu o kit PVP!");
    9. p.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
    10. p.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
    11. p.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
    12. p.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
    13. p.getInventory().addItem(new ItemStack[]{dsword});
    14. dsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
    15. for(int i = 0; i < 34; i++){
    16. p.getInventory().addItem(new ItemStack[]{soup});
    17. }
    18. }
     
  2. Offline

    fanaticmw2

    Your adding the sword to the inventory before you add the enchantment.
     
    Iervolino likes this.
  3. Offline

    soulofw0lf

    you've already cleared their inventory so don't need a for loop for the soup, just add 34 of them, as for the sword add the enchantment before you give it to them not afterwards
     
  4. Offline

    Iervolino


    Worked, ty mate!
     
  5. Offline

    fanaticmw2

    I think he's doing that so each soup takes up a slot in an inventory, not stacked.
     
Thread Status:
Not open for further replies.

Share This Page