Enchanted Items + Killed ID

Discussion in 'Plugin Development' started by Paradrakor, Jul 18, 2014.

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



    Hello, I have 2 probably very nooby questions about how to improve my plugin.

    1) How do I change this code to make the diamond sword enchanted with sharpness I? What is the format for enchantments?

    1. player.getInventory().addItem(new ItemStack (Material.DIAMOND_SWORD, 1));

    2) How do I tell the ID of someone who killed another player so I can give credits or money to that player?
  2. Offline


    1: You have to modify the ItemMeta.

    2: What do you mean by ID?
  3. Offline


    1. How do I do that? Can I do it by code?

    2. The name of the player

    I can't find this information through research :/

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


  5. Offline


  6. Offline


    Paradrakor I just gave you the page containing the methods of the player and the itemmeta objects, as you needed. Can you not find the needed method or is there something else you don't understand?
  7. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    Paradrakor We're not going to spoon feed you code. Look at the javadocs for ItemStack
    FabeGabeMC likes this.
  8. Offline


    I am not sure how to use .addEnchant, I'm really new.
  9. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

  10. Offline


    1. clearInventory(player.getInventory());
    2. ItemStack pvpSword = new ItemStack (276);
    3. Enchantment sharpness = new EnchantmentWrapper(16);
    4. pvpSword.addEnchantment(sharpness, 0);
    5. player.getInventory().addItem(pvpSword);
    6. player.getInventory().setHelmet(new ItemStack (Material.IRON_HELMET,1));
    7. player.getInventory().setChestplate(new ItemStack (Material.IRON_CHESTPLATE,1));
    8. player.getInventory().setLeggings(new ItemStack (Material.IRON_LEGGINGS,1));
    10. player.getInventory().setBoots(new ItemStack (Material.IRON_BOOTS,1));

    "An internal error occured while attempting to perform this command."

    Any help?
  11. Offline


    Paste stacktrace from console as well as full class.
Thread Status:
Not open for further replies.

Share This Page