Last active
July 12, 2017 21:03
-
-
Save PaintNinja/a28cbfd1170d32c06fcd5b710778a271 to your computer and use it in GitHub Desktop.
Extends MultiMC's core commandline functionality to permit basic creation, deletion and modification of instances. Must be put in the same folder as the MultiMC exe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set BINDIR=%~dp0 | |
cd /d %BINDIR% | |
if "%1"=="create" (goto CreateInstance) | |
if "%1"=="delete" (goto DeleteInstance) | |
if "%1"=="add-component" (goto AddComponentToInstance) | |
:Welcome | |
echo MMC CLI Extender v0.1 | |
echo. | |
echo To create an instance: create "InstanceName" "Minecraft" "MinecraftVersion" | |
echo To delete an instance: delete "InstanceName" | |
echo. | |
echo To add a component to an existing instance: add-component "InstanceName" "ComponentName" "ComponentVersion" | |
echo Available components: Forge, Liteloader | |
echo. | |
pause | |
exit /b | |
:CreateInstance | |
if not exist instances mkdir instances | |
pushd instances | |
set InstanceName="%2" | |
set MinecraftVersion="%4" | |
echo InstanceName: %2 | |
echo MinecraftVersion: %4 | |
if not exist %InstanceName% ( | |
md %InstanceName% | |
pushd %InstanceName% | |
if not exist instance.cfg ( | |
echo InstanceType=OneSix>instance.cfg | |
echo name=%InstanceName%>>instance.cfg | |
echo IntendedVersion=%MinecraftVersion%>>instance.cfg | |
REM TODO: Call add-component for adding MC to the instance.cfg rather than doing it directly | |
popd | |
) else ( | |
echo Error: An instance.cfg file already exists for that InstanceName. | |
popd | |
popd | |
pause | |
exit /b | |
) | |
) else ( | |
echo Error: An instance already exists with that InstanceName. | |
) | |
popd | |
exit /b | |
:DeleteInstance | |
set InstanceName=%2 | |
echo InstanceName: %2 | |
if exist instances ( | |
pushd instances | |
if exist %InstanceName% ( | |
rmdir /s %InstanceName% | |
) else ( | |
echo Error: The instance "%InstanceName%" was not found | |
popd | |
pause | |
exit /b | |
) | |
popd | |
) else ( | |
echo Error: Instances folder not found. | |
pause | |
exit /b | |
) | |
exit /b | |
:AddComponentToInstance | |
set InstanceName=%2 | |
set ComponentName=%3 | |
set ComponentVersion=%4 | |
echo InstanceName: %2 | |
echo ComponentName: %3 | |
echo ComponentVersion: %4 | |
if exist instances ( | |
pushd instances | |
if exist "%InstanceName%" ( | |
pushd "%InstanceName%" | |
if exist instance.cfg ( | |
if %ComponentName%=="Forge" ( | |
echo ForgeVersion^=%ComponentVersion%>>instance.cfg | |
) else ( | |
if %ComponentName%=="Liteloader" ( | |
echo LiteloaderVersion^=%ComponentVersion%>>instance.cfg | |
) else ( | |
if %ComponentName%=="Minecraft" ( | |
echo IntendedVersion=%ComponentVersion%>>instance.cfg | |
) else ( | |
echo Unknown component. Available components: Forge, Liteloader. | |
popd | |
popd | |
pause | |
exit /b | |
) | |
) | |
) | |
popd | |
popd | |
) else ( | |
echo Error: An instance.cfg file doesn't yet exist for that InstanceName. | |
popd | |
pause | |
exit /b | |
) | |
) else ( | |
echo Error: The instance "%InstanceName%" was not found | |
popd | |
pause | |
exit /b | |
) | |
) else ( | |
echo Error: Instances folder not found. | |
popd | |
) | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MIT License