➽ ♛ Item Exchange GUI ♛ ✪

Discussion in 'Plugin Development' started by ProMCKingz, Sep 23, 2014.

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

    ProMCKingz

    timtower
    I haven't tried anything yet..
     
  2. Online

    timtower Administrator Administrator Moderator

    ProMCKingz Serialization, deserialization, itemstacks
     
  3. Offline

    ProMCKingz

  4. Offline

    CraftCreeper6

    Skionz likes this.
  5. Offline

    ProMCKingz

  6. Offline

    CraftCreeper6

  7. Offline

    Skionz

    Google it.
     
  8. Online

    timtower Administrator Administrator Moderator

    Well, no.
    I work command based, GUI's aren't exactly my specialty.
     
  9. Offline

    CraftCreeper6

    GUI's are fairly simple;
    1) Create the GUI (Done)
    2) Add items (Not done)

    Get the items in the Config;
    Create an ItemStack and make the Material of the ItemStack the Material in the Config;
    Add the ItemStack to the GUI. Done.
     
  10. Offline

    ProMCKingz

    CraftCreeper6 timtower
    Ok, why won't
    Code:java
    1. CP.getConfig().set(player.getName(), clicked);
    2. CP.saveConfig();
    save "clicked" which is a string for the item clicked. In the config
     
  11. Offline

    CraftCreeper6

  12. Offline

    ProMCKingz

    CraftCreeper6
    Code:java
    1. ItemStack clicked = event.getCurrentItem();
     
  13. Offline

    CraftCreeper6

    So, essentially, you're saying;
    Make an inventory with .... in;
    When I click it. Set clicked to the item I click.
    Add the item I clicked to the config?

    By the way; is CP the constructor for your Main class?
     
  14. Offline

    ProMCKingz

    CraftCreeper6
    CP is a reference to my main class. As you can see the code in the first page. Also I want it to do this:
    I already have a "My Wardrobe" GUI, in which I would like to store the items, which have been clicked in a different GUI. So if I go to Wardrobe, click an item there, it should then store it and keep it in the "My Wardrobe" GUI.
    The method
    Code:java
    1. CP.getConfig().set(player.getName(), clicked);
    2. CP.saveConfig();
    does not save it in the config.yml.
     
  15. Offline

    CraftCreeper6

    ProMCKingz
    Set a repeating task in your onEnable; Inside, set it to save the config.
     
  16. Offline

    SmooshCakez

    Or you could not waste resources and save it at the end of every method you edit the configuration in.
    You could always try using the Java File object and make a YamlConfiguration object from that instead of getConfig() and saveConfig(). Also, you should probably use UUIDs (name changing).
     
  17. Offline

    CraftCreeper6

    SmooshCakez
    The only reason I said that is because every method of saving he/she tried, it didn't save.

    This is unnecessary.
    Although, I do agree ProMCKingz You should use UUIDs
     
  18. Offline

    ProMCKingz

    SmooshCakez
    I do save it after every method, and have also in this case.
     
  19. Offline

    CraftCreeper6

    ProMCKingz
    Stacktrace?
    Try clicked.toString();?
     
  20. Offline

    nuno1212sss

    This is wayyyy to much trouble for simply saving and loading stuff
    here's a tip:
    File's,
    Serialize,
    Deserialize,
    YamlConfiguration,
    ConfigurationSection,
    getItemStack,
    set(Path, itemstack);

    I know it's confusing, but I wasn't spoon fed in the beginning so I will not spoon feed you, I think it will be better this way :3
     
  21. Offline

    ProMCKingz

    nuno1212sss
    What is serialization ? I know what it is, however I am unaware of how to use it

    CraftCreeper6
    Doesn't work

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

    nuno1212sss

    ProMCKingz
    Serialization is making a class, into something you can save in a config file
     
  23. Offline

    ProMCKingz

    nuno1212sss
    How can I implement that onto my code?
     
  24. Offline

    nuno1212sss

    ProMCKingz In the itemstack case you just need to do
    SEC.set("Item", item);
    and to load;
    ItemStack i = SEC.getItemStack("Item");
     
  25. Offline

    ProMCKingz

    nuno1212sss
    I need it so it is unique for each user. e.g if someone clicks a chestplate, and another guy clicks a helmet, it should be the item they clicked.
     
  26. Offline

    nuno1212sss

    ProMCKingz dude, I told you everything you need, try to do it by yourself.
     
  27. Offline

    ProMCKingz

Thread Status:
Not open for further replies.

Share This Page