NetworkManager:
- Fixed the mod version pattern being incorrect. - Fixed mod version checking not working. - Fixed MismatchedVersionException not being thrown if the mod versions are wrong.
This commit is contained in:
@ -14,7 +14,7 @@ import java.util.regex.Pattern;
|
||||
public class NetworkManager {
|
||||
private static final String VERSION = LoginProtection.MOD_ID + "-net-1";
|
||||
private static final Pattern NET_VERSION_PATTERN = Pattern.compile(String.format("^%s-net-\\d+$", LoginProtection.MOD_ID));
|
||||
private static final Pattern MOD_VERSION_PATTERN = Pattern.compile("^Forge-\\d+\\.\\d+\\.\\d+-\\d+\\.\\d+\\.\\d+$");
|
||||
private static final Pattern MOD_VERSION_PATTERN = Pattern.compile("^\\d+\\.\\d+\\.\\d+-\\d+\\.\\d+\\.\\d+$");
|
||||
private static SimpleChannel channel;
|
||||
|
||||
public static void init() {
|
||||
@ -62,7 +62,7 @@ public class NetworkManager {
|
||||
String clientNetVersion = (senderIsServer) ? VERSION : readNetVersion(buffer);
|
||||
String clientModVersion = (senderIsServer) ? LoginProtection.getVersion() : readModVersion(buffer);
|
||||
|
||||
if (!serverNetVersion.equals(clientNetVersion)) {
|
||||
if (!serverNetVersion.equals(clientNetVersion) || !serverModVersion.equals(clientModVersion)) {
|
||||
throw new MismatchedVersionException(String.format("The server and client are running mismatched " +
|
||||
"versions of [Micle's Login Protection]. Try updating this mod on either the client and or " +
|
||||
"the server. Client version is %s (%s). Server version is %s (%s).", clientModVersion,
|
||||
@ -80,7 +80,7 @@ public class NetworkManager {
|
||||
|
||||
public static String readModVersion(FriendlyByteBuf buffer) {
|
||||
String modVersion = buffer.readUtf();
|
||||
if (!modVersion.equals("NONE") && !MOD_VERSION_PATTERN.matcher(modVersion).matches()) {
|
||||
if (modVersion.equals("NONE") || !MOD_VERSION_PATTERN.matcher(modVersion).matches()) {
|
||||
return String.format("UNKNOWN (%s)", modVersion);
|
||||
}
|
||||
return modVersion;
|
||||
|
||||
Reference in New Issue
Block a user