Kit command not working (Custom Plugin)

Discussion in 'Plugin Development' started by RainingTNT123, Jun 6, 2018.

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

    RainingTNT123

    So, I'm making a KitPvP plugin and the kit is not working I try doing /pvpkit and it does not work.
    If you can help that would be nice :) If you need anything I can give it to you, so you can help!
    2018-06-06_17.00.41.png

    2018-06-06_17.08.01.png

    Thank you!
    Code:
    package me.VizaPvP.main;
    
    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.meta.ItemMeta;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import me.VizaPvP.soupkit.PlayerListeners;
    public class Main extends JavaPlugin{
    private static Main instance;
     
    
    public void log(String string) {
      System.out.println(string);
    }
    
    public static Main getInstance() {
    return instance;
    }
    public void registerListeners() {
      PluginManager pm = getServer().getPluginManager();
      pm.registerEvents(new PlayerListeners(this), this);
      }
    public void registerCommands() {
    /// Not using this right now.
    }
    // Enable And Disable
    @Override
    public void onEnable(){
      getLogger().info("Soup kits are enabled!");
      instance = this;
      registerListeners();
      registerCommands();
    }
    @Override
    public void onDisable(){
      getLogger().info("Soup kits are disabled =(");
      instance = null;
    }
    
    // COMMANDS
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    The Kit
      //PvP kit
    
      if(commandLabel.equalsIgnoreCase("pvpkit")){
      if(sender instanceof Player) {
      Player player = (Player) sender;
     
      player.getInventory().clear();
      ItemStack pvpsword = new ItemStack(Material.IRON_SWORD);
      ItemMeta m = pvpsword.getItemMeta();
      m.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "PvP Sword");
      pvpsword.setItemMeta(m);
      player.getInventory().addItem(pvpsword);
      player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP, 35));
      player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
      player.getInventory().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
      player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
      player.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
      player.sendMessage(ChatColor.GREEN + "You were given kit" + ChatColor.BOLD + ChatColor.GOLD + "PvP");
      }
    // End of pvp command
     
    //Archer
      if(cmd.getName().equalsIgnoreCase("spvp kit archer") && sender instanceof Player) {
     
      Player player = (Player) sender;
      player.getInventory().clear();
      ItemStack archersword = new ItemStack(Material.STONE_SWORD);
      ItemMeta m = archersword.getItemMeta();
      m.setDisplayName("" + ChatColor.GOLD + ChatColor.BOLD + "Archer Sword");
      archersword.setItemMeta(m);
      player.getInventory().addItem(archersword);
     
      ItemStack archerbow = new ItemStack(Material.BOW);
      ItemMeta o = archerbow.getItemMeta();
      o.setDisplayName("" + ChatColor.GOLD + ChatColor.BOLD + "Archer Bow");
      archerbow.setItemMeta(o);
      archerbow.addEnchantment(Enchantment.ARROW_DAMAGE, 2);
      player.getInventory().addItem(archerbow);
     
      player.getInventory().addItem(new ItemStack(Material.ARROW, 16));
      player.getInventory().addItem(new ItemStack(Material.MUSHROOM_SOUP, 33));
      player.getInventory().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
      player.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET));
      player.getInventory().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
      player.getInventory().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
      player.sendMessage(ChatColor.GREEN + "You were given kit" + ChatColor.BOLD + ChatColor.GOLD + "Archer");
      }
     
      }
      return true;
     
    }
    }
     

    Attached Files:

    Last edited by a moderator: Jun 6, 2018
  2. Offline

    timtower Moderator Moderator

    @RainingTNT123 You need to check everything after spvp with arguments, it is not part of the command anymore.
     
  3. Offline

    RainingTNT123

    Thank You =D
     
Thread Status:
Not open for further replies.

Share This Page