Skip to content

Instantly share code, notes, and snippets.

@SpaceManiac
Created December 2, 2014 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpaceManiac/ed8886a6d71657f5c694 to your computer and use it in GitHub Desktop.
Save SpaceManiac/ed8886a6d71657f5c694 to your computer and use it in GitHub Desktop.
package spongetest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.Game;
import org.spongepowered.api.util.event.Subscribe;
import org.spongepowered.api.event.state.PreInitializationEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
import javax.inject.Inject;
import java.io.File;
@Plugin(id = "spongetest", name = "Sponge Test")
public class SpongeTestPlugin {
public final Game game;
public final PluginContainer container;
public Logger factory_logger;
public Logger event_logger;
public File main_config_dir;
public File rec_config_file;
public File rec_config_dir;
@Inject
public SpongeTestPlugin(Game game, PluginContainer container) {
this.game = game;
this.container = container;
this.factory_logger = LoggerFactory.getLogger("spongetest");
this.factory_logger.info("SpongeTestPlugin constructed");
this.factory_logger.info("game = " + game);
this.factory_logger.info("container = " + container.getId());
}
@Subscribe
public void onPreInit(PreInitializationEvent e) {
this.event_logger = e.getPluginLog();
this.main_config_dir = e.getConfigurationDirectory();
this.rec_config_file = e.getRecommendedConfigurationFile();
this.rec_config_dir = e.getRecommendedConfigurationDirectory();
try {
this.event_logger.info("Main Config Directory: " + this.main_config_dir.getCanonicalPath());
} catch (Throwable t) {
this.event_logger.info("Display Main Config Directory Failed", t);
}
try {
this.event_logger.info("Recommended Config File: " + this.rec_config_file.getCanonicalPath());
} catch (Throwable t) {
this.event_logger.info("Display Recommended Config File Failed", t);
}
try {
this.event_logger.info("Recommended Config Directory: " + this.rec_config_dir.getCanonicalPath());
} catch (Throwable t) {
this.event_logger.info("Display Recommended Config Directory Failed", t);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment