2018-06-15 19:03:35 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2018-06-15 19:03:35 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
package net.minecraftforge.fml.loading;
|
|
|
|
|
2018-07-01 20:10:13 +00:00
|
|
|
import com.electronwill.nightconfig.core.file.FileConfig;
|
2019-01-14 03:51:36 +00:00
|
|
|
import net.minecraftforge.forgespi.language.IModInfo;
|
2018-06-15 19:03:35 +00:00
|
|
|
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
|
|
|
|
2018-09-24 04:07:33 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.URI;
|
2018-06-15 19:03:35 +00:00
|
|
|
import java.net.URISyntaxException;
|
2018-09-24 04:07:33 +00:00
|
|
|
import java.nio.file.FileSystems;
|
2018-06-15 19:03:35 +00:00
|
|
|
import java.nio.file.Paths;
|
|
|
|
import java.util.Arrays;
|
2018-09-24 04:07:33 +00:00
|
|
|
import java.util.HashMap;
|
2018-06-15 19:03:35 +00:00
|
|
|
import java.util.List;
|
2018-09-24 04:07:33 +00:00
|
|
|
import java.util.Objects;
|
2018-06-15 19:03:35 +00:00
|
|
|
|
|
|
|
public class DefaultModInfos
|
|
|
|
{
|
|
|
|
static {
|
2019-01-01 21:50:04 +00:00
|
|
|
FileConfig minecraftmod;
|
2018-06-15 19:03:35 +00:00
|
|
|
try
|
|
|
|
{
|
2018-09-24 04:07:33 +00:00
|
|
|
final URI jarFileURI = DefaultModInfos.class.getClassLoader().getResource("minecraftmod.toml").toURI();
|
|
|
|
if (Objects.equals(jarFileURI.getScheme(), "jar")) {
|
|
|
|
// Initialize the filesystem for the forge jar, because otherwise this barfs?
|
|
|
|
FileSystems.newFileSystem(jarFileURI, new HashMap<>());
|
|
|
|
}
|
|
|
|
minecraftmod = FileConfig.of(Paths.get(jarFileURI));
|
2018-06-15 19:03:35 +00:00
|
|
|
minecraftmod.load();
|
|
|
|
}
|
2018-09-24 04:07:33 +00:00
|
|
|
catch (IOException | URISyntaxException | NullPointerException e)
|
2018-06-15 19:03:35 +00:00
|
|
|
{
|
2019-01-01 21:50:04 +00:00
|
|
|
throw new RuntimeException("Missing toml config for minecraft!", e);
|
2018-06-15 19:03:35 +00:00
|
|
|
}
|
|
|
|
minecraftModInfo = new ModInfo(null, minecraftmod);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final IModInfo minecraftModInfo;
|
|
|
|
|
|
|
|
// no construction
|
|
|
|
private DefaultModInfos() {}
|
|
|
|
|
|
|
|
public static List<IModInfo> getModInfos()
|
|
|
|
{
|
2018-12-22 00:07:39 +00:00
|
|
|
return Arrays.asList(minecraftModInfo);
|
2018-06-15 19:03:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-22 10:40:22 +00:00
|
|
|
}
|