Copy usernames in the GroupManager migration (#883)

This commit is contained in:
Luck
2018-04-02 13:34:30 +01:00
Unverified
parent c8bb85a06b
commit 3453f05aca
2 changed files with 36 additions and 14 deletions
@@ -27,14 +27,27 @@ package me.lucko.luckperms.common.references;
import me.lucko.luckperms.common.model.User;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Used to identify a specific {@link User}.
*/
public final class UserIdentifier implements Identifiable<UUID> {
public static UserIdentifier of(UUID uuid, String username) {
/**
* Creates a {@link UserIdentifier}.
*
* @param uuid the uuid of the user
* @param username the username of the user, nullable
* @return
*/
public static UserIdentifier of(@Nonnull UUID uuid, @Nullable String username) {
Objects.requireNonNull(uuid, "uuid");
if (username == null || username.equalsIgnoreCase("null") || username.isEmpty()) {
username = null;
}
@@ -50,6 +63,10 @@ public final class UserIdentifier implements Identifiable<UUID> {
this.username = username;
}
public UUID getUuid() {
return this.uuid;
}
@Override
public UUID getId() {
return getUuid();
@@ -74,10 +91,6 @@ public final class UserIdentifier implements Identifiable<UUID> {
@Override
public String toString() {
return "UserIdentifier(uuid=" + this.uuid + ", username=" + this.getUsername() + ")";
}
public UUID getUuid() {
return this.uuid;
return "UserIdentifier(uuid=" + this.uuid + ", username=" + this.username + ")";
}
}