├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ └── feature_request.yml └── workflows │ ├── check_pr_translations.yml │ └── stale.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── de │ └── melanx │ └── simplebackups │ ├── BackupData.java │ ├── BackupThread.java │ ├── EventListener.java │ ├── SimpleBackups.java │ ├── StorageSize.java │ ├── client │ ├── ClientEventHandler.java │ └── ClientInit.java │ ├── commands │ ├── BackupCommand.java │ ├── MergeCommand.java │ └── PauseCommand.java │ ├── compat │ └── Mc2DiscordCompat.java │ ├── config │ ├── BackupType.java │ ├── CommonConfig.java │ └── ServerConfig.java │ └── network │ └── Pause.java └── resources ├── META-INF ├── accesstransformer.cfg └── neoforge.mods.toml └── assets └── simplebackups └── lang ├── de_de.json ├── en_us.json ├── ja_jp.json ├── pt_br.json ├── ru_ru.json ├── tr_tr.json ├── zh_cn.json └── zh_tw.json /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Report an issue with supported versions of Simple Backups 3 | labels: [ bug ] 4 | body: 5 | - type: dropdown 6 | id: mc-version 7 | attributes: 8 | label: Minecraft version 9 | options: 10 | - 1.19.x 11 | - 1.20.x 12 | - 1.21.x 13 | validations: 14 | required: true 15 | - type: input 16 | id: mod-version 17 | attributes: 18 | label: Simple Backups version 19 | placeholder: eg. 1.19.4-2.2.0 20 | validations: 21 | required: true 22 | - type: input 23 | id: forge-version 24 | attributes: 25 | label: (Neo)Forge version 26 | placeholder: eg. 45.0.1 27 | validations: 28 | required: true 29 | - type: input 30 | id: log-file 31 | attributes: 32 | label: The latest.log file 33 | description: | 34 | Please use a paste site such as [gist](https://gist.github.com/) / [pastebin](https://pastebin.com/) / etc. 35 | For more information, see https://git.io/mclogs 36 | validations: 37 | required: true 38 | - type: textarea 39 | id: description 40 | attributes: 41 | label: Issue description 42 | placeholder: A description of the issue. 43 | validations: 44 | required: true 45 | - type: textarea 46 | id: steps-to-reproduce 47 | attributes: 48 | label: Steps to reproduce 49 | placeholder: | 50 | 1. First step 51 | 2. Second step 52 | 3. etc... 53 | - type: textarea 54 | id: additional-information 55 | attributes: 56 | label: Other information 57 | description: Any other relevant information that is related to this issue, such as modpacks, other mods and their versions. 58 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea, or enhancement 3 | labels: [ enhancement ] 4 | body: 5 | - type: textarea 6 | id: description 7 | attributes: 8 | label: Describe your idea 9 | placeholder: A clear and reasoned description of your idea. 10 | validations: 11 | required: true 12 | -------------------------------------------------------------------------------- /.github/workflows/check_pr_translations.yml: -------------------------------------------------------------------------------- 1 | # Do not edit this file directly 2 | # This file is synced by https://github.com/ChaoticTrials/ModMeta 3 | 4 | name: Check Localization Files 5 | on: 6 | pull_request_target: 7 | types: [ opened, synchronize, reopened ] 8 | paths: 9 | - 'src/main/resources/assets/**/lang/*.json' 10 | 11 | permissions: 12 | pull-requests: write 13 | contents: read 14 | 15 | jobs: 16 | check-localization: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Check out code 20 | uses: actions/checkout@v4 21 | with: 22 | ref: ${{ github.event.pull_request.head.ref }} 23 | repository: ${{ github.event.pull_request.head.repo.full_name }} 24 | fetch-depth: 0 25 | 26 | - name: Debug PR context 27 | run: | 28 | echo "Pull request number: ${{ github.event.pull_request.number }}" 29 | echo "Repository full name: ${{ github.repository }}" 30 | echo "Event path: $GITHUB_EVENT_PATH" 31 | 32 | - name: Check localization files 33 | run: | 34 | PR_NUMBER="${{ github.event.pull_request.number }}" 35 | REPO_FULL_NAME="${{ github.repository }}" 36 | # Ensure GitHub CLI is authenticated and correctly identifies the PR context 37 | echo "Processing PR #$PR_NUMBER for repository $REPO_FULL_NAME" 38 | 39 | # Get the list of added or modified localization files 40 | FILES=$(gh pr diff "$PR_NUMBER" --repo "$REPO_FULL_NAME" --name-only | grep -E 'src/main/resources/assets/.*/lang/.*\.json' || true) 41 | 42 | if [[ -z "$FILES" ]]; then 43 | echo "No localization files have been modified." 44 | exit 0 45 | fi 46 | 47 | # Initialize an array to store the missing keys 48 | MISSING_KEYS=() 49 | # Iterate over each file 50 | for FILE in $FILES; do 51 | # Check if the file is not the default English translation 52 | if [[ $FILE != *"en_us.json" ]]; then 53 | # Get the modid and language key from the file path 54 | MODID=$(echo $FILE | cut -d'/' -f5) 55 | LANGUAGE_KEY=$(echo $FILE | cut -d'/' -f7 | cut -d'.' -f1) 56 | # Check if all keys from the default English translation are included in this file 57 | KEYS=$(jq -n --slurpfile en src/main/resources/assets/$MODID/lang/en_us.json --slurpfile current $FILE '($en[0] | keys) - ($current[0] | keys)' ) 58 | if [[ $KEYS != "[]" ]]; then 59 | MISSING_KEYS+=("$LANGUAGE_KEY: $KEYS") 60 | fi 61 | fi 62 | done 63 | 64 | # Post a comment on the pull request with the missing keys or a success message 65 | if [[ ${#MISSING_KEYS[@]} -gt 0 ]]; then 66 | echo "# 🚨 Missing translation keys 🚨" > review.md 67 | for MISSING_KEY in "${MISSING_KEYS[@]}"; do 68 | LANGUAGE=$(echo $MISSING_KEY | cut -d':' -f1) 69 | KEYS=$(echo $MISSING_KEY | cut -d':' -f2 | jq -r '.[]') 70 | echo "## **$LANGUAGE**" >> review.md 71 | for KEY in $KEYS; do 72 | echo "- $KEY" >> review.md 73 | done 74 | echo "" >> review.md 75 | done 76 | 77 | # Request changes on the pull request 78 | gh pr review "$PR_NUMBER" --repo "$REPO_FULL_NAME" --request-changes --body-file review.md 79 | else 80 | echo "## ✅ All localization files have been checked and are complete! ✅" > review.md 81 | echo "Waiting for approval by @MelanX" >> review.md 82 | 83 | # Approve the pull request 84 | gh pr review "$PR_NUMBER" --repo "$REPO_FULL_NAME" --comment --body-file review.md 85 | fi 86 | env: 87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 88 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # Do not edit this file directly 2 | # This file is synced by https://github.com/ChaoticTrials/ModMeta 3 | 4 | name: Close stale issues and PRs 5 | 6 | on: 7 | schedule: 8 | - cron: '0 */6 * * *' 9 | 10 | jobs: 11 | stale: 12 | runs-on: ubuntu-latest 13 | permissions: 14 | issues: write 15 | steps: 16 | - uses: actions/stale@v9 17 | with: 18 | stale-issue-message: The required information were not provided yet. Thus, this was marked as stale. 19 | 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. 20 | only-labels: needs more info 21 | days-before-stale: 7 22 | days-before-close: 3 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | /run* 23 | /logs 24 | 25 | # Files from Forge MDK 26 | forge*changelog.txt 27 | /src/generated/resources/.cache 28 | 29 | # CoreMods 30 | *.d.ts 31 | **/tsconfig.json 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Backups 2 | A simple mod to create scheduled backups. 3 | 4 | [![Modrinth](https://badges.moddingx.org/modrinth/versions/fzSKSXVK)](https://modrinth.com/mod/simple-backups) 5 | [![Modrinth](https://badges.moddingx.org/modrinth/downloads/fzSKSXVK)](https://modrinth.com/mod/simple-backups) 6 | 7 | [![CurseForge](https://badges.moddingx.org/curseforge/versions/583228)](https://www.curseforge.com/minecraft/mc-mods/simple-backups) 8 | [![CurseForge](https://badges.moddingx.org/curseforge/downloads/583228)](https://www.curseforge.com/minecraft/mc-mods/simple-backups) 9 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.moddingx.modgradle.meta' version '5.0.3' 3 | } 4 | 5 | var dev = System.getenv('IS_DEV')?.toBoolean() ?: false 6 | var releaseType = 'release' 7 | var baseVersion = '21.5' 8 | mod.configure { 9 | modid 'simplebackups' 10 | group 'de.melanx' 11 | versioning { 12 | if (dev) { 13 | def gitCommitHash = ['git', 'rev-parse', 'HEAD'].execute().text.trim() 14 | constant baseVersion + (gitCommitHash ? "-${gitCommitHash}" : '') 15 | } else { 16 | base baseVersion 17 | maven 'https://maven.melanx.de/release' 18 | } 19 | } 20 | 21 | neoforge "${baseVersion}.0-beta" 22 | 23 | license 'The Apache License, Version 2.0' 24 | github 'ChaoticTrials/SimpleBackups' 25 | 26 | artifacts { 27 | sources { 28 | publishToRepositories() 29 | } 30 | } 31 | 32 | changelog { 33 | def lines = defaultChangelog.toString().split('\n') 34 | def filteredChangelog = lines.findAll { !it.startsWith('- [[meta]') }.join('\n') 35 | 36 | return filteredChangelog 37 | } 38 | 39 | 40 | publishing { 41 | maven { 42 | name 'melanx' 43 | url 'https://maven.melanx.de/release' 44 | credentials(PasswordCredentials) 45 | } 46 | } 47 | 48 | upload { 49 | all { 50 | type releaseType 51 | version '1.21.5' 52 | } 53 | curseforge { 54 | projectId 583228 55 | } 56 | modrinth { 57 | projectId 'fzSKSXVK' 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx6G 2 | org.gradle.daemon=false 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChaoticTrials/SimpleBackups/67c8ce56638805a29e6251032aaf6cb673f12c87/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven { url = 'https://maven.neoforged.net/releases' } 5 | maven { url = 'https://maven.moddingx.org/release' } 6 | } 7 | } 8 | 9 | rootProject.name = 'SimpleBackups' 10 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/BackupData.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups; 2 | 3 | import com.mojang.serialization.Codec; 4 | import com.mojang.serialization.codecs.RecordCodecBuilder; 5 | import de.melanx.simplebackups.config.CommonConfig; 6 | import net.minecraft.server.MinecraftServer; 7 | import net.minecraft.server.level.ServerLevel; 8 | import net.minecraft.world.level.saveddata.SavedData; 9 | import net.minecraft.world.level.saveddata.SavedDataType; 10 | 11 | public class BackupData extends SavedData { 12 | 13 | private long lastSaved; 14 | private long lastFullBackup; 15 | private boolean paused; 16 | private boolean merging; 17 | private boolean usesTickCounter; 18 | 19 | public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( 20 | Codec.LONG.fieldOf("lastSaved").forGetter(BackupData::getLastSaved), 21 | Codec.LONG.fieldOf("lastFullBackup").forGetter(BackupData::getLastFullBackup), 22 | Codec.BOOL.fieldOf("paused").forGetter(BackupData::isPaused), 23 | Codec.BOOL.fieldOf("merging").forGetter(BackupData::isMerging), 24 | Codec.BOOL.fieldOf("usesTickCounter").forGetter(BackupData::usesTickCounter) 25 | ) 26 | .apply(instance, BackupData::new)); 27 | 28 | public static SavedDataType type() { 29 | return new SavedDataType<>("simplebackups", context -> new BackupData(0, 0, false, false, CommonConfig.useTickCounter()), context -> CODEC); 30 | } 31 | 32 | private BackupData(long lastSaved, long lastFullBackup, boolean paused, boolean merging, boolean usesTickCounter) { 33 | this.lastSaved = lastSaved; 34 | this.lastFullBackup = lastFullBackup; 35 | this.paused = paused; 36 | this.merging = merging; 37 | this.usesTickCounter = usesTickCounter; 38 | } 39 | 40 | public static BackupData get(ServerLevel level) { 41 | return BackupData.get(level.getServer()); 42 | } 43 | 44 | public static BackupData get(MinecraftServer server) { 45 | return server.overworld().getDataStorage().computeIfAbsent(BackupData.type()); 46 | } 47 | 48 | public void setPaused(boolean paused) { 49 | this.paused = paused; 50 | this.setDirty(); 51 | } 52 | 53 | public boolean isPaused() { 54 | return this.paused; 55 | } 56 | 57 | public long getLastSaved() { 58 | return this.lastSaved; 59 | } 60 | 61 | public void updateSaveTime(long time) { 62 | this.lastSaved = time; 63 | this.setDirty(); 64 | } 65 | 66 | public long getLastFullBackup() { 67 | return this.lastFullBackup; 68 | } 69 | 70 | public void updateFullBackupTime(long time) { 71 | this.lastFullBackup = time; 72 | this.setDirty(); 73 | } 74 | 75 | public boolean isMerging() { 76 | return this.merging; 77 | } 78 | 79 | public void startMerging() { 80 | this.merging = true; 81 | } 82 | 83 | public void stopMerging() { 84 | this.merging = false; 85 | } 86 | 87 | public boolean usesTickCounter() { 88 | return this.usesTickCounter; 89 | } 90 | 91 | public void setUsesTickCounter(boolean usesTickCounter) { 92 | this.usesTickCounter = usesTickCounter; 93 | this.setDirty(); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/BackupThread.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups; 2 | 3 | import de.melanx.simplebackups.compat.Mc2DiscordCompat; 4 | import de.melanx.simplebackups.config.BackupType; 5 | import de.melanx.simplebackups.config.CommonConfig; 6 | import de.melanx.simplebackups.config.ServerConfig; 7 | import de.melanx.simplebackups.network.Pause; 8 | import net.minecraft.ChatFormatting; 9 | import net.minecraft.DefaultUncaughtExceptionHandler; 10 | import net.minecraft.FileUtil; 11 | import net.minecraft.network.chat.Component; 12 | import net.minecraft.network.chat.MutableComponent; 13 | import net.minecraft.network.chat.Style; 14 | import net.minecraft.server.MinecraftServer; 15 | import net.minecraft.server.level.ServerPlayer; 16 | import net.minecraft.world.level.storage.LevelStorageSource; 17 | import net.neoforged.fml.i18n.FMLTranslations; 18 | import net.neoforged.neoforge.network.registration.NetworkRegistry; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | import javax.annotation.Nonnull; 23 | import javax.annotation.Nullable; 24 | import java.io.BufferedOutputStream; 25 | import java.io.File; 26 | import java.io.IOException; 27 | import java.nio.file.*; 28 | import java.nio.file.attribute.BasicFileAttributes; 29 | import java.text.SimpleDateFormat; 30 | import java.time.LocalDateTime; 31 | import java.time.format.DateTimeFormatter; 32 | import java.time.format.DateTimeFormatterBuilder; 33 | import java.time.format.SignStyle; 34 | import java.time.temporal.ChronoField; 35 | import java.util.*; 36 | import java.util.zip.ZipEntry; 37 | import java.util.zip.ZipOutputStream; 38 | 39 | public class BackupThread extends Thread { 40 | 41 | private static final DateTimeFormatter FORMATTER = new DateTimeFormatterBuilder() 42 | .appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD).appendLiteral('-') 43 | .appendValue(ChronoField.MONTH_OF_YEAR, 2).appendLiteral('-') 44 | .appendValue(ChronoField.DAY_OF_MONTH, 2).appendLiteral('_') 45 | .appendValue(ChronoField.HOUR_OF_DAY, 2).appendLiteral('-') 46 | .appendValue(ChronoField.MINUTE_OF_HOUR, 2).appendLiteral('-') 47 | .appendValue(ChronoField.SECOND_OF_MINUTE, 2) 48 | .toFormatter(); 49 | public static final Logger LOGGER = LoggerFactory.getLogger(BackupThread.class); 50 | private final MinecraftServer server; 51 | private final boolean quiet; 52 | private final long lastSaved; 53 | private final boolean fullBackup; 54 | private final LevelStorageSource.LevelStorageAccess storageSource; 55 | private final Path backupPath; 56 | 57 | private BackupThread(@Nonnull MinecraftServer server, boolean quiet, BackupData backupData) { 58 | this.server = server; 59 | this.storageSource = server.storageSource; 60 | this.quiet = quiet; 61 | if (backupData == null) { 62 | this.lastSaved = 0; 63 | this.fullBackup = true; 64 | } else { 65 | this.lastSaved = CommonConfig.backupType() == BackupType.MODIFIED_SINCE_LAST ? backupData.getLastSaved() : backupData.getLastFullBackup(); 66 | this.fullBackup = CommonConfig.backupType() == BackupType.FULL_BACKUPS || (CommonConfig.useTickCounter() ? server.overworld().getGameTime() : System.currentTimeMillis()) - CommonConfig.getFullBackupTimer() > backupData.getLastFullBackup(); 67 | } 68 | this.setName("SimpleBackups"); 69 | this.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)); 70 | this.backupPath = CommonConfig.getOutputPath(this.storageSource.getLevelId()); 71 | } 72 | 73 | public static boolean tryCreateBackup(MinecraftServer server) { 74 | BackupData backupData = BackupData.get(server); 75 | if (BackupThread.shouldRunBackup(server)) { 76 | BackupThread thread = new BackupThread(server, false, backupData); 77 | thread.start(); 78 | long currentTime = CommonConfig.useTickCounter() ? server.overworld().getGameTime() : System.currentTimeMillis(); 79 | backupData.updateSaveTime(currentTime); 80 | if (thread.fullBackup) { 81 | backupData.updateFullBackupTime(currentTime); 82 | } 83 | 84 | return true; 85 | } 86 | 87 | return false; 88 | } 89 | 90 | public static boolean shouldRunBackup(MinecraftServer server) { 91 | BackupData backupData = BackupData.get(server); 92 | if (!CommonConfig.isEnabled() || backupData.isPaused()) { 93 | return false; 94 | } 95 | 96 | if (CommonConfig.useTickCounter()) { 97 | long gameTime = server.overworld().getGameTime(); 98 | long lastSaved = backupData.getLastSaved(); 99 | // convert timer from minutes into ticks 100 | int timer = CommonConfig.getTimer() * 20 * 60; 101 | return gameTime - lastSaved >= timer; 102 | } 103 | 104 | return System.currentTimeMillis() - CommonConfig.getTimer() > backupData.getLastSaved(); 105 | } 106 | 107 | public static void createBackup(MinecraftServer server, boolean quiet) { 108 | BackupThread thread = new BackupThread(server, quiet, null); 109 | thread.start(); 110 | } 111 | 112 | public void deleteFiles() { 113 | File backups = this.backupPath.toFile(); 114 | if (backups.isDirectory()) { 115 | List files = new ArrayList<>(Arrays.stream(Objects.requireNonNull(backups.listFiles())).filter(File::isFile).toList()); 116 | if (files.size() >= CommonConfig.getBackupsToKeep()) { 117 | files.sort(Comparator.comparingLong(File::lastModified)); 118 | while (files.size() >= CommonConfig.getBackupsToKeep()) { 119 | boolean deleted = files.getFirst().delete(); 120 | String name = files.getFirst().getName(); 121 | if (deleted) { 122 | files.removeFirst(); 123 | LOGGER.info("Successfully deleted \"{}\"", name); 124 | } 125 | } 126 | } 127 | } 128 | } 129 | 130 | public void saveStorageSize() { 131 | try { 132 | while (this.getOutputFolderSize() > CommonConfig.getMaxDiskSize()) { 133 | File[] files = this.backupPath.toFile().listFiles(); 134 | if (Objects.requireNonNull(files).length == 1) { 135 | LOGGER.error("Cannot delete old files to save disk space. Only one backup file left!"); 136 | return; 137 | } 138 | 139 | Arrays.sort(Objects.requireNonNull(files), Comparator.comparingLong(File::lastModified)); 140 | File file = files[0]; 141 | String name = file.getName(); 142 | if (file.delete()) { 143 | LOGGER.info("Successfully deleted \"{}\"", name); 144 | } 145 | } 146 | } catch (NullPointerException | IOException e) { 147 | LOGGER.error("Cannot delete old files to save disk space", e); 148 | } 149 | } 150 | 151 | @Override 152 | public void run() { 153 | try { 154 | this.deleteFiles(); 155 | 156 | Files.createDirectories(this.backupPath); 157 | long start = System.currentTimeMillis(); 158 | this.broadcast("simplebackups.backup_started", Style.EMPTY.withColor(ChatFormatting.GOLD)); 159 | long size = this.makeWorldBackup(); 160 | long end = System.currentTimeMillis(); 161 | String time = Timer.getTimer(end - start); 162 | this.saveStorageSize(); 163 | this.broadcast("simplebackups.backup_finished", Style.EMPTY.withColor(ChatFormatting.GOLD), time, StorageSize.getFormattedSize(size), StorageSize.getFormattedSize(this.getOutputFolderSize())); 164 | } catch (IOException e) { 165 | SimpleBackups.LOGGER.error("Error backing up", e); 166 | } 167 | } 168 | 169 | private long getOutputFolderSize() throws IOException { 170 | File[] files = this.backupPath.toFile().listFiles(); 171 | long size = 0; 172 | try { 173 | for (File file : Objects.requireNonNull(files)) { 174 | size += Files.size(file.toPath()); 175 | } 176 | } catch (NullPointerException e) { 177 | return 0; 178 | } 179 | 180 | return size; 181 | } 182 | 183 | private void broadcast(String message, Style style, Object... parameters) { 184 | if (CommonConfig.sendMessages() && !this.quiet) { 185 | this.server.execute(() -> { 186 | this.server.getPlayerList().getPlayers().forEach(player -> { 187 | if (ServerConfig.messagesForEveryone() || player.hasPermissions(2)) { 188 | player.sendSystemMessage(BackupThread.component(player, message, parameters).withStyle(style)); 189 | } 190 | }); 191 | }); 192 | 193 | if (Mc2DiscordCompat.isLoaded() && CommonConfig.mc2discord()) { 194 | Mc2DiscordCompat.announce(BackupThread.component(null, message, parameters)); 195 | } 196 | } 197 | } 198 | 199 | public static MutableComponent component(@Nullable ServerPlayer player, String key, Object... parameters) { 200 | if (player != null) { 201 | //noinspection UnstableApiUsage 202 | if (NetworkRegistry.hasChannel(player.connection.connection, null, Pause.ID)) { 203 | return Component.translatable(key, parameters); 204 | } 205 | } 206 | 207 | //noinspection UnstableApiUsage 208 | return Component.literal(String.format(FMLTranslations.getPattern(key, () -> key), parameters)); 209 | } 210 | 211 | // vanilla copy with modifications 212 | private long makeWorldBackup() throws IOException { 213 | this.storageSource.checkLock(); 214 | if (CommonConfig.saveAll()) { 215 | this.server.executeBlocking(() -> { 216 | this.server.saveEverything(true, false, true); 217 | }); 218 | } 219 | 220 | String fileName = this.storageSource.getLevelId() + "_" + LocalDateTime.now().format(FORMATTER); 221 | Path path = CommonConfig.getOutputPath(this.storageSource.getLevelId()); 222 | 223 | try { 224 | Files.createDirectories(Files.exists(path) ? path.toRealPath() : path); 225 | } catch (IOException ioexception) { 226 | throw new RuntimeException(ioexception); 227 | } 228 | 229 | Path outputFile = path.resolve(FileUtil.findAvailableName(path, fileName, ".zip")); 230 | 231 | try (ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(outputFile)))) { 232 | zipStream.setLevel(CommonConfig.getCompressionLevel()); 233 | Path levelName = Paths.get(this.storageSource.getLevelId()); 234 | Path levelPath = this.storageSource.getWorldDir().resolve(this.storageSource.getLevelId()).toRealPath(); 235 | 236 | List ignoredPaths = CommonConfig.getIgnoredPaths(); 237 | List ignoredFiles = CommonConfig.getIgnoredFiles(); 238 | String ignoredFilesRegex = CommonConfig.getIgnoredFilesRegex(); 239 | boolean ignoreSomething = !ignoredPaths.isEmpty() || !ignoredFiles.isEmpty() || !ignoredFilesRegex.isEmpty(); 240 | 241 | Files.walkFileTree(levelPath, new SimpleFileVisitor<>() { 242 | @Nonnull 243 | public FileVisitResult visitFile(@Nonnull Path file, @Nonnull BasicFileAttributes attrs) throws IOException { 244 | if (file.endsWith("session.lock")) { 245 | return FileVisitResult.CONTINUE; 246 | } 247 | 248 | if (ignoreSomething && this.shouldSkipFile(levelPath.relativize(file))) { 249 | SimpleBackups.LOGGER.debug("Skipping file: {}", file); 250 | return FileVisitResult.CONTINUE; 251 | } 252 | 253 | long lastModified = file.toFile().lastModified(); 254 | if (BackupThread.this.fullBackup || lastModified - BackupThread.this.lastSaved > 0) { 255 | String completePath = levelName.resolve(levelPath.relativize(file)).toString().replace('\\', '/'); 256 | ZipEntry zipentry = new ZipEntry(completePath); 257 | zipStream.putNextEntry(zipentry); 258 | com.google.common.io.Files.asByteSource(file.toFile()).copyTo(zipStream); 259 | zipStream.closeEntry(); 260 | } 261 | 262 | return FileVisitResult.CONTINUE; 263 | } 264 | 265 | private boolean shouldSkipFile(Path relativePath) { 266 | return ignoredPaths.contains(relativePath.getParent()) 267 | || ignoredFiles.contains(relativePath) 268 | || (!ignoredFilesRegex.isEmpty() && this.getNormalizedPath(relativePath).matches(ignoredFilesRegex)); 269 | } 270 | 271 | private String getNormalizedPath(Path path) { 272 | return path.toString().replace('\\', '/'); 273 | } 274 | }); 275 | } 276 | 277 | return Files.size(outputFile); 278 | } 279 | 280 | private static class Timer { 281 | 282 | private static final SimpleDateFormat SECONDS = new SimpleDateFormat("s.SSS"); 283 | private static final SimpleDateFormat MINUTES = new SimpleDateFormat("mm:ss"); 284 | private static final SimpleDateFormat HOURS = new SimpleDateFormat("HH:mm"); 285 | 286 | public static String getTimer(long milliseconds) { 287 | Date date = new Date(milliseconds); 288 | double seconds = milliseconds / 1000d; 289 | if (seconds < 60) { 290 | return SECONDS.format(date) + "s"; 291 | } else if (seconds < 3600) { 292 | return MINUTES.format(date) + "min"; 293 | } else { 294 | return HOURS.format(date) + "h"; 295 | } 296 | } 297 | } 298 | } 299 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/EventListener.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups; 2 | 3 | import de.melanx.simplebackups.commands.BackupCommand; 4 | import de.melanx.simplebackups.commands.MergeCommand; 5 | import de.melanx.simplebackups.commands.PauseCommand; 6 | import de.melanx.simplebackups.config.CommonConfig; 7 | import de.melanx.simplebackups.config.ServerConfig; 8 | import de.melanx.simplebackups.network.Pause; 9 | import net.minecraft.commands.Commands; 10 | import net.minecraft.server.MinecraftServer; 11 | import net.minecraft.server.level.ServerLevel; 12 | import net.minecraft.server.level.ServerPlayer; 13 | import net.neoforged.bus.api.SubscribeEvent; 14 | import net.neoforged.neoforge.event.RegisterCommandsEvent; 15 | import net.neoforged.neoforge.event.entity.player.PlayerEvent; 16 | import net.neoforged.neoforge.event.tick.LevelTickEvent; 17 | import net.neoforged.neoforge.network.PacketDistributor; 18 | import net.neoforged.neoforge.network.registration.NetworkRegistry; 19 | 20 | public class EventListener { 21 | 22 | private boolean doBackup; 23 | 24 | @SubscribeEvent 25 | public void registerCommands(RegisterCommandsEvent event) { 26 | event.getDispatcher().register(Commands.literal(SimpleBackups.MODID) 27 | .requires(stack -> ServerConfig.commandsCheatsDisabled() || stack.hasPermission(2)) 28 | .then(BackupCommand.register()) 29 | .then(PauseCommand.register()) 30 | .then(MergeCommand.register())); 31 | } 32 | 33 | @SubscribeEvent 34 | public void onServerTick(LevelTickEvent.Post event) { 35 | if (event.getLevel() instanceof ServerLevel level && !level.isClientSide 36 | && level.getGameTime() % 20 == 0 && level == level.getServer().overworld()) { 37 | EventListener.checkForTickCounterConfigUpdate(event.getLevel().getServer()); 38 | 39 | if (!level.getServer().getPlayerList().getPlayers().isEmpty() || this.doBackup || CommonConfig.doNoPlayerBackups()) { 40 | this.doBackup = false; 41 | 42 | boolean done = BackupThread.tryCreateBackup(level.getServer()); 43 | if (done) { 44 | SimpleBackups.LOGGER.info("Backup done."); 45 | } 46 | } 47 | } 48 | } 49 | 50 | @SubscribeEvent 51 | public void onPlayerConnect(PlayerEvent.PlayerLoggedInEvent event) { 52 | ServerPlayer player = (ServerPlayer) event.getEntity(); 53 | //noinspection UnstableApiUsage 54 | if (CommonConfig.isEnabled() && event.getEntity().getServer() != null && NetworkRegistry.hasChannel(player.connection.connection, null, Pause.ID)) { 55 | PacketDistributor.sendToPlayer(player, new Pause(BackupData.get(event.getEntity().getServer()).isPaused())); 56 | } 57 | } 58 | 59 | @SubscribeEvent 60 | public void onPlayerDisconnect(PlayerEvent.PlayerLoggedOutEvent event) { 61 | if (event.getEntity() instanceof ServerPlayer player) { 62 | //noinspection ConstantConditions 63 | if (player.getServer().getPlayerList().getPlayers().isEmpty()) { 64 | this.doBackup = true; 65 | } 66 | } 67 | } 68 | 69 | private static void checkForTickCounterConfigUpdate(MinecraftServer server) { 70 | BackupData backupData = BackupData.get(server); 71 | boolean usesTickCounter = CommonConfig.useTickCounter(); 72 | 73 | if (usesTickCounter != backupData.usesTickCounter()) { 74 | SimpleBackups.LOGGER.info("Tick counter config updated, usesTickCounter: {}", usesTickCounter); 75 | backupData.setUsesTickCounter(usesTickCounter); 76 | 77 | long lastTimeSaved = backupData.getLastSaved(); 78 | int commonConfigTimer = CommonConfig.getTimer(); 79 | 80 | SimpleBackups.LOGGER.info("Initial lastTimeSaved: {}", lastTimeSaved); 81 | SimpleBackups.LOGGER.info("Config timer in minutes: {}", commonConfigTimer); 82 | 83 | if (usesTickCounter) { 84 | long millisecondsTimeDifference = System.currentTimeMillis() - lastTimeSaved; 85 | long tickTimeDifference = millisecondsTimeDifference / 50L; 86 | lastTimeSaved = server.overworld().getGameTime() - tickTimeDifference; 87 | long timerInTicks = commonConfigTimer * 60L * 20L; 88 | 89 | SimpleBackups.LOGGER.info("Milliseconds difference: {}, Tick difference: {}", millisecondsTimeDifference, tickTimeDifference); 90 | SimpleBackups.LOGGER.info("Updated lastTimeSaved in ticks: {}", lastTimeSaved); 91 | SimpleBackups.LOGGER.info("Timer value in ticks: {}", timerInTicks); 92 | 93 | lastTimeSaved = Math.max(lastTimeSaved, timerInTicks); 94 | SimpleBackups.LOGGER.info("Final lastTimeSaved after max comparison (ticks): {}", lastTimeSaved); 95 | } else { 96 | long tickTimeDifference = server.overworld().getGameTime() - lastTimeSaved; 97 | long millisecondsTimeDifference = tickTimeDifference * 50L; 98 | lastTimeSaved = System.currentTimeMillis() - millisecondsTimeDifference; 99 | long timerInMilliseconds = commonConfigTimer * 60L * 1000L; 100 | 101 | SimpleBackups.LOGGER.info("Tick difference: {}, Milliseconds difference: {}", tickTimeDifference, millisecondsTimeDifference); 102 | SimpleBackups.LOGGER.info("Updated lastTimeSaved in milliseconds: {}", lastTimeSaved); 103 | SimpleBackups.LOGGER.info("Timer value in milliseconds: {}", timerInMilliseconds); 104 | 105 | lastTimeSaved = Math.max(lastTimeSaved, timerInMilliseconds); 106 | SimpleBackups.LOGGER.info("Final lastTimeSaved after max comparison (milliseconds): {}", lastTimeSaved); 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/SimpleBackups.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups; 2 | 3 | import de.melanx.simplebackups.client.ClientInit; 4 | import de.melanx.simplebackups.config.CommonConfig; 5 | import de.melanx.simplebackups.config.ServerConfig; 6 | import de.melanx.simplebackups.network.Pause; 7 | import net.neoforged.api.distmarker.Dist; 8 | import net.neoforged.bus.api.IEventBus; 9 | import net.neoforged.fml.ModContainer; 10 | import net.neoforged.fml.common.Mod; 11 | import net.neoforged.fml.config.ModConfig; 12 | import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; 13 | import net.neoforged.neoforge.common.NeoForge; 14 | import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; 15 | import net.neoforged.neoforge.network.registration.PayloadRegistrar; 16 | import org.slf4j.Logger; 17 | import org.slf4j.LoggerFactory; 18 | 19 | @Mod(SimpleBackups.MODID) 20 | public class SimpleBackups { 21 | 22 | public static final Logger LOGGER = LoggerFactory.getLogger(SimpleBackups.class); 23 | public static final String MODID = "simplebackups"; 24 | 25 | public SimpleBackups(IEventBus modEventBus, ModContainer modContainer, Dist dist) { 26 | modContainer.registerConfig(ModConfig.Type.COMMON, CommonConfig.CONFIG); 27 | modContainer.registerConfig(ModConfig.Type.SERVER, ServerConfig.CONFIG); 28 | NeoForge.EVENT_BUS.register(new EventListener()); 29 | modEventBus.addListener(this::setup); 30 | modEventBus.addListener(this::onRegisterPayloadHandler); 31 | 32 | if (dist.isClient()) { 33 | ClientInit.init(modEventBus, modContainer); 34 | } 35 | } 36 | 37 | private void onRegisterPayloadHandler(RegisterPayloadHandlersEvent event) { 38 | PayloadRegistrar registrar = event.registrar(SimpleBackups.MODID) 39 | .versioned("1.0") 40 | .optional(); 41 | 42 | registrar.playToClient(Pause.TYPE, Pause.CODEC, Pause::handle); 43 | } 44 | 45 | private void setup(FMLCommonSetupEvent event) { 46 | // NO-OP 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/StorageSize.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups; 2 | 3 | import java.util.Locale; 4 | 5 | public enum StorageSize { 6 | B(0), 7 | KB(1), 8 | MB(2), 9 | GB(3), 10 | TB(4); 11 | 12 | private final long sizeInBytes; 13 | private final String postfix; 14 | 15 | StorageSize(int factor) { 16 | this.sizeInBytes = (long) Math.pow(1024, factor); 17 | this.postfix = this.name().toUpperCase(Locale.ROOT); 18 | } 19 | 20 | public static StorageSize getSizeFor(double bytes) { 21 | for (StorageSize value : StorageSize.values()) { 22 | if (bytes < value.sizeInBytes) { 23 | return value.getLower(); 24 | } else if (value == TB) { 25 | return value; 26 | } 27 | } 28 | 29 | return B; 30 | } 31 | 32 | public static long getBytes(String s) { 33 | String[] splits = s.split(" "); 34 | int amount = Integer.parseInt(splits[0]); 35 | StorageSize size = StorageSize.valueOf(splits[1].toUpperCase(Locale.ROOT)); 36 | return amount * size.sizeInBytes; 37 | } 38 | 39 | public static String getFormattedSize(double bytes) { 40 | StorageSize size = StorageSize.getSizeFor(bytes); 41 | double small = bytes / size.sizeInBytes; 42 | return String.format("%.1f %s", small, size.postfix); 43 | } 44 | 45 | public StorageSize getLower() { 46 | return this.ordinal() == 0 ? this : StorageSize.values()[this.ordinal() - 1]; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/client/ClientEventHandler.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.client; 2 | 3 | import net.minecraft.ChatFormatting; 4 | import net.minecraft.client.DeltaTracker; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.GuiGraphics; 7 | import net.minecraft.network.chat.Component; 8 | import net.minecraft.network.chat.MutableComponent; 9 | import net.minecraft.resources.ResourceLocation; 10 | import net.neoforged.bus.api.SubscribeEvent; 11 | import net.neoforged.neoforge.client.event.RegisterGuiLayersEvent; 12 | import net.neoforged.neoforge.client.gui.VanillaGuiLayers; 13 | 14 | public class ClientEventHandler { 15 | 16 | private static final MutableComponent COMPONENT = Component.translatable("simplebackups.backups_paused").withStyle(ChatFormatting.RED); 17 | private static boolean isPaused = false; 18 | 19 | public static void setPaused(boolean paused) { 20 | isPaused = paused; 21 | } 22 | 23 | public static boolean isPaused() { 24 | return isPaused; 25 | } 26 | 27 | @SubscribeEvent 28 | public void onRenderText(RegisterGuiLayersEvent event) { 29 | event.registerBelow(VanillaGuiLayers.HOTBAR, ResourceLocation.fromNamespaceAndPath("simplebackups", "pause"), this::renderText); 30 | } 31 | 32 | private void renderText(GuiGraphics guiGraphics, DeltaTracker deltaTracker) { 33 | if (!isPaused) { 34 | return; 35 | } 36 | 37 | guiGraphics.fill(3, 3, 20, 20, 0); 38 | guiGraphics.drawString(Minecraft.getInstance().font, COMPONENT, 3, 3, 0); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/client/ClientInit.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.client; 2 | 3 | import net.neoforged.bus.api.IEventBus; 4 | import net.neoforged.fml.ModContainer; 5 | import net.neoforged.neoforge.client.gui.ConfigurationScreen; 6 | import net.neoforged.neoforge.client.gui.IConfigScreenFactory; 7 | 8 | public class ClientInit { 9 | 10 | public static void init(IEventBus modEventBus, ModContainer modContainer) { 11 | modEventBus.register(new ClientEventHandler()); 12 | modContainer.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/commands/BackupCommand.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.commands; 2 | 3 | import com.mojang.brigadier.Command; 4 | import com.mojang.brigadier.arguments.BoolArgumentType; 5 | import com.mojang.brigadier.builder.ArgumentBuilder; 6 | import com.mojang.brigadier.context.CommandContext; 7 | import de.melanx.simplebackups.BackupThread; 8 | import net.minecraft.commands.CommandSourceStack; 9 | import net.minecraft.commands.Commands; 10 | import net.minecraft.server.MinecraftServer; 11 | 12 | public class BackupCommand implements Command { 13 | 14 | public static ArgumentBuilder register() { 15 | return Commands.literal("backup") 16 | .then(Commands.literal("start") 17 | .executes(new BackupCommand()) 18 | .then(Commands.argument("quiet", BoolArgumentType.bool()) 19 | .executes(new BackupCommand()) 20 | ) 21 | ); 22 | } 23 | 24 | @Override 25 | public int run(CommandContext context) { 26 | boolean quiet = false; 27 | try { 28 | quiet = BoolArgumentType.getBool(context, "quiet"); 29 | } catch (IllegalArgumentException e) { 30 | // do nothing 31 | } 32 | 33 | MinecraftServer server = context.getSource().getServer(); 34 | BackupThread.createBackup(server, quiet); 35 | return 1; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/commands/MergeCommand.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.commands; 2 | 3 | import com.mojang.brigadier.Command; 4 | import com.mojang.brigadier.builder.ArgumentBuilder; 5 | import com.mojang.brigadier.context.CommandContext; 6 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 7 | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; 8 | import de.melanx.simplebackups.BackupData; 9 | import de.melanx.simplebackups.config.BackupType; 10 | import de.melanx.simplebackups.config.CommonConfig; 11 | import net.minecraft.commands.CommandSourceStack; 12 | import net.minecraft.commands.Commands; 13 | import net.minecraft.network.chat.Component; 14 | 15 | import javax.annotation.Nonnull; 16 | import java.io.FileOutputStream; 17 | import java.io.IOException; 18 | import java.io.InputStream; 19 | import java.io.UncheckedIOException; 20 | import java.nio.file.FileVisitResult; 21 | import java.nio.file.Files; 22 | import java.nio.file.Path; 23 | import java.nio.file.SimpleFileVisitor; 24 | import java.nio.file.attribute.BasicFileAttributes; 25 | import java.nio.file.attribute.FileTime; 26 | import java.util.Enumeration; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | import java.util.UUID; 30 | import java.util.zip.ZipEntry; 31 | import java.util.zip.ZipFile; 32 | import java.util.zip.ZipOutputStream; 33 | 34 | public class MergeCommand implements Command { 35 | 36 | 37 | public static ArgumentBuilder register() { 38 | return Commands.literal("mergeBackups") 39 | .executes(new MergeCommand()); 40 | } 41 | 42 | @Override 43 | public int run(CommandContext commandContext) throws CommandSyntaxException { 44 | // Check if only modified files should be backed up 45 | if (CommonConfig.backupType() == BackupType.FULL_BACKUPS) { 46 | throw new SimpleCommandExceptionType(Component.translatable("simplebackups.commands.only_modified")).create(); 47 | } 48 | 49 | BackupData data = BackupData.get(commandContext.getSource().getServer()); 50 | 51 | // Check if a merge operation is already in progress 52 | if (data.isMerging()) { 53 | throw new SimpleCommandExceptionType(Component.translatable("simplebackups.commands.is_merging")).create(); 54 | } 55 | 56 | MergingThread mergingThread = new MergingThread(commandContext); 57 | try { 58 | data.startMerging(); 59 | mergingThread.start(); 60 | } catch (Exception e) { 61 | e.printStackTrace(); 62 | data.stopMerging(); 63 | return 0; 64 | } 65 | 66 | data.stopMerging(); 67 | return 1; 68 | } 69 | 70 | private static class MergingThread extends Thread { 71 | 72 | private final CommandContext commandContext; 73 | 74 | public MergingThread(CommandContext commandContext) { 75 | this.commandContext = commandContext; 76 | } 77 | 78 | @Override 79 | public void run() { 80 | try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("merged_backup-" + UUID.randomUUID() + ".zip"))) { 81 | Map zipFiles = new HashMap<>(); 82 | 83 | // Walk the file tree of the output path 84 | Files.walkFileTree(CommonConfig.getOutputPath(this.commandContext.getSource().getServer().storageSource.getLevelId()), new SimpleFileVisitor<>() { 85 | @Nonnull 86 | @Override 87 | public FileVisitResult visitFile(Path file, @Nonnull BasicFileAttributes attrs) throws IOException { 88 | MergingThread.this.processFile(file, zipFiles); 89 | return FileVisitResult.CONTINUE; 90 | } 91 | }); 92 | 93 | // Write the merged zip file 94 | this.writeMergedZipFile(zos, zipFiles); 95 | } catch (IOException e) { 96 | throw new IllegalStateException("Error while processing backups", e); 97 | } finally { 98 | this.commandContext.getSource().sendSuccess(() -> Component.translatable("simplebackups.commands.finished"), false); 99 | } 100 | } 101 | 102 | private void processFile(Path file, Map zipFiles) throws IOException { 103 | if (file.toString().endsWith(".zip")) { 104 | try (ZipFile zipFile = new ZipFile(file.toFile())) { 105 | Enumeration entries = zipFile.entries(); 106 | 107 | while (entries.hasMoreElements()) { 108 | ZipEntry entry = entries.nextElement(); 109 | String name = entry.getName(); 110 | 111 | zipFiles.merge(name, file, this::getLatestModifiedFile); 112 | } 113 | } 114 | } 115 | } 116 | 117 | private Path getLatestModifiedFile(Path existingFile, Path newFile) { 118 | try { 119 | FileTime existingFileTime = Files.getLastModifiedTime(existingFile); 120 | FileTime newFileTime = Files.getLastModifiedTime(newFile); 121 | return existingFileTime.compareTo(newFileTime) > 0 ? existingFile : newFile; 122 | } catch (IOException e) { 123 | throw new UncheckedIOException(e); 124 | } 125 | } 126 | 127 | private void writeMergedZipFile(ZipOutputStream zos, Map zipFiles) throws IOException { 128 | for (Map.Entry entry : zipFiles.entrySet()) { 129 | String fileName = entry.getKey(); 130 | Path zipFilePath = entry.getValue(); 131 | 132 | try (ZipFile zipFile = new ZipFile(zipFilePath.toFile())) { 133 | ZipEntry zipEntry = zipFile.getEntry(fileName); 134 | if (zipEntry != null) { 135 | zos.putNextEntry(new ZipEntry(fileName)); 136 | 137 | try (InputStream is = zipFile.getInputStream(zipEntry)) { 138 | byte[] buffer = new byte[1024]; 139 | int len; 140 | while ((len = is.read(buffer)) > 0) { 141 | zos.write(buffer, 0, len); 142 | } 143 | } 144 | 145 | zos.closeEntry(); 146 | } 147 | } 148 | } 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/commands/PauseCommand.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.commands; 2 | 3 | import com.mojang.brigadier.Command; 4 | import com.mojang.brigadier.builder.ArgumentBuilder; 5 | import com.mojang.brigadier.context.CommandContext; 6 | import de.melanx.simplebackups.BackupData; 7 | import de.melanx.simplebackups.network.Pause; 8 | import net.minecraft.commands.CommandSourceStack; 9 | import net.minecraft.commands.Commands; 10 | import net.neoforged.neoforge.network.PacketDistributor; 11 | 12 | public class PauseCommand implements Command { 13 | 14 | private final boolean paused; 15 | 16 | private PauseCommand(boolean paused) { 17 | this.paused = paused; 18 | } 19 | 20 | public static ArgumentBuilder register() { 21 | return Commands.literal("backup") 22 | .then(Commands.literal("pause") 23 | .executes(new PauseCommand(true))) 24 | .then(Commands.literal("unpause") 25 | .executes(new PauseCommand(false))); 26 | } 27 | 28 | 29 | @Override 30 | public int run(CommandContext context) { 31 | BackupData data = BackupData.get(context.getSource().getServer()); 32 | data.setPaused(this.paused); 33 | PacketDistributor.sendToAllPlayers(new Pause(this.paused)); 34 | return this.paused ? 1 : 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/compat/Mc2DiscordCompat.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.compat; 2 | 3 | import net.minecraft.network.chat.Component; 4 | import net.neoforged.fml.ModList; 5 | 6 | public class Mc2DiscordCompat { 7 | 8 | public static void announce(Component text) { 9 | // MessageManager.sendInfoMessage(SimpleBackups.MODID, text.getString()); 10 | } 11 | 12 | public static boolean isLoaded() { 13 | return ModList.get().isLoaded("mc2discord"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/config/BackupType.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.config; 2 | 3 | public enum BackupType { 4 | FULL_BACKUPS, 5 | MODIFIED_SINCE_LAST, 6 | MODIFIED_SINCE_FULL 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/config/CommonConfig.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.config; 2 | 3 | import de.melanx.simplebackups.StorageSize; 4 | import net.neoforged.neoforge.common.ModConfigSpec; 5 | 6 | import javax.annotation.Nullable; 7 | import java.io.IOException; 8 | import java.nio.file.Path; 9 | import java.nio.file.Paths; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.zip.Deflater; 13 | 14 | public class CommonConfig { 15 | 16 | public static final ModConfigSpec CONFIG; 17 | private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); 18 | private static final String DEFAULT_DISK_SIZE = "25 GB"; 19 | 20 | static { 21 | init(BUILDER); 22 | CONFIG = BUILDER.build(); 23 | } 24 | 25 | private static ModConfigSpec.BooleanValue enabled; 26 | private static ModConfigSpec.EnumValue backupType; 27 | private static ModConfigSpec.BooleanValue saveAll; 28 | private static ModConfigSpec.IntValue fullBackupTimer; 29 | private static ModConfigSpec.IntValue backupsToKeep; 30 | private static ModConfigSpec.IntValue timer; 31 | private static ModConfigSpec.IntValue compressionLevel; 32 | private static ModConfigSpec.BooleanValue sendMessages; 33 | private static ModConfigSpec.ConfigValue maxDiskSize; 34 | private static ModConfigSpec.ConfigValue outputPath; 35 | private static ModConfigSpec.BooleanValue noPlayerBackups; 36 | private static ModConfigSpec.BooleanValue createSubDirs; 37 | private static ModConfigSpec.BooleanValue useTickCounter; 38 | private static ModConfigSpec.ConfigValue> ignoredPaths; 39 | private static ModConfigSpec.ConfigValue> ignoredFiles; 40 | private static ModConfigSpec.ConfigValue ignoredFilesRegex; 41 | 42 | private static ModConfigSpec.BooleanValue mc2discord; 43 | 44 | public static void init(ModConfigSpec.Builder builder) { 45 | enabled = builder.comment("If set false, no backups are being made.") 46 | .define("enabled", true); 47 | backupType = builder.comment("Defines the backup type.\n- FULL_BACKUPS - always creates full backups\n- MODIFIED_SINCE_LAST - only saves the files which changed since last (partial) backup\n- MODIFIED_SINCE_FULL - saves all files which changed after the last full backup") 48 | .defineEnum("backupType", BackupType.FULL_BACKUPS); 49 | saveAll = builder.comment("Should a save-all be forced before backup?") 50 | .define("saveAll", true); 51 | fullBackupTimer = builder.comment("How often should a full backup be created if only modified files should be saved? This creates a full backup when x minutes are over and the next backup needs to be done. Once a year is default.") 52 | .defineInRange("fullBackupTimer", 525960, 1, 5259600); 53 | backupsToKeep = builder.comment("The max amount of backup files to keep.") 54 | .defineInRange("backupsToKeep", 10, 1, Short.MAX_VALUE); 55 | timer = builder.comment("The time between two backups in minutes", "5 = each 5 minutes", "60 = each hour", "1440 = each day") 56 | .defineInRange("timer", 120, 1, Short.MAX_VALUE); 57 | compressionLevel = builder.comment("Compression level:", 58 | " 0 = no compression (low CPU usage, larger files)", 59 | " 9 = maximum compression (high CPU usage, smaller files)", 60 | " -1 = default; balances speed and compression (recommended)") 61 | .defineInRange("compressionLevel", Deflater.DEFAULT_COMPRESSION, Math.min(Deflater.DEFAULT_COMPRESSION, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION); 62 | sendMessages = builder.comment("Should message be sent when backup is in the making?") 63 | .define("sendMessages", true); 64 | maxDiskSize = builder.comment("The max size of storage the backup folder. If it takes more storage, old files will be deleted.", 65 | "Needs to be written as ", 66 | "Valid storage types: B, KB, MB, GB, TB") 67 | .define("maxDiskSize", DEFAULT_DISK_SIZE); 68 | outputPath = builder.comment("Used to define the output path.") 69 | .define("outputPath", "simplebackups"); 70 | noPlayerBackups = builder.comment("Create backups, even if nobody is online") 71 | .define("noPlayerBackups", false); 72 | createSubDirs = builder.comment("Should sub-directories be generated for each world?", 73 | "Keep in mind that all configs above, including backupsToKeep and maxDiskSize, will be calculated for each sub directory.") 74 | .define("createSubDirs", true); 75 | useTickCounter = builder.comment("Use an internal tick counter instead of the real world time. The value of the timer will be converted to ticks. When the timer is over, the backup will be created.", 76 | "Keep in mind that lagging servers will result in larger gaps between two backups, e.g. 10 FPS in average will result in double the time set between backups.") 77 | .define("useTickCounter", false); 78 | 79 | builder.comment("WARNING Please check your configuration before using permanently.", 80 | "The backup system will ignore these paths and files.") 81 | .push("to_ignore"); 82 | ignoredPaths = builder.comment("All directories that should be excluded from backups", 83 | "Format: Enter paths relative to the world directory (e.g., 'logs', 'data/cache')", 84 | "All files within these directories will also be excluded") 85 | .defineList("ignored_paths", List.of(), () -> "", obj -> obj instanceof String); 86 | ignoredFiles = builder.comment("Specific files that should be excluded from backups", 87 | "Format: Enter complete file paths relative to the world directory (e.g., 'level.dat_old', 'stats/player.json')", 88 | "Use this for individual files rather than entire directories") 89 | .defineList("ignored_files", List.of(), () -> "", obj -> obj instanceof String); 90 | ignoredFilesRegex = builder.comment("Regular expression pattern to exclude matching files from backups", 91 | "All files with paths matching this pattern will be skipped", 92 | "Example: '.*\\.temp$' excludes all files ending with .temp", 93 | "Leave empty to disable regex-based file exclusion") 94 | .define("ignored_files_regex", ""); 95 | builder.pop(); 96 | 97 | builder.push("mod_compat"); 98 | mc2discord = builder.comment("Should backup notifications be sent to Discord by using mc2discord? (needs to be installed)") 99 | .define("mc2discord", true); 100 | builder.pop(); 101 | } 102 | 103 | public static boolean isEnabled() { 104 | return enabled.get(); 105 | } 106 | 107 | public static int getBackupsToKeep() { 108 | return backupsToKeep.get(); 109 | } 110 | 111 | // converts config value from milliseconds to minutes 112 | public static int getTimer() { 113 | return timer.get() * 60 * 1000; 114 | } 115 | 116 | // converts config value from milliseconds to minutes 117 | public static int getFullBackupTimer() { 118 | return fullBackupTimer.get() * 60 * 1000; 119 | } 120 | 121 | public static int getCompressionLevel() { 122 | return compressionLevel.get(); 123 | } 124 | 125 | public static long getMaxDiskSize() { 126 | String s = maxDiskSize.get(); 127 | if (s.split(" ").length != 2) { 128 | s = DEFAULT_DISK_SIZE; 129 | } 130 | 131 | return StorageSize.getBytes(s); 132 | } 133 | 134 | public static Path getOutputPath(@Nullable String levelId) { 135 | Path base = Paths.get(outputPath.get()); 136 | boolean withSubDir = levelId != null && !levelId.isEmpty() && createSubDirs.get(); 137 | try { 138 | return withSubDir ? base.toRealPath().resolve(levelId) : base.toRealPath(); 139 | } catch (IOException e) { 140 | return withSubDir ? base.resolve(levelId) : base; 141 | } 142 | } 143 | 144 | public static boolean doNoPlayerBackups() { 145 | return noPlayerBackups.get(); 146 | } 147 | 148 | public static BackupType backupType() { 149 | return backupType.get(); 150 | } 151 | 152 | public static boolean saveAll() { 153 | return saveAll.get(); 154 | } 155 | 156 | public static boolean sendMessages() { 157 | return sendMessages.get(); 158 | } 159 | 160 | public static List getIgnoredPaths() { 161 | List paths = new ArrayList<>(); 162 | for (String path : ignoredPaths.get()) { 163 | paths.add(Path.of(path)); 164 | } 165 | 166 | return paths; 167 | } 168 | 169 | public static List getIgnoredFiles() { 170 | List paths = new ArrayList<>(); 171 | for (String path : ignoredFiles.get()) { 172 | paths.add(Path.of(path)); 173 | } 174 | 175 | return paths; 176 | } 177 | 178 | public static String getIgnoredFilesRegex() { 179 | return ignoredFilesRegex.get(); 180 | } 181 | 182 | public static boolean useTickCounter() { 183 | return useTickCounter.get(); 184 | } 185 | 186 | public static boolean mc2discord() { 187 | return mc2discord.get(); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/config/ServerConfig.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.config; 2 | 3 | import net.neoforged.neoforge.common.ModConfigSpec; 4 | 5 | public class ServerConfig { 6 | 7 | public static final ModConfigSpec CONFIG; 8 | private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); 9 | 10 | static { 11 | init(BUILDER); 12 | CONFIG = BUILDER.build(); 13 | } 14 | 15 | private static ModConfigSpec.BooleanValue commandsCheatsDisabled; 16 | private static ModConfigSpec.BooleanValue messagesForEveryone; 17 | 18 | public static void init(ModConfigSpec.Builder builder) { 19 | commandsCheatsDisabled = builder.comment("Should commands work without cheats enabled? Mainly recommended for single player, otherwise all users on servers can trigger commands.") 20 | .define("commandsCheatsDisabled", false); 21 | messagesForEveryone = builder.comment("Should all users receive the backup message? Disable to only have users with permission level 2 and higher receive them.") 22 | .define("messagesForEveryone", true); 23 | } 24 | 25 | public static boolean commandsCheatsDisabled() { 26 | return commandsCheatsDisabled.get(); 27 | } 28 | 29 | public static boolean messagesForEveryone() { 30 | return messagesForEveryone.get(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/melanx/simplebackups/network/Pause.java: -------------------------------------------------------------------------------- 1 | package de.melanx.simplebackups.network; 2 | 3 | import de.melanx.simplebackups.SimpleBackups; 4 | import de.melanx.simplebackups.client.ClientEventHandler; 5 | import net.minecraft.network.FriendlyByteBuf; 6 | import net.minecraft.network.codec.ByteBufCodecs; 7 | import net.minecraft.network.codec.StreamCodec; 8 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 9 | import net.minecraft.resources.ResourceLocation; 10 | import net.neoforged.neoforge.network.handling.IPayloadContext; 11 | 12 | import javax.annotation.Nonnull; 13 | 14 | public record Pause(boolean pause) implements CustomPacketPayload { 15 | 16 | public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(SimpleBackups.MODID, "pause"); 17 | public static final CustomPacketPayload.Type TYPE = new Type<>(ID); 18 | 19 | public static final StreamCodec CODEC = StreamCodec.composite( 20 | ByteBufCodecs.BOOL, Pause::pause, Pause::new 21 | ); 22 | 23 | @Nonnull 24 | @Override 25 | public Type type() { 26 | return Pause.TYPE; 27 | } 28 | 29 | public void handle(IPayloadContext context) { 30 | ClientEventHandler.setPaused(this.pause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/accesstransformer.cfg: -------------------------------------------------------------------------------- 1 | public net.minecraft.server.MinecraftServer storageSource 2 | public net.minecraft.server.network.ServerCommonPacketListenerImpl connection 3 | public net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess checkLock()V 4 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/neoforge.mods.toml: -------------------------------------------------------------------------------- 1 | modLoader="javafml" 2 | loaderVersion = "[4,)" 3 | license = "${mod.license}" 4 | issueTrackerURL = "${mod.issue_url}" 5 | 6 | [[mods]] 7 | modId = "${mod.modid}" 8 | version = "${mod.version}" 9 | displayName = "Simple Backups" 10 | displayURL = "${mod.source_url}" 11 | updateJSONURL = "https://assets.melanx.de/updates/simple-backups.json" 12 | authors = "MelanX" 13 | displayTest = "IGNORE_ALL_VERSION" 14 | description = ''' 15 | A simple mod to create scheduled backups. 16 | ''' 17 | 18 | [[dependencies.${ mod.modid }]] 19 | modId = "neoforge" 20 | type = "required" 21 | versionRange = "[${mod.neoforge},)" 22 | ordering="NONE" 23 | side="BOTH" 24 | 25 | [[dependencies.${ mod.modid }]] 26 | modId="minecraft" 27 | type="required" 28 | versionRange = "[${mod.minecraft},)" 29 | ordering="NONE" 30 | side="BOTH" 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/de_de.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "Backup gestartet...", 3 | "simplebackups.backup_finished": "Backup fertiggestellt in %s (%s | %s)", 4 | "simplebackups.backups_paused": "Backups pausiert", 5 | "simplebackups.commands.only_modified": "Es werden nicht nur veränderte Dateien gesichert, prüfe deine Konfigurationsdatei", 6 | "simplebackups.commands.is_merging": "Ein Zusammenführungsvorgang ist bereits im Gange", 7 | "simplebackups.commands.finished": "Zusammenführen der Backups erfolgreich abgeschlossen", 8 | 9 | "simplebackups.configuration.noPlayerBackups": "Backups ohne Spieler", 10 | "simplebackups.configuration.messagesForEveryone": "Nachrichten für alle", 11 | "simplebackups.configuration.createSubDirs": "Unterverzeichnisse erstellen", 12 | "simplebackups.configuration.timer": "Timer", 13 | "simplebackups.configuration.backupsToKeep": "Zu behaltende Backups", 14 | "simplebackups.configuration.backupType": "Backup-Typ", 15 | "simplebackups.configuration.useTickCounter": "Tick-Zähler verwenden", 16 | "simplebackups.configuration.maxDiskSize": "Maximale Festplattengröße", 17 | "simplebackups.configuration.enabled": "Mod aktiviert", 18 | "simplebackups.configuration.sendMessages": "Benachrichtigungen senden", 19 | "simplebackups.configuration.fullBackupTimer": "Vollständiger Backup-Timer", 20 | "simplebackups.configuration.compressionLevel": "Kompressionsstufe", 21 | "simplebackups.configuration.outputPath": "Ausgabepfad", 22 | "simplebackups.configuration.to_ignore": "Zu Ignorieren", 23 | "simplebackups.configuration.ignored_paths": "Pfade zum Ignorieren", 24 | "simplebackups.configuration.ignored_files": "Dateien zum Ignorieren", 25 | "simplebackups.configuration.ignored_files_regex": "Ignorier-RegEx", 26 | "simplebackups.configuration.mod_compat": "Mod-Kompatibilität", 27 | "simplebackups.configuration.mc2discord": "Mc2Discord", 28 | "simplebackups.configuration.commandsCheatsDisabled": "Befehle für Nicht-OPs" 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "Backup started...", 3 | "simplebackups.backup_finished": "Backup completed in %s (%s | %s)", 4 | "simplebackups.backups_paused": "Backups paused", 5 | "simplebackups.commands.only_modified": "Not only modified files are being backed up, please check your configuration file", 6 | "simplebackups.commands.is_merging": "A merge operation is already in progress", 7 | "simplebackups.commands.finished": "Merging backups completed successfully", 8 | 9 | "simplebackups.configuration.noPlayerBackups": "Backups without Players", 10 | "simplebackups.configuration.messagesForEveryone": "Messages for Everyone", 11 | "simplebackups.configuration.createSubDirs": "Create subdirectories", 12 | "simplebackups.configuration.timer": "Timer", 13 | "simplebackups.configuration.backupsToKeep": "Backups to keep", 14 | "simplebackups.configuration.backupType": "Backup Type", 15 | "simplebackups.configuration.useTickCounter": "Use tick counter", 16 | "simplebackups.configuration.maxDiskSize": "Max Disk Size", 17 | "simplebackups.configuration.enabled": "Mod Enabled", 18 | "simplebackups.configuration.sendMessages": "Send Notification Messages", 19 | "simplebackups.configuration.fullBackupTimer": "Full Backup Timer", 20 | "simplebackups.configuration.compressionLevel": "Compression Level", 21 | "simplebackups.configuration.outputPath": "Output Path", 22 | "simplebackups.configuration.to_ignore": "To Ignore", 23 | "simplebackups.configuration.ignored_paths": "Ignored Paths", 24 | "simplebackups.configuration.ignored_files": "Ignored Files", 25 | "simplebackups.configuration.ignored_files_regex": "Ignore RegEx", 26 | "simplebackups.configuration.mod_compat": "Mod Compat", 27 | "simplebackups.configuration.mc2discord": "Mc2Discord", 28 | "simplebackups.configuration.commandsCheatsDisabled": "Commands for Non-OP" 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/ja_jp.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "バックアップ開始...", 3 | "simplebackups.backup_finished": "バックアップ完了、%s (%s | %s)", 4 | "simplebackups.backups_paused": "バックアップ一時停止", 5 | "simplebackups.commands.only_modified": "変更されたファイルだけがバックアップされるわけではありません。コンフィグファイルを確認してください。", 6 | "simplebackups.commands.is_merging": "マージ操作がすでに進行中です。", 7 | "simplebackups.commands.finished": "バックアップのマージが正常に完了" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/pt_br.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "Backup iniciado...", 3 | "simplebackups.backup_finished": "Backup concluído em %s (%s | %s)", 4 | "simplebackups.backups_paused": "Backups pausados", 5 | "simplebackups.commands.only_modified": "Não apenas arquivos modificados estão sendo salvos, por favor, verifique seu arquivo de configuração", 6 | "simplebackups.commands.is_merging": "Uma operação de mesclagem já está em andamento", 7 | "simplebackups.commands.finished": "Mesclagem de backups concluída com sucesso" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/ru_ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "Запущено резервное копирование...", 3 | "simplebackups.backup_finished": "Резервное копирование завершено в %s (%s | %s)", 4 | "simplebackups.backups_paused": "Резервное копирование приостановлено", 5 | "simplebackups.commands.only_modified": "Сохраняются не только изменённые файлы, пожалуйста, проверьте ваш файл конфигурации", 6 | "simplebackups.commands.is_merging": "Операция слияния уже выполняется", 7 | "simplebackups.commands.finished": "Слияние резервных копий успешно завершено", 8 | 9 | "simplebackups.configuration.noPlayerBackups": "Резервные копии без игроков", 10 | "simplebackups.configuration.messagesForEveryone": "Сообщения для всех игроков", 11 | "simplebackups.configuration.createSubDirs": "Создавать подкаталоги", 12 | "simplebackups.configuration.timer": "Интервал", 13 | "simplebackups.configuration.backupsToKeep": "Количество хранимых копий", 14 | "simplebackups.configuration.backupType": "Тип резервного копирования", 15 | "simplebackups.configuration.useTickCounter": "Использовать счётчик тактов", 16 | "simplebackups.configuration.maxDiskSize": "Максимальный размер на диске", 17 | "simplebackups.configuration.enabled": "Мод включён", 18 | "simplebackups.configuration.sendMessages": "Отправлять уведомления", 19 | "simplebackups.configuration.fullBackupTimer": "Интервал полного копирования", 20 | "simplebackups.configuration.compressionLevel": "Степень сжатия", 21 | "simplebackups.configuration.outputPath": "Путь сохранения", 22 | "simplebackups.configuration.to_ignore": "Исключения", 23 | "simplebackups.configuration.ignored_paths": "Игнорируемые пути", 24 | "simplebackups.configuration.ignored_files": "Игнорируемые файлы", 25 | "simplebackups.configuration.ignored_files_regex": "Регулярные выражения исключений", 26 | "simplebackups.configuration.mod_compat": "Совместимость с модами", 27 | "simplebackups.configuration.mc2discord": "Mc2Discord", 28 | "simplebackups.configuration.commandsCheatsDisabled": "Команды только для операторов" 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/tr_tr.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "Yedekleme başladı...", 3 | "simplebackups.backup_finished": "Yedekleme %s içinde tamamlandı (%s | %s)", 4 | "simplebackups.backups_paused": "Yedeklemeler duraklatıldı", 5 | "simplebackups.commands.only_modified": "Yalnızca değiştirilen dosyalar yedeklenmiyor, lütfen yapılandırma dosyanızı kontrol edin", 6 | "simplebackups.commands.is_merging": "Bir birleştirme işlemi zaten devam ediyor", 7 | "simplebackups.commands.finished": "Yedeklerin birleştirilmesi başarıyla tamamlandı" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "备份开始……", 3 | "simplebackups.backup_finished": "备份在%s内完成 (%s | %s)", 4 | "simplebackups.backups_paused": "备份中止", 5 | "simplebackups.commands.only_modified": "不只备份了修改后的文件,请检查你的配置文件", 6 | "simplebackups.commands.is_merging": "已有一个合并操作正在执行", 7 | "simplebackups.commands.finished": "合并备份成功" 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/assets/simplebackups/lang/zh_tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "simplebackups.backup_started": "備份開始...", 3 | "simplebackups.backup_finished": "備份已於 %s 內完成(%s|%s)", 4 | "simplebackups.backups_paused": "備份已暫停", 5 | "simplebackups.commands.only_modified": "目前備份的對象不只是已修改的檔案,請檢查你的設定檔", 6 | "simplebackups.commands.is_merging": "合併操作已在進行中", 7 | "simplebackups.commands.finished": "備份合併已成功完成" 8 | } 9 | --------------------------------------------------------------------------------