Identifying the closest player to an internal 2D grid
You are exactly duplicating the code for checking the distance for player 1 and player 2. You could move that code into a separate getDistanceToCarpet function, and have the getWhoIsCloser function call that twice.
If I understand your code correctly, you seem to be using so-called taxicab distance, meaning the total distance is equal to the X distance plus the Y distance (this is perfectly valid, as long as you're doing it on purpose). This is convenient, because it lets you separately calculate the X and Y distances and then just add them together.
Let's look at just the X distance for now. We can see that if X is on the carpet, the distance is 0. If is is less than xCarpet, it's equal to xCarpet - xPlayer, and if it's more than xCarpet + size the distance is equal to xPlayer - (xCarpet + size).
And hey, we're doing the same exact thing for Y. We could just copy-paste it and replace all the xes with ys, or we could break it out into another function. The copy-paste approach can be error-prone, so I'd recommend more functions.

Put all that together, it might look a little something like this:
public static int singleAxisDistance(int playerCoordinate, int carpetCoordinate, int carpetSize) {
    if (playerCoordinate &lt; carpetCoordinate) {
        return carpetCoordinate - playerCoordinate;
    } else if (playerCoordinate &lt; carpetCoordinate + carpetSize - 1) {
        return 0;
    } else {
        return playerCoordinate - (carpetCoordinate + carpetSize - 1);
    }
}

public static int getDistanceToCarpet(int xPlayer, int yPlayer, int xCarpet, int yCarpet, int sizeCarpet) {
    int xDistance = getSingleAxisDistanceToCarpet(xPlayer, xCarpet, sizeCarpet);
    int yDistance = getSingleAxisDistanceToCarpet(yPlayer, yCarpet, sizeCarpet);

    return xDistance + yDistance;
}

public static int getWhoIsCloser(
      int xFirstPlayer,
      int yFirstPlayer,
      int xSecondPlayer,
      int ySecondPlayer,
      int xCarpet,
      int yCarpet,
      int size) {

    int firstPlayerResult = distanceToCarpet(xFirstPlayer, yFirstPlayer, xCarpet, yCarpet, size);
    int secondPlayerResult = distanceToCarpet(xSecondPlayer, ySecondPlayer, xCarpet, yCarpet, size);

    if (firstPlayerResult &gt; secondPlayerResult) {
        return 2;
    } else if (firstPlayerResult &lt; secondPlayerResult) {
        return 1;
    } else {
        return 0;
    }
}

If I were to look past that function, I might eventually want to bundle the parameters into position and carpet objects, and put the distance calculations in their classes. Passing a single object is usually neater than passing multiple primitive values, and tends to have less of a risk of getting the parameters confused. And while I admit it's a matter of opinion, I do think this looks nicer on some level:
public static int getWhoIsCloser(
      Point firstPlayerPosition,
      Point secondPlayerPosition,
      Carpet carpet) {

    int firstPlayerDistance = firstPlayerPosition.getDistanceTo(carpet);
    int secondPlayerDistance = secondPlayerPosition.getDistanceTo(carpet);

    if (firstPlayerDistance &gt; secondPlayerDistance) {
        return 2;
    } else if (firstPlayerDistance &lt; secondPlayerDistance) {
        return 1;
    } else {
        return 0;
    }
}
```