Add mod state in console

This commit is contained in:
Darto KLoning
2026-09-06 14:28:45 +07:00
parent 7c747f9036
commit ecc67d99ae
10 changed files with 689 additions and 329 deletions
+15 -113
View File
@@ -4,17 +4,13 @@ setlocal EnableExtensions EnableDelayedExpansion
REM ============================================================
REM Lobby Systems - Fabric Build Script
REM Windows
REM
REM Features:
REM - Read version from gradle.properties
REM - Check Java 25
REM - Download Gradle 9.5.1 automatically if needed
REM - Clean build
REM - Ask for Git commit + push ONLY after BUILD SUCCESS
REM ============================================================
cd /d "%~dp0"
set "BUILD_ONLY=0"
if /I "%~1"=="--build-only" set "BUILD_ONLY=1"
set "GRADLE_PROPERTIES=%CD%\gradle.properties"
set "LOCAL_GRADLE_DIR=%CD%\.gradle-local"
set "GRADLE_VERSION=9.5.1"
@@ -25,10 +21,6 @@ set "MOD_VERSION="
set "MINECRAFT_VERSION="
set "MAVEN_GROUP="
REM ============================================================
REM Read gradle.properties
REM ============================================================
if not exist "%GRADLE_PROPERTIES%" (
echo [ERROR] gradle.properties tidak ditemukan.
goto :failed
@@ -51,12 +43,7 @@ echo Namespace: id.dartokloning.lobbysystems
echo Mod ID: dartokloning
echo ============================================
REM ============================================================
REM Check Java
REM ============================================================
where java.exe >nul 2>&1
if errorlevel 1 (
echo [ERROR] Java tidak ditemukan di PATH.
echo Install JDK 25, buka terminal baru, lalu jalankan script lagi.
@@ -69,11 +56,9 @@ for /f "delims=" %%J in ('where java.exe 2^>nul') do (
)
:java_path_found
echo [INFO] Java executable: %JAVA_PATH%
set "JAVA_VERSION="
for /f "tokens=2" %%V in ('java --version 2^>^&1 ^| findstr /R /C:"^openjdk " /C:"^java "') do (
if not defined JAVA_VERSION set "JAVA_VERSION=%%V"
)
@@ -83,9 +68,7 @@ if not defined JAVA_VERSION (
goto :failed
)
for /f "tokens=1 delims=." %%M in ("%JAVA_VERSION%") do (
set "JAVA_MAJOR=%%M"
)
for /f "tokens=1 delims=." %%M in ("%JAVA_VERSION%") do set "JAVA_MAJOR=%%M"
if not "%JAVA_MAJOR%"=="25" (
echo [ERROR] Java 25 diperlukan.
@@ -95,42 +78,30 @@ if not "%JAVA_MAJOR%"=="25" (
echo [OK] Java 25 terdeteksi.
REM ============================================================
REM Prepare Gradle
REM ============================================================
if exist "%GRADLE_BIN%" goto :gradle_ready
echo [INFO] Gradle %GRADLE_VERSION% belum tersedia.
echo [INFO] Mengunduh distribusi resmi...
if not exist "%LOCAL_GRADLE_DIR%" (
mkdir "%LOCAL_GRADLE_DIR%"
)
if not exist "%LOCAL_GRADLE_DIR%" mkdir "%LOCAL_GRADLE_DIR%"
set "GRADLE_ZIP=%LOCAL_GRADLE_DIR%\gradle-%GRADLE_VERSION%-bin.zip"
set "GRADLE_URL=https://services.gradle.org/distributions/gradle-%GRADLE_VERSION%-bin.zip"
where curl.exe >nul 2>&1
if errorlevel 1 (
echo [ERROR] curl.exe tidak ditemukan.
echo Windows 10/11 biasanya sudah menyediakan curl.
goto :failed
)
curl.exe -L --fail --progress-bar "%GRADLE_URL%" -o "%GRADLE_ZIP%"
if errorlevel 1 (
echo [ERROR] Gagal mengunduh Gradle %GRADLE_VERSION%.
goto :failed
)
echo [INFO] Mengekstrak Gradle %GRADLE_VERSION%...
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command ^
"Expand-Archive -LiteralPath '%GRADLE_ZIP%' -DestinationPath '%LOCAL_GRADLE_DIR%' -Force"
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive -LiteralPath '%GRADLE_ZIP%' -DestinationPath '%LOCAL_GRADLE_DIR%' -Force"
if errorlevel 1 (
echo [ERROR] Gagal mengekstrak Gradle.
goto :failed
@@ -144,31 +115,19 @@ if not exist "%GRADLE_BIN%" (
)
:gradle_ready
echo [OK] Gradle %GRADLE_VERSION% tersedia.
REM ============================================================
REM Build
REM ============================================================
echo [INFO] Menjalankan clean build Lobby Systems v%MOD_VERSION%...
echo.
call "%GRADLE_BIN%" clean build --no-daemon
if errorlevel 1 goto :build_failed
REM ============================================================
REM BUILD SUCCESS
REM ============================================================
echo.
echo ============================================
echo BUILD SUCCESS
echo ============================================
set "JAR_PATH=%CD%\build\libs\lobby-systems-%MOD_VERSION%.jar"
if exist "%JAR_PATH%" (
echo JAR:
echo %JAR_PATH%
@@ -177,26 +136,21 @@ if exist "%JAR_PATH%" (
echo %JAR_PATH%
)
REM release.bat memakai mode ini supaya prompt Git tidak muncul dua kali.
if "%BUILD_ONLY%"=="1" exit /b 0
echo.
REM ============================================================
REM Ask whether to continue to Git
REM ============================================================
choice /C YN /N /M "Commit dan push perubahan ke Git/Gitea? [Y/N]: "
if errorlevel 2 goto :skip_git
if errorlevel 1 goto :git_integration
:git_integration
echo.
echo ============================================
echo Git Integration
echo ============================================
where git.exe >nul 2>&1
if errorlevel 1 (
echo [ERROR] Git tidak ditemukan di PATH.
echo Build tetap berhasil, tetapi Git tidak dapat dijalankan.
@@ -204,7 +158,6 @@ if errorlevel 1 (
)
git rev-parse --is-inside-work-tree >nul 2>&1
if errorlevel 1 (
echo [ERROR] Folder ini belum menjadi Git repository.
echo.
@@ -217,12 +170,8 @@ if errorlevel 1 (
)
echo [INFO] Memeriksa perubahan...
set "HAS_CHANGES="
for /f "delims=" %%G in ('git status --porcelain') do (
set "HAS_CHANGES=1"
)
for /f "delims=" %%G in ('git status --porcelain') do set "HAS_CHANGES=1"
if defined HAS_CHANGES (
echo.
@@ -231,76 +180,45 @@ if defined HAS_CHANGES (
echo.
set "COMMIT_MESSAGE="
set /p "COMMIT_MESSAGE=Commit message [Lobby Systems v%MOD_VERSION% build]: "
if not defined COMMIT_MESSAGE (
for /f "tokens=1-3 delims=/ " %%A in ("%date%") do (
set "DATESTAMP=%date%"
)
set "COMMIT_MESSAGE=Lobby Systems v%MOD_VERSION% build"
)
if not defined COMMIT_MESSAGE set "COMMIT_MESSAGE=Lobby Systems v%MOD_VERSION% build"
echo.
echo [INFO] Menambahkan perubahan ke staging...
git add -A
if errorlevel 1 (
echo [ERROR] git add gagal.
goto :git_failed
)
echo [INFO] Membuat commit...
git commit -m "!COMMIT_MESSAGE!"
if errorlevel 1 (
echo [ERROR] git commit gagal.
goto :git_failed
)
) else (
echo [INFO] Tidak ada perubahan source yang perlu di-commit.
echo [INFO] Akan mencoba push commit yang sudah ada.
)
REM ============================================================
REM Determine current branch
REM ============================================================
set "CURRENT_BRANCH="
for /f "delims=" %%B in ('git branch --show-current') do (
set "CURRENT_BRANCH=%%B"
)
for /f "delims=" %%B in ('git branch --show-current') do set "CURRENT_BRANCH=%%B"
if not defined CURRENT_BRANCH (
echo [ERROR] Tidak dapat menentukan branch Git aktif.
goto :git_failed
)
REM ============================================================
REM Check origin
REM ============================================================
git remote get-url origin >nul 2>&1
if errorlevel 1 (
echo [ERROR] Remote Git 'origin' belum dikonfigurasi.
echo.
echo Tambahkan Gitea dengan:
echo git remote add origin ^<URL-GITEA^>
echo.
echo Commit lokal tetap tersimpan.
goto :git_failed
)
echo [INFO] Push ke origin/!CURRENT_BRANCH!...
git push origin "!CURRENT_BRANCH!"
if errorlevel 1 (
echo [ERROR] Git push gagal.
echo [INFO] Commit lokal tetap tersimpan.
@@ -311,22 +229,12 @@ echo.
echo [SUCCESS] Push ke Git/Gitea berhasil.
goto :success
REM ============================================================
REM Skip Git
REM ============================================================
:skip_git
echo.
echo [INFO] Git commit/push dilewati.
goto :success
REM ============================================================
REM Success
REM ============================================================
:success
echo.
echo ============================================
echo Lobby Systems v%MOD_VERSION% selesai.
@@ -335,13 +243,7 @@ echo.
pause
exit /b 0
REM ============================================================
REM Build failed
REM Git section is NEVER reached
REM ============================================================
:build_failed
echo.
echo ============================================
echo BUILD FAILED
@@ -350,11 +252,11 @@ echo.
echo [ERROR] Build gagal.
echo [INFO] Git Integration tidak dijalankan.
echo.
if "%BUILD_ONLY%"=="1" exit /b 1
pause
exit /b 1
:git_failed
echo.
echo ============================================
echo GIT FAILED
@@ -367,9 +269,9 @@ pause
exit /b 2
:failed
echo.
echo Build gagal.
echo.
if "%BUILD_ONLY%"=="1" exit /b 1
pause
exit /b 1
exit /b 1