games647 / FlexibleLogin

A Sponge minecraft server plugin for second factor authentication
https://forums.spongepowered.org/t/8872
MIT License
87 stars 22 forks source link

NBT database suggestion #107

Closed ghost closed 6 years ago

ghost commented 6 years ago

Can you add an option to save hash-password data not in the database, but in nbt file located in the world folder.

games647 commented 6 years ago

I think it doesn't make sense really. Permissions are also stored independently from the NBT data. I think player login data are such critical things that should persist even if you delete the worlds folder.

ghost commented 6 years ago

You can store it in a separated dat file even outside of world folder which mission is to store passwords in minecraft style (nbt).

games647 commented 6 years ago

Yes, but in databases you can build indices and search using different columns. This is necessarry, because FlexibleLogin searches using the UUID for login data and for optionally for admin commands like reset password using the player name. If we use file-based storage we have to visit every file.

ghost commented 6 years ago

You are wrong about nbt readers, its pretty fast a lot. You can read only neccessary information per query. Dat files can be locked per session. Minecraft worlds works the same way, youre not reading entire world chunks, only that is nesessary. It will be enough to put one dat file like your db file same directory if u want.

games647 commented 6 years ago

Yes, but still have to search through all data if you want to make a lookup using the player name or you implement database indices and all other features like caches and concurrent reads yourself.

Databases are great for saving the data in the same structure with a fixed amount of columns. I don't see the actual benefit on using NBT in comparison to SQL databases in this scenario (not raw data or key-value with different length). NBT might be useful if it's the only database storage option, but implementing it as an alternative to SQL complicates it a lot.