use of fr.neatmonster.nocheatplus.compat.registry.MCAccessFactory 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;
}
Aggregations