Plugin Help Kit Plugin Help

Discussion in 'Plugin Help/Development/Requests' started by Lukas12137, May 16, 2015.

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

    Lukas12137

    So i want it to make it that a player has to die before using another kit, but it seems to not work i get the kit with the message but i also get the message if the player was in the "list" and i don't know what to do, also i can use the kit unlimited times so its not working any advice? Im new to coding so try your best to explain it simple or post a code that i can copy but explain it so i can learn from it. Thank you

    Code:
    package me.lukas.kitpvp;
    
    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.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class kitpvp extends JavaPlugin{
       
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent e){
            Player player = (Player) e.getEntity();
            if(list.contains(player.getName())){
            list.remove(player.getName());
                }
            }
                  List<String> list = new ArrayList<String>();
                    
                public void onEnable(){
                    System.out.print("CreeperKits is disabled!");
                }
            
                public void onDisable(){
                    System.out.print("CreeperKits is enabled!");
                }
            
                public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
                   
    
                    Player player = (Player) sender;
                    //kit pvp, I assume
                    if(commandLabel.equalsIgnoreCase("Tank")){
                        if(list.contains(player.getName())); {
                            player.sendMessage(ChatColor.RED + "You can use a kit when you die");
                        }
                        }else{
                            player.sendMessage(ChatColor.DARK_GREEN + "CreeperKits:" + ChatColor.DARK_GRAY + "Enjoy the PvP Kit!");
                            ItemStack dsword = new ItemStack(Material.IRON_SWORD);
                            player.getInventory().addItem(dsword);
                            dsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
                            player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
                            player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
                            player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
                            player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
                            player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 16));
                            player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 1000000 , 4));
                            player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000000 , (int) 0.5));
                            list.add(getName());
                           
                        }
                                       
                    //kit archer, I assume
                    if(commandLabel.equalsIgnoreCase("Archer")){
                        if(list.contains(player.getName()));{
                            player.sendMessage(ChatColor.RED + "You can use a kit when you die");
                        }
                        }else{
                            player.sendMessage(ChatColor.DARK_GREEN + "CreeperKits:" + ChatColor.DARK_GRAY + "Enjoy the Archer Kit!");
                            ItemStack b = new ItemStack(Material.BOW);
                            b.addEnchantment(Enchantment.ARROW_INFINITE, 1);
                            b.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
                            player.getInventory().addItem(b);
                            player.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET));
                            player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
                            player.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
                            player.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS));
                            player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 16));
                            player.getInventory().addItem(new ItemStack(Material.ARROW));
                            player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000 , (int) 0.5));
                            list.add(player.getName());
                        }
                                    
                return false;
                }
            }
     
Thread Status:
Not open for further replies.

Share This Page