Help with RPG plugin player data management

Discussion in 'Plugin Development' started by MX26, Nov 29, 2015.

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


    I'm fairly new to oop and thought making a plugin was a good way to learn something, which turned out to be true, but my lack of knowledge put the plugin to a full stop.

    In it's current state the plugin itself is divided into a few classes: The base plugin class. A RPGSetStats class which handles all changes to stats, the 1st setup of a player and storing of the data. A RPGStats class which has static final arrays with base stats and values for classes and other things. And a RPGPlayer class, which tracks the players current stats.

    The thing is i can't figure out is how to store the data from the RPGSetStats class and what the best way of getting that data for the RPGPlayer class is. Hashmaps would require saving and loading of config files on each stat change, which should probably be avoided, and i don't actually get how Properties work, so i gave up on using that. *Also is there a way to get the data from a hashmap in one class in another class without saving it into a config file?

    part of the RPGSetStats class so you get a better idea of the whole thing.
        //stat declaration
        private UUID RPGPlayerUUID;
        private int level;
        private int health, mana;
        private int vit, str, dex, intel;
        private int damage, ArmorPen, LifeSteal;
        private String RPGClass;
        //constructor, player setup
        public RPGPlayerStats(UUID pUUID, String pclass)
   = RPGSetHealth(level, vit);
            this.RPGPlayerUUID = pUUID;
            //long if switch for getting the rest of the player stats
    Any help is appreciated :)

    EDIT(*): added something i forgot previously
    Last edited: Nov 29, 2015
  2. Offline


    Updating your storage files whenever a stat changes probably isn't such a bad thing, at least your data will be up to date regularly.

    This could be quite an extensive plugin, it may be worth trying something less complex to begin with if you're new to this kind of thing

    Otherwise, yeah.. I don't see why storing the stat changes would be such a bad thing, but I also don't see why you'd need to load from that file each time.
    For something as large as this, you'll probably want to step away from YML files, and start dealing in binary format saving
  3. Offline


    If you're also learning OOP by another course (either from school or from a course online), then yes. It would be good that way. If bukkit is all you're learning off of, then it's not a good way to learn OOP. Bukkit is good for testing out thing that you learned, but I wouldn't say that you should learn OOP from bukkit.
  4. Offline


    I'm doing OOP in school too, and everything outside of the issue was somewhat relatable to what i did before, so it was pretty much just expanding what i already knew, but this is something i haven't encountered yet...

    back to my issue: The more i'v been thinking about it the more lost i am. I've realized that i have no idea of how to set up the hashmap so that i can use it for storing the data i want to store. The way i have it right now i would have to save it to config and load it in the RPGPlayer class for each change in RPGPlayerStats. And after spending at least 4 hours reading through all sorts of forums and documentations for the last week, i still can't find a way to use the same hashmap between at least 2 classes and have it be the same. Is there any way i could do this or will i just have to put 90% of the plugin into one giant messy class?
    Last edited: Nov 29, 2015
  5. Offline


    getters and setters?
  6. Offline


    i tried using getters and setters, but, unless i did something awfully wrong, that didn't work, as it only set it for that one time i was calling it.
  7. Offline


    Show your code
  8. Offline


    It is good OOP practice to have the getter and the setter for the Object/primitive in the same class. This link might help you as it demonstrates good OOP and shows you how to deal with saving/getting info from configs.
Thread Status:
Not open for further replies.

Share This Page