Search in sources :

Example 1 with SimpleFacetMessage

use of com.ichorpowered.guardian.launch.message.SimpleFacetMessage in project guardian by ichorpowered.

the class FacetBootstrap method forceShutdown.

private void forceShutdown() {
    SortedSet<String> backwards = new TreeSet<>(Collections.reverseOrder());
    backwards.addAll(this.facets.keySet());
    this.send(FacetRequest.SHUTDOWN, new SimpleFacetMessage(System.currentTimeMillis(), "Critical failure.", this.plugin), backwards);
}
Also used : SimpleFacetMessage(com.ichorpowered.guardian.launch.message.SimpleFacetMessage) TreeSet(java.util.TreeSet)

Example 2 with SimpleFacetMessage

use of com.ichorpowered.guardian.launch.message.SimpleFacetMessage 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)

Example 3 with SimpleFacetMessage

use of com.ichorpowered.guardian.launch.message.SimpleFacetMessage in project guardian by ichorpowered.

the class GuardianPlugin method onGameReload.

// PLUGIN RELOAD
@Listener
public void onGameReload(GameReloadEvent event) {
    this.facetBootstrap.send(FacetBootstrap.FacetRequest.RESTART, new SimpleFacetMessage(System.currentTimeMillis(), "Game Reload", this), "game");
    this.facetBootstrap.send(FacetBootstrap.FacetRequest.RESTART, new SimpleFacetMessage(System.currentTimeMillis(), "Game Reload", this), "common");
}
Also used : SimpleFacetMessage(com.ichorpowered.guardian.launch.message.SimpleFacetMessage) GuardianSequenceListener(com.ichorpowered.guardian.sequence.GuardianSequenceListener) GuardianListener(com.ichorpowered.guardianapi.event.GuardianListener) Listener(org.spongepowered.api.event.Listener)

Example 4 with SimpleFacetMessage

use of com.ichorpowered.guardian.launch.message.SimpleFacetMessage in project guardian by ichorpowered.

the class GuardianPlugin method onGameInitialization.

// PLUGIN INITIALIZATION
@Listener
public void onGameInitialization(GameInitializationEvent event) {
    this.facetBootstrap.addComponent("core", new CorePluginFacet(this.logger, this));
    this.facetBootstrap.addComponent("common", new InternalPluginFacet(this.logger, this));
    this.facetBootstrap.addComponent("game", new GamePluginFacet(this.logger, this));
    this.facetBootstrap.send(FacetBootstrap.FacetRequest.STARTUP, new SimpleFacetMessage(System.currentTimeMillis(), "Game Initialization", this), "core");
}
Also used : CorePluginFacet(com.ichorpowered.guardian.launch.facet.CorePluginFacet) GamePluginFacet(com.ichorpowered.guardian.launch.facet.GamePluginFacet) SimpleFacetMessage(com.ichorpowered.guardian.launch.message.SimpleFacetMessage) InternalPluginFacet(com.ichorpowered.guardian.launch.facet.InternalPluginFacet) GuardianSequenceListener(com.ichorpowered.guardian.sequence.GuardianSequenceListener) GuardianListener(com.ichorpowered.guardianapi.event.GuardianListener) Listener(org.spongepowered.api.event.Listener)

Example 5 with SimpleFacetMessage

use of com.ichorpowered.guardian.launch.message.SimpleFacetMessage in project guardian by ichorpowered.

the class FacetBootstrap method recover.

private void recover() {
    this.attemptedRecoveries++;
    final SortedSet<String> backwards = new TreeSet<>(Collections.reverseOrder());
    backwards.addAll(this.facets.keySet());
    this.send(FacetRequest.SHUTDOWN, new SimpleFacetMessage(System.currentTimeMillis(), "Error recovery.", this.plugin), backwards);
    this.send(FacetRequest.STARTUP, new SimpleFacetMessage(System.currentTimeMillis(), "Error recovery.", this.plugin), this.facets.keySet());
}
Also used : SimpleFacetMessage(com.ichorpowered.guardian.launch.message.SimpleFacetMessage) TreeSet(java.util.TreeSet)

Aggregations

SimpleFacetMessage (com.ichorpowered.guardian.launch.message.SimpleFacetMessage)5 GuardianSequenceListener (com.ichorpowered.guardian.sequence.GuardianSequenceListener)3 GuardianListener (com.ichorpowered.guardianapi.event.GuardianListener)3 TreeSet (java.util.TreeSet)2 Listener (org.spongepowered.api.event.Listener)2 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 CorePluginFacet (com.ichorpowered.guardian.launch.facet.CorePluginFacet)1 GamePluginFacet (com.ichorpowered.guardian.launch.facet.GamePluginFacet)1