Help with this code not returning anything.

Discussion in 'Plugin Development' started by CdoingBaddie, Oct 20, 2013.

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

    CdoingBaddie

    Code:
            if(commandLabel.equalsIgnoreCase("kits")){
                if(player.isOp()){
                    if(sender instanceof Player){
                        //kitinv.addItem(pvpSword);
                        player.sendMessage(ChatColor.GRAY + "/Pvp - The regular pvp kit that everyone has!");
                        player.sendMessage(ChatColor.GRAY + "/Thor - Temparalily Disabled for non-ops due to bugs!");
                        player.sendMessage(ChatColor.GRAY + "/Viper - Have a chance of poisoning a player!");
                        player.sendMessage(ChatColor.GRAY + "/Fireman - You don't take damage lightning or fire!");
                        player.sendMessage(ChatColor.GRAY + "/Snail - Give a player slowness!");
                        player.sendMessage(ChatColor.RED + "Admin Commands!");
                        player.sendMessage(ChatColor.GRAY + "/Override [player] - Allow a player to get a kit without dieing!");
                    }
                }else
                    if(!player.isOp()){
                        ItemStack rocket = new ItemStack(Material.FIREWORK);
                        ItemMeta rmeta = rocket.getItemMeta();
                        rmeta.setDisplayName(ChatColor.RED + "Kangaroo Rocket");
                        rocket.setItemMeta(rmeta);
                        ItemStack FiremanBucket = new ItemStack(Material.WATER);
                        ItemMeta firemeta = FiremanBucket.getItemMeta();
                        firemeta.setDisplayName(ChatColor.BLUE + "FireMan's Bucket");
                        FiremanBucket.setItemMeta(firemeta);
                        kitinv.clear();
                        player.openInventory(kitinv);
                        ItemStack pvpsword = new ItemStack(Material.STONE_SWORD);
                        ItemMeta pvpmeta = pvpsword.getItemMeta();
                        pvpmeta.setDisplayName(ChatColor.BLACK + "PvP Sword");
                        pvpsword.setItemMeta(pvpmeta);
                        ItemStack viper = new ItemStack(Material.SPIDER_EYE);
                        ItemMeta vmeta = viper.getItemMeta();
                        vmeta.setDisplayName(ChatColor.GREEN + "Viper");
                        viper.setItemMeta(vmeta);
                        ItemStack snail = new ItemStack(Material.SLIME_BALL);
                        ItemMeta smeta = snail.getItemMeta();
                        smeta.setDisplayName(ChatColor.GRAY + "Snail ball");
                        snail.setItemMeta(smeta);
                        kitinv.addItem(pvpsword);
                        kitinv.setItem(1, new ItemStack(Material.GLASS));
                        kitinv.addItem(FiremanBucket);
                        kitinv.setItem(3, new ItemStack(Material.GLASS));
                        kitinv.addItem(viper);
                        kitinv.setItem(5, new ItemStack(Material.GLASS));
                        kitinv.addItem(snail);
                        kitinv.setItem(7, new ItemStack(Material.GLASS));
                        kitinv.addItem(rocket);
                        return true;
                    }
            }
    This ^ Specifically wont return ANYTHING. Everything else in the plugin will return something. *Working* Please help.
     
  2. Offline

    TomTheDeveloper

    Did you put the command in the plugin.yml file?
     
  3. Offline

    CdoingBaddie

    Yes, yes I did.

    TomTheDeveloper Yeah we did..

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  4. Offline

    DailyLove

  5. Offline

    CdoingBaddie

    DailyLove The command. The command it'self.
     
  6. Offline

    DailyLove

    CdoingBaddie When you type the command what does it do? Is there a problem with the player.isOp() code, or !player.isOp() code?
     
  7. Offline

    CdoingBaddie

    DailyLove It dosent return anything, no messages. It's just in console:
    Code:
    HighOnSwiftness: /kit
    HighOnSwiftness: /kit
    That's when I did it twice.
     
  8. Offline

    DailyLove

    CdoingBaddie Can you add me on skype? dailylove.dev. So we can debug it.
     
  9. Offline

    user_90854156

    Shouldn't the "else" be }else{ ?
    If it's "else if", you'll need an "else" at the end
     
  10. Offline

    CdoingBaddie

  11. Offline

    xviniciox

    Hm, change the return boolean to false, remove the statement "if(!player.isOp()){" under the "} else" and unless "} else " put "} else {". I think it'll work.
    PS: If this is not the first/only command in the class, you have to change it to
    else if(commandLabel.equalsIgnoreCase("kits")){
    And insert the maximum (Until it has any errors) brackets up the command, unless it wont return.

    I hope helped you! (I've already had this error before...)
     
Thread Status:
Not open for further replies.

Share This Page