|
| 1 | +package micdoodle8.mods.galacticraft.core.util; |
| 2 | + |
| 3 | +import java.util.Optional; |
| 4 | +import net.minecraftforge.fml.common.Loader; |
| 5 | +import net.minecraftforge.fml.common.ModContainer; |
| 6 | + |
| 7 | +public enum Compatibility |
| 8 | +{ |
| 9 | + |
| 10 | + ACTUALLYADDITIONS("actuallyadditions"), |
| 11 | + APPLIEDENERGISTICS2("appliedenergistics2"), |
| 12 | + BIOMESOPLENTY("biomesoplenty"), |
| 13 | + BUILDCRAFT("buildcraftcore"), |
| 14 | + BUILDCRAFT_TRANSPORT("buildcrafttransport"), |
| 15 | + BUILDCRAFT_ENERGY("buildcraftenergy"), |
| 16 | + CUBIC_CHUNKS("cubicchunks"), |
| 17 | + ENDERIO("enderio"), |
| 18 | + GRECHTECH("gregtech", "gregtech_addon"), |
| 19 | + INDUSTRIALCRAFT("ic2"), |
| 20 | + JEI("jei"), |
| 21 | + MATTEROVERDRIVE("matteroverdrive"), |
| 22 | + MEKANISM("mekanism"), |
| 23 | + PLAYER_API("PlayerAPI"), |
| 24 | + RENDER_PLAYER_API("RenderPlayerAPI"), |
| 25 | + PNEUMATICCRAFT("pneumaticcraft"), |
| 26 | + SPONGEFORGE("spongeforge"), |
| 27 | + TINKERS_CONSTRUCT("tconstruct"), |
| 28 | + WAILA("waila"); |
| 29 | + |
| 30 | + |
| 31 | + private final String modid; |
| 32 | + private final String displayName; |
| 33 | + private final boolean isLoaded; |
| 34 | + private final Optional<ModContainer> modContainer; |
| 35 | + |
| 36 | + Compatibility(String modid, String altModid) |
| 37 | + { |
| 38 | + final boolean loaded = (Loader.isModLoaded(modid) || Loader.isModLoaded(altModid)); |
| 39 | + this.modid = modid; |
| 40 | + this.isLoaded = loaded; |
| 41 | + this.modContainer = Loader.instance().getModList().stream().filter(m -> m.getModId().equals(modid)).findFirst(); |
| 42 | + this.displayName = loaded ? modContainer.get().getName() : ""; |
| 43 | + } |
| 44 | + |
| 45 | + Compatibility(String modid) |
| 46 | + { |
| 47 | + final boolean loaded = Loader.isModLoaded(modid); |
| 48 | + this.modid = modid; |
| 49 | + this.isLoaded = loaded; |
| 50 | + this.modContainer = Loader.instance().getModList().stream().filter(m -> m.getModId().equals(modid)).findFirst(); |
| 51 | + this.displayName = loaded ? modContainer.get().getName() : ""; |
| 52 | + } |
| 53 | + |
| 54 | + public String modid() |
| 55 | + { |
| 56 | + return modid; |
| 57 | + } |
| 58 | + |
| 59 | + public String displayName() |
| 60 | + { |
| 61 | + return displayName; |
| 62 | + } |
| 63 | + |
| 64 | + public boolean isLoaded() |
| 65 | + { |
| 66 | + return isLoaded; |
| 67 | + } |
| 68 | + |
| 69 | + public String getVersion() |
| 70 | + { |
| 71 | + if (modContainer.isPresent()) |
| 72 | + { |
| 73 | + return modContainer.get().getVersion(); |
| 74 | + } |
| 75 | + return "unspecified"; |
| 76 | + } |
| 77 | +} |
0 commit comments