mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Server run profile, also setup logging for client profile.
This commit is contained in:
1 parent
2b23eb96fb
commit
1c9b5fae5e
5 files changed
+118
-2
No files matched your search
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2018.
|
||||
*
|
||||
* 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;
|
||||
|
||||
import cpw.mods.modlauncher.api.IEnvironment;
|
||||
import cpw.mods.modlauncher.api.ILaunchHandlerService;
|
||||
import cpw.mods.modlauncher.api.ITransformingClassLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class FMLServerLaunchProvider extends FMLCommonLaunchHandler implements ILaunchHandlerService
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
return "fmlserver";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path[] identifyTransformationTargets()
|
||||
{
|
||||
Path libsPath = findLibsPath();
|
||||
Path patchedBinariesPath = libsPath.resolve(Paths.get("net","minecraftforge","forge",MCPVersion.getMCVersion()+"-"+ForgeVersion.getVersion(),"forge-"+MCPVersion.getMCVersion()+"-"+ForgeVersion.getVersion()+"-server.jar"));
|
||||
Path srgMcPath = libsPath.resolve(Paths.get("net","minecraft", "server", MCPVersion.getMCPandMCVersion(), "server-"+MCPVersion.getMCPandMCVersion()+"-srg.jar"));
|
||||
LOGGER.info("SRG MC at {} is {}", srgMcPath.toString(), Files.exists(srgMcPath) ? "present" : "missing");
|
||||
LOGGER.info("Forge patches at {} is {}", patchedBinariesPath.toString(), Files.exists(patchedBinariesPath) ? "present" : "missing");
|
||||
LOGGER.info("Forge at {} is {}", getForgePath().toString(), Files.exists(getForgePath()) ? "present" : "missing");
|
||||
if (!(Files.exists(srgMcPath) && Files.exists(patchedBinariesPath) && Files.exists(getForgePath()))) {
|
||||
throw new RuntimeException("Failed to find patched jars");
|
||||
}
|
||||
return new Path[] {getForgePath(), patchedBinariesPath, srgMcPath};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Callable<Void> launchService(String[] arguments, ITransformingClassLoader launchClassLoader)
|
||||
{
|
||||
return () -> {
|
||||
super.beforeStart(launchClassLoader);
|
||||
launchClassLoader.addTargetPackageFilter(getPackagePredicate());
|
||||
Class.forName("net.minecraft.server.MinecraftServer", true, launchClassLoader.getInstance()).getMethod("main", String[].class).invoke(null, (Object)arguments);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(final IEnvironment environment) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dist getDist()
|
||||
{
|
||||
return Dist.DEDICATED_SERVER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.minecraftforge.server;
|
||||
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import cpw.mods.modlauncher.Launcher;
|
||||
|
||||
public class ServerMain {
|
||||
public static void main(String[] args) {
|
||||
final String[] argArray = ObjectArrays.concat(new String[]{"--launchTarget", "fmlserver","--gameDir", "."}, args, String.class);
|
||||
Launcher.main(argArray);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user