Fix join gamemode enforcement in Lobby Systems v1.5.2
This commit is contained in:
+116
-82
@@ -18,6 +18,7 @@ LOCAL_GRADLE_DIR="$SCRIPT_DIR/.gradle-local"
|
||||
GRADLE_VERSION="9.5.1"
|
||||
GRADLE_HOME="$LOCAL_GRADLE_DIR/gradle-$GRADLE_VERSION"
|
||||
GRADLE_BIN="$GRADLE_HOME/bin/gradle"
|
||||
GIT_ONLY=0
|
||||
|
||||
info() { echo "[INFO] $1"; }
|
||||
ok() { echo "[OK] $1"; }
|
||||
@@ -36,7 +37,7 @@ suggest_commit_message() {
|
||||
SUGGESTED_COMMIT="Update Lobby Systems v$MOD_VERSION"
|
||||
|
||||
if grep -qiE '(^|[[:space:]])src/' <<<"$status"; then
|
||||
SUGGESTED_COMMIT="Update Lobby Systems v$MOD_VERSION"
|
||||
SUGGESTED_COMMIT="Fix join gamemode enforcement in Lobby Systems v$MOD_VERSION"
|
||||
elif grep -qiE 'compile\.(bat|sh)|release\.(bat|sh)' <<<"$status"; then
|
||||
SUGGESTED_COMMIT="Improve build and Git workflow"
|
||||
elif grep -qiE 'README\.md|LICENSE' <<<"$status"; then
|
||||
@@ -78,6 +79,88 @@ push_branch_with_retry() {
|
||||
done
|
||||
}
|
||||
|
||||
run_git_integration() {
|
||||
echo
|
||||
separator
|
||||
echo " Git Integration"
|
||||
separator
|
||||
if [[ $GIT_ONLY -eq 1 ]]; then
|
||||
info "Mode Git-only: build dilewati karena JAR v$MOD_VERSION sudah tersedia."
|
||||
fi
|
||||
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
error "Git tidak ditemukan di PATH."
|
||||
return 2
|
||||
fi
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
error "Folder ini belum menjadi Git repository."
|
||||
echo
|
||||
echo "Jalankan terlebih dahulu:"
|
||||
echo " git init"
|
||||
echo " git branch -M main"
|
||||
echo " git remote add origin <URL-GITEA>"
|
||||
return 2
|
||||
fi
|
||||
|
||||
info "Memeriksa perubahan Git..."
|
||||
CHANGES="$(git status --porcelain)"
|
||||
|
||||
if [[ -n "$CHANGES" ]]; then
|
||||
echo
|
||||
echo "Perubahan ditemukan:"
|
||||
echo
|
||||
git status --short
|
||||
echo
|
||||
|
||||
suggest_commit_message
|
||||
echo "[SUGGEST] Commit message: $SUGGESTED_COMMIT"
|
||||
info "Tekan Enter untuk memakai saran tersebut, atau ketik pesan sendiri."
|
||||
read -r -p "Commit message [$SUGGESTED_COMMIT]: " COMMIT_MESSAGE
|
||||
[[ -z "$COMMIT_MESSAGE" ]] && COMMIT_MESSAGE="$SUGGESTED_COMMIT"
|
||||
|
||||
info "Menambahkan perubahan ke staging..."
|
||||
if ! git add -A; then
|
||||
error "git add gagal."
|
||||
return 2
|
||||
fi
|
||||
|
||||
info "Membuat commit..."
|
||||
if ! git commit -m "$COMMIT_MESSAGE"; then
|
||||
error "git commit gagal."
|
||||
return 2
|
||||
fi
|
||||
else
|
||||
info "Tidak ada perubahan source yang perlu di-commit."
|
||||
info "Akan mencoba push commit lokal yang belum terkirim, jika ada."
|
||||
fi
|
||||
|
||||
CURRENT_BRANCH="$(git branch --show-current)"
|
||||
if [[ -z "$CURRENT_BRANCH" ]]; then
|
||||
error "Tidak dapat menentukan branch Git aktif."
|
||||
return 2
|
||||
fi
|
||||
|
||||
info "Branch aktif: $CURRENT_BRANCH"
|
||||
|
||||
if ! git remote get-url origin >/dev/null 2>&1; then
|
||||
error "Remote Git 'origin' belum dikonfigurasi."
|
||||
info "Commit lokal tetap tersimpan."
|
||||
return 2
|
||||
fi
|
||||
|
||||
REMOTE_URL="$(git remote get-url origin)"
|
||||
info "Remote origin: $REMOTE_URL"
|
||||
|
||||
if ! push_branch_with_retry; then
|
||||
return 2
|
||||
fi
|
||||
|
||||
echo
|
||||
ok "Push ke Git/Gitea berhasil."
|
||||
return 0
|
||||
}
|
||||
|
||||
if [[ ! -f "$GRADLE_PROPERTIES" ]]; then
|
||||
error "gradle.properties tidak ditemukan."
|
||||
exit 1
|
||||
@@ -91,6 +174,8 @@ MAVEN_GROUP="$(read_property "maven_group")"
|
||||
[[ -z "$MINECRAFT_VERSION" ]] && MINECRAFT_VERSION="26.2"
|
||||
[[ -z "$MAVEN_GROUP" ]] && MAVEN_GROUP="id.dartokloning"
|
||||
|
||||
JAR_PATH="$SCRIPT_DIR/build/libs/lobby-systems-$MOD_VERSION.jar"
|
||||
|
||||
separator
|
||||
echo " Lobby Systems - Fabric $MINECRAFT_VERSION Build"
|
||||
echo " Version: $MOD_VERSION"
|
||||
@@ -98,6 +183,34 @@ echo " Namespace: id.dartokloning.lobbysystems"
|
||||
echo " Mod ID: dartokloning"
|
||||
separator
|
||||
|
||||
if [[ $BUILD_ONLY -eq 0 && -f "$JAR_PATH" ]]; then
|
||||
echo
|
||||
info "JAR untuk v$MOD_VERSION sudah pernah dibuild:"
|
||||
echo " $JAR_PATH"
|
||||
echo
|
||||
read -r -p "[C] Compile ulang / [G] Git saja: " EXISTING_ACTION
|
||||
case "$EXISTING_ACTION" in
|
||||
g|G|git|GIT|Git)
|
||||
GIT_ONLY=1
|
||||
if run_git_integration; then
|
||||
echo
|
||||
separator
|
||||
echo " Lobby Systems v$MOD_VERSION selesai."
|
||||
separator
|
||||
exit 0
|
||||
fi
|
||||
echo
|
||||
separator
|
||||
echo " GIT FAILED"
|
||||
separator
|
||||
info "Build tidak dijalankan; JAR v$MOD_VERSION yang sudah ada tetap aman."
|
||||
info "Commit lokal tetap tersimpan."
|
||||
exit 2
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ! command -v java >/dev/null 2>&1; then
|
||||
error "Java tidak ditemukan di PATH."
|
||||
echo "Install JDK 25 lalu jalankan script lagi."
|
||||
@@ -192,8 +305,6 @@ separator
|
||||
echo " BUILD SUCCESS"
|
||||
separator
|
||||
|
||||
JAR_PATH="$SCRIPT_DIR/build/libs/lobby-systems-$MOD_VERSION.jar"
|
||||
|
||||
if [[ -f "$JAR_PATH" ]]; then
|
||||
echo "JAR:"
|
||||
echo "$JAR_PATH"
|
||||
@@ -221,94 +332,17 @@ case "$GIT_CONFIRM" in
|
||||
;;
|
||||
esac
|
||||
|
||||
echo
|
||||
separator
|
||||
echo " Git Integration"
|
||||
separator
|
||||
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
error "Git tidak ditemukan di PATH."
|
||||
info "Build tetap berhasil."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
error "Folder ini belum menjadi Git repository."
|
||||
echo
|
||||
echo "Jalankan terlebih dahulu:"
|
||||
echo " git init"
|
||||
echo " git branch -M main"
|
||||
echo " git remote add origin <URL-GITEA>"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
info "Memeriksa perubahan Git..."
|
||||
CHANGES="$(git status --porcelain)"
|
||||
|
||||
if [[ -n "$CHANGES" ]]; then
|
||||
echo
|
||||
echo "Perubahan ditemukan:"
|
||||
echo
|
||||
git status --short
|
||||
echo
|
||||
|
||||
suggest_commit_message
|
||||
echo "[SUGGEST] Commit message: $SUGGESTED_COMMIT"
|
||||
info "Tekan Enter untuk memakai saran tersebut, atau ketik pesan sendiri."
|
||||
read -r -p "Commit message [$SUGGESTED_COMMIT]: " COMMIT_MESSAGE
|
||||
[[ -z "$COMMIT_MESSAGE" ]] && COMMIT_MESSAGE="$SUGGESTED_COMMIT"
|
||||
|
||||
info "Menambahkan perubahan ke staging..."
|
||||
if ! git add -A; then
|
||||
error "git add gagal."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
info "Membuat commit..."
|
||||
if ! git commit -m "$COMMIT_MESSAGE"; then
|
||||
error "git commit gagal."
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
info "Tidak ada perubahan source yang perlu di-commit."
|
||||
info "Akan mencoba push commit yang sudah ada."
|
||||
fi
|
||||
|
||||
CURRENT_BRANCH="$(git branch --show-current)"
|
||||
if [[ -z "$CURRENT_BRANCH" ]]; then
|
||||
error "Tidak dapat menentukan branch Git aktif."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
info "Branch aktif: $CURRENT_BRANCH"
|
||||
|
||||
if ! git remote get-url origin >/dev/null 2>&1; then
|
||||
error "Remote Git 'origin' belum dikonfigurasi."
|
||||
echo
|
||||
echo "Tambahkan remote Gitea dengan:"
|
||||
echo " git remote add origin <URL-GITEA>"
|
||||
echo
|
||||
info "Commit lokal tetap tersimpan."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
REMOTE_URL="$(git remote get-url origin)"
|
||||
info "Remote origin: $REMOTE_URL"
|
||||
|
||||
if ! push_branch_with_retry; then
|
||||
if ! run_git_integration; then
|
||||
echo
|
||||
separator
|
||||
echo " GIT FAILED"
|
||||
separator
|
||||
info "Build Lobby Systems tetap berhasil."
|
||||
info "Commit lokal tetap tersimpan."
|
||||
info "Jalankan compile.sh lagi dan pilih Y; bila tidak ada perubahan, script langsung mencoba push commit yang tertunda."
|
||||
info "Jalankan compile.sh lagi; jika JAR versi sama terdeteksi, pilih G untuk Git-only."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo
|
||||
ok "Push ke Git/Gitea berhasil."
|
||||
echo
|
||||
separator
|
||||
echo " Lobby Systems v$MOD_VERSION selesai."
|
||||
|
||||
Reference in New Issue
Block a user