aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/eu/olli/cowlection/Cowlection.java
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-07-05 05:42:45 +0200
committerCow <cow@volloeko.de>2020-07-05 05:42:45 +0200
commit1b446698398c648b38311975a6cfd54859ea5cfe (patch)
tree521ecc4ce9ad968281094eb8c5453dca606931e3 /src/main/java/eu/olli/cowlection/Cowlection.java
parentedaca1fd41a612c71c526ceb20b89c5dec2d81b3 (diff)
downloadCowlection-1b446698398c648b38311975a6cfd54859ea5cfe.tar.gz
Cowlection-1b446698398c648b38311975a6cfd54859ea5cfe.tar.bz2
Cowlection-1b446698398c648b38311975a6cfd54859ea5cfe.zip
Renamed mod to Cowlection
Bumped version to 1.8.9-0.7.0
Diffstat (limited to 'src/main/java/eu/olli/cowlection/Cowlection.java')
-rw-r--r--src/main/java/eu/olli/cowlection/Cowlection.java116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/main/java/eu/olli/cowlection/Cowlection.java b/src/main/java/eu/olli/cowlection/Cowlection.java
new file mode 100644
index 0000000..dfa3456
--- /dev/null
+++ b/src/main/java/eu/olli/cowlection/Cowlection.java
@@ -0,0 +1,116 @@
+package eu.olli.cowlection;
+
+import eu.olli.cowlection.command.MooCommand;
+import eu.olli.cowlection.command.ShrugCommand;
+import eu.olli.cowlection.command.TabCompletableCommand;
+import eu.olli.cowlection.config.MooConfig;
+import eu.olli.cowlection.handler.FriendsHandler;
+import eu.olli.cowlection.handler.PlayerCache;
+import eu.olli.cowlection.listener.ChatListener;
+import eu.olli.cowlection.listener.PlayerListener;
+import eu.olli.cowlection.util.ChatHelper;
+import eu.olli.cowlection.util.VersionChecker;
+import net.minecraftforge.client.ClientCommandHandler;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.fml.common.Mod;
+import net.minecraftforge.fml.common.Mod.EventHandler;
+import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+import org.apache.logging.log4j.Logger;
+
+import java.io.File;
+
+@Mod(modid = Cowlection.MODID, name = Cowlection.MODNAME, version = Cowlection.VERSION,
+ clientSideOnly = true,
+ guiFactory = "@PACKAGE@.config.MooGuiFactory",
+ updateJSON = "https://raw.githubusercontent.com/cow-mc/Cowlection/master/update.json")
+public class Cowlection {
+ public static final String MODID = "@MODID@";
+ public static final String VERSION = "@VERSION@";
+ public static final String MODNAME = "@MODNAME@";
+ public static final String GITURL = "@GITURL@";
+ private static Cowlection instance;
+ private File configDir;
+ private File modsDir;
+ private MooConfig config;
+ private FriendsHandler friendsHandler;
+ private VersionChecker versionChecker;
+ private ChatHelper chatHelper;
+ private PlayerCache playerCache;
+ private Logger logger;
+
+ @Mod.EventHandler
+ public void preInit(FMLPreInitializationEvent e) {
+ instance = this;
+ logger = e.getModLog();
+ modsDir = e.getSourceFile().getParentFile();
+
+ this.configDir = new File(e.getModConfigurationDirectory(), MODID + File.separatorChar);
+ if (!configDir.exists()) {
+ configDir.mkdirs();
+ }
+
+ friendsHandler = new FriendsHandler(this, new File(configDir, "friends.json"));
+ config = new MooConfig(this, new Configuration(new File(configDir, MODID + ".cfg")));
+
+ chatHelper = new ChatHelper();
+ }
+
+ @EventHandler
+ public void init(FMLInitializationEvent e) {
+ MinecraftForge.EVENT_BUS.register(new ChatListener(this));
+ MinecraftForge.EVENT_BUS.register(new PlayerListener(this));
+ ClientCommandHandler.instance.registerCommand(new MooCommand(this));
+ ClientCommandHandler.instance.registerCommand(new ShrugCommand(this));
+ for (String tabCompletableNamesCommand : MooConfig.tabCompletableNamesCommands) {
+ ClientCommandHandler.instance.registerCommand(new TabCompletableCommand(this, tabCompletableNamesCommand));
+ }
+ }
+
+ @EventHandler
+ public void postInit(FMLPostInitializationEvent e) {
+ versionChecker = new VersionChecker(this);
+ playerCache = new PlayerCache(this);
+ }
+
+ public MooConfig getConfig() {
+ return config;
+ }
+
+ public FriendsHandler getFriendsHandler() {
+ return friendsHandler;
+ }
+
+ public VersionChecker getVersionChecker() {
+ return versionChecker;
+ }
+
+ public ChatHelper getChatHelper() {
+ return chatHelper;
+ }
+
+ public PlayerCache getPlayerCache() {
+ return playerCache;
+ }
+
+ public File getConfigDirectory() {
+ return configDir;
+ }
+
+ public File getModsDirectory() {
+ return modsDir;
+ }
+
+ public Logger getLogger() {
+ return logger;
+ }
+
+ /**
+ * Get mod's instance; instead of this method use dependency injection where possible
+ */
+ public static Cowlection getInstance() {
+ return instance;
+ }
+}