From 1ca35ce4b086f49a033954f4f023f91fec3d89f2 Mon Sep 17 00:00:00 2001 From: SchnTgaiSpock Date: Fri, 26 Jan 2024 18:47:48 -0500 Subject: [PATCH] move to blob builds --- .github/workflows/maven.yml | 38 +++++++++++-------- pom.xml | 2 +- .../schntgaispock/slimehud/SlimeHUD.java | 13 ++++++- .../translation/TranslationManager.java | 14 +++++-- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7a522c1..ebe6cbd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,24 +1,32 @@ -name: Java CI +# Modified from https://blob.build/docs/upload/github-action/ +name: Publish build on: push: branches: - - master - pull_request: - branches: - - master + - master jobs: - build: - + publish: + name: Upload build runs-on: ubuntu-latest + if: contains(github.event.head_commit.message, '[ci skip]') == false steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3.4.1 - with: - java-version: '17' - distribution: 'adopt' - - name: Build with Maven - run: mvn clean package + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3.4.1 + with: + java-version: "17" + distribution: "adopt" + + - name: Build with Maven + run: mvn clean package + + - name: Upload to Blob Builds + uses: WalshyDev/blob-builds/gh-action@main + with: + project: SlimeHUD + apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }} + releaseNotes: ${{ github.event.head_commit.message }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index debc2a0..2a6122e 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ com.github.Slimefun Slimefun4 - RC-33 + RC-36 provided diff --git a/src/main/java/io/github/schntgaispock/slimehud/SlimeHUD.java b/src/main/java/io/github/schntgaispock/slimehud/SlimeHUD.java index 8e2362f..5e30c35 100644 --- a/src/main/java/io/github/schntgaispock/slimehud/SlimeHUD.java +++ b/src/main/java/io/github/schntgaispock/slimehud/SlimeHUD.java @@ -14,6 +14,7 @@ import io.github.mooy1.infinitylib.core.AddonConfig; import io.github.schntgaispock.slimehud.command.CommandManager; import io.github.schntgaispock.slimehud.waila.WAILAManager; +import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.BlobBuildUpdater; import lombok.Getter; public class SlimeHUD extends AbstractAddon { @@ -27,6 +28,7 @@ public SlimeHUD() { super("SchnTgaiSpock", "SlimeHUD", "master", "options.auto-update"); } + @Override public void enable() { instance = this; @@ -35,7 +37,16 @@ public void enable() { getLogger().info("# SlimeHUD by SchnTgaiSpock #"); getLogger().info("#=================================#"); - Metrics metrics = new Metrics(this, 15883); + if (getConfig().getBoolean("options.auto-update")) { + if (getDescription().getVersion().startsWith("Dev - ")) { + new BlobBuildUpdater(this, getFile(), "SlimeHUD", "Dev").start(); + } else { + getLogger().info("This is an unofficial build of SlimeHUD, so auto updates are disabled!"); + getLogger().info("You can download the official build here: https://blob.build/project/Gastronomicon"); + } + } + + final Metrics metrics = new Metrics(this, 15883); metrics.addCustomChart( new SimplePie("disabled", () -> { return "" + getConfig().getBoolean("waila.disabled"); diff --git a/src/main/java/io/github/schntgaispock/slimehud/translation/TranslationManager.java b/src/main/java/io/github/schntgaispock/slimehud/translation/TranslationManager.java index 2274666..8af4c88 100644 --- a/src/main/java/io/github/schntgaispock/slimehud/translation/TranslationManager.java +++ b/src/main/java/io/github/schntgaispock/slimehud/translation/TranslationManager.java @@ -29,9 +29,15 @@ public String getItemName(Player p, SlimefunItem sfItem) { if (!translationEnabled) { return sfItem.getItemName(); } - return SlimefunTranslation.getTranslationService().getTranslatedItemName( - SlimefunTranslation.getUserService().getUser(p), - sfItem - ); + + try { + return SlimefunTranslation.getTranslationService().getTranslatedItemName( + SlimefunTranslation.getUserService().getUser(p), + sfItem); + } catch (NoClassDefFoundError e) { + SlimeHUD.getInstance().getLogger().info("Could not get item translation! Please update SlimefunTranslation"); + translationEnabled = false; + return sfItem.getItemName(); + } } }