the_big_one/src/main/java/jesse/keeblarcraft/Keeblarcraft.java
2024-08-10 15:01:08 -04:00

62 lines
2.5 KiB
Java

/*
*
* Keeblarcraft
*
* This is the primary server side "main" object that is referenced by Fabric. This is where everything is setup for the mod
* and a very important class. Please becareful as you add to it
*
*/
package jesse.keeblarcraft;
import net.fabricmc.api.ModInitializer;
// import net.minecraft.server.command.ServerCommandSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jesse.keeblarcraft.Commands.CustomCommandManager;
import jesse.keeblarcraft.Utils.CustomExceptions.SETUP_FAILED_EXCEPTION;
import jesse.keeblarcraft.Utils.ChatUtil;
import jesse.keeblarcraft.Utils.Setup;
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
// import com.mojang.brigadier.Command;
public class Keeblarcraft implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("keeblarcraft");
CustomCommandManager cmdMgr = new CustomCommandManager();
Setup setup = Setup.GetInstance();
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
ChatUtil.LoggerColored("Hello Fabric world!", CONSOLE_COLOR.CYAN, LOGGER);
if (setup != null) {
try {
// Run setup. If setup fails; it throws SETUP_FAILED_EXCEPTION
LOGGER.info("\033[34m Running setup stage \033[0m");
setup.RunSetup();
// Run command registrations from the command manager
LOGGER.info("\033[34m Running command registration \033[0m");
cmdMgr.RegisterCustomCommands();
} catch (SETUP_FAILED_EXCEPTION e) {
System.out.println(ChatUtil.ColoredString("ERROR. Setup failed to initialize environment. Mod likely does not have read/write permissions inside area. Mod will now close out.", CONSOLE_COLOR.RED));
e.printStackTrace();
}
} else {
// Program exit. Dual definition of setup somehow happened!
System.out.println(ChatUtil.ColoredString("Dual definition of singleton attempted! Out of order initialization? How did this even happen?", CONSOLE_COLOR.RED));
}
}
}