Search in sources :

Example 1 with AttributeAccessFactory

use of fr.neatmonster.nocheatplus.compat.registry.AttributeAccessFactory in project NoCheatPlus by NoCheatPlus.

the class NoCheatPlus method initMCAccess.

/**
 * (Re-) Setup MCAccess and other access providers from the internal
 * factories. Only call from the primary thread.
 *
 * @param config
 */
private MCAccess initMCAccess(final ConfigFile config) {
    // TODO: Auto registry with unregister on reload hooks (more clean reload).
    // Reset MCAccess.
    // TODO: Might fire a NCPSetMCAccessFromFactoryEvent (include getting and setting)!
    final MCAccessConfig mcaC = new MCAccessConfig(config);
    final MCAccess mcAccess = new MCAccessFactory().getMCAccess(mcaC);
    /*
         * NOTE: previously registration was done last, to allow fetching the
         * previous registration. That has been discarded, due to the number of
         * related objects registering anyway.
         */
    // Set in registry.
    genericInstanceRegistry.registerGenericInstance(MCAccess.class, mcAccess);
    // Register a BlockCache instance for temporary use (enables using handle thing).
    genericInstanceRegistry.registerGenericInstance(BlockCache.class, mcAccess.getBlockCache());
    // Spin-off.
    new AttributeAccessFactory().setupAttributeAccess(mcAccess, mcaC);
    new EntityAccessFactory().setupEntityAccess(mcAccess, mcaC);
    // TODO: Summary event or listener call-back (possibly in another place.).
    // Log.
    logManager.info(Streams.INIT, "McAccess set to: " + mcAccess.getMCVersion() + " / " + mcAccess.getServerVersionTag());
    return mcAccess;
}
Also used : EntityAccessFactory(fr.neatmonster.nocheatplus.compat.registry.EntityAccessFactory) MCAccess(fr.neatmonster.nocheatplus.compat.MCAccess) MCAccessFactory(fr.neatmonster.nocheatplus.compat.registry.MCAccessFactory) MCAccessConfig(fr.neatmonster.nocheatplus.compat.registry.MCAccessConfig) AttributeAccessFactory(fr.neatmonster.nocheatplus.compat.registry.AttributeAccessFactory)

Aggregations

MCAccess (fr.neatmonster.nocheatplus.compat.MCAccess)1 AttributeAccessFactory (fr.neatmonster.nocheatplus.compat.registry.AttributeAccessFactory)1 EntityAccessFactory (fr.neatmonster.nocheatplus.compat.registry.EntityAccessFactory)1 MCAccessConfig (fr.neatmonster.nocheatplus.compat.registry.MCAccessConfig)1 MCAccessFactory (fr.neatmonster.nocheatplus.compat.registry.MCAccessFactory)1