Solved [JAVA CODE] Inventory slot

Discussion in 'Plugin Development' started by Henriksen1000, Aug 22, 2014.

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

    Henriksen1000

    Hello! I am working on my FIRST plugin! (So exited) :D:p

    Well, i need a code to select slots!

    Example:
    When i type /gadget pb will the item be put in slot 4!
    [​IMG]
     
  2. Offline

    MasterDoctor

    So to clarify, do you need the code to select the slot or put the item in the slot?

    To select the slot use this:
    Code:java
    1. player.setHeldItemSlot(4);


    To put an item in the slot use this:
    Code:java
    1. player.getInventory().setItem(slotNumber, item);


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

    Jake6177

    So are you asking us to code for you or what?
     
    MasterDoctor and Skyost like this.
  4. Offline

    Henriksen1000

    I am asking about a code to give an item to SLOT 4!

    MasterDoctor , Thanks!

    :D

    I get an ERROR when i use it

    player.getInventory().setItem(slotNumber, item)

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

    MasterDoctor

    Where does the Error appear? In the console or in your IDE (Eclipse)

    Could you post your main class?

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

    Henriksen1000

    ok!

    MasterDoctor, answer in the Conversation

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page