Assigning players to personal string variable E.G. RPG Class

Discussion in 'Plugin Development' started by AaronL98, Jul 20, 2013.

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


    So I'm creating an RPG plugin and I want players to choose their class and it will save their class but first i need some help. This requires me to store user data. I will be storing each user's data in a seperate yml file per player as I'm not experienced with databases and would rather use a yml.

    I Have never experimented with storing user data so i would like some help here (I'm new to bukkit)

    First , how would I create a yml file for every user that joins looking like this

    File name: 'Player'sname.yml'
    Contents: 'Race:'

    I would also like to know what would be the best place to store the variables and how it would be done? Like add the variables just before the onEnable and onDisable and how I would assign each player to that race/class. How would I get the senders yml file after
    if(args.length == 1){
    if(args[0] == "CLASSNAME"){
    then set the class string in the players config to args[0]



    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 3, 2016
  2. Offline


  3. Offline


    xTrollxDudex Thanks, but how would a hash map work in this situation? Don't they reset every time your server is reloaded or restarted
  4. Offline


    AaronL98 When the plugin disables, save the keys and values to the appropriate YML file. When the plugin enables, load data from the YML file to the HashMap.
  5. Offline


    Compressions Thanks. P.S. just a quick question, when /reload is performed, does the server do the onDisable then onEnable method?
  6. Offline


  7. Offline


  8. Offline


    AaronL98 a good way to get started is by looking at basic plugins that have been created. Try and recreate them. Then once you're done have a look at the way they did it and see which way is more efficent yours? or theirs? otherwise if you cannot recreate it google different ways of how you could do something, it's really effective to learn multiple methods. You're answer would either to use a HashMap or you could save and retrive players using the

    getConfig().set("location.location2", "this is my location");

    how this would turn out:
        location2: this is my location
    but please make sure you read this before you attempt to use configuration files:
  9. Offline


Thread Status:
Not open for further replies.

Share This Page