Util Chainable Inventory menus

Discussion in 'Resources' started by CraftCreeper6, Oct 25, 2014.

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

    CraftCreeper6

    Hello! First off, this is my first resource so please give constructive criticism.

    Have you ever wondered how to make an Inventory menu? Did you manage to find out how but it was just to complicated? Then try EasyGUI, it has a Chainable system in-which you can type:
    Code:java
    1. new EasyGUI(ChatColor.BLUE + "Title 32 characters").setSlots(9)
    2. .setItem(8, new ItemStack(Material.GLASS)).openGUIFor(p);


    For an inventory that would look like this:
    http://prntscr.com/4zk75c

    Easy as that! In the coming updates I will be adding:
    - Easy Inventory clicks
    - Need more ideas!!! :p

    Here is the class!

    Just 54 lines! :) | Update: 74 lines | Update Two: 128 lines!

    Usage of the methods:
    setSlots(Integer);

    Sets the slots that the inventory has.
    Code:java
    1. new EasyGUI("Test").setSlots(9);


    addItem(ItemStack);
    Add an item to the inventory
    Code:java
    1. new EasyGUI("Test").setSlots(9).addItem(new ItemStack(Material.WOOD));


    setItem(Integer, ItemStack);
    Set a slot to a specific item.
    Code:java
    1. new EasyGUI("Test").setSlots(9).setItem(8, new ItemStack(Material.WOOD));


    openGUIFor(Player);
    Opens a GUI for specified player.
    Code:java
    1. new EasyGUI("Test").setSlots(9).
    2. setItem(8, new ItemStack(Material.WOOD)).openGUIFor(player);


    getName();
    Returns the name of the inventory

    getSize();
    Returns the size of the inventory (Integer).

    clear();
    Clear the inventory
    Code:java
    1. new EasyGUI("Test").clear();


    contains(ItemStack);
    Returns a boolean value whether the inventory contains the ItemStack or not.
    Code:java
    1. if(new EasyGUI("Test").contains(new ItemStack(Material.WOOD))) return;


    contains(Material);
    Returns a boolean value whether the inventory contains the Material or not.
    Code:java
    1. if(new EasyGUI("Test").contains(Material.WOOD) return;


    removeItem(ItemStack);
    Remove an item from the inventory.
    Code:
    EasyGUI easyGUI = new EasyGUI("Test");
    if(easyGUI.contains(Material.WOOD)){
    easyGUI.removeItem(new ItemStack(Material.WOOD));
    }
    easyGUI.openGUIFor(player);
    Thank you for reading & enjoy!

    EDIT: Updated link to Gist!
    EDIT: Annotated, fixed contains (No one noticed :3)
    EDIT: Added support for contains(Material material); & removeItem(ItemStack item);
    EDIT: Fixed a code block that contained a false method ;p
     
    Last edited: May 11, 2015
    ChipDev likes this.
  2. Offline

    ChipDev

  3. Offline

    RingOfStorms

  4. Offline

    CraftCreeper6

    ChipDev Uh yea... Totaly the same thing :confused:
    RingOfStorms I have no idea what the similarity's are either...

    EDIT: ChipDev if your question is it works like it then no... It can work with it. But it is nothing alike it.
     
  5. Offline

    ChipDev

  6. Offline

    CraftCreeper6

  7. Offline

    ChipDev

    Some people do that... :l
     
  8. Offline

    CraftCreeper6

    ChipDev
    I am not a person.
    EDIT: I am a cyborg.
     
    Regablith likes this.
  9. Offline

    ChipDev

    you are a creeper, an entity.
     
  10. Offline

    CraftCreeper6

    ChipDev
    I am a cyborg from the planet Creeper in the Entity solar system.
     
  11. Offline

    ChipDev

    from the coco way from this universe from the multiverse through the lapses in time wrinkles where dark matter is invaded by red matter and that is what causes the big bangs, every second..

    Wat did I just type?
     
  12. Offline

    CraftCreeper6

    ChipDev
    I no longer understand life.
     
    ChipDev likes this.
  13. Offline

    CraftCreeper6

  14. Offline

    ChipDev

    I'm not asking for a fight, but If CraftCreeper6 wants to have a random conversation with me, Let it be. He created a good thread; and its nice to be funny sometimes. If he wants to be on-topic, he could say! :p
     
  15. Offline

    CraftCreeper6

    ChipDev
    Be on topic (This was clearly going to be in bwfcwalshy favor :)) You had it coming :)
     
  16. CraftCreeper6 ChipDev The major problem with this section is that it's bogged down by people who do not even consider that it could be used for genuine resource (I'm not saying this is a bad resource) and ends up with people making irrelevant, off-topic jokes between two people spanning ~8 posts.

    ChipDev, no offence, but you seem to be an example of this concept. Let me tell you, this isn't a section for you to just joke around in. This is a place to submit genuinely useful resources. If you do not find that fun enough, then maybe this section isn't for you. :)
     
    CraftCreeper6 likes this.
  17. Hmm, super util, but it's not working with same itemstacks :/
     
  18. Offline

    CraftCreeper6

    Nyqi
    What do you mean?
    EDIT: Updateed Gist. Better for support with Java 8 and added a more realistic "setItem()", now setItem(int slot, ItemStack item);
     
    ChipDev likes this.
  19. Offline

    CraftCreeper6

  20. CraftCreeper6, if I use same ItemStack for ex.
    Code:java
    1.  
    2. Menu.setItem(2, new ItemStack(Material.DIAMOND_BLOCK));
    3. Menu.setItem(3, new ItemStack(Material.DIAMOND_BLOCK));
    4.  

    it sets DIAMOND_BLOCK only to slot 3, because it overwrite previous ItemStack with slot in HashMap, can u repair it please? Thanks. :)

    I hope you will understand :D
     
  21. Offline

    CraftCreeper6

    Nyqi
    Hmm... Could you maybe try creating an ItemStack? As in, make an ItemStack before adding it to the inventory and see what it does?
     
  22. You mean like this
    Code:java
    1. ItemStack is = new ItemStack(Material.GOLD_INGOT);
    2. Menu.setItem(12, is);
    3. Menu.setItem(13, is);
    4. Menu.setItem(14, is);


    if yes, it's also not working :/

    it sets item only to last position (14)
    [​IMG]
     
  23. Offline

    mrCookieSlime

    CraftCreeper6
    You should not use the ItemStack as the key in the HashMap...
    Use the slot instead because with the current setup you are unable to have the same item in the inventory more than once.
     
  24. Offline

    CraftCreeper6

    Nyqi likes this.
  25. Offline

    CraftCreeper6

    Added:
    • .contains(Material material);.
    • .removeItem(ItemStack item);
     
    Last edited: Jan 22, 2015
Thread Status:
Not open for further replies.

Share This Page