use of net.modificationstation.stationapi.impl.network.ModdedPacketHandlerSetter in project StationAPI by ModificationStation.
the class ClientVanillaChecker method handleServerLogin.
@EventListener(priority = ListenerPriority.HIGH)
private static void handleServerLogin(ServerLoginSuccessEvent event) {
if (Arrays.asList(event.loginRequestPacket.username.split(";")).contains(MODID.toString())) {
((ModdedPacketHandlerSetter) event.networkHandler).setModded();
Message message = new Message(of(MODID, "modlist"));
List<String> mods = new ArrayList<>();
mods.add(MODID.getVersion().getFriendlyString());
FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).forEach(modMetadata -> Collections.addAll(mods, modMetadata.getId(), modMetadata.getVersion().getFriendlyString()));
message.strings = mods.toArray(new String[0]);
event.networkHandler.sendPacket(message);
}
}
Aggregations