KitPvp - Not working?

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

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

    JollyGiant16

    kreashenz

     
  2. Offline

    kreashenz

    It can't be wrong.. I just tested it! Do you have any other classes, or is that the main one?
    Post your WHOLE plugin.yml.
     
  3. Offline

    JollyGiant16

    kreashenz
    Works! I found out in plugin.yml I had it me.anonymous350.Kits.Kits but the Class was called Kit

    I have an issue were only /kit regular works
     
  4. Offline

    kreashenz

    There! See, I told you it wasn't wrong.. :p Its my own code xD
     
  5. Offline

    JollyGiant16

    kreashenz

    I have an issue were only /kit regular works
     
  6. Offline

    kreashenz

    Oh wow, plugin.yml, post please.
     
  7. Offline

    JollyGiant16

    kreashenz

     
  8. Offline

    kreashenz

    default: false.. WRONG
    default: true OR op
    Problem solved :)
     
  9. Offline

    JollyGiant16

    kreashenz

    Where would I add player.getInventory().clear() cause when I type /kit Donor I want it to clear when I type /kit Regular
     
  10. Offline

    kreashenz

    I already put it there, didn't I?.. pi.clear();
     
  11. Offline

    JollyGiant16

    kreashenz

    I know you did but for some reason when I type /kit regular then /kit Archer my armor changes but not the Inventory like I'll still have the Diamond sword.
     
  12. Offline

    kreashenz

    What.. Lol, I didn't get that for when I tested it.. Well, that's most likely a little mistake, like pi.setsword(getswodr);
    instead of pi.setsword(getsword).. Check through them , and then tell me.
     
  13. Offline

    JollyGiant16

    kreashenz

    Code:
    }
                        else if (args[0].equalsIgnoreCase("Medic")){
                                  if ((sender instanceof Player )) {
                                      if (sender.hasPermission("kit.medic")) {
                                          Player player = (Player)sender;
                                          PlayerInventory pi = player.getInventory();
                                          for (PotionEffect effect : player.getActivePotionEffects()) {
                                              player.removePotionEffect(effect.getType());
                                              pi.clear();
                                          }
                                          ItemStack gethat = new ItemStack(Material.GOLD_HELMET);
                                          gethat.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
                                          ItemStack gettop = new ItemStack(Material.GOLD_CHESTPLATE);
                                          gettop.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
                                          ItemStack getlegs = new ItemStack(Material.GOLD_LEGGINGS);
                                          getlegs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
                                          ItemStack getshoes = new ItemStack(Material.GOLD_BOOTS);
                                          getshoes.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
                                          ItemStack getsword = new ItemStack(Material.IRON_SWORD);
                                          getsword.addEnchantment(Enchantment.KNOCKBACK, 1);
                                          player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 2400000, 0));
                                          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 + "Medic" + ChatColor.GRAY + " kit.");
                                      } else sender.sendMessage(this.prefix + ChatColor.DARK_RED + "No permission to do this command.");
    Plugin.yml:

     
  14. Offline

    kreashenz

    That should work.. :p
     
  15. Offline

    JollyGiant16

    I mean it dosn't work and I added kit Mage aswell.
     
  16. Offline

    kreashenz

    Well, I publicly released my plugin.. So just if you want, you can use that.. Or, fix this yourself, because I do not see any problem..
     
  17. Offline

    JollyGiant16

    I fixed the issue but I get this werid little error/glitch.
    If I have access to a kit it tells me You've switch to (Class)
    and then tells me Invalid kit.
     
  18. Offline

    kreashenz

    Hmmm... Look, I guess I could send you a code ( working ) for the archer kit, and regular, and a good medic kit, and that will DEFINITELY work.. If it doesn't, its most likely something your editing or trying to change in it..

    Code:
    package me.anonymous350.Kits;
     
    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 Kit {
     
        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.");
        }
    }
    PLUGIN.YML:
    Code:
    name: KitPvp
    main: me.anonymous350.Kits.Kit
    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
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  19. Offline

    noamro

    Hey ,im new and i tried that code... but some how i dosnt work for me..
    What i did wrong? O.O
    are you sure the plugin.yml is correct ?
     
  20. Offline

    kreashenz

    -.- It is my OWN DAMN CODE! I know if its broken or not, make sure you renamed the package your using, correctly. Most likely , you didn't rename the MAIN: in the plugin.yml, I surely have tested this, and I know it works.
     
  21. Offline

    noamro

    I used the same name.. me.anonymous350.Kits.Kit

    here , look

    Code:
    package me.anonymous350.Kits;
     
    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 Kit {
     
        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.anonymous350.Kits.Kit
    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
    the name of the package is "package me.anonymous350.Kits;"
    and the class name is "Kit"
     
  22. do u even use the right yml format? the space between the words does matter soo if you change that...idk..
     
  23. Offline

    noamro

    The space between default: true ?
    there is a space there O.O
    i need to remove it ?
     
  24. Code:
    name: KitPvp
    main: me.anonymous350.Kits.Kit
    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
    ^--this
      kit.Archer:
        default: true
      kit.Regular:
        default: true
      kit.Medic:
        default: true
     
  25. Offline

    noamro

    i just copy paste what he wrote...
    can you send me the plugin.yml in a notepad file so the spaces wont mess around ?
     
  26. wait start ur plugin and show error report again...
     
  27. Offline

    GodzOfMadness

    kreashenz JollyGiant16
    your plugin.yml is loading the wrong class file
    you are doing
    main: me.anonymous350.Kits.Kits
    your main class is named "Kit"
    main: me.anonymous350.Kits.Kit

    [EDIT] forum post didn't update so i didn't see the message noamro sent when i was making my post
     
  28. Offline

    noamro

    I did another one from the start
    and i call it me.noamro.war.war
    and its still dosnt work
     
  29. Offline

    GodzOfMadness

    noamro is it exactly what the path is? because me.germanchocolate.Hi
    could go wrong if i do me.germanchocolate.hi
     
  30. Offline

    noamro

    Really? O.O
    its me.noamro.war.war
    i need to change the package to me.noamro.War
    and the class to War
    too ?
    edit : ohh.. no i write the same without caps... still dosnt work
     
Thread Status:
Not open for further replies.

Share This Page