Solved Getting a player's name form a saved UUID in a separate file

Discussion in 'Plugin Development' started by e1kfws7, Feb 20, 2015.

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

    e1kfws7

    I have been coding a plugin for a few weeks and I need to know how I would get a Player's name from their saved UUID in a separate file and display the stats on a scoreboard. I have tried this >

    Code:
    public static void createScoreBoard(final Player p, final boolean b) {
    
    String uuid = p.getUniqueId().toString();
    Player UUIDname = Bukkit.getServer().getPlayer(UUID.fromString(uuid));
    
    
    UUIDname.setScoreboard(board);
    }
    But it doesn't work. The scoreboard and stats in the file reset on relog/respawn.
     
  2. Offline

    candyfloss20

    @e1kfws7
    Are you sure that you saved the stats config "saveConfig();" ?
     
  3. Offline

    crolemol

    @e1kfws7
    what is this supposed to do??
    your method asks for a player object and you use its UUID to get the same object from the server? so setting the scoreboard to p would be equal to you method.
     
  4. Offline

    e1kfws7

    Sorry replying late had other things to do. But yes, I have done that already.

    Okay, what this does is when a player gets a kill it displays it everything works, but now that UUID's are something I have to figure out how to either display their stats from their UUID which I have tried and it doesn't work. I have tried this method and of course still nothing. But setting the scoreboard to p isn't what is wrong that works, but I need to get their stats from the stats.yml to display only for them. This worked for names, but I haven't had to work with UUIDs yet so sorry if what I'm asking/saying is dumb.

    EDIT: I saved the stats config like this >

    Code:
    7f3653a7-9185-4981-9a5e-8697f3b71ce6:
      KillStreak: 0
      Kills: 0
      Deaths: 0
      Credits: 0
      Name: e1kfws7
    It saves all the stats the first time only when they're online, but if they relog the stats reset to 0 so does the config. Not sure whatt else to do about this. I tried getting the name like this >

    Code:
    String Name = stats.getString(p.getUniqueId().toString()
            + ".Name");
    And doing this I thought it would be easier to save their last known name but even doing this I cannot seem to figure out the resetting when they relog.

    EDIT: Would setting the UUID first, then the player's name under that then the stats under their username be easier to do instead of doing what I did the first time?
     
    Last edited: Feb 20, 2015
  5. Offline

    crolemol

    @e1kfws7
    I still don't understand it? Do you want to know the name of a player? If so why not just p.getName() And you are trying to store things in a yml file and what does it return when you try to get the name?
     
  6. Offline

    e1kfws7

    I figured it out. All I needed to do is check if the player was in the config and it worked. So thank you both for trying to help.
     
Thread Status:
Not open for further replies.

Share This Page