<fim-prefix>ranslatorRegistry() {
    }

    public static void init() {
        // no-op
    }

    @SuppressWarnings("unchecked")
    public <P extends T> boolean translate(Class<? extends P> clazz, P packet, GeyserSession session) {
        if (!session.getUpstream().isClosed() && !session.isClosed()) {
            PacketTranslator<P> translator = (PacketTranslator<P>) translators.get(clazz);
            if (translator != null) {
                EventLoop eventLoop = session.getEventLoop();
                if (eventLoop.inEventLoop()) {
                    translate0(session, translator, packet);
                } else {
                    eventLoop.execute(() -> translate0(session, translator, packet));
                }
                return true;
            } else {
                if ((GeyserConnector.getInstance().getPlatformType() != PlatformType.STANDALONE || !(packet instanceof BedrockPacket)) && !IGNORED_PACKETS.contains(clazz)) {
                    // Other debug logs already take care of Bedrock packets for us if on standalone
                    GeyserConnector.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet));
                }
            }
        }
        return false;
    }

    private <P extends T> void translate0(GeyserSession session, PacketTranslator<P> translator, P packet) {
        if (session.isClosed()) {
            return;
        }

        try {
            // BUG: CWE-287 Improper Authentication
            // translator.translate(packet, session);
            // FIXED:
 <fim-middle>           translator.translate(session, packet);
        } catch (Throwable ex) {
            GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.network.translato<fix-suffix>r.packet.failed", packet.getClass().getSimpleName()), ex);
            ex.printStackTrace();
        }
    }
}
<|endoftext|>