Inventories

Discussion in 'Plugin Development' started by ewrs, Oct 8, 2018.

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

    new-ewrs728

    I wanted to ask you about how to add.

    Small error

    The method loadConfiguration(File) in the type YamlConfiguration is not applicable for the arguments (InputStream)

    https://pastebin.com/UibcKAxc
     
  2. Online

    timtower Administrator Administrator Moderator

    @new-ewrs728 Then look at the other constructors / methods that you can use.
     
  3. Offline

    new-ewrs728

    I would prefer a professional opinion
     
  4. Online

    timtower Administrator Administrator Moderator

  5. Offline

    new-ewrs728

    File CreativeInventory = new File(this.getDataFolder() + File.separator + "Inventories" + File.separator + "Inventories_", p.getUniqueId() + File.separator + "creative.yml");
    FileConfiguration data = YamlConfiguration.loadConfiguration(CreativeInventory);

    I did such a thing, but it does not create a file, if it does not exist, but if I check the file specifically, it is created as a folder. I threw you at that time.
     
  6. Online

    timtower Administrator Administrator Moderator

  7. Offline

    new-ewrs728

  8. Online

    timtower Administrator Administrator Moderator

    Well, you want to know what is in which slot, so the slot is the key. ItemStack the value.
     
  9. Offline

    new-ewrs728

    In this case I will ask an example ... :(
     
  10. Online

    timtower Administrator Administrator Moderator

    I won't give that.
     
  11. Offline

    new-ewrs728

    https://pastebin.com/itk2NeTj
    Why doesn't it create? Explain

    I'm already mad at this situation.
    If you explained it would be easier
     
  12. Online

    timtower Administrator Administrator Moderator

    @new-ewrs728 I explained as much as possible.
    Load the file.
    Set the config.
    And the step that you forgot: save the file
     
  13. Offline

    new-ewrs728

    https://pastebin.com/BKGqBsu1

    Now everything works. As I understood, I will need to receive these things further.

    But when should I register player inventories? GameModeChangeEvent?

    And even if the GameMode Change Event, how to know its past, to write in yml
     
    Last edited: Oct 8, 2018
  14. Online

    timtower Administrator Administrator Moderator

  15. Offline

    new-ewrs728

    Made and everything works great. Let's look at my question above, please
     
  16. Online

    timtower Administrator Administrator Moderator

    @new-ewrs728 You listen to it with eventPriority Logging.
    Then you check if it is cancelled or not.
     
  17. Offline

    new-ewrs728

    Canceled or not? What are we talking about? : D
     
  18. Online

    timtower Administrator Administrator Moderator

    Find the event in the javadocs, look at the methods with the word cancelled in mind.
    Or look at the event reference on the wiki
     
  19. Offline

    new-ewrs728

    I understand. Do you mean the LoginEvent event?
     
  20. Online

    timtower Administrator Administrator Moderator

    Did anybody mention that event?
     
  21. Offline

    new-ewrs728

    I thought it was about him ...
    How can I find out which game mode the player has changed? For example, if he changed to creative, then the saveSurvivalInventory method should be called, if for survival, then loadSurvivalInventory
     
    Last edited: Oct 8, 2018
  22. Online

    timtower Administrator Administrator Moderator

    @new-ewrs728
     
  23. Offline

    new-ewrs728

    I have already figured out and everything works, thanks for the support. Most likely, in the future I will ask more questions. Although, why would we not now?

    See, I need to make sure that if a block is put by a player in a creative, then the drop from it is canceled. I understand that I will need to write it in yml?
     
  24. Online

    timtower Administrator Administrator Moderator

    Or somewhere else, but YML is a good place for it.
    Gets very big though when you have a lot of blocks being placed with creative.
     
  25. Offline

    new-ewrs728

    But there is no better option? :D
     
  26. Online

    timtower Administrator Administrator Moderator

    There are different options, there always are, but in the end you need to be able to have them loaded in runtime so it is not that big of a deal.
    Certainly not when you split the YML into the chunks that the blocks are in.
     
  27. Offline

    new-ewrs728

    I do not understand with which key I need to add a block.
     
  28. Online

    timtower Administrator Administrator Moderator

    What value do you want to give it then?
     
  29. Offline

    new-ewrs728

    Then I have two questions :D
     
  30. Online

    timtower Administrator Administrator Moderator

    What information do you want to store?
     
Thread Status:
Not open for further replies.

Share This Page