Solved Enchantments?

Discussion in 'Plugin Development' started by DiamondSworder, Dec 27, 2015.

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

    DiamondSworder

    Cant figure out why my enchantments dont work on my sword.

    Code:
    package me.kitpvp.main;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerDropItemEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class PvP implements CommandExecutor{
       
        public Main plugin;
        public PvP(Main instance) {
            plugin = instance;
        }
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            cmd.getName().equalsIgnoreCase("/pvp");
            Player p = (Player) sender;
            String pname = p.getName();
            p.getInventory().clear();
           
            for (PotionEffect potionEffect : p.getActivePotionEffects()){
            p.removePotionEffect(potionEffect.getType());
           
            }
    
            ItemStack DiamondSword = new ItemStack(Material.DIAMOND_SWORD);
            p.getInventory().addItem(DiamondSword);
            DiamondSword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
           
            ItemStack Soup = new ItemStack(Material.MUSHROOM_SOUP);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
            p.getInventory().addItem(Soup);
           
            //Armor - Helmet
            ItemStack helmet = new ItemStack(Material.IRON_HELMET);;
            p.getInventory().setHelmet(helmet);
            //Armor - Chestplate
            ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);;
            p.getInventory().setChestplate(chestplate);
            //Armor - Leggings
            ItemStack leggings = new ItemStack(Material.IRON_LEGGINGS);;
            p.getInventory().setLeggings(leggings);
            //Armor - Boots
            ItemStack boots = new ItemStack(Material.IRON_BOOTS);;
            p.getInventory().setBoots(boots);
            //Potion Effects
            p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100000, 1));
            p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 100000, 1));
    
            p.sendMessage(ChatColor.WHITE + "You now have the PVP kit!");
            return true;
        }
    
    }
    
     
  2. Offline

    Zombie_Striker

    @DiamondSworder
    Neither can we if we don't know what you mean by "Don't work". Do you get any errors? Did you debug? If you did, where is your problem?
     
  3. Offline

    DiamondSworder

    No errors, just the enchant aint on the sword when i type /pvp @Zombie_Striker
     
  4. Offline

    mug561

    try swapping the add enchant and give the item.

    enchant the itemStack
    and then p.getInventory().addItem();
     
  5. Offline

    DiamondSworder

Thread Status:
Not open for further replies.

Share This Page