Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.feeliiix.fundamental.plugin;
- import com.feeliiix.fundamental.api.Fundamental;
- import com.feeliiix.fundamental.api.configuration.hocon.HoconConfiguration;
- import com.feeliiix.fundamental.api.message.style.MessageStyle;
- import com.feeliiix.fundamental.api.message.style.MessageStyles;
- import com.feeliiix.fundamental.plugin.configuration.MainConfiguration;
- import com.feeliiix.fundamental.plugin.registry.MessageStyleRegistryModule;
- import com.google.inject.Inject;
- import org.slf4j.Logger;
- import org.spongepowered.api.Sponge;
- import org.spongepowered.api.config.ConfigDir;
- import org.spongepowered.api.event.Listener;
- import org.spongepowered.api.event.game.state.GameInitializationEvent;
- import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
- import org.spongepowered.api.event.game.state.GameStartedServerEvent;
- import org.spongepowered.api.plugin.Plugin;
- import java.nio.file.Path;
- @Plugin(name = "Fundamentals", id = "Fundamentals", version = "0.1-SNAPSHOT")
- public final class FundamentalPlugin implements Fundamental {
- private static Fundamental INSTANCE;
- @Inject private Logger logger;
- @Inject @ConfigDir(sharedRoot = false) private Path configDirectory;
- private HoconConfiguration mainConfiguration;
- @Listener
- public void onPreInitialization(GamePreInitializationEvent event) {
- INSTANCE = this;
- Sponge.getRegistry().registerModule(MessageStyle.class, new MessageStyleRegistryModule());
- }
- @Listener
- public void onInitialization(GameInitializationEvent event) {
- this.mainConfiguration = new MainConfiguration(this.configDirectory.resolve("config.conf"));
- }
- @Listener
- public void onStarted(GameStartedServerEvent event) {
- StringBuilder stringBuilder = new StringBuilder("MessageStyles: ");
- Sponge.getRegistry().getAllOf(MessageStyle.class).forEach(messageStyle -> stringBuilder.append(messageStyle.getName() + ", "));
- this.logger.info(stringBuilder.toString().substring(0, stringBuilder.toString().length() -1));
- }
- public static Fundamental getInstance() {
- return INSTANCE;
- }
- @Override
- public Logger getLogger() {
- return this.logger;
- }
- public Path getConfigDirectory() {
- return this.configDirectory;
- }
- @Override
- public HoconConfiguration getMainConfiguration() {
- return this.mainConfiguration;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement