use of dte.employme.messages.service.TranslatedMessageService in project EmployMe by DavidTheExplorer.
the class EmployMe method onEnable.
@Override
public void onEnable() {
INSTANCE = this;
// init economy
this.economy = getEconomy();
if (this.economy == null) {
disableWithError(RED + "Economy wasn't found! Shutting Down...");
return;
}
ServiceLocator.register(Economy.class, this.economy);
// init the configs
Stream.of(SimpleJob.class, MoneyReward.class, ItemsReward.class).forEach(ConfigurationSerialization::registerClass);
ConfigFileFactory configFileFactory = new ConfigFileFactory.Builder().handleCreationException((exception, config) -> disableWithError(RED + String.format("Error while creating %s: %s", config.getFile().getName(), exception.getMessage()))).handleSaveException((exception, config) -> disableWithError(RED + String.format("Error while saving %s: %s", config.getFile().getName(), exception.getMessage()))).build();
this.subscriptionsConfig = configFileFactory.loadConfig("subscriptions");
this.jobAddNotifiersConfig = configFileFactory.loadConfig("job add notifiers");
this.itemsContainersConfig = configFileFactory.loadContainer("items");
this.rewardsContainersConfig = configFileFactory.loadContainer("rewards");
this.messagesConfig = configFileFactory.loadMessagesConfig(Messages.ENGLISH);
if (this.subscriptionsConfig == null || this.jobAddNotifiersConfig == null || this.itemsContainersConfig == null || this.rewardsContainersConfig == null || this.messagesConfig == null)
return;
// init the global job board, services, factories, etc.
this.globalJobBoard = new SimpleListenableJobBoard(new SimpleJobBoard());
TranslatedMessageService translatedMessageService = new TranslatedMessageService(this.messagesConfig);
this.reloadables.add(translatedMessageService);
this.messageService = new ColoredMessageService(translatedMessageService);
this.jobSubscriptionService = new SimpleJobSubscriptionService(this.subscriptionsConfig);
this.jobSubscriptionService.loadSubscriptions();
ServiceLocator.register(JobSubscriptionService.class, this.jobSubscriptionService);
this.playerContainerService = new SimplePlayerContainerService(this.itemsContainersConfig, this.rewardsContainersConfig, this.messageService);
this.playerContainerService.loadContainers();
ServiceLocator.register(PlayerContainerService.class, this.playerContainerService);
this.rewardService = new SimpleRewardService(this.messageService);
this.jobsConfig = configFileFactory.loadConfig("jobs");
if (this.jobsConfig == null)
return;
this.jobIconFactory = new JobIconFactory(this.messageService);
this.jobService = new SimpleJobService(this.globalJobBoard, this.jobsConfig);
this.jobService.loadJobs();
this.jobAddedNotifierService = new SimpleJobAddedNotifierService(this.jobAddNotifiersConfig);
this.jobAddedNotifierService.register(new DoNotNotify());
this.jobAddedNotifierService.register(new AllJobsNotifier(this.messageService));
this.jobAddedNotifierService.register(new MaterialSubscriptionNotifier(this.messageService, this.jobSubscriptionService));
this.jobAddedNotifierService.loadPlayersNotifiers();
this.globalJobBoard.registerCompleteListener(new JobRewardGiveListener(), new JobGoalTransferListener(this.playerContainerService), new JobCompletedMessagesListener(this.messageService));
this.globalJobBoard.registerAddListener(new EmployerNotificationListener(this.messageService), new JobAddNotificationListener(this.jobAddedNotifierService));
// register commands, listeners, metrics
registerCommands();
registerListeners(new PlayerContainerAbuseListener(this.playerContainerService));
setDisableListener(() -> {
this.jobService.saveJobs();
this.playerContainerService.saveContainers();
this.jobSubscriptionService.saveSubscriptions();
this.jobAddedNotifierService.savePlayersNotifiers();
});
new Metrics(this, 13423);
AutoUpdater.forPlugin(this, 96513).ifRequestFailed(exception -> logToConsole(RED + "There was an internet error while checking for an update!")).ifNewUpdate(newVersion -> registerListeners(new AutoUpdateListeners(this.messageService, newVersion))).check();
}
Aggregations