mirror of
https://github.com/ViaVersion/ViaAprilFools.git
synced 2025-01-22 21:21:26 +01:00
Updated Via API usage
This commit is contained in:
parent
035d63847c
commit
37ecd17dbd
@ -23,8 +23,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion-common:4.10.0-24w06a-SNAPSHOT"
|
||||
compileOnly "com.viaversion:viabackwards-common:4.10.0-24w06a-SNAPSHOT"
|
||||
compileOnly "com.viaversion:viaversion-common:4.10.0-24w07a-SNAPSHOT"
|
||||
compileOnly "com.viaversion:viabackwards-common:4.10.0-24w07a-SNAPSHOT"
|
||||
compileOnly "org.yaml:snakeyaml:2.2"
|
||||
compileOnly "com.google.guava:guava:33.0.0-jre"
|
||||
compileOnly "io.netty:netty-handler:4.1.107.Final"
|
||||
|
@ -20,31 +20,76 @@ package net.raphimc.viaaprilfools.api;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.viaversion.viaversion.api.protocol.version.VersionType.SPECIAL;
|
||||
|
||||
public class AprilFoolsProtocolVersion {
|
||||
|
||||
public static final List<ProtocolVersion> PROTOCOLS = new ArrayList<>();
|
||||
public static final List<ProtocolVersion> SNAPSHOTS_PROTOCOLS = new ArrayList<>();
|
||||
public static final List<ProtocolVersion> APRIL_FOOLS_PROTOCOLS = new ArrayList<>();
|
||||
|
||||
public static final ProtocolVersion s3d_shareware = registerAprilFools(1, "3D Shareware");
|
||||
public static final ProtocolVersion s20w14infinite = registerAprilFools(709, "20w14infinite");
|
||||
public static final ProtocolVersion sCombatTest8c = registerSnapshot(803, "Combat Test 8c");
|
||||
public static final ProtocolVersion s3d_shareware = new ProtocolVersion(SPECIAL, 1, -1, "3D Shareware", null) {
|
||||
@Override
|
||||
protected Comparator<ProtocolVersion> customComparator() {
|
||||
return (o1, o2) -> {
|
||||
if (o1 == s3d_shareware) {
|
||||
o1 = ProtocolVersion.v1_13_2;
|
||||
}
|
||||
if (o2 == s3d_shareware) {
|
||||
o2 = ProtocolVersion.v1_13_2;
|
||||
}
|
||||
return o1.compareTo(o2);
|
||||
};
|
||||
}
|
||||
};
|
||||
public static final ProtocolVersion s20w14infinite = new ProtocolVersion(SPECIAL, 709, -1, "20w14infinite", null) {
|
||||
@Override
|
||||
protected Comparator<ProtocolVersion> customComparator() {
|
||||
return (o1, o2) -> {
|
||||
if (o1 == s20w14infinite) {
|
||||
o1 = ProtocolVersion.v1_15_2;
|
||||
}
|
||||
if (o2 == s20w14infinite) {
|
||||
o2 = ProtocolVersion.v1_15_2;
|
||||
}
|
||||
return o1.compareTo(o2);
|
||||
};
|
||||
}
|
||||
};
|
||||
public static final ProtocolVersion sCombatTest8c = new ProtocolVersion(SPECIAL, 803, -1, "Combat Test 8c", null) {
|
||||
@Override
|
||||
protected Comparator<ProtocolVersion> customComparator() {
|
||||
return (o1, o2) -> {
|
||||
if (o1 == sCombatTest8c) {
|
||||
o1 = ProtocolVersion.v1_16_1;
|
||||
}
|
||||
if (o2 == sCombatTest8c) {
|
||||
o2 = ProtocolVersion.v1_16_1;
|
||||
}
|
||||
return o1.compareTo(o2);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private static ProtocolVersion registerSnapshot(final int version, final String name) {
|
||||
final ProtocolVersion protocolVersion = ProtocolVersion.register(version, name);
|
||||
PROTOCOLS.add(protocolVersion);
|
||||
SNAPSHOTS_PROTOCOLS.add(protocolVersion);
|
||||
return protocolVersion;
|
||||
static {
|
||||
registerAprilFools(s3d_shareware);
|
||||
registerAprilFools(s20w14infinite);
|
||||
registerSnapshot(sCombatTest8c);
|
||||
}
|
||||
|
||||
private static ProtocolVersion registerAprilFools(final int version, final String name) {
|
||||
final ProtocolVersion protocolVersion = ProtocolVersion.register(version, name);
|
||||
private static void registerSnapshot(final ProtocolVersion protocolVersion) {
|
||||
ProtocolVersion.register(protocolVersion);
|
||||
PROTOCOLS.add(protocolVersion);
|
||||
SNAPSHOTS_PROTOCOLS.add(protocolVersion);
|
||||
}
|
||||
|
||||
private static void registerAprilFools(final ProtocolVersion protocolVersion) {
|
||||
ProtocolVersion.register(protocolVersion);
|
||||
PROTOCOLS.add(protocolVersion);
|
||||
APRIL_FOOLS_PROTOCOLS.add(protocolVersion);
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public interface ViaAprilFoolsPlatform {
|
||||
protocolManager.registerProtocol(new Protocol1_16to20w14infinite(), ProtocolVersion.v1_16, AprilFoolsProtocolVersion.s20w14infinite);
|
||||
protocolManager.registerProtocol(new Protocol1_16_2toCombatTest8c(), ProtocolVersion.v1_16_2, AprilFoolsProtocolVersion.sCombatTest8c);
|
||||
|
||||
protocolManager.registerBaseProtocol(new BaseProtocol1_16(), Range.singleton(AprilFoolsProtocolVersion.s20w14infinite.getVersion()));
|
||||
protocolManager.registerBaseProtocol(new BaseProtocol1_16(), Range.singleton(AprilFoolsProtocolVersion.sCombatTest8c.getVersion()));
|
||||
protocolManager.registerBaseProtocol(new BaseProtocol1_16(), Range.singleton(AprilFoolsProtocolVersion.s20w14infinite));
|
||||
protocolManager.registerBaseProtocol(new BaseProtocol1_16(), Range.singleton(AprilFoolsProtocolVersion.sCombatTest8c));
|
||||
}
|
||||
|
||||
Logger getLogger();
|
||||
|
Loading…
Reference in New Issue
Block a user