mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-04 09:10:36 +01:00
Tweaked some things
This commit is contained in:
parent
1706b8c718
commit
859f5b7fcd
@ -19,8 +19,11 @@ package net.raphimc.viaproxy.injection;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.lenni0451.reflect.Enums;
|
||||
import net.lenni0451.reflect.stream.RStream;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class VersionEnumExtension {
|
||||
|
||||
private static final ProtocolVersion autoDetect = ProtocolVersion.register(-2, "Auto Detect (1.7+ servers)");
|
||||
@ -28,6 +31,7 @@ public class VersionEnumExtension {
|
||||
|
||||
static {
|
||||
Enums.addEnumInstance(VersionEnum.class, AUTO_DETECT);
|
||||
RStream.of(VersionEnum.class).fields().by("VERSION_REGISTRY").<Map<ProtocolVersion, VersionEnum>>get().put(autoDetect, AUTO_DETECT);
|
||||
VersionEnum.SORTED_VERSIONS.add(AUTO_DETECT);
|
||||
}
|
||||
|
||||
|
@ -21,16 +21,12 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionRange;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
import net.raphimc.viaproxy.injection.VersionEnumExtension;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -39,10 +35,6 @@ import java.util.Set;
|
||||
@Mixin(value = ProtocolVersion.class, remap = false)
|
||||
public abstract class MixinProtocolVersion {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private int version;
|
||||
|
||||
@Unique
|
||||
private static Set<String> skips;
|
||||
|
||||
@ -97,11 +89,4 @@ public abstract class MixinProtocolVersion {
|
||||
return ProtocolVersion.register(version, name, versionRange);
|
||||
}
|
||||
|
||||
@Inject(method = "isKnown", at = @At("HEAD"), cancellable = true)
|
||||
private void markAutoDetectAsUnknown(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (VersionEnumExtension.AUTO_DETECT != null && this.version == VersionEnumExtension.AUTO_DETECT.getVersion()) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import net.raphimc.vialoader.util.VersionEnum;
|
||||
|
||||
public class ProtocolVersionDetector {
|
||||
|
||||
private static final int TIMEOUT = 1000;
|
||||
private static final int TIMEOUT = 3000;
|
||||
|
||||
public static VersionEnum get(final ServerAddress serverAddress, final VersionEnum clientVersion) {
|
||||
MCPingResponse response = MCPing
|
||||
|
Loading…
Reference in New Issue
Block a user