public PlayerData getPlayerData(EntityPlayer player) {
    PlayerData data = (PlayerData) player.getExtendedProperties("CustomNpcsData");
    if (data == null) {
      player.registerExtendedProperties("CustomNpcsData", data = new PlayerData());
      data.player = player;
      data.loadNBTData((NBTTagCompound) null);
    }

    return data;
  }
  public PlayerData getDataFromUsername(String username) {
    EntityPlayerMP player =
        MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username);
    PlayerData data = null;
    if (player == null) {
      Map map = this.getUsernameData();
      Iterator var5 = map.keySet().iterator();

      while (var5.hasNext()) {
        String name = (String) var5.next();
        if (name.equalsIgnoreCase(username)) {
          data = new PlayerData();
          data.setNBT((NBTTagCompound) map.get(name));
          break;
        }
      }
    } else {
      data = this.getPlayerData(player);
    }

    return data;
  }
  public void savePlayerData(PlayerData data) {
    NBTTagCompound compound = data.getNBT();
    String filename = data.uuid + ".json";

    try {
      File e = this.getSaveDir();
      File file = new File(e, filename + "_new");
      File file1 = new File(e, filename);
      NBTJsonUtil.SaveFile(file, compound);
      if (file1.exists()) {
        file1.delete();
      }

      file.renameTo(file1);
    } catch (Exception var7) {
      LogWriter.except(var7);
    }
  }