Discussion in 'Plugin Development' started by ewrs, Oct 8, 2018.
I think between Location and Block
You only need to store locations to be honest, what is in the block itself is not important.
But I still do not understand which key to use
Block.add ("???", block.getLocation ())
@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.
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
@new-ewrs728 And what makes a list (that you can put in the config) not suitable for that then?
Which VALUE will I need to create? ...
@new-ewrs728 A list of locations.
True, now it replaces another one and does not react if the block is in YML
@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.
I rummaged through the internet and did it.
@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.
In onEnable ()? Something I'm confused at all.
Why didn't we do it with the Gamemode? Tell me, please
@new-ewrs728 I am talking about the blocks...
And I'm talking about "analyze the file"
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.
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
@new-ewrs728 You need to get access it somehow, how you do that is up to you.
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.
@new-ewrs728 Then post your code, I don't know how you are doing everything now so can't say anything yet.
Join Event: https://pastebin.com/jpkww1Nf
@new-ewrs728 Join event, line 20 and 21.
And how will this help me ???
They are both saving to data!
Well, I know what they are doing. What do you suggest I do with them?
You do realize that you have 1 inventory writing to 2 files? Unlike line 34 and 35?
Yeah, if you post code without includes then line numbers don't say anything anymore.
Try debugging it yourself first.
Separate names with a comma.