use of com.ichorpowered.guardian.util.property.PropertyInjector 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;
}
use of com.ichorpowered.guardian.util.property.PropertyInjector in project guardian by ichorpowered.
the class GamePluginFacet method startup.
public Boolean startup() {
this.facetState = FacetState.PREPARE;
PropertyInjector propertyInjector = this.plugin.getPropertyInjector();
propertyInjector.inject("state", GuardianState.STARTING);
// STATE: STARTING
this.logger.info(ConsoleUtil.of(this.facetPrefix + "Preparing environment adaptions."));
// TODO: Environment adaptions are a future feature.
this.plugin.getSequenceTask().start();
this.plugin.getEventBus().post(new GuardianStartingEvent(this.plugin, Origin.source(this.plugin.getPluginContainer()).build()));
propertyInjector.inject("state", GuardianState.STARTED);
// STATE: STARTED
this.logger.info(ConsoleUtil.of(this.facetPrefix + "Startup complete. ({} sec)", String.valueOf((double) (System.currentTimeMillis() - this.plugin.getCoreTime()) / 1000)));
this.plugin.getEventBus().post(new GuardianStartedEvent(this.plugin, Origin.source(this.plugin.getPluginContainer()).build()));
this.facetState = FacetState.START;
return true;
}
use of com.ichorpowered.guardian.util.property.PropertyInjector in project guardian by ichorpowered.
the class InternalPluginFacet method startup.
public Boolean startup() {
this.facetState = FacetState.PREPARE;
PropertyInjector propertyInjector = this.plugin.getPropertyInjector();
propertyInjector.inject("state", GuardianState.POST_INITIALIZATION);
// STATE: POST_INITIALIZATION
this.plugin.getCommon().registerPermissions();
this.plugin.getCommon().loadPenalties();
this.plugin.getCommon().loadHeuristics();
this.plugin.getCommon().loadChecks();
this.plugin.getCommon().loadModules(this.plugin.getModuleController());
this.logger.info(ConsoleUtil.of(this.facetPrefix + " Preparing modules."));
this.logger.info(ConsoleUtil.of(Ansi.Color.YELLOW, "Discovered {} module(s).", String.valueOf(this.plugin.getModuleController().getModules().size())));
this.plugin.getModuleController().enableModules(moduleWrapper -> {
try {
if (this.plugin.getConfiguration().getEnabledModules().contains(moduleWrapper.getId()))
return true;
} catch (ObjectMappingException e) {
this.logger.error("Failed to acquire enable modules list from the configuration.", e);
}
return false;
});
AtomicInteger detections = new AtomicInteger(0);
AtomicInteger checks = new AtomicInteger(0);
AtomicInteger heuristics = new AtomicInteger(0);
AtomicInteger penalties = new AtomicInteger(0);
this.plugin.getModuleController().getModules().stream().filter(ModuleWrapper::isEnabled).forEach(moduleWrapper -> {
if (!moduleWrapper.getModule().isPresent())
return;
if (moduleWrapper.getModule().get() instanceof Detection) {
AbstractDetection detection = (AbstractDetection) moduleWrapper.getModule().get();
// Precogs detection registration.
Sponge.getRegistry().register(DetectionType.class, detection);
// Register event listeners and provide detection to the manager.
this.plugin.getEventBus().register(detection);
this.plugin.getDetectionManager().provideDetection(detection.getClass(), detection);
// Register the detection and inject its properties.
detection.register(this.plugin.getDetectionManager());
// Call the load method.
detection.onLoad();
if (this.plugin.getDetectionManager().getStageModel(CheckModel.class).isPresent())
checks.addAndGet(detection.getStageCycle().sizeFor(this.plugin.getDetectionManager().getStageModel(CheckModel.class).get()));
if (this.plugin.getDetectionManager().getStageModel(HeuristicModel.class).isPresent())
heuristics.addAndGet(detection.getStageCycle().sizeFor(this.plugin.getDetectionManager().getStageModel(HeuristicModel.class).get()));
if (this.plugin.getDetectionManager().getStageModel(PenaltyModel.class).isPresent())
penalties.addAndGet(detection.getStageCycle().sizeFor(this.plugin.getDetectionManager().getStageModel(PenaltyModel.class).get()));
detections.incrementAndGet();
}
});
this.logger.info(ConsoleUtil.of(Ansi.Color.YELLOW, "Loaded {} punishment(s), {} heuristic(s) and " + "{} check(s) for {} detection(s).", String.valueOf(penalties.get()), String.valueOf(heuristics.get()), String.valueOf(checks.get()), String.valueOf(detections.get())));
this.plugin.getEventBus().post(new GuardianPostInitialization(this.plugin, Origin.source(this.plugin.getPluginContainer()).build()));
Sponge.getEventManager().registerListeners(this.plugin, this.plugin.getSequenceListener());
this.facetState = FacetState.START;
return true;
}
use of com.ichorpowered.guardian.util.property.PropertyInjector in project guardian by ichorpowered.
the class GamePluginFacet method shutdown.
public Boolean shutdown() {
PropertyInjector propertyInjector = this.plugin.getPropertyInjector();
propertyInjector.inject("state", GuardianState.STOPPING);
this.plugin.getEventBus().post(new GuardianStoppingEvent(this.plugin, Origin.source(this.plugin.getPluginContainer()).build()));
this.plugin.getSequenceTask().stop();
this.facetState = FacetState.STOP;
return true;
}
Aggregations