(Need Help) I don't now how to add enchantments.

Discussion in 'Bukkit Help' started by anwyl19, Jul 2, 2013.

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

    anwyl19

    Hey Guys anwyl19 here well so far I have been working on a kit plugin today and I have done most things now all I have to do is add in enchantments. But I don't know where and what to write for the enchantment (all I know is I want Diamond Sword to have sharp 1 on it)


    Code:
    [/B][/SIZE]
    [SIZE=7][B]____________________________[/B][/SIZE]
    package me.FuullOnPvP;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class main extends JavaPlugin implements Listener{
     
    List<String> usedkit = new ArrayList<String>();
     
        public void onEnable(){
    {
       getServer().getPluginManager().registerEvents(this, this);}
    }
     
        @EventHandler 
        public void onPlayerDeath(PlayerDeathEvent event){
       Player player = event.getEntity().getPlayer();
       usedkit.remove(player.getName());
        }
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event){
    Player player =event.getPlayer();
    int soup = 7;
    if(player.getHealth() == 20){
    }else{
    if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK){
    if(player.getItemInHand().getType() == Material.MUSHROOM_SOUP){
    player.setHealth(player.getHealth() + soup > player.getMaxHealth() ? player.getMaxHealth() : player.getHealth() + soup);
    player.getItemInHand().setType(Material.BOWL);
    }
    }
    }
    }
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
       Player player = (Player) sender;
       if(commandLabel.equalsIgnoreCase("kits") && args.length == 0){
       player.sendMessage(ChatColor.BLUE + "Kit Commands For Test");
       player.sendMessage(ChatColor.RED + "/kit (KitName)" + ChatColor.BLUE + " - Get a kit.");
       player.sendMessage(ChatColor.RED + "/kit New" + ChatColor.BLUE + " - Get a New Kit if needed.");
       }
       if(commandLabel.equalsIgnoreCase("kit") && args.length == 1 && args[0].equalsIgnoreCase("Standard")){
       if(usedkit.contains(player.getName())){
       player.sendMessage("Oh, snap");
       }else{
       if(player.hasPermission("p.kit")){
       usedkit.add(player.getName());
       player.sendMessage("Obtained Standard Kit.");
       player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD, 1));
       player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Integer.MAX_VALUE, 0));
       player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
       }
       }
       if(commandLabel.equalsIgnoreCase("kit")&& args.length == 1 && args[0].equalsIgnoreCase("new")){
       if(player.hasPermission("p.kit")){
       player.getInventory().clear();
       player.getInventory().setHelmet(new ItemStack(Material.AIR));
       player.getInventory().setChestplate(new ItemStack(Material.AIR));
       player.getInventory().setLeggings(new ItemStack(Material.AIR));
       player.getInventory().setBoots(new ItemStack(Material.AIR));
       usedkit.remove(player.getName());
       }
       }
       }
       return false;
        }
    }
    __________________________________________________________
    [B][SIZE=7]PLEASE HELP ASAP[/SIZE][/B]
     
  2. you should ask in the plugin development section. this forum is for bukkit/plugin problems like config problems and so on...
     
  3. At the begging add:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    Player player = (Player) sender;
    if(commandLabel.equalsIgnoreCase("kits") && args.length == 0){
    player.sendMessage(ChatColor.BLUE + "Kit Commands For Test");
    player.sendMessage(ChatColor.RED + "/kit (KitName)" + ChatColor.BLUE + " - Get a kit.");
    player.sendMessage(ChatColor.RED + "/kit New" + ChatColor.BLUE + " - Get a New Kit if needed.");
    }
    if(commandLabel.equalsIgnoreCase("kit") && args.length == 1 && args[0].equalsIgnoreCase("Standard")){
    So right here add(Don't add this msg add this): ItemStack dsword = new ItemStack (Material.DIAMOND_SWORD)
    then add:
    dsword.addEnchantment(Enchantment.DAMAGE_ALL, 1); *Sharp 1*
    if(usedkit.contains(player.getName())){
    player.sendMessage("Oh, snap");
    }else{
    if(player.hasPermission("p.kit")){
    usedkit.add(player.getName());
    player.sendMessage("Obtained Standard Kit.");
    replace:
    player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD, 1)); /THIS
    with: player.getInventory().addItem(dsword)


    player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD, 1));
    player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Integer.MAX_VALUE, 0));
    player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
    }
     
Thread Status:
Not open for further replies.

Share This Page