Fixed NPE when checking username (#153)

This commit is contained in:
Hutchy 2020-03-31 15:50:13 +11:00 committed by GitHub
parent 189187fd25
commit 80964978bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -79,7 +79,7 @@ public GDPermissionUser getOrCreateUser(UUID uuid) {
}
public GDPermissionUser getOrCreateUser(String username) {
if (username == null) {
if (username == null || username.length() > 16) {
return null;
}

View File

@ -82,7 +82,7 @@ public GDPermissionUser getOrCreateUser(UUID uuid) {
}
public GDPermissionUser getOrCreateUser(String username) {
if (username == null) {
if (username == null || username.length() > 16) {
return null;
}

View File

@ -4,6 +4,7 @@
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.claim.ClaimTypes;
import com.griefdefender.api.permission.flag.Flag;
import com.griefdefender.api.permission.flag.Flags;
@ -168,7 +169,7 @@ public User createUserFromCache(UUID uuid) {
public User createUserFromCache(String username) {
final UUID uuid = SpongeUsernameCache.getLastKnownUUID(username);
if (username != null) {
if (uuid != null) {
return Sponge.getGame().getServiceManager().provide(UserStorageService.class).get().get(GameProfile.of(uuid, username)).orElse(null);
}
return null;