Help Giving Player Items

Discussion in 'Plugin Development' started by Warren2497, Dec 22, 2014.

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

    Warren2497

    Im working on my first plugin and im using this as a reference. Heres what i need help with: When someone clicks one of the wools (creative, survival, adventure) what do i add to make it give them an item?
    Im gonna turn this into a kitpvp plugin. so i need to instead of changing there gamemmodes i wanna give them items. Thanks!

    Link:

    MenuInv.java ~ http://pastebin.com/Kp5wsx5Y
    Menu.java ~ http://pastebin.com/jNWWdgma
     
  2. Offline

    Skionz

  3. Offline

    Warren2497

    @Skionz could you be a litte more detailed? Like i said this is my first plugin i dont understand much :p
     
  4. Offline

    WesJD

  5. Offline

    Skionz

    @Warren2497 Inventory is the class, addItem is the method.
     
  6. Offline

    Warren2497

    @Skionz okay thanks ill try it out when i get back from work. also could you tell me what to add instead of players right clicking a "block" i want to add a chest in the inventory labled "kits" and then they right click it in ther inventory it will bring up the menu of kits
     
  7. Offline

    Skionz

    @Warren2497 Player#openInventory(Inventory)
    Look into the InventoryClickEvent as well.
     
  8. Offline

    Warren2497

    thanks too ill try it out as well when i come home tonight

    @WesJD @Skionz could one of you add it to my script so i can understand it a little better? Id really appreciate it :)
    you could just make it where it gives them a diamond sword when they click one of the wools, and make it where they right click a chest in there hand instead of a block on the ground

    thanks

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

    Skionz

    @Warren2497 I doubt anyone will write your code for you. I suggest looking at the plugin requests forum.
     
  10. Offline

    Warren2497

    @Skionz yeah all good, im just looking for help. im trying to learn this stuff and im just not getting everything yet. but when i see it done i understand what its doing
     
  11. Offline

    Skionz

    @Warren2497 First off, I suggest you learn at least basic Java.
    That quote pretty much sums up what you should have a basic understanding of.
    Onto Bukkit:
    Bukkit has these things called events and contains a Listener interface. To create a class that listens to events, simply register this class as a listener in your main class (google if you don't know how), and let that class implement the Listener interface. Also make sure to have an EventHandler annotation above your method. Here is an example:
    Code:
    @EventHandler
    public void doStuff(BlockBreakEvent event) {
        System.out.println("A block was broken :0");
    }
    This method will be invoked when a player breaks a block. Bukkit listeners are similar to listening to keys with Swing (MouseListener, KeyListener, etc.). You can find a list of all Bukkit classes, methods, interfaces, and all that stuff in Bukkit's Javadocs.
     
Thread Status:
Not open for further replies.

Share This Page