Solved No Errors,But wont work! HELP

Discussion in 'Plugin Development' started by Ula492, Jun 2, 2014.

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

    Ula492

    This command right there wont work in game there is no errors on consoles and no invalid messages in game and on eclipse no errors were found PLEASE HELP!


    Code:java
    1. if(cmd.getName().equalsIgnoreCase("VIP+Fighter")) {
    2. if(!sender.hasPermission("VIP+Fighter.set")) {
    3. sender.sendMessage(ChatColor.RED + "You Do Not Have Permission To use this Kit!");
    4. }
    5.  
    6. player.getInventory().clear();
    7. ItemStack VIPPlusSword = new ItemStack(Material.DIAMOND_SWORD);
    8. VIPPlusSword.addEnchantment(Enchantment.KNOCKBACK, 2);
    9. VIPPlusSword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    10. ItemStack VIPPlusHelmet = new ItemStack(Material.DIAMOND_HELMET);
    11. VIPPlusHelmet.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    12. ItemStack VIPPlusChest = new ItemStack(Material.DIAMOND_CHESTPLATE);
    13. VIPPlusChest.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    14. ItemStack VIPPlusLegs = new ItemStack(Material.DIAMOND_LEGGINGS);
    15. VIPPlusLegs.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
    16. ItemStack VIPPlusBoots = new ItemStack(Material.DIAMOND_BOOTS);
    17. VIPPlusBoots.addEnchantment(Enchantment.PROTECTION_PROJECTILE, 4);
     
  2. Ula492
    [1] Is the command registered in your plugin.yml?
    [2] Is the command's executor registered in your main class?
    [3] Even if someone doesn't have the permission, the command will still run because you forgot to put
    Code:
    return true
    after saying that they do not have permission.
     
  3. Offline

    pluginsbyjason

    Your permission check is flawed because all it does is send a message to the player if they don't have the permission and continues on to gives the player the items. You should probably encapsulate that item giving portion with else { }
     
  4. Offline

    es359

    Ula492 Can you show us the whole class?
     
  5. Offline

    Necrodoom

    These items are not being added to player inventory in this code piece either.
     
  6. Offline

    Konkz

    Or just add a return; after perm. check
     
    pluginsbyjason likes this.
  7. Offline

    Ula492

    Yea i got it fixed i was missing the add inventory code:D thanks guys! But Now i have another error while trying to add custom names to items. I Know the codes are right but Im not sure there in order
    Code:java
    1. player.getInventory().clear();
    2. ItemStack VIPPlusSword = new ItemStack(Material.DIAMOND_SWORD);
    3. VIPPlusSword.addEnchantment(Enchantment.KNOCKBACK, 2);
    4. VIPPlusSword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
    5. ItemMeta meta = (ItemMeta) VIPPlusSword.getItemMeta();
    6. meta.setDisplayName(ChatColor.RED + "VIPPlusSword");
    7. VIPPlusSword.setItemMeta(meta);
    8. player.getInventory().addItem(VIPPlusSword);
     
Thread Status:
Not open for further replies.

Share This Page