Storing player values

Discussion in 'Plugin Development' started by mattdog0601, Dec 5, 2015.

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


    So im making a replica of Jerry and Harry's AgarPvp and I need to know how to store player values and then change then if the player is punched/killed/kills someone. i have no idea how hashmaps work but is that my only option?
  2. Offline


    There's a bunch of ways you can do it.

    Why don't you look at what that other plugin does? Because I sure don't know what it does
  3. Offline


    that plugin is on a private server and there is no way to access it. I want to re-create it because most of the perks in that game are donator only so the donators get a huge advantage. Plus i wanted to make a plugin.
  4. Offline


    Well generally it helps us help you if we know what you're talking about.
    Wanna explain to us what it does?
  5. Offline


    you go around killing animals to gain mass which is a player variable that i don't know how to store then you can kill people to gain all of their mass or they can kill you to gain your mass. Basically i need a variable that stores a person's mass that can be easily be reset automatically when the player dies. so im guessing it would be something like this:

        public void OnPlayerDeath(PlayerDeathEvent e) {
        Player p = e.getEntity();
        Player k = p.getKiller();
        //insert variable creation here that is called mass
        k.mass = k.mass p.mass
        p.teleport(x, y, z)
        k.sendMessage(ChatColor.GREEN + "You killed " + p.getName() + " For " ChatColor.BLUE + p.mass + ChatColor.GREEN + " mass!")
    sorry if that's a bit confusing i hope that helped

    EDIT: i tried HashMaps but got very confused by the tutorials and they only showed boolean values for them

    Also the variable would have to be able to be put on the sidebar scoreboard
    Last edited by a moderator: Dec 5, 2015
  6. Offline


    Booleans are the single least useful thing to use HashMaps for, what tutorial were you watching?

    You're not checking if the player even has a killer, let alone if it's another player in your event, you're gonna get a lot of errors.
    Also, what is:
    k.mass = k.mass p.mass
    What are you trying to achieve with that?

    HashMaps are easy to learn, it's just a value stored with a Key to reference it.
    Store the Player's UUID as a Key, and their "mass" as the value.

    HashMap#put(p.getUniqueId(), mass);

    Look, if you don't understand Java, you shouldn't be making a plugin.
    Submit a plugin request instead
  7. Offline


    I meant to put k.mass = k.mass + p.mass because i want the player to gain the person that they kill
  8. Offline


    Cool, let us know how it goes
Thread Status:
Not open for further replies.

Share This Page