This commit is contained in:
parent
ca56fcc671
commit
b103bcba03
11 changed files with 311 additions and 16 deletions
57
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
57
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
name: Bug Report
|
||||
description: Report an issue with supported versions of ExtBackup
|
||||
labels: [ bug ]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: mc-version
|
||||
attributes:
|
||||
label: Minecraft version
|
||||
options:
|
||||
- 1.19.x
|
||||
- 1.20.x
|
||||
- 1.21.x
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: mod-version
|
||||
attributes:
|
||||
label: ExtBackup version
|
||||
placeholder: eg. 1.19.4-1.2.0
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: forge-version
|
||||
attributes:
|
||||
label: (Neo)Forge version
|
||||
placeholder: eg. 45.0.1
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: log-file
|
||||
attributes:
|
||||
label: The latest.log file
|
||||
description: |
|
||||
Please use a paste site such as [gist](https://gist.github.com/) / [pastebin](https://pastebin.com/) / etc.
|
||||
For more information, see https://git.io/mclogs
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Issue description
|
||||
placeholder: A description of the issue.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps-to-reproduce
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
placeholder: |
|
||||
1. First step
|
||||
2. Second step
|
||||
3. etc...
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Other information
|
||||
description: Any other relevant information that is related to this issue, such as modpacks, other mods and their versions.
|
11
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
11
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
name: Feature request
|
||||
description: Suggest an idea, or enhancement
|
||||
labels: [ enhancement ]
|
||||
body:
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe your idea
|
||||
placeholder: A clear and reasoned description of your idea.
|
||||
validations:
|
||||
required: true
|
47
.github/workflows/check_latest_compatibility.yml
vendored
Normal file
47
.github/workflows/check_latest_compatibility.yml
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Do not edit this file directly
|
||||
# This file is synced by https://github.com/ChaoticTrials/ModMeta
|
||||
|
||||
name: Check NeoForge compatibility
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 3 * * 5'
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Extract Minecraft Version
|
||||
id: extract-minecraft-version
|
||||
run: |
|
||||
minecraft_version=$(grep -m 1 "^minecraft_version=" gradle.properties | cut -d'=' -f2)
|
||||
echo "minecraft_version=$minecraft_version" >> $GITHUB_ENV
|
||||
|
||||
- name: Get latest NeoForge
|
||||
id: get-version
|
||||
uses: ChaoticTrials/action-latest-forge@v1
|
||||
with:
|
||||
minecraft-version: ${{ env.minecraft_version }}
|
||||
|
||||
- name: Check compiling
|
||||
uses: ChaoticTrials/action-test-different-property@v1
|
||||
with:
|
||||
gradle-property: neo_version
|
||||
gradle-value: ${{ steps.get-version.outputs.version }}
|
||||
properties-file: gradle.properties
|
||||
issue-title: "[${{ env.minecraft_version }}] NeoForge incompatibility"
|
||||
issue-comment: |
|
||||
## NeoForge version
|
||||
- ${{ steps.get-version.outputs.version }}
|
||||
issue-labels: Compat, bug
|
88
.github/workflows/check_pr_translations.yml
vendored
Normal file
88
.github/workflows/check_pr_translations.yml
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
# Do not edit this file directly
|
||||
# This file is synced by https://github.com/ChaoticTrials/ModMeta
|
||||
|
||||
# This workflow was generated with the help of OpenAI's GPT.
|
||||
|
||||
name: Check Localization Files
|
||||
on:
|
||||
pull_request_target:
|
||||
paths:
|
||||
- 'src/main/resources/assets/**/lang/*.json'
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check-localization:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Debug PR context
|
||||
run: |
|
||||
echo "Pull request number: ${{ github.event.pull_request.number }}"
|
||||
echo "Repository full name: ${{ github.repository }}"
|
||||
echo "Event path: $GITHUB_EVENT_PATH"
|
||||
|
||||
- name: Check localization files
|
||||
run: |
|
||||
PR_NUMBER="${{ github.event.pull_request.number }}"
|
||||
REPO_FULL_NAME="${{ github.repository }}"
|
||||
# Ensure GitHub CLI is authenticated and correctly identifies the PR context
|
||||
echo "Processing PR #$PR_NUMBER for repository $REPO_FULL_NAME"
|
||||
|
||||
# Get the list of added or modified localization files
|
||||
FILES=$(gh pr diff "$PR_NUMBER" --repo "$REPO_FULL_NAME" --name-only | grep -E 'src/main/resources/assets/.*/lang/.*\.json' || true)
|
||||
|
||||
if [[ -z "$FILES" ]]; then
|
||||
echo "No localization files have been modified."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Initialize an array to store the missing keys
|
||||
MISSING_KEYS=()
|
||||
# Iterate over each file
|
||||
for FILE in $FILES; do
|
||||
# Check if the file is not the default English translation
|
||||
if [[ $FILE != *"en_us.json" ]]; then
|
||||
# Get the modid and language key from the file path
|
||||
MODID=$(echo $FILE | cut -d'/' -f5)
|
||||
LANGUAGE_KEY=$(echo $FILE | cut -d'/' -f7 | cut -d'.' -f1)
|
||||
# Check if all keys from the default English translation are included in this file
|
||||
KEYS=$(jq -n --argfile en src/main/resources/assets/$MODID/lang/en_us.json --argfile current $FILE '($en | keys) - ($current | keys)' )
|
||||
if [[ $KEYS != "[]" ]]; then
|
||||
MISSING_KEYS+=("$LANGUAGE_KEY: $KEYS")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Post a comment on the pull request with the missing keys or a success message
|
||||
if [[ ${#MISSING_KEYS[@]} -gt 0 ]]; then
|
||||
echo "# 🚨 Missing translation keys 🚨" > review.md
|
||||
for MISSING_KEY in "${MISSING_KEYS[@]}"; do
|
||||
LANGUAGE=$(echo $MISSING_KEY | cut -d':' -f1)
|
||||
KEYS=$(echo $MISSING_KEY | cut -d':' -f2 | jq -r '.[]')
|
||||
echo "## **$LANGUAGE**" >> review.md
|
||||
for KEY in $KEYS; do
|
||||
echo "- $KEY" >> review.md
|
||||
done
|
||||
echo "" >> review.md
|
||||
done
|
||||
|
||||
# Request changes on the pull request
|
||||
gh pr review "$PR_NUMBER" --repo "$REPO_FULL_NAME" --request-changes --body-file review.md
|
||||
else
|
||||
echo "## ✅ All localization files have been checked and are complete! ✅" > review.md
|
||||
echo "Waiting for approval by @MelanX" >> review.md
|
||||
|
||||
# Approve the pull request
|
||||
gh pr review "$PR_NUMBER" --repo "$REPO_FULL_NAME" --comment --body-file review.md
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
63
.github/workflows/publish.yml
vendored
Normal file
63
.github/workflows/publish.yml
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Do not edit this file directly
|
||||
# This file is synced by https://github.com/ChaoticTrials/ModMeta
|
||||
|
||||
name: publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Determine previous commit
|
||||
id: determine_previous_commit
|
||||
run: |
|
||||
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
|
||||
gitPrevHash=$(git rev-parse HEAD~1)
|
||||
else
|
||||
gitPrevHash=${{ github.event.before }}
|
||||
fi
|
||||
echo "GIT_PREVIOUS_COMMIT=$gitPrevHash" >> $GITHUB_ENV
|
||||
|
||||
- name: Check commit messages
|
||||
id: check_commit_messages
|
||||
run: |
|
||||
commits=$(git log $GIT_PREVIOUS_COMMIT..${{ github.sha }} --pretty=format:'%s')
|
||||
echo "Commits since last push:"
|
||||
echo "$commits"
|
||||
|
||||
total_commits=$(echo "$commits" | wc -l)
|
||||
meta_commits=$(echo "$commits" | grep -E '^\[meta\]' | wc -l)
|
||||
|
||||
if [ "$total_commits" -eq "$meta_commits" ]; then
|
||||
echo "Only meta commits present, skip publishing"
|
||||
echo "run_publish=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "run_publish=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Build and publish to maven
|
||||
if: env.run_publish == 'true'
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew clean build publish curseforge modrinth --no-configuration-cache
|
||||
env:
|
||||
GIT_COMMIT: ${{ github.sha }}
|
||||
GIT_PREVIOUS_COMMIT: ${{ github.event.before }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
|
||||
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
22
.github/workflows/stale.yml
vendored
Normal file
22
.github/workflows/stale.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Do not edit this file directly
|
||||
# This file is synced by https://github.com/ChaoticTrials/ModMeta
|
||||
|
||||
name: Close stale issues and PRs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 */6 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
stale-issue-message: The required information were not provided yet. Thus, this was marked as stale.
|
||||
close-issue-message: None of the required information was ever provided. If this is still an issue, feel free to reopen with the required information, or create a new issue.
|
||||
only-labels: needs more info
|
||||
days-before-stale: 7
|
||||
days-before-close: 3
|
|
@ -14,7 +14,7 @@ loader_version_range=[4,)
|
|||
modid=extbackup
|
||||
mod_name=ExtBackup
|
||||
group=net.sweevo
|
||||
mod_version=2.0.1
|
||||
mod_version=2.0.6
|
||||
## Upload Properties
|
||||
upload_versions=1.21, 1.21.1
|
||||
upload_release=release
|
||||
|
|
|
@ -5,8 +5,10 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.saveddata.SavedData;
|
||||
import net.sweevo.jinks.config.CommonConfig;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class BackupData extends SavedData {
|
||||
|
||||
|
@ -56,6 +58,10 @@ public class BackupData extends SavedData {
|
|||
return this.lastSaved;
|
||||
}
|
||||
|
||||
public String getNextBackup() {
|
||||
return new SimpleDateFormat("HH:mm:ss").format(this.lastSaved + CommonConfig.getTimer());
|
||||
}
|
||||
|
||||
public void updateSaveTime(long time) {
|
||||
this.lastSaved = time;
|
||||
this.setDirty();
|
||||
|
|
|
@ -82,11 +82,11 @@ public class BackupThread extends Thread {
|
|||
public void run() {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
this.broadcast("extbackup.backup_started", Style.EMPTY.withColor(ChatFormatting.GOLD));
|
||||
this.broadcast("ExtBackup started...", Style.EMPTY.withColor(ChatFormatting.BLUE));
|
||||
this.makeWorldBackup();
|
||||
long end = System.currentTimeMillis();
|
||||
String time = Timer.getTimer(end - start);
|
||||
this.broadcast("extbackup.backup_finished", Style.EMPTY.withColor(ChatFormatting.GOLD), time);
|
||||
this.broadcast("ExtBackup completed in %s", Style.EMPTY.withColor(ChatFormatting.BLUE), time);
|
||||
} catch (Exception e) {
|
||||
ExtBackup.LOGGER.error("Error backing up", e);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class BackupThread extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Timer {
|
||||
private static class Timer {
|
||||
|
||||
private static final SimpleDateFormat SECONDS = new SimpleDateFormat("s.SSS");
|
||||
private static final SimpleDateFormat MINUTES = new SimpleDateFormat("mm:ss");
|
||||
|
|
|
@ -42,7 +42,12 @@ public class EventListener {
|
|||
if (!script.exists()) {
|
||||
try {
|
||||
script.getParentFile().mkdirs();
|
||||
Files.writeString(script.toPath(), "#!/bin/bash\n# Put your backup script here!\n\nexit 0");
|
||||
Files.writeString(script.toPath(), """
|
||||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
# Put your backup script here!
|
||||
exit 0""");
|
||||
script.setExecutable(true);
|
||||
ExtBackup.LOGGER.info("No backup script was found, a script has been created at {}, please modify it to your liking.", script.getAbsolutePath());
|
||||
} catch (IOException | SecurityException e) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.mojang.brigadier.context.CommandContext;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.sweevo.jinks.BackupData;
|
||||
|
@ -15,27 +16,22 @@ import net.sweevo.jinks.config.CommonConfig;
|
|||
|
||||
public class StatusCommand implements Command<CommandSourceStack> {
|
||||
|
||||
|
||||
private StatusCommand() {
|
||||
}
|
||||
|
||||
public static ArgumentBuilder<CommandSourceStack, ?> register() {
|
||||
return Commands.literal("backup")
|
||||
.then(Commands.literal("status")
|
||||
.executes(new StatusCommand()));
|
||||
return Commands.literal("status")
|
||||
.executes(new StatusCommand());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int run(CommandContext<CommandSourceStack> context) {
|
||||
BackupData data = BackupData.get(context.getSource().getServer());
|
||||
String paused = data.isPaused() ? "true" : "false";
|
||||
String nextUp = BackupThread.Timer.getTimer(data.getLastSaved() + CommonConfig.getTimer());
|
||||
String nextUp = data.getNextBackup();
|
||||
ServerPlayer player = context.getSource().getPlayer();
|
||||
MutableComponent message = BackupThread.component(player, "Backups paused: %s. - Next backup: %s", paused, nextUp);
|
||||
if (player != null) {
|
||||
player.sendSystemMessage(BackupThread.component(player, "extbackup.status_message", paused, nextUp).withStyle(Style.EMPTY.withColor(ChatFormatting.GOLD)));
|
||||
player.sendSystemMessage(message.withStyle(Style.EMPTY.withColor(ChatFormatting.BLUE)));
|
||||
} else {
|
||||
ExtBackup.LOGGER.info("Backups paused: {} - Next backup: {}", paused, nextUp);
|
||||
ExtBackup.LOGGER.info(String.valueOf(message));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue