Search in sources :

Example 1 with SimpleEventBus

use of net.kyori.event.SimpleEventBus in project guardian by ichorpowered.

the class CorePluginFacet method startup.

public Boolean startup(SimpleFacetMessage componentMessage) {
    this.facetState = FacetState.PREPARE;
    SimpleGuardian.setInstance(this.plugin);
    PropertyInjector propertyInjector = this.plugin.getPropertyInjector();
    propertyInjector.inject("state", GuardianState.PRE_INITIALIZATION);
    // STATE: PRE_INITIALIZATION
    if (PluginInfo.EXPERIMENTAL) {
        this.logger.warn(ConsoleUtil.of(Ansi.Color.RED, "You are using an experimental build of Guardian."));
        this.logger.warn(ConsoleUtil.of(Ansi.Color.RED, "This may not be ready for a production environment. Use at your own risk!"));
    }
    this.logger.info(ConsoleUtil.of("Guardian v{} for Sponge {} and Minecraft {}", PluginInfo.VERSION, Sponge.getPlatform().getContainer(Platform.Component.API).getVersion().map(version -> version.substring(0, 5)).orElse("?"), Sponge.getPlatform().getContainer(Platform.Component.GAME).getVersion().orElse("?")));
    Sponge.getServiceManager().setProvider(this.plugin, AntiCheatService.class, new GuardianBypassService(this.plugin));
    ModuleController<GuardianPlugin> moduleController = ShadedModularFramework.registerModuleController(this.plugin, Sponge.getGame());
    SimpleEventBus<GuardianEvent, GuardianListener> eventBus = new SimpleEventBus<>(new ASMEventExecutorFactory<GuardianEvent, GuardianListener>());
    this.logger.info(ConsoleUtil.of("Loaded pre-facet systems: { me4502/modularframework v1.8.5, kyoripowered/event v1.0.0 }"));
    // PROVIDE: PRE_INITIALIZATION
    propertyInjector.inject("coreTime", componentMessage.getTime());
    propertyInjector.inject("moduleController", moduleController);
    propertyInjector.inject("eventBus", eventBus);
    this.plugin.getEventBus().post(new GuardianPreInitializationEvent(Origin.source(this.plugin.getPluginContainer()).build()));
    propertyInjector.inject("state", GuardianState.INITIALIZATION);
    // State: INITIALIZATION
    this.logger.info(this.facetPrefix + "Initializing storage.");
    Configuration configuration = new Configuration(this.plugin, this.plugin.getConfigDirectory());
    configuration.load();
    this.logger.info(this.facetPrefix + "Initializing registries.");
    InternalBypassService internalBypassService = new InternalBypassService(this.plugin);
    GuardianDetectionManager detectionManager = new GuardianDetectionManager(this.plugin);
    SequenceRegistry<Event> sequenceRegistry = new SequenceRegistry<>();
    this.logger.info(this.facetPrefix + "Initializing systems.");
    GuardianSequenceManager sequenceManager = new GuardianSequenceManager(this.plugin, sequenceRegistry);
    GuardianSequenceManager.SequenceTask sequenceTask = new GuardianSequenceManager.SequenceTask(this.plugin, sequenceManager);
    GuardianSequenceListener sequenceListener = new GuardianSequenceListener(this.plugin);
    Common common = new Common(this.plugin);
    GuardianContentKeys contentKeys = new GuardianContentKeys();
    contentKeys.createKeys();
    // PROVIDE: INITIALIZATION
    propertyInjector.inject("common", common);
    propertyInjector.inject("configuration", configuration);
    propertyInjector.inject("internalBypassService", internalBypassService);
    propertyInjector.inject("detectionManager", detectionManager);
    propertyInjector.inject("sequenceManager", sequenceManager);
    propertyInjector.inject("sequenceTask", sequenceTask);
    propertyInjector.inject("sequenceRegistry", sequenceRegistry);
    propertyInjector.inject("sequenceListener", sequenceListener);
    this.plugin.getEventBus().post(new GuardianInitializationEvent(Origin.source(this.plugin.getPluginContainer()).build()));
    this.facetState = FacetState.START;
    return true;
}
Also used : Ansi(org.fusesource.jansi.Ansi) FacetMessage(com.ichorpowered.guardian.launch.message.FacetMessage) AntiCheatService(com.me4502.precogs.service.AntiCheatService) SimpleEventBus(net.kyori.event.SimpleEventBus) SimpleFacetMessage(com.ichorpowered.guardian.launch.message.SimpleFacetMessage) GuardianSequenceListener(com.ichorpowered.guardian.sequence.GuardianSequenceListener) ASMEventExecutorFactory(net.kyori.event.ASMEventExecutorFactory) GuardianPlugin(com.ichorpowered.guardian.GuardianPlugin) GuardianListener(com.ichorpowered.guardianapi.event.GuardianListener) PluginInfo(com.ichorpowered.guardian.PluginInfo) Platform(org.spongepowered.api.Platform) Origin(com.ichorpowered.guardianapi.event.origin.Origin) InternalBypassService(com.ichorpowered.guardian.service.InternalBypassService) Common(com.ichorpowered.guardian.Common) GuardianInitializationEvent(com.ichorpowered.guardian.event.GuardianInitializationEvent) GuardianSequenceManager(com.ichorpowered.guardian.sequence.GuardianSequenceManager) FacetState(com.ichorpowered.guardian.launch.FacetState) GuardianState(com.ichorpowered.guardianapi.GuardianState) GuardianBypassService(com.ichorpowered.guardian.service.GuardianBypassService) PropertyInjector(com.ichorpowered.guardian.util.property.PropertyInjector) Configuration(com.ichorpowered.guardian.Configuration) SequenceRegistry(com.abilityapi.sequenceapi.SequenceRegistry) FacetBootstrap(com.ichorpowered.guardian.launch.FacetBootstrap) SimpleGuardian(com.ichorpowered.guardianapi.SimpleGuardian) Logger(org.slf4j.Logger) GuardianDetectionManager(com.ichorpowered.guardian.detection.GuardianDetectionManager) Event(org.spongepowered.api.event.Event) ConsoleUtil(com.ichorpowered.guardian.util.ConsoleUtil) Sponge(org.spongepowered.api.Sponge) GuardianEvent(com.ichorpowered.guardianapi.event.GuardianEvent) Facet(com.ichorpowered.guardian.launch.Facet) GuardianPreInitializationEvent(com.ichorpowered.guardian.event.GuardianPreInitializationEvent) ModuleController(com.me4502.modularframework.ModuleController) GuardianContentKeys(com.ichorpowered.guardian.content.GuardianContentKeys) FacetException(com.ichorpowered.guardian.launch.exception.FacetException) ShadedModularFramework(com.me4502.modularframework.ShadedModularFramework) InternalBypassService(com.ichorpowered.guardian.service.InternalBypassService) Configuration(com.ichorpowered.guardian.Configuration) SequenceRegistry(com.abilityapi.sequenceapi.SequenceRegistry) GuardianEvent(com.ichorpowered.guardianapi.event.GuardianEvent) GuardianListener(com.ichorpowered.guardianapi.event.GuardianListener) GuardianContentKeys(com.ichorpowered.guardian.content.GuardianContentKeys) GuardianPreInitializationEvent(com.ichorpowered.guardian.event.GuardianPreInitializationEvent) GuardianSequenceManager(com.ichorpowered.guardian.sequence.GuardianSequenceManager) Common(com.ichorpowered.guardian.Common) PropertyInjector(com.ichorpowered.guardian.util.property.PropertyInjector) GuardianBypassService(com.ichorpowered.guardian.service.GuardianBypassService) SimpleEventBus(net.kyori.event.SimpleEventBus) GuardianInitializationEvent(com.ichorpowered.guardian.event.GuardianInitializationEvent) Event(org.spongepowered.api.event.Event) GuardianEvent(com.ichorpowered.guardianapi.event.GuardianEvent) GuardianPreInitializationEvent(com.ichorpowered.guardian.event.GuardianPreInitializationEvent) GuardianDetectionManager(com.ichorpowered.guardian.detection.GuardianDetectionManager) GuardianSequenceListener(com.ichorpowered.guardian.sequence.GuardianSequenceListener) GuardianPlugin(com.ichorpowered.guardian.GuardianPlugin) GuardianInitializationEvent(com.ichorpowered.guardian.event.GuardianInitializationEvent)

Aggregations

SequenceRegistry (com.abilityapi.sequenceapi.SequenceRegistry)1 Common (com.ichorpowered.guardian.Common)1 Configuration (com.ichorpowered.guardian.Configuration)1 GuardianPlugin (com.ichorpowered.guardian.GuardianPlugin)1 PluginInfo (com.ichorpowered.guardian.PluginInfo)1 GuardianContentKeys (com.ichorpowered.guardian.content.GuardianContentKeys)1 GuardianDetectionManager (com.ichorpowered.guardian.detection.GuardianDetectionManager)1 GuardianInitializationEvent (com.ichorpowered.guardian.event.GuardianInitializationEvent)1 GuardianPreInitializationEvent (com.ichorpowered.guardian.event.GuardianPreInitializationEvent)1 Facet (com.ichorpowered.guardian.launch.Facet)1 FacetBootstrap (com.ichorpowered.guardian.launch.FacetBootstrap)1 FacetState (com.ichorpowered.guardian.launch.FacetState)1 FacetException (com.ichorpowered.guardian.launch.exception.FacetException)1 FacetMessage (com.ichorpowered.guardian.launch.message.FacetMessage)1 SimpleFacetMessage (com.ichorpowered.guardian.launch.message.SimpleFacetMessage)1 GuardianSequenceListener (com.ichorpowered.guardian.sequence.GuardianSequenceListener)1 GuardianSequenceManager (com.ichorpowered.guardian.sequence.GuardianSequenceManager)1 GuardianBypassService (com.ichorpowered.guardian.service.GuardianBypassService)1 InternalBypassService (com.ichorpowered.guardian.service.InternalBypassService)1 ConsoleUtil (com.ichorpowered.guardian.util.ConsoleUtil)1