Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
52 lines
1.9 KiB
Java
52 lines
1.9 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* javax.annotation.Nullable
|
|
*/
|
|
package de.maxhenkel.voicechat.integration.viaversion;
|
|
|
|
import de.maxhenkel.voicechat.Voicechat;
|
|
import de.maxhenkel.voicechat.util.Key;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
import javax.annotation.Nullable;
|
|
|
|
public class ViaVersionCompatibility {
|
|
public static void register() throws Exception {
|
|
Class<?> protocol113to1122 = ViaVersionCompatibility.getClass("com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2");
|
|
if (protocol113to1122 != null) {
|
|
ViaVersionCompatibility.registerPackets(protocol113to1122);
|
|
return;
|
|
}
|
|
Class<?> protocol1122to113 = ViaVersionCompatibility.getClass("com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13");
|
|
if (protocol1122to113 != null) {
|
|
ViaVersionCompatibility.registerPackets(protocol1122to113);
|
|
return;
|
|
}
|
|
}
|
|
|
|
private static void registerPackets(Class<?> protocolClass) throws Exception {
|
|
Field mappingsField = protocolClass.getDeclaredField("MAPPINGS");
|
|
Object mappings = mappingsField.get(null);
|
|
Method getChannelMappings = mappings.getClass().getDeclaredMethod("getChannelMappings", new Class[0]);
|
|
Object mappingMap = getChannelMappings.invoke(mappings, new Object[0]);
|
|
Method put = mappingMap.getClass().getDeclaredMethod("put", Object.class, Object.class);
|
|
for (String id : Voicechat.netManager.getPackets()) {
|
|
Key key = Key.parse(id);
|
|
put.invoke(mappingMap, String.format("%s:%s", "vc", key.getValue()), String.format("%s:%s", "voicechat", key.getValue()));
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
private static Class<?> getClass(String name) {
|
|
try {
|
|
return Class.forName(name);
|
|
}
|
|
catch (ClassNotFoundException e) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|