KitPvp - Not working?

Discussion in 'Plugin Development' started by JollyGiant16, Feb 8, 2013.

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

    GodzOfMadness

    noamro no what i am saying is it's case sensative so if i have a package called me.germanchocolate.war
    and my class file is named WarPlugin
    it would have to be: me.germanchocolate.war.WarPlugin (case sensative)
     
  2. Offline

    noamro

    This is my plugin now
    Code:
    package me.noamro.war;
    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.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.potion.PotionEffect;
     
    public class WarPlugin {
     
        public String prefix;
        public void onEnable() {
            this.prefix = (ChatColor.WHITE + "[" + ChatColor.AQUA + "KitPvp" + ChatColor.WHITE + "] ");
        }
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("kits") || sender.hasPermission("kit.help")) {
                if (args.length == 0) sendHelp((Player)sender);
                else if (args.length == 1) {
                    if (args[0].equalsIgnoreCase("regular")) {
                        if ((sender instanceof Player)) {
                            if (sender.hasPermission("kit.regular")) {
                                Player player = (Player)sender;
                                PlayerInventory pi = player.getInventory();
                                for (PotionEffect effect : player.getActivePotionEffects()) {
                                    player.removePotionEffect(effect.getType());
                                    pi.clear();
                                }
                                ItemStack gethat = new ItemStack(Material.IRON_HELMET);
                                gethat.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack gettop = new ItemStack(Material.IRON_CHESTPLATE);
                                gettop.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getlegs = new ItemStack(Material.IRON_LEGGINGS);
                                getlegs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getshoes = new ItemStack(Material.IRON_BOOTS);
                                getshoes.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getsword = new ItemStack(Material.DIAMOND_SWORD);
                                getsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
                                pi.setHelmet(gethat);
                                pi.setChestplate(gettop);
                                pi.setLeggings(getlegs);
                                pi.setBoots(getshoes);
                                pi.addItem(getsword);
                                ItemStack getSoup = new ItemStack(Material.MUSHROOM_SOUP, 1);
                                for(int i=1; i <=34; i++)
                                    pi.addItem(getSoup);
                                sender.sendMessage(this.prefix + ChatColor.GRAY + "You have chosen the " + ChatColor.GREEN + ChatColor.UNDERLINE + "Regular" + ChatColor.GRAY + " kit.");
                            } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "No permission to do this command.");
                        } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "You must be a player to do this command.");
                    }
                    else if (args[0].equalsIgnoreCase("archer")) {
                        if ((sender instanceof Player)) {
                            if (sender.hasPermission("kit.archer")) {
                                Player player = (Player)sender;
                                PlayerInventory pi = player.getInventory();
                                for (PotionEffect effect : player.getActivePotionEffects()) {
                                    player.removePotionEffect(effect.getType());
                                    pi.clear();
                                }
                                ItemStack gethat = new ItemStack(Material.IRON_HELMET);
                                gethat.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack gettop = new ItemStack(Material.IRON_CHESTPLATE);
                                gettop.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getlegs = new ItemStack(Material.IRON_LEGGINGS);
                                getlegs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getshoes = new ItemStack(Material.IRON_BOOTS);
                                getshoes.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getsword = new ItemStack(Material.DIAMOND_SWORD);
                                getsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
                                ItemStack getbow = new ItemStack(Material.BOW, 1);
                                ItemStack getarrow = new ItemStack(Material.ARROW, 128);
                                pi.setHelmet(gethat);
                                pi.setChestplate(gettop);
                                pi.setLeggings(getlegs);
                                pi.setBoots(getshoes);
                                pi.addItem(getsword);
                                pi.addItem(getbow);
                                ItemStack getSoup = new ItemStack(Material.MUSHROOM_SOUP, 1);
                                for(int i=1; i <=31; i++)
                                    pi.addItem(getSoup);
                                pi.addItem(getarrow);
                                sender.sendMessage(this.prefix + ChatColor.GRAY + "You have chosen the " + ChatColor.GREEN + ChatColor.UNDERLINE + "Archer" + ChatColor.GRAY + " kit.");
                            } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "No permission to do this command.");
                        } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "You must be a player to do this command.");
                    }
                    else if (args[0].equalsIgnoreCase("donor")){
                        if ((sender instanceof Player )) {
                            if (sender.hasPermission("kit.donor")) {
                                Player player = (Player)sender;
                                PlayerInventory pi = player.getInventory();
                                for (PotionEffect effect : player.getActivePotionEffects()) {
                                    player.removePotionEffect(effect.getType());
                                    pi.clear();
                                }
                                ItemStack gethat = new ItemStack(Material.IRON_HELMET);
                                gethat.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack gettop = new ItemStack(Material.IRON_CHESTPLATE);
                                gettop.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getlegs = new ItemStack(Material.IRON_LEGGINGS);
                                getlegs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getshoes = new ItemStack(Material.IRON_BOOTS);
                                getshoes.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
                                ItemStack getsword = new ItemStack(Material.DIAMOND_SWORD);
                                getsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
                                pi.setHelmet(gethat);
                                pi.setChestplate(gettop);
                                pi.setLeggings(getlegs);
                                pi.setBoots(getshoes);
                                pi.addItem(getsword);
                                ItemStack getSoup = new ItemStack(Material.MUSHROOM_SOUP, 1);
                                for(int i=1; i <=34; i++)
                                    pi.addItem(getSoup);
                                sender.sendMessage(this.prefix + ChatColor.GRAY + "You have chosen the " + ChatColor.GREEN + ChatColor.UNDERLINE + "Donor" + ChatColor.GRAY + " kit.");
                            } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "No permission to do this command.");
                        } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "You must be a player to do this command.");
                    } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "Invalid Kit");
                }  else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "Invalid Kit");
            }
            return true;
        }
        public void sendHelp(Player sender) {
     
            sender.sendMessage(ChatColor.GRAY + "[--------------------" + this.prefix + ChatColor.GRAY + "--------------------]");
            sender.sendMessage(this.prefix + "/kit Regular" + ChatColor.DARK_BLUE + " : " + ChatColor.WHITE + "Choose the Regular Kit.");
            sender.sendMessage(this.prefix + "/kit Donor" + ChatColor.DARK_BLUE + " : " + ChatColor.WHITE + "Choose the Donor Kit.");
            sender.sendMessage(this.prefix + "/kit Archer" + ChatColor.DARK_BLUE + " : " + ChatColor.WHITE + "Choose the Archer Kit.");
        }
    }
    Code:
    name: KitPvp
    main: me.noamro.war.WarPlugin
    description: KitPvp Plugin, Select your kits!
    commands:
      kit:
        description: Gives you your selected kit.
      kits:
        description: Gives you your selected kit.
    permission:
      kit.Donor:
        default: true
      kit.Archer:
        default: true
      kit.Regular:
        default: true
      kit.Medic:
        default: true
    Dosnt work
     
  3. Offline

    GodzOfMadness

    noamro can you show me the console error?
    [EDIT] you don't have extends JavaPlugin
     
  4. Offline

    noamro


    I extend it still dosnt work..
    Code:
    -b2561jnks (MC: 1.4.6) (Implementing API version 1.4.6-R0.1)
    19:41:15 [SEVERE] Could not load 'plugins\war.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: version is not defined
            at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile
    .java:202)
            at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.
    java:42)
            at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPlug
    inLoader.java:252)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:132)
            at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(CraftServer.jav
    a:235)
            at org.bukkit.craftbukkit.v1_4_6.CraftServer.<init>(CraftServer.java:213
    )
            at net.minecraft.server.v1_4_6.PlayerList.<init>(PlayerList.java:52)
            at net.minecraft.server.v1_4_6.DedicatedPlayerList.<init>(SourceFile:11)
     
            at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java
    :104)
            at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:
    399)
            at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:84
    9)
    Caused by: java.lang.NullPointerException
            at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile
    .java:200)
            ... 10 more
    
    [EDIT] Maybe this will help

    http://up364.siz.co.il/up3/dzhuzn5cjlnj.jpg

    http://up364.siz.co.il/up1/nz2dmw2mu2et.jpg
     
  5. Offline

    GodzOfMadness

    noamro you can't have description:
    unless it's for a command
    like when you do
    kit:
    description:
    that's valid
    but
    description:
    is not
     
  6. Offline

    noamro


    So i need to change it to

    Code:
    name: KitPvp
    main: me.noamro.war.WarPlugin
    commands:
      kit:
      kits:
    permission:
      kit.Donor:
        default: true
      kit.Archer:
        default: true
      kit.Regular:
        default: true
      kit.Medic:
        default: true
    ??
     
  7. Offline

    GodzOfMadness

    noamro yes and also add
    version: <version>
    after main
    and you don't need to remove the description: in the commands part of the plugin.yml
     
  8. Offline

    noamro

    Ok so like this its suppoes to work ?

    Code:
    name: KitPvp
    main: me.noamro.war.WarPlugin
    version: 1.0
    commands:
      kit:
        description: Gives you your selected kit.
      kits:
        description: Gives you your selected kit.
    permission:
      kit.Donor:
        default: true
      kit.Archer:
        default: true
      kit.Regular:
        default: true
      kit.Medic:
        default: true

    [EDIT]
    WORKS! Thanks!
     
Thread Status:
Not open for further replies.

Share This Page