[Bukkit Coding Help] How would I do this?

Status
This thread has been locked.

Plus.

livin
Supreme
Feedback score
16
Posts
311
Reactions
158
Resources
0
Hey everyone,

So I'm trying to make it so my plugin can hold every player's stats. Like some sort of player stat holder in a file. Like e.g. each player has their own "balance" or "energy count" etc.
What would I use for this? MySQL? HashMaps, what would I use?
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Ghast

Founding Father of Hypocrisy - https://artemis.ac
Supreme
Feedback score
54
Posts
2,096
Reactions
3,285
Resources
79
Config or YML file
 

Turtle

turtle#1989
Supreme
Feedback score
17
Posts
751
Reactions
419
Resources
0
Hey everyone,

So I'm trying to make it so my plugin can hold every player's stats. Like some sort of player stat holder in a file. Like e.g. each player has their own "balance" or "energy count" etc.
What would I use for this? MySQL? HashMaps, what would I use?
a custom class and some sort of database
 

Fire

Always DM me here before dealing via Discord.
Supreme
Feedback score
74
Posts
3,045
Reactions
1,745
Resources
0
What would I use for this? MySQL? HashMaps, what would I use?
Use MySQL. Storing data like this is okay in a file, but its not that much harder making your plugin use MySQL instead. Which is faster, and more efficient, especially if larger servers are going to be using it.
 

LCastr0

Feedback score
0
Posts
15
Reactions
5
Resources
0
Depends.
If you have multiple servers (like in a network) you need SQL. If you don't, you can have it in a YAML file, but I'd recommend MySQL anyway, because if someday you have multiple servers, you won't need to worry about that.
HashMaps reset after the server restarts so... Not really an option.
 

Turtle

turtle#1989
Supreme
Feedback score
17
Posts
751
Reactions
419
Resources
0
What sort of database? Also will this be hard?
mysql, mongodb which ever one you prefer[DOUBLEPOST=1497459028][/DOUBLEPOST]
Depends.
If you have multiple servers (like in a network) you need SQL. If you don't, you can have it in a YAML file, but I'd recommend MySQL anyway, because if someday you have multiple servers, you won't need to worry about that.
HashMaps reset after the server restarts so... Not really an option.
mysql is faster than file.
 

Plus.

livin
Supreme
Feedback score
16
Posts
311
Reactions
158
Resources
0
Use MySQL. Storing data like this is okay in a file, but its not that much harder making your plugin use MySQL instead. Which is faster, and more efficient, especially if larger servers are going to be using it.
Larger servers will not be using it, only me, should I just use a file?
 

Fire

Always DM me here before dealing via Discord.
Supreme
Feedback score
74
Posts
3,045
Reactions
1,745
Resources
0
Larger servers will not be using it, only me, should I just use a file?
If only a smallish server is going to be using it (Under 50 players) then I dont see a great deal of harm in using a file. Though it would still be a bit better using SQL.
 

Plus.

livin
Supreme
Feedback score
16
Posts
311
Reactions
158
Resources
0
If only a smallish server is going to be using it (Under 50 players) then I dont see a great deal of harm in using a file. Though it would still be a bit better using SQL.
Thanks for your ideas!
Is SQL hard to learn/use? Can you give me some bukkit related SQL tutorials, please? I could slip in a rep for you. ;)
 

Ghast

Founding Father of Hypocrisy - https://artemis.ac
Supreme
Feedback score
54
Posts
2,096
Reactions
3,285
Resources
79
Thanks for your ideas!
Is SQL hard to learn/use? Can you give me some bukkit related SQL tutorials, please? I could slip in a rep for you. ;)
It is easy :)
 

Plus.

livin
Supreme
Feedback score
16
Posts
311
Reactions
158
Resources
0
From the sounds of things you're a beginner which is completely ok, welcome to programming.

Store all the data that you'd want in a YML file to start with, however do not get and modify all the data from the file in real time as events that you're tracking will happen quite quickly.

When the player joins, check that the data storage file contains his UUID, if not, then set up his part in the data storage file.

Have a "PlayerStats" object that stores all this data, and has all the data loaded into it from the data file.
When the player leaves save all his/her data to the file and remove the instance of the PlayerStats object.

If you don't have a clue what I'm on about then I would advise going and reading this book: http://pdf.th7.cn/down/files/1411/Java For Dummies, 6th Edition.pdf from cover to cover, then coming back to the Spigot API, once you've read that book you should be very well equipped to deal with issues like this.
Thanks, I will read it all.
 

Tyler

Developer
Supreme
Feedback score
14
Posts
2,589
Reactions
2,238
Resources
0
don't use that use the one built into java
I would recommend the one build into java I'm just saying it could be easier for him to use an API to do it, sometimes that can be easier for new users to use.
 
Status
This thread has been locked.
Top