mirror of
https://github.com/ViaVersion/ViaAprilFools.git
synced 2025-01-08 19:17:40 +01:00
Tidy up AprilFoolsProtocolVersion
This commit is contained in:
parent
37ecd17dbd
commit
2f375bf448
@ -18,78 +18,35 @@
|
||||
package net.raphimc.viaaprilfools.api;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.protocol.RedirectProtocolVersion;
|
||||
|
||||
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 = 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);
|
||||
};
|
||||
}
|
||||
};
|
||||
public static final ProtocolVersion s3d_shareware = registerAprilFools(1, "3D Shareware", ProtocolVersion.v1_13_2);
|
||||
public static final ProtocolVersion s20w14infinite = registerAprilFools(709, "20w14infinite", ProtocolVersion.v1_15_2);
|
||||
public static final ProtocolVersion sCombatTest8c = registerSnapshot(803, "Combat Test 8c", ProtocolVersion.v1_16_1);
|
||||
|
||||
static {
|
||||
registerAprilFools(s3d_shareware);
|
||||
registerAprilFools(s20w14infinite);
|
||||
registerSnapshot(sCombatTest8c);
|
||||
}
|
||||
|
||||
private static void registerSnapshot(final ProtocolVersion protocolVersion) {
|
||||
private static ProtocolVersion registerSnapshot(final int version, final String name, final ProtocolVersion origin) {
|
||||
final ProtocolVersion protocolVersion = new RedirectProtocolVersion(version, name, origin);
|
||||
ProtocolVersion.register(protocolVersion);
|
||||
PROTOCOLS.add(protocolVersion);
|
||||
SNAPSHOTS_PROTOCOLS.add(protocolVersion);
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
private static void registerAprilFools(final ProtocolVersion protocolVersion) {
|
||||
private static ProtocolVersion registerAprilFools(final int version, final String name, final ProtocolVersion origin) {
|
||||
final ProtocolVersion protocolVersion = new RedirectProtocolVersion(version, name, origin);
|
||||
ProtocolVersion.register(protocolVersion);
|
||||
PROTOCOLS.add(protocolVersion);
|
||||
APRIL_FOOLS_PROTOCOLS.add(protocolVersion);
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user