|
| 1 | +package org.dynmap.fabric_1_21; |
| 2 | + |
| 3 | +import net.fabricmc.api.ModInitializer; |
| 4 | +import net.fabricmc.loader.api.FabricLoader; |
| 5 | +import net.fabricmc.loader.api.ModContainer; |
| 6 | +import org.dynmap.DynmapCore; |
| 7 | +import org.dynmap.Log; |
| 8 | + |
| 9 | +import java.io.File; |
| 10 | +import java.net.URISyntaxException; |
| 11 | +import java.nio.file.Path; |
| 12 | +import java.nio.file.Paths; |
| 13 | + |
| 14 | +public class DynmapMod implements ModInitializer { |
| 15 | + private static final String MODID = "dynmap"; |
| 16 | + private static final ModContainer MOD_CONTAINER = FabricLoader.getInstance().getModContainer(MODID) |
| 17 | + .orElseThrow(() -> new RuntimeException("Failed to get mod container: " + MODID)); |
| 18 | + // The instance of your mod that Fabric uses. |
| 19 | + public static DynmapMod instance; |
| 20 | + |
| 21 | + public static DynmapPlugin plugin; |
| 22 | + public static File jarfile; |
| 23 | + public static String ver; |
| 24 | + public static boolean useforcedchunks; |
| 25 | + |
| 26 | + @Override |
| 27 | + public void onInitialize() { |
| 28 | + instance = this; |
| 29 | + |
| 30 | + Path path = MOD_CONTAINER.getRootPath(); |
| 31 | + try { |
| 32 | + jarfile = new File(DynmapCore.class.getProtectionDomain().getCodeSource().getLocation().toURI()); |
| 33 | + } catch (URISyntaxException e) { |
| 34 | + Log.severe("Unable to get DynmapCore jar path", e); |
| 35 | + } |
| 36 | + |
| 37 | + if (path.getFileSystem().provider().getScheme().equals("jar")) { |
| 38 | + path = Paths.get(path.getFileSystem().toString()); |
| 39 | + jarfile = path.toFile(); |
| 40 | + } |
| 41 | + |
| 42 | + ver = MOD_CONTAINER.getMetadata().getVersion().getFriendlyString(); |
| 43 | + |
| 44 | + Log.setLogger(new FabricLogger()); |
| 45 | + org.dynmap.modsupport.ModSupportImpl.init(); |
| 46 | + |
| 47 | + // Initialize the plugin, we will enable it fully when the server starts. |
| 48 | + plugin = new DynmapPlugin(); |
| 49 | + } |
| 50 | +} |
0 commit comments