diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7687c75 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "gradle" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..250106e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: Build + +on: [pull_request, push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'zulu' + cache: gradle + - name: Make Gradle wrapper executable + run: chmod +x ./gradlew + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Build with Gradle + run: ./gradlew build + - uses: actions/upload-artifact@v2 + with: + name: Package + path: build/libs + - name: Cleanup Gradle Cache + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties diff --git a/.github/workflows/build.yaml b/.github/workflows/build2.yaml similarity index 98% rename from .github/workflows/build.yaml rename to .github/workflows/build2.yaml index efbf0a4..acae9c3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build2.yaml @@ -1,4 +1,4 @@ -name: Build +name: Build2 on: [ push, pull_request ] diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..bdeab7a --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '39 9 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.gitignore b/.gitignore index a09312e..ee4187e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,12 @@ -# gradle - .gradle/ build/ out/ classes/ - -# eclipse - *.launch - -# idea - .idea/ *.iml *.ipr *.iws - -# vscode - .settings/ .vscode/* !.vscode/extensions.json @@ -25,11 +14,60 @@ classes/ bin/ .classpath .project - -# macos - *.DS_Store - -# fabric - run/ +.env +/run/ +.idea_modules/ +atlassian-ide-plugin.xml +*.class +*.log +*.ctxt +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar +hs_err_pid* +*~ +.fuse_hidden* +.directory +.Trash-* +.nfs* +.DS_Store +.AppleDouble +.LSOverride +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +*.stackdump +[Dd]esktop.ini +$RECYCLE.BIN/ +*.cab +*.msi +*.msix +*.msm +*.msp +*.lnk +.gradle +gradle-app.setting +.gradletasknamecache +**/build/ +logs/ +!gradle-wrapper.jar diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..81248ea --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +* **NOTE THAT GUI AND AUTOCHECK WILL BE LATER!** +* Its working, provide all ModGet functional diff --git a/README.md b/README.md index 9e61b01..1fff058 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,26 @@ # Modget-Minecraft [![CurseForge downloads](https://cf.way2muchnoise.eu/modget.svg)](https://www.curseforge.com/minecraft/mc-mods/modget) [![CurseForge versions](https://cf.way2muchnoise.eu/versions/modget.svg)](https://www.curseforge.com/minecraft/mc-mods/modget) -[![Modrinth downloads](https://img.shields.io/badge/dynamic/json?color=5da545&label=modrinth&prefix=downloads%20&query=downloads&url=https://api.modrinth.com/api/v1/mod/2NpFE0R3&style=flat&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMSAxMSIgd2lkdGg9IjE0LjY2NyIgaGVpZ2h0PSIxNC42NjciICB4bWxuczp2PSJodHRwczovL3ZlY3RhLmlvL25hbm8iPjxkZWZzPjxjbGlwUGF0aCBpZD0iQSI+PHBhdGggZD0iTTAgMGgxMXYxMUgweiIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNBKSI+PHBhdGggZD0iTTEuMzA5IDcuODU3YTQuNjQgNC42NCAwIDAgMS0uNDYxLTEuMDYzSDBDLjU5MSA5LjIwNiAyLjc5NiAxMSA1LjQyMiAxMWMxLjk4MSAwIDMuNzIyLTEuMDIgNC43MTEtMi41NTZoMGwtLjc1LS4zNDVjLS44NTQgMS4yNjEtMi4zMSAyLjA5Mi0zLjk2MSAyLjA5MmE0Ljc4IDQuNzggMCAwIDEtMy4wMDUtMS4wNTVsMS44MDktMS40NzQuOTg0Ljg0NyAxLjkwNS0xLjAwM0w4LjE3NCA1LjgybC0uMzg0LS43ODYtMS4xMTYuNjM1LS41MTYuNjk0LS42MjYuMjM2LS44NzMtLjM4N2gwbC0uMjEzLS45MS4zNTUtLjU2Ljc4Ny0uMzcuODQ1LS45NTktLjcwMi0uNTEtMS44NzQuNzEzLTEuMzYyIDEuNjUxLjY0NSAxLjA5OC0xLjgzMSAxLjQ5MnptOS42MTQtMS40NEE1LjQ0IDUuNDQgMCAwIDAgMTEgNS41QzExIDIuNDY0IDguNTAxIDAgNS40MjIgMCAyLjc5NiAwIC41OTEgMS43OTQgMCA0LjIwNmguODQ4QzEuNDE5IDIuMjQ1IDMuMjUyLjgwOSA1LjQyMi44MDljMi42MjYgMCA0Ljc1OCAyLjEwMiA0Ljc1OCA0LjY5MSAwIC4xOS0uMDEyLjM3Ni0uMDM0LjU2bC43NzcuMzU3aDB6IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGZpbGw9IiM1ZGE0MjYiLz48L2c+PC9zdmc+)](https://www.curseforge.com/minecraft/mc-mods/modget) +[![Modrinth downloads](https://img.shields.io/badge/dynamic/json?color=5da545&label=modrinth&prefix=downloads%20&query=downloads&url=https://api.modrinth.com/api/v1/mod/2NpFE0R3&style=flat&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMSAxMSIgd2lkdGg9IjE0LjY2NyIgaGVpZ2h0PSIxNC42NjciICB4bWxuczp2PSJodHRwczovL3ZlY3RhLmlvL25hbm8iPjxkZWZzPjxjbGlwUGF0aCBpZD0iQSI+PHBhdGggZD0iTTAgMGgxMXYxMUgweiIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNBKSI+PHBhdGggZD0iTTEuMzA5IDcuODU3YTQuNjQgNC42NCAwIDAgMS0uNDYxLTEuMDYzSDBDLjU5MSA5LjIwNiAyLjc5NiAxMSA1LjQyMiAxMWMxLjk4MSAwIDMuNzIyLTEuMDIgNC43MTEtMi41NTZoMGwtLjc1LS4zNDVjLS44NTQgMS4yNjEtMi4zMSAyLjA5Mi0zLjk2MSAyLjA5MmE0Ljc4IDQuNzggMCAwIDEtMy4wMDUtMS4wNTVsMS44MDktMS40NzQuOTg0Ljg0NyAxLjkwNS0xLjAwM0w4LjE3NCA1LjgybC0uMzg0LS43ODYtMS4xMTYuNjM1LS41MTYuNjk0LS42MjYuMjM2LS44NzMtLjM4N2gwbC0uMjEzLS45MS4zNTUtLjU2Ljc4Ny0uMzcuODQ1LS45NTktLjcwMi0uNTEtMS44NzQuNzEzLTEuMzYyIDEuNjUxLjY0NSAxLjA5OC0xLjgzMSAxLjQ5MnptOS42MTQtMS40NEE1LjQ0IDUuNDQgMCAwIDAgMTEgNS41QzExIDIuNDY0IDguNTAxIDAgNS40MjIgMCAyLjc5NiAwIC41OTEgMS43OTQgMCA0LjIwNmguODQ4QzEuNDE5IDIuMjQ1IDMuMjUyLjgwOSA1LjQyMi44MDljMi42MjYgMCA0Ljc1OCAyLjEwMiA0Ljc1OCA0LjY5MSAwIC4xOS0uMDEyLjM3Ni0uMDM0LjU2bC43NzcuMzU3aDB6IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGZpbGw9IiM1ZGE0MjYiLz48L2c+PC9zdmc+)](https://modrinth.com/mod/modget) +[![Build](https://github.com/ReviversMC/modget-minecraft/actions/workflows/build.yml/badge.svg)](https://github.com/ReviversMC/modget-minecraft/actions/workflows/build.yml) +[![License](https://img.shields.io/github/license/ReviversMC/modget-minecraft.svg)](https://github.com/ReviversMC/modget-minecraft/blob/main/LICENSE) +[![Release](https://img.shields.io/github/release/ReviversMC/modget-minecraft.svg)](https://github.com/ReviversMC/modget-minecraft/releases/latest) +[![Downloads](https://img.shields.io/github/downloads/ReviversMC/modget-minecraft/total.svg)](https://github.com/ReviversMC/modget-minecraft/releases/latest) The Minecraft Mod Package Manager! Modget is based on TheBrokenRail's [ModUpdater](https://gitea.thebrokenrail.com/TheBrokenRail/ModUpdater) mod and is inspired heavily by Microsoft's [Winget](https://github.com/microsoft/winget-cli). -Currently, Modget supports the following commands: +**[Mod Menu](https://modrinth.com/mod/modmenu) and [Cloth Config API](https://www.curseforge.com/minecraft/mc-mods/cloth-config) should be installed!** + +Nightly builds download link [here](https://nightly.link/ReviversMC/modget-minecraft/workflows/build/main/Package.zip) + +## Contributors + + + + +## Currently, Modget supports the following commands: ``` /modget list Lists all installed mods recognized by modget /modget repos list Lists all installed manifest repositories @@ -42,7 +55,7 @@ If you want to add first-party support for your mods, please regularly submit ne [![Discord chat](https://img.shields.io/badge/chat%20on-discord-7289DA?logo=discord&logoColor=white)](https://discord.gg/6bTGYFppfz) We have an [official Discord community](https://discord.gg/6bTGYFppfz) for all of our projects. By joining, you can: -- Get installation help and technical support with all of our mods +- Get installation help and technical support with all of our mods - Be notified of the latest developments as they happen - Get involved and collaborate with the rest of our team - ... and just hang out with the rest of our community. diff --git a/build.gradle b/build.gradle index dd09f96..6e98b06 100644 --- a/build.gradle +++ b/build.gradle @@ -2,14 +2,15 @@ plugins { id 'fabric-loom' version '0.10.local' // id 'com.matthewprenger.cursegradle' version '1.4.0' id 'maven-publish' + id "com.modrinth.minotaur" version "1.2.1" } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 // def mod_version = project.mod_version as Object // version = "${mod_version}+${project.minecraft_version}" -version = project.mod_version +version = project.mod_version as Object archivesBaseName = project.archives_base_name group = project.maven_group as Object @@ -25,7 +26,10 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. - + mavenLocal() + maven { name = "TerraformersMC" + url = "https://maven.terraformersmc.com/releases" } + maven { url = "https://maven.shedaniel.me/" } maven { url = "https://mvnrepository.com/" } @@ -52,6 +56,7 @@ repositories { name = "NucleoidMC" url = "https://maven.nucleoid.xyz/" } + mavenCentral() } @@ -86,6 +91,14 @@ dependencies { compileOnly "com.github.spotbugs:spotbugs:${project.spotbugs_version}" + modRuntimeOnly "fr.catcore:server-translations-api:1.4.8+1.18-pre1" + modImplementation "net.fabricmc:fabric-language-kotlin:1.7.0+kotlin.1.6.0" + modImplementation "com.terraformersmc:modmenu:3.0.0" + modApi("me.shedaniel.cloth:cloth-config-fabric:6.0.45") { + exclude(group: "net.fabricmc.fabric-api") + } + modImplementation "net.fabricmc.fabric-api:fabric-api:0.43.1+1.18" + if (project.use_third_party_mods) { configurations { @@ -101,20 +114,20 @@ dependencies { } } - modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modRuntimeOnly "fr.catcore:server-translations-api:${project.server_translations_version}" - // modRuntimeOnly "curse.maven:modmenu-308702:3199797" - modRuntimeOnly "curse.maven:borderless-mining-310205:3033277" - modRuntimeOnly "curse.maven:dark-loading-screen-365727:3185761" - // modRuntimeOnly "curse.maven:dynamic-fps-335493:3302730" - // modRuntimeOnly "curse.maven:enhanced-block-entities-452046:3378154" - modRuntimeOnly "curse.maven:lazydfu-433518:3209972" - modRuntimeOnly "curse.maven:lithium-360438:3344974" - modRuntimeOnly "curse.maven:no-fade-452768:3228523" - modRuntimeOnly "curse.maven:phosphor-372124:3294303" - modRuntimeOnly "curse.maven:resolution-control-plus-446974:3206545" - modRuntimeOnly "curse.maven:smooth-boot-415758:3248104" - modRuntimeOnly "curse.maven:sodium-394468:3488820" +// modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" +// modRuntimeOnly "fr.catcore:server-translations-api:${project.server_translations_version}" +// // modRuntimeOnly "curse.maven:modmenu-308702:3199797" +// modRuntimeOnly "curse.maven:borderless-mining-310205:3033277" +// modRuntimeOnly "curse.maven:dark-loading-screen-365727:3185761" +// // modRuntimeOnly "curse.maven:dynamic-fps-335493:3302730" +// // modRuntimeOnly "curse.maven:enhanced-block-entities-452046:3378154" +// modRuntimeOnly "curse.maven:lazydfu-433518:3209972" +// modRuntimeOnly "curse.maven:lithium-360438:3344974" +// modRuntimeOnly "curse.maven:no-fade-452768:3228523" +// modRuntimeOnly "curse.maven:phosphor-372124:3294303" +// modRuntimeOnly "curse.maven:resolution-control-plus-446974:3206545" +// modRuntimeOnly "curse.maven:smooth-boot-415758:3248104" +// modRuntimeOnly "curse.maven:sodium-394468:3488820" // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. @@ -159,6 +172,10 @@ jar { from "LICENSE" } +test { + useJUnitPlatform() +} + // if (project.hasProperty('curseforge.api_key')) { // curseforge { // apiKey = project.getProperty('curseforge.api_key') @@ -210,3 +227,24 @@ publishing { // } } } + +//import com.modrinth.minotaur.TaskModrinthUpload +//import com.modrinth.minotaur.request.VersionType +//import com.modrinth.minotaur.request.Dependency +// +//task publishModrinth (type: TaskModrinthUpload){ +// onlyIf { +// System.getenv("MODRINTH") +// } +// +// token = System.getenv("MODRINTH") +// projectId = "2NpFE0R3" +// versionNumber = version +// uploadFile = remapJar +// versionType = VersionType.ALPHA +// addGameVersion(project.minecraft_version) +// addLoader("fabric") +// addDependency("JPP6w2U1", Dependency.DependencyType.REQUIRED) +// changelog = file("CHANGELOG.md").getText("UTF-8") +// enabled = true +//} diff --git a/gradle.properties b/gradle.properties index f7b4f38..156180e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,26 +1,30 @@ # Done to increase the memory available to gradle. +org.gradle.parallel=true +org.gradle.console=rich +org.gradle.warning.mode=all + org.gradle.jvmargs = -Xmx1G # Fabric Properties - minecraft_version=1.16.4 - yarn_mappings=1.16.4+build.9:v2 - loader_version=0.12.5 + minecraft_version=1.18 + yarn_mappings=1.18+build.1:v2 + loader_version=0.12.8 # Mod Properties mod_version = 0.3.0 maven_group = com.github.reviversmc.modget - archives_base_name = modget-minecraft + archives_base_name = modget-minecraft-gui # Dependencies - fabric_version = 0.34.6+1.16 + fabric_version = 0.44.0+1.18 modget_lib_version = 3.0.0-rc.2 modget_manifest_api_version = 0.2.0 commons_text_version = 1.9 jackson_version = 2.13.0 snakeyaml_version = 1.29 - spotbugs_version = 4.4.1 + spotbugs_version = 4.5.0 # If true, third-party mods will be loaded during runtime in the developer run configurations use_third_party_mods = true - server_translations_version = 1.4.1+1.16 - databreaker_version = 0.2.6 + server_translations_version = 1.4.8+1.18-pre1 + databreaker_version = 0.2.7 diff --git a/src/main/java/com/github/reviversmc/modget/minecraft/config/ConfigManager.java b/src/main/java/com/github/reviversmc/modget/minecraft/config/ConfigManager.java new file mode 100644 index 0000000..6a9f50e --- /dev/null +++ b/src/main/java/com/github/reviversmc/modget/minecraft/config/ConfigManager.java @@ -0,0 +1,60 @@ +package com.github.reviversmc.modget.minecraft.config; + +import java.io.*; +import java.util.*; + + +class ConfigManager { + public static ConfigManager INSTANCE = new ConfigManager(); + private Boolean loaded = false; + private final Properties prop = new Properties(); + + + Boolean getBooleanProperty(String key) { + if (!loaded) load(); + return java.lang.Boolean.parseBoolean(prop.getProperty(key)); + } + +/* fun getStringProperty(key: String?): String? { + if (!loaded) load() + return prop.getProperty(key) + } + + fun getNumberProperty(key: String?): Int { + if (!loaded) load() + return prop.getProperty(key).toInt() + } + + fun getDoubleProperty(key: String?): Double { + if (!loaded) load() + return prop.getProperty(key).toDouble() + }*/ + + private final File file = new File("./config/modget/config.properties"); + void setValue(String key, String value) throws IOException { + prop.setProperty(key, value); + FileOutputStream writer = new FileOutputStream(file); + file.createNewFile(); + prop.store(writer, "ModGet Config"); + writer.close(); + } + private void load() { + loaded = true; + try { + new File("./config/modget").mkdir(); + if (file.exists()) { + FileReader reader = new FileReader(file); + prop.load(reader); + reader.close(); + } else { + FileOutputStream writer = new FileOutputStream(file); + file.createNewFile(); + prop.setProperty("autoCheck", "true"); + prop.store(writer, "ModGet Config"); + writer.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/reviversmc/modget/minecraft/config/ModMenuConfig.java b/src/main/java/com/github/reviversmc/modget/minecraft/config/ModMenuConfig.java new file mode 100644 index 0000000..3014b20 --- /dev/null +++ b/src/main/java/com/github/reviversmc/modget/minecraft/config/ModMenuConfig.java @@ -0,0 +1,37 @@ +package com.github.reviversmc.modget.minecraft.config; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import me.shedaniel.clothconfig2.api.ConfigBuilder; +import me.shedaniel.clothconfig2.api.ConfigCategory; +import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import net.minecraft.text.LiteralText; + +import java.io.IOException; + +public class ModMenuConfig implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> { + ConfigBuilder builder = ConfigBuilder.create() + .setParentScreen(parent) + .setTitle(new LiteralText("Auto Check Updates")); + + ConfigCategory general = builder.getOrCreateCategory(new LiteralText("General")); + builder.setFallbackCategory(general); + + ConfigEntryBuilder entryBuilder = builder.entryBuilder(); + general.addEntry( + entryBuilder.startBooleanToggle(new LiteralText("Auto Check Updates"), ConfigManager.INSTANCE.getBooleanProperty("autoCheck")) + .setSaveConsumer(b -> { + try { + ConfigManager.INSTANCE.setValue("autoCheck", b.toString()); + } catch (IOException e) { + e.printStackTrace(); + } + }) + .build()); + return builder.build(); + }; + } +} diff --git a/src/main/java/com/github/reviversmc/modget/minecraft/mixin/ModsCheckMixin.java b/src/main/java/com/github/reviversmc/modget/minecraft/mixin/ModsCheckMixin.java new file mode 100644 index 0000000..c7aeb75 --- /dev/null +++ b/src/main/java/com/github/reviversmc/modget/minecraft/mixin/ModsCheckMixin.java @@ -0,0 +1,42 @@ +package com.github.reviversmc.modget.minecraft.mixin; + +import com.github.reviversmc.modget.minecraft.util.Utils; +import com.terraformersmc.modmenu.gui.ModsScreen; +import com.terraformersmc.modmenu.gui.widget.ModMenuTexturedButtonWidget; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ModsScreen.class) +public abstract class ModsCheckMixin extends Screen { + private static final Identifier UPDATE_BUTTON_LOCATION = new Identifier("modget", "textures/gui/install_button.png"); + @Shadow + private int paneWidth; +// @Shadow +// private int paneY; + + protected ModsCheckMixin(Text title) { + super(title); + } + + @Inject(method = "init", at = @At("TAIL")) + public void onInit(CallbackInfo ci) { + int searchBoxWidth = this.paneWidth - 32 - 22; + this.addDrawableChild(new ModMenuTexturedButtonWidget(this.paneWidth / 2 + searchBoxWidth / 2 + 14, + 22, 20, 20, 0, 0, UPDATE_BUTTON_LOCATION, 32, 64, + button -> Utils.showToast(new LiteralText("Feature in development!"), new LiteralText("We are working on it")), LiteralText.EMPTY, + (button, matrices, mouseX, mouseY) -> { + if (!button.isHovered()) { + return; + } + this.renderTooltip(matrices, new LiteralText("Updates"), mouseX, mouseY); + })); + } +} diff --git a/src/main/java/com/github/reviversmc/modget/minecraft/mixin/TitleCheckMixin.java b/src/main/java/com/github/reviversmc/modget/minecraft/mixin/TitleCheckMixin.java new file mode 100644 index 0000000..1c53ad4 --- /dev/null +++ b/src/main/java/com/github/reviversmc/modget/minecraft/mixin/TitleCheckMixin.java @@ -0,0 +1,31 @@ +package com.github.reviversmc.modget.minecraft.mixin; + +import com.github.reviversmc.modget.minecraft.util.Utils; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public class TitleCheckMixin extends Screen { + + protected TitleCheckMixin(Text title) { + super(title); + } + + @Inject(at = @At("TAIL"), method = "render") + public void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + if (Utils.shownUpdateNotification) { + return; + } + Utils.shownUpdateNotification = true; +// Runnable runnable = () -> new ModPlatform().start(null, "update"); +// Thread t = new Thread(runnable); +// t.start(); + } +} + diff --git a/src/main/java/com/github/reviversmc/modget/minecraft/util/Utils.java b/src/main/java/com/github/reviversmc/modget/minecraft/util/Utils.java index 7d83696..53bf271 100644 --- a/src/main/java/com/github/reviversmc/modget/minecraft/util/Utils.java +++ b/src/main/java/com/github/reviversmc/modget/minecraft/util/Utils.java @@ -4,13 +4,18 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.util.Objects; import java.util.Optional; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.toast.SystemToast; +import net.minecraft.text.Text; public class Utils { public static final String JAR_EXTENSION = ".jar"; + public static Boolean shownUpdateNotification = false; public static Utils create() { return new Utils(); @@ -55,4 +60,11 @@ public String getMinecraftVersion() { public boolean isFileCompatible(String fileName) { return !fileName.endsWith("-dev" + JAR_EXTENSION) && !fileName.endsWith("-sources" + JAR_EXTENSION) && !fileName.endsWith("-sources-dev" + JAR_EXTENSION) && fileName.endsWith(JAR_EXTENSION); } + + public static void showToast(Text line1, Text line2) { + Objects.requireNonNull(MinecraftClient.getInstance()).getToastManager().add(new SystemToast(SystemToast.Type.TUTORIAL_HINT, + line1, + line2 + )); + } } diff --git a/src/main/resources/assets/modget/lang/ru_ru.json b/src/main/resources/assets/modget/lang/ru_ru.json new file mode 100644 index 0000000..d049ee7 --- /dev/null +++ b/src/main/resources/assets/modget/lang/ru_ru.json @@ -0,0 +1,31 @@ +{ + "gui.modget.title": "Доступны обновления модов", + "gui.modget.download": "Скачать", + "gui.modget.refresh": "Обновить", + "gui.modget.loading": "Загрузка...", + "commands.modget.not_loaded": "Невозможно выполнить операцию когда моды обновляются", + "commands.modget.refresh_start": "Обновляем Modget...", + "commands.modget.refresh_finish": "Обновляем Modget... готово.", + "commands.modget.hover": "Нажмите чтобы скачать %s с %s", + "commands.modget.search_start": "Поиск...", + "commands.modget.search_mods_found": "Данные соместимые пакеты найдены:", + "commands.modget.search_no_mods_found": "Моды не найдены.", + "commands.modget.search_no_mods_found_enter_at_least_4_chars": "Моды не найдены. Чтобы получить более точные результаты введите минимум 4 символа!", + "commands.modget.list_title": "Распознанные моды:", + "commands.modget.repos_list_title": "Установленные репозитории модов:", + "commands.modget.repo_added": "Репозиторий с ID %s добавлен успешно", + "commands.modget.repo_removed": "Репозиторий с ID %s удалён успешно", + "commands.modget.upgrade_title": "Обновления данных модов найдены:", + "commands.modget.searching_for_updates": "Поиск обновлений модов...", + "commands.modget.no_updates_found": "Обновления модов не найдены.", + "info.modget.multiple_packages_available": "Несколько пакетов для мода %s найдено:", + "info.modget.use_for_server_mods": "Помните: Используйте \"%s\" для серверных модов.", + "info.modget.init_failed_try_running_refresh": "Была ошибка во время запуска Modget. Попробуйте '/%s refresh' перед тем как выполнять команду снова!", + "error.modget.repo_connection_error": "Невозможно подключиться к репозиторию. Проверьте подключение к интернету! %s", + "error.modget.refresh_error": "При попытке обновления информации о модах произошла ошибка: %s", + "error.modget.command_already_processing": "Команда уже выполняется! Пожалуйста подождите.", + "error.modget.not_an_url": "Введённая строка имеет неверную ссылку!", + "error.modget.repo_not_found": "Репозиторий с ID %s не найден. Используйте '/%s repos list' чтобы увидеть все ID!", + "error.modget.repo_not_removable": "Вы не можете убрать стандартный репозиторий! Используйте '/%s repos disable 0' вместо этого.", + "error.modget.repo_already_exists": "Репозиторий (ID: %s) с этой ссылкой уже существует." +} diff --git a/src/main/resources/assets/modget/textures/gui/install_button.png b/src/main/resources/assets/modget/textures/gui/install_button.png new file mode 100644 index 0000000..3fd02a0 Binary files /dev/null and b/src/main/resources/assets/modget/textures/gui/install_button.png differ diff --git a/src/main/resources/data/modget/lang/ru_ru.json b/src/main/resources/data/modget/lang/ru_ru.json new file mode 100644 index 0000000..6977885 --- /dev/null +++ b/src/main/resources/data/modget/lang/ru_ru.json @@ -0,0 +1,27 @@ +{ + "commands.modget.not_loaded": "Невозможно выполнить операцию когда моды обновляются", + "commands.modget.refresh_start": "Обновляем Modget...", + "commands.modget.refresh_finish": "Обновляем Modget... готово.", + "commands.modget.hover": "Нажмите чтобы скачать %s с %s", + "commands.modget.search_start": "Поиск...", + "commands.modget.search_mods_found": "Данные соместимые пакеты найдены:", + "commands.modget.search_no_mods_found": "Моды не найдены.", + "commands.modget.search_no_mods_found_enter_at_least_4_chars": "Моды не найдены. Чтобы получить более точные результаты введите минимум 4 символа!", + "commands.modget.list_title": "Распознанные моды:", + "commands.modget.repos_list_title": "Установленные репозитории модов:", + "commands.modget.repo_added": "Репозиторий с ID %s добавлен успешно", + "commands.modget.repo_removed": "Репозиторий с ID %s удалён успешно", + "commands.modget.upgrade_title": "Обновления данных модов найдены:", + "commands.modget.searching_for_updates": "Поиск обновлений модов...", + "commands.modget.no_updates_found": "Обновления модов не найдены.", + "info.modget.multiple_packages_available": "Несколько пакетов для мода %s найдено:", + "info.modget.use_for_server_mods": "Помните: Используйте \"%s\" для серверных модов.", + "info.modget.init_failed_try_running_refresh": "Была ошибка во время запуска Modget. Попробуйте '/%s refresh' перед тем как выполнять команду снова!", + "error.modget.repo_connection_error": "Невозможно подключиться к репозиторию. Проверьте подключение к интернету! %s", + "error.modget.refresh_error": "При попытке обновления информации о модах произошла ошибка: %s", + "error.modget.command_already_processing": "Команда уже выполняется! Пожалуйста подождите.", + "error.modget.not_an_url": "Введённая строка имеет неверную ссылку!", + "error.modget.repo_not_found": "Репозиторий с ID %s не найден. Используйте '/%s repos list' чтобы увидеть все ID!", + "error.modget.repo_not_removable": "Вы не можете убрать стандартный репозиторий! Используйте '/%s repos disable 0' вместо этого.", + "error.modget.repo_already_exists": "Репозиторий (ID: %s) с этой ссылкой уже существует." +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a27e1a0..583a7a6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,12 @@ "name": "Modget", "description": "Minecraft Mod Package Manager! Can install mods via commands, search for updates and more.", "authors": [ - "NebelNidas" + "NebelNidas", + "TheBrokenRail", + "gbl", + "Samekichi", + "pozitp", + "TheEnderOfficial" ], "contact": { "homepage": "https://github.com/ReviversMC/modget-minecraft", @@ -18,13 +23,20 @@ "entrypoints": { "main": [ "com.github.reviversmc.modget.minecraft.Modget" + ], + "modmenu": [ + "com.github.reviversmc.modget.minecraft.config.ModMenuConfig" ] }, + "mixins": [ + "modgetminecraft.mixins.json" + ], "depends": { "fabricloader": ">=0.7.4", "fabric-api-base": "*", "fabric-command-api-v1": ">=1.1.0+f9b3753b7d", "fabric-networking-api-v1": "*", + "modmenu": ">=1.16.22", "minecraft": ">=1.16" }, "recommends": { diff --git a/src/main/resources/modgetminecraft.mixins.json b/src/main/resources/modgetminecraft.mixins.json new file mode 100644 index 0000000..1036c4e --- /dev/null +++ b/src/main/resources/modgetminecraft.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.github.reviversmc.modget.minecraft.mixin", + "compatibilityLevel": "JAVA_16", + "mixins": [ + ], + "client": [ + "ModsCheckMixin", + "TitleCheckMixin" + ], + "injectors": { + "defaultRequire": 1 + } +}