Including regex check for autologin

This commit is contained in:
samo_lego 2020-11-02 09:24:12 +01:00
parent 37b3102919
commit 9a85914d4f
1 changed files with 5 additions and 1 deletions

View File

@ -16,6 +16,8 @@ import javax.net.ssl.HttpsURLConnection;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.samo_lego.simpleauth.SimpleAuth.*; import static org.samo_lego.simpleauth.SimpleAuth.*;
import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; import static org.samo_lego.simpleauth.utils.SimpleLogger.logError;
@ -78,7 +80,9 @@ public abstract class MixinServerLoginNetworkHandler {
if(config.experimental.premiumAutologin) { if(config.experimental.premiumAutologin) {
try { try {
String playername = packet.getProfile().getName().toLowerCase(); String playername = packet.getProfile().getName().toLowerCase();
if(playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString())) { Pattern pattern = Pattern.compile("^[a-z0-9_]{3,16}$");
Matcher matcher = pattern.matcher(playername);
if(playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString()) || !matcher.matches()) {
// Player definitely doesn't have a mojang account // Player definitely doesn't have a mojang account
this.acceptCrackedPlayer = true; this.acceptCrackedPlayer = true;