Search in sources :

Example 1 with ModdedPacketHandlerSetter

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);
    }
}
Also used : ModdedPacketHandlerSetter(net.modificationstation.stationapi.impl.network.ModdedPacketHandlerSetter) Message(net.modificationstation.stationapi.api.packet.Message) EventListener(net.mine_diver.unsafeevents.listener.EventListener)

Aggregations

EventListener (net.mine_diver.unsafeevents.listener.EventListener)1 Message (net.modificationstation.stationapi.api.packet.Message)1 ModdedPacketHandlerSetter (net.modificationstation.stationapi.impl.network.ModdedPacketHandlerSetter)1