Avoid requesting invalid names from Mojang (old UUID conversion code) (#1092)
This commit is contained in:
parent
d5c5e4983e
commit
de7a1372f0
|
|
@ -16,7 +16,9 @@ import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
class UUIDFetcher
|
class UUIDFetcher
|
||||||
{
|
{
|
||||||
|
|
@ -95,9 +97,23 @@ class UUIDFetcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
names.removeIf(Objects::isNull);
|
||||||
|
|
||||||
//for online mode, call Mojang to resolve the rest
|
//for online mode, call Mojang to resolve the rest
|
||||||
if (GriefPrevention.instance.getServer().getOnlineMode())
|
if (GriefPrevention.instance.getServer().getOnlineMode())
|
||||||
{
|
{
|
||||||
|
Pattern validNamePattern = Pattern.compile("^\\w+$");
|
||||||
|
|
||||||
|
// Don't bother requesting UUIDs for invalid names from Mojang.
|
||||||
|
names.removeIf(name ->
|
||||||
|
{
|
||||||
|
if (name.length() >= 3 && name.length() <= 16 && validNamePattern.matcher(name).find())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GriefPrevention.AddLogEntry(String.format("Cannot convert invalid name: %s", name));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
GriefPrevention.AddLogEntry("Calling Mojang to get UUIDs for remaining unresolved players (this is the slowest step)...");
|
GriefPrevention.AddLogEntry("Calling Mojang to get UUIDs for remaining unresolved players (this is the slowest step)...");
|
||||||
|
|
||||||
for (int i = 0; i * PROFILES_PER_REQUEST < names.size(); i++)
|
for (int i = 0; i * PROFILES_PER_REQUEST < names.size(); i++)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user