package leigh.minecraft.link.test;

import leigh.minecraft.link.PlayerNameProvider;

import java.util.Objects;
import java.util.UUID;

/**
 * Mock implementation of {@link PlayerNameProvider} which is useful for testing outside of the Bukkit environment.
 *
 * @author Alex Leigh
 */
public class MockPlayerNameProvider implements PlayerNameProvider {
    private final String fakeName;

    public MockPlayerNameProvider(String fakeName) {
        this.fakeName = fakeName;
    }

    @Override
    public String getPlayerName(UUID playerId) {
        return fakeName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MockPlayerNameProvider that = (MockPlayerNameProvider) o;
        return Objects.equals(fakeName, that.fakeName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(fakeName);
    }

    @Override
    public String toString() {
        return "MockUsernameProvider{" +
                "fakeName='" + fakeName + '\'' +
                '}';
    }
}
