Inventories

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

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

    new-ewrs728

    I think between Location and Block
     
  2. Offline

    timtower Administrator Administrator Moderator

    You only need to store locations to be honest, what is in the block itself is not important.
     
  3. Offline

    new-ewrs728

    But I still do not understand which key to use
    Block.add ("???", block.getLocation ())
     
  4. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 Who said that you need to use key value pairs?
    If you only need to store locations then you should use a list.
     
  5. Offline

    new-ewrs728

    I do not understand you.

    I need to record the location, because if the block is changed to another Material, then it will occupy a place in the config
     
  6. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 And what makes a list (that you can put in the config) not suitable for that then?
     
  7. Offline

    new-ewrs728

    Which VALUE will I need to create? ...
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    new-ewrs728

  10. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 1. That is not a list.
    2. Your value is a single locations, your key a single word. Based on that the if statement always returns false.
     
  11. Offline

    new-ewrs728

    https://pastebin.com/X7XL60T7
    I rummaged through the internet and did it.
     
  12. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 Now parse the file in the onEnable so you don't have to read a huge file every time somebody breaks a block.
    And save in the onDisable.
     
  13. Offline

    new-ewrs728

    In onEnable ()? Something I'm confused at all.

    Why didn't we do it with the Gamemode? Tell me, please
     
  14. Offline

    timtower Administrator Administrator Moderator

  15. Offline

    new-ewrs728

    And I'm talking about "analyze the file"
     
  16. Offline

    timtower Administrator Administrator Moderator

    If you load the file contents into the memory in the onEnable then you don't have to do that when a block is broken.
    It is a performance improvement.
     
  17. Offline

    new-ewrs728


    File Blocks = new File(this.getDataFolder() + File.separator + "Blocks" + File.separator + "Blocks.yml");
    FileConfiguration data = YamlConfiguration.loadConfiguration(Blocks);

    I'll write it in onEnable, and then I need to get it from Main, right? I'm drowning in the morning
     
  18. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 You need to get access it somehow, how you do that is up to you.
     
  19. Offline

    new-ewrs728

    I had this problem. When INVENTORIES is not created for a player, then if a player enters with the gamemode 1, then survival.yml will create an empty and creative.yml will copy survival.yml, I have a question how to create creative.yml if not, but with an empty inventory.
     
    Last edited by a moderator: Oct 9, 2018
  20. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 Then post your code, I don't know how you are doing everything now so can't say anything yet.
     
  21. Offline

    new-ewrs728

  22. Offline

    timtower Administrator Administrator Moderator

  23. Offline

    new-ewrs728

    And how will this help me ???
     
  24. Offline

    timtower Administrator Administrator Moderator

    data.save(CreativeInventory); data.save(SurvivalInventory);
    They are both saving to data!
    Check them.
     
  25. Offline

    new-ewrs728

    Well, I know what they are doing. What do you suggest I do with them?
     
  26. Offline

    timtower Administrator Administrator Moderator

    You do realize that you have 1 inventory writing to 2 files? Unlike line 34 and 35?
     
  27. Offline

    new-ewrs728

  28. Offline

    timtower Administrator Administrator Moderator

    Yeah, if you post code without includes then line numbers don't say anything anymore.
    Try debugging it yourself first.
     
Thread Status:
Not open for further replies.

Share This Page